Skip to content

fix: add React Hooks es-linting#4978

Open
Agrawal-Anamika wants to merge 1 commit into
tektoncd:mainfrom
Agrawal-Anamika:fix/issue-4540-react-hooks-linting
Open

fix: add React Hooks es-linting#4978
Agrawal-Anamika wants to merge 1 commit into
tektoncd:mainfrom
Agrawal-Anamika:fix/issue-4540-react-hooks-linting

Conversation

@Agrawal-Anamika

@Agrawal-Anamika Agrawal-Anamika commented May 20, 2026

Copy link
Copy Markdown
Contributor

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:

  • Added eslint-plugin-react-hooks (v7.1.1) as a dev dependency
  • Configured two React Hooks rules in eslint.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 hooks

Why these settings:

  • rules-of-hooks is set to 'error' because violating the Rules of Hooks causes bugs
  • exhaustive-deps is 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:

  • Docs included if any changes are user facing
  • Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (new features, significant UI changes, API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

NONE

@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 20, 2026
@tekton-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign briangleeson after the PR has been reviewed.
You can assign the PR to them by writing /assign @briangleeson in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@linux-foundation-easycla

linux-foundation-easycla Bot commented May 20, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: Agrawal-Anamika / name: Anamika Agrawal (0d25729)

Signed-off-by: Anamika Agrawal <anamikaaggarwal43@gmail.com>
@Agrawal-Anamika
Agrawal-Anamika force-pushed the fix/issue-4540-react-hooks-linting branch from 0d25729 to e4caf3a Compare May 20, 2026 18:29
@Agrawal-Anamika

Copy link
Copy Markdown
Contributor Author

/kind misc

@tekton-robot tekton-robot added the kind/misc Categorizes issue or PR as a miscellaneuous one. label May 20, 2026

@AlanGreene AlanGreene left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Comment thread eslint.config.js
// eslint-plugin-notice only works using this approach
notice
notice,
'react-hooks': reactHooks

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Comment thread eslint.config.js
Comment on lines +84 to +86
// React Hooks rules
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See above re. recommended config

@AlanGreene

This comment was marked as resolved.

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 26, 2026
@tekton-robot

Copy link
Copy Markdown
Contributor

@Agrawal-Anamika: PR needs rebase.

Details

Instructions 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/misc Categorizes issue or PR as a miscellaneuous one. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants