Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: make react-hooks/exhaustive-deps eslint rule error vs. warn #950

Merged
merged 7 commits into from
Sep 13, 2023

Conversation

blimmer
Copy link
Contributor

@blimmer blimmer commented Sep 13, 2023

[sc-40033]

https://homeboundinc.slack.com/archives/C012SEYSQGG/p1694472845039779

I used a codemod to supress all existing errors:

npx suppress-eslint-errors ./src --extensions=ts,tsx --parser=tsx --rules=react-hooks/exhaustive-deps --message="TODO: validate this eslint-disable. It was automatically ignored as part of https://app.shortcut.com/homebound-team/story/40033/enable-react-hooks-exhaustive-deps-for-internal-frontend"

I also used a simple regex replace to clean up the comments:

\}, (\/\/ TODO: validate.*)
}, \n $1

Screenshot 2023-09-13 at 12 48 06

Then, finally, run yarn lint:fix (or commit to get the pre-commit hook) to run prettier.

@shortcut-integration
Copy link

This pull request has been linked to Shortcut Story #40033: Enable react-hooks/exhaustive-deps for React projects.

@blimmer
Copy link
Contributor Author

blimmer commented Sep 13, 2023

@bdow - there was never a lint step in CI for this project, so I added one. I didn't disable these existing errors:

/Users/blimmer/code/homebound/beam/src/components/Table/GridTable.test.tsx
  3137:13  error  Avoid wrapping Testing Library util calls in `act`  testing-library/no-unnecessary-act
  3219:13  error  Avoid wrapping Testing Library util calls in `act`  testing-library/no-unnecessary-act

/Users/blimmer/code/homebound/beam/src/components/internal/MenuItem.tsx
  33:15  error  React Hook "useRef" is called conditionally. React Hooks must be called in the exact same order in every component render       react-hooks/rules-of-hooks
  34:19  error  React Hook "useHistory" is called conditionally. React Hooks must be called in the exact same order in every component render   react-hooks/rules-of-hooks
  35:37  error  React Hook "useHover" is called conditionally. React Hooks must be called in the exact same order in every component render     react-hooks/rules-of-hooks
  36:15  error  React Hook "useTestIds" is called conditionally. React Hooks must be called in the exact same order in every component render   react-hooks/rules-of-hooks
  37:29  error  React Hook "useMenuItem" is called conditionally. React Hooks must be called in the exact same order in every component render  react-hooks/rules-of-hooks

/Users/blimmer/code/homebound/beam/src/inputs/TreeSelectField/TreeOption.tsx
  26:15  error  React Hook "useRef" is called conditionally. React Hooks must be called in the exact same order in every component render                      react-hooks/rules-of-hooks
  27:37  error  React Hook "useHover" is called conditionally. React Hooks must be called in the exact same order in every component render                    react-hooks/rules-of-hooks
  28:15  error  React Hook "useTestIds" is called conditionally. React Hooks must be called in the exact same order in every component render                  react-hooks/rules-of-hooks
  30:63  error  React Hook "useTreeSelectFieldProvider" is called conditionally. React Hooks must be called in the exact same order in every component render  react-hooks/rules-of-hooks
  32:62  error  React Hook "useOption" is called conditionally. React Hooks must be called in the exact same order in every component render                   react-hooks/rules-of-hooks

/Users/blimmer/code/homebound/beam/src/utils/rtl.test.tsx
  218:6  error  Test title is used multiple times in the same describe block  jest/no-identical-title

✖ 13 problems (13 errors, 0 warnings)

Do you want me to disable them? Or do you (or someone else) want to look at it?

Copy link
Contributor

@stephenh stephenh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@bdow
Copy link
Contributor

bdow commented Sep 13, 2023

Do you want me to disable them? Or do you (or someone else) want to look at it?

Let's disable them for now. If you don't mind, could you write a ticket and assign it to me I can take it from there. Thanks!

@blimmer
Copy link
Contributor Author

blimmer commented Sep 13, 2023

Yep, can do.

@blimmer
Copy link
Contributor Author

blimmer commented Sep 13, 2023

@bdow https://app.shortcut.com/homebound-team/story/40045

@blimmer blimmer changed the title feat: make react-hooks/exhaustive-deps eslint rule error vs. warn chore: make react-hooks/exhaustive-deps eslint rule error vs. warn Sep 13, 2023
@blimmer blimmer enabled auto-merge (squash) September 13, 2023 19:45
@blimmer blimmer merged commit a9d2793 into main Sep 13, 2023
@blimmer blimmer deleted the eslint-hooks branch September 13, 2023 19:45
@homebound-team-bot
Copy link

🎉 This PR is included in version 2.318.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants