Skip to content

Report optional chained hook calls#36415

Open
raashish1601 wants to merge 1 commit intofacebook:mainfrom
raashish1601:codex/rules-of-hooks-optional-member-calls
Open

Report optional chained hook calls#36415
raashish1601 wants to merge 1 commit intofacebook:mainfrom
raashish1601:codex/rules-of-hooks-optional-member-calls

Conversation

@raashish1601
Copy link
Copy Markdown

Summary

  • Report hook calls made through optional chaining as conditional in rules-of-hooks.
  • Support parser ASTs that expose optional chains as OptionalCallExpression/OptionalMemberExpression.
  • Add a regression test for optional-chained member hook calls.

Fixes #20196.

Test plan

  • corepack yarn --cwd packages/eslint-plugin-react-hooks jest ESLintRulesOfHooks-test --runInBand
  • corepack yarn --cwd packages/eslint-plugin-react-hooks typecheck
  • git diff --check

@meta-cla meta-cla Bot added the CLA Signed label May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: eslint-plugin-react-hooks doesn't report conditional typescript "?." hooks

1 participant