commerce icon indicating copy to clipboard operation
commerce copied to clipboard

Linting issues

Open danielgent opened this issue 5 years ago • 1 comments

Hey all :wave:

Great project.

I see a few eslint warnings in the console introduced in https://github.com/vercel/commerce/pull/425 added linting (pasted below)

Are there any plans to fix these? (Or at least disable eslint for these lines if the offending lines are meant to be like this)

A few are passHref is missing. See https://nextjs.org/docs/messages/link-passhrefeslint(@next/next/link-passhref) I would assume these need fixing.

components/common/I18nWidget/I18nWidget.tsx should use Next.js's <Image/> component.

components/ui/context.tsx and lib/focus-trap.tsx have hooks that are missing dependencies

I'm assuming the useEffect with the empty dependency array in lib/hooks/useUserAvatar.ts is meant to run when mounting.

As Dan Abramov mentions here https://github.com/facebook/create-react-app/issues/6880#issuecomment-486636121 "please remember nothing prevents you from creating your own useMount Hook " - and in the useMount hook we could disable eslint-plugin-react-hooks

I'd be happy to do this.

./components/cart/CartItem/CartItem.tsx
87:11  Warning: passHref is missing. See https://nextjs.org/docs/messages/link-passhref  @next/next/link-passhref
100:11  Warning: passHref is missing. See https://nextjs.org/docs/messages/link-passhref  @next/next/link-passhref

./components/cart/CartSidebarView/CartSidebarView.tsx
76:13  Warning: passHref is missing. See https://nextjs.org/docs/messages/link-passhref  @next/next/link-passhref

./components/checkout/CheckoutSidebarView/CheckoutSidebarView.tsx
37:9  Warning: passHref is missing. See https://nextjs.org/docs/messages/link-passhref  @next/next/link-passhref

./components/common/I18nWidget/I18nWidget.tsx
53:13  Warning: Do not use <img>. Use Image from 'next/image' instead. See https://nextjs.org/docs/messages/no-img-element.  @next/next/no-img-element

./components/ui/context.tsx
198:5  Warning: React Hook useMemo has missing dependencies: 'closeDropdown', 'closeModal', 'closeSidebar', 'closeSidebarIfPresent', 'openDropdown', 'openModal', 'openSidebar', 'setModalView', 'setSidebarView', 'setUserAvatar', and 'toggleSidebar'. Either include them or remove the dependency array.  react-hooks/exhaustive-deps

./lib/focus-trap.tsx
56:6  Warning: React Hook useEffect has a missing dependency: 'trapFocus'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps

./lib/hooks/useUserAvatar.ts
20:6  Warning: React Hook useEffect has missing dependencies: 'name', 'setUserAvatar', and 'userAvatar'. Either include them or remove the dependency array.  react-hooks/exhaustive-deps

danielgent avatar Aug 23 '21 16:08 danielgent

@danielgent are you getting any of the rules-of-hooks issues in files like framework/shopify/cart ?

brantchoate avatar Sep 08 '21 04:09 brantchoate