File tree Expand file tree Collapse file tree 2 files changed +18
-11
lines changed Expand file tree Collapse file tree 2 files changed +18
-11
lines changed Original file line number Diff line number Diff line change 1- import { dirname } from "path" ;
2- import { fileURLToPath } from "url" ;
3- import { FlatCompat } from "@eslint/eslintrc" ;
1+ import js from '@eslint/js'
2+ import { FlatCompat } from '@eslint/eslintrc'
3+ import path from 'path'
4+ import { fileURLToPath } from 'url'
45
5- const __filename = fileURLToPath ( import . meta. url ) ;
6- const __dirname = dirname ( __filename ) ;
6+ const __filename = fileURLToPath ( import . meta. url )
7+ const __dirname = path . dirname ( __filename )
78
89const compat = new FlatCompat ( {
910 baseDirectory : __dirname ,
10- } ) ;
11+ } )
1112
1213const eslintConfig = [
13- ...compat . extends ( "next/core-web-vitals" , "next/typescript" ) ,
14- ] ;
14+ js . configs . recommended ,
15+ ...compat . extends ( 'next/core-web-vitals' ) ,
16+ {
17+ rules : {
18+ 'react-hooks/exhaustive-deps' : 'warn' ,
19+ } ,
20+ } ,
21+ ]
1522
16- export default eslintConfig ;
23+ export default eslintConfig
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ export function CartButton({ userId }: CartButtonProps) {
2020 const response = await fetch ( '/api/cart' )
2121 if ( response . ok ) {
2222 const data = await response . json ( )
23- const count = data . reduce ( ( total : number , item : { quantity : number } ) => total + item . quantity , 0 )
23+ const count = data . reduce ( ( total : number , item : { quantity : number } ) => total + ( item . quantity || 0 ) , 0 )
2424 setCartItemCount ( count )
2525 }
2626 } catch ( error ) {
@@ -31,7 +31,7 @@ export function CartButton({ userId }: CartButtonProps) {
3131 const savedCart = localStorage . getItem ( 'cartzy-cart' )
3232 if ( savedCart ) {
3333 const cartItems = JSON . parse ( savedCart )
34- const count = cartItems . reduce ( ( total : number , item : { quantity : number } ) => total + item . quantity , 0 )
34+ const count = cartItems . reduce ( ( total : number , item : { quantity : number } ) => total + ( item . quantity || 0 ) , 0 )
3535 setCartItemCount ( count )
3636 }
3737 }
You can’t perform that action at this time.
0 commit comments