The Wayback Machine - https://web.archive.org/web/20250521213610/https://github.com/vercel/swr/pull/270
Skip to content

Add React and Hook config for ESLint #270

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

Merged
merged 4 commits into from
Sep 22, 2020

Conversation

innocentiv
Copy link
Contributor

This PR adds eslint-plugin-react and eslint-plugin-react-hooks to the swr repository.

ESLint config extends plugin:react/recommended and add the react-hooks/rules-of-hooks rule as warning.

The use of useMemo after the early return in if (config.suspense) is a violation of the rules of hooks and even if I do not expect config.suspense to change during the normal use of the library, I moved it above that piece of code. I think it is a safer approach. We could add and an eslint-disable-next-line comment if you prefer.

@pke
Copy link

pke commented Sep 20, 2020

@innocentiv could you rebase please to increase the chance of a merge?

@innocentiv innocentiv force-pushed the add_eslint_config_react branch from f11742b to 34d0f22 Compare September 22, 2020 05:36
@innocentiv
Copy link
Contributor Author

I have rebased this feature, updated the eslint plugins to the latest version, changed the rules to the recommended config from react docs (now they fixed the autofix on react-hooks/exhaustive-deps). I hope this suffices, but after seven months I have nome doubt 😄

Copy link
Member

@shuding shuding left a comment

Choose a reason for hiding this comment

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

Thank you for your great work @innocentiv!

@shuding shuding merged commit ace7be5 into vercel:master Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants