Skip to content

Preserve optional chains in exhaustive-deps suggestions#36411

Open
raashish1601 wants to merge 1 commit intofacebook:mainfrom
raashish1601:codex/exhaustive-deps-optional-chain-suggestion
Open

Preserve optional chains in exhaustive-deps suggestions#36411
raashish1601 wants to merge 1 commit intofacebook:mainfrom
raashish1601:codex/exhaustive-deps-optional-chain-suggestion

Conversation

@raashish1601
Copy link
Copy Markdown

Summary

Fixes #23248.

When the same dependency path is read through both optional and non-optional member expressions, the exhaustive-deps suggestion should keep the optional form. Dependency arrays are evaluated outside guarded blocks, so suggesting the non-optional form can introduce a render-time error while fixing an unrelated dependency.

Tests

  • corepack yarn --cwd packages/eslint-plugin-react-hooks jest ESLintRuleExhaustiveDeps-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

1 participant