[eslint-plugin-react-hooks] Skip TSQualifiedName chains inside typeof#36300
Open
ousamabenyounes wants to merge 1 commit intofacebook:mainfrom
Open
[eslint-plugin-react-hooks] Skip TSQualifiedName chains inside typeof#36300ousamabenyounes wants to merge 1 commit intofacebook:mainfrom
ousamabenyounes wants to merge 1 commit intofacebook:mainfrom
Conversation
`exhaustive-deps` skipped references whose parent was a `TSTypeQuery` or `TSTypeReference`, which correctly handled `typeof foo` / `Foo` but not nested access like `typeof foo.bar` — there the root identifier's parent is a `TSQualifiedName`, not the outer `TSTypeQuery`, so the reference slipped through and was reported as a missing dependency. Walk up through any `TSQualifiedName` nodes before checking the ancestor kind, so `typeof foo.bar.baz` and similar chains are now also treated as purely type-level references (fixes facebook#27335). Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #27335.
exhaustive-depsskipped references whose parent was aTSTypeQuery(e.g.typeof foo) orTSTypeReference(e.g.Foo). That correctly handled direct usage, but nested type paths liketypeof foo.barslipped through: in the AST the root identifier's parent is aTSQualifiedName, not the outerTSTypeQuery, so the reference was recorded as a missing dependency.Walking up through
TSQualifiedNamebefore checking the ancestor kind covers arbitrary-depth chains (typeof a.b.c, etc.).How did you test this change?
Added a regression case to
ESLintRuleExhaustiveDeps-test.jsexercising the exact repro from the issue.ESLintRuleExhaustiveDeps-test.js: 3652 passed / 0 failed (3644 baseline + new case × 2 ESLint versions × 4 parser configs).ESLintRulesOfHooks-test.js: 1420 passed / 0 failed (unaffected, verified).yarn flow dom-node— clean.yarn linc— clean.yarn prettier— clean.🤖 Generated with Claude Code