fix: add React Hooks es-linting#4978
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
|
Signed-off-by: Anamika Agrawal <anamikaaggarwal43@gmail.com>
0d25729 to
e4caf3a
Compare
|
/kind misc |
AlanGreene
left a comment
There was a problem hiding this comment.
Thanks for the PR @Agrawal-Anamika.
There's a lot of potential for unwanted behaviour changes with some of these updates so it may make sense to break it down into a series of PRs that can be tested, reviewed, and merged separately. That way if issues are encountered it's easier to revert a small set of them instead of the whole thing.
I'd also suggest trying to enable the recommended config as suggested in the issue description. We can disable rules for certain files or lines as needed and make incremental progress to having them fully enabled across the codebase.
| // eslint-plugin-notice only works using this approach | ||
| notice | ||
| notice, | ||
| 'react-hooks': reactHooks |
There was a problem hiding this comment.
Was there an issue with adding the recommended config as suggested in the issue? It would be good to describe any issues encountered so we can plan how best to address them.
| // React Hooks rules | ||
| 'react-hooks/rules-of-hooks': 'error', | ||
| 'react-hooks/exhaustive-deps': 'warn', |
There was a problem hiding this comment.
See above re. recommended config
This comment was marked as resolved.
This comment was marked as resolved.
|
@Agrawal-Anamika: PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Changes
Issue - #4540
This PR adds React Hooks ESLint rules to the project to enforce proper usage of React Hooks and prevent common mistakes.
Changes made:
eslint-plugin-react-hooks(v7.1.1) as a dev dependencyeslint.config.js:react-hooks/rules-of-hooks: 'error'- Enforces the Rules of Hooks (hooks must be called at the top level, only in React functions)react-hooks/exhaustive-deps: 'warn'- Warns about missing dependencies in useEffect, useMemo, and useCallback hooksWhy these settings:
rules-of-hooksis set to 'error' because violating the Rules of Hooks causes bugsexhaustive-depsis set to 'warn' (not 'error') to allow gradual adoption and intentional exceptions with eslint-disable comments/kind misc
Submitter Checklist
As the author of this PR, please check off the items in this checklist:
functionality, content, code)
/kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepRelease Notes