fix(linter/exhaustive-deps): fix fixer incorrectly adding property chain from destructuring pattern#17167
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Merge activity
|
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #17159 where the exhaustive-deps linter rule's fixer was incorrectly suggesting property chains from destructuring patterns when the identifier was used inside a function call rather than directly destructured.
Key Changes:
- Added logic to check if an identifier is inside a CallExpression before applying destructuring property chain logic
- Updated error message in snapshot from
foo.bartofoofor the affected test case - Added a new test case to verify the fix
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/oxc_linter/src/rules/react/exhaustive_deps.rs | Adds a check to prevent applying destructuring logic when an identifier is nested inside a call expression, and adds a test case for the fix |
| crates/oxc_linter/src/snapshots/react_exhaustive_deps.snap | Updates the expected diagnostic message to correctly identify foo instead of foo.bar as the missing dependency |
The implementation is correct and handles the issue appropriately. When an identifier like booleanValue is used as an argument in a function call fn(booleanValue) where the result is destructured (const { headers } = fn(booleanValue)), the dependency should be just booleanValue, not booleanValue.headers. The fix correctly distinguishes this from the case where the identifier is directly destructured (const { headers } = booleanValue), where booleanValue.headers would be the correct dependency.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CodSpeed Performance ReportMerging #17167 will not alter performanceComparing Summary
Footnotes
|
5c46a39 to
c08e6df
Compare

Fixes #17159