fix(linter/no-unused-vars): handle loop-carried self-reassignments#20457
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. |
There was a problem hiding this comment.
Pull request overview
Fixes a no-unused-vars false positive by treating loop-carried self-reassignments (e.g. chain = chain.extend() inside a loop body) as real usages, aligning behavior with ESLint and addressing #20456.
Changes:
- Update
is_self_reassignmentlogic to treat self-reassignments inside loop bodies as usages (not ignorable self-updates). - Add new regression test cases for loop-carried self-reassignment (pass) vs single self-reassignment (fail).
- Update the snapshot for the self-use test suite to include the new failing case output.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/oxc_linter/src/rules/eslint/no_unused_vars/usage.rs | Adds loop-body detection to avoid classifying loop-carried self-reassignments as “unused”. |
| crates/oxc_linter/src/rules/eslint/no_unused_vars/tests/oxc.rs | Introduces new pass/fail cases covering the reported scenario. |
| crates/oxc_linter/src/snapshots/eslint_no_unused_vars@oxc-vars-self-use.snap | Updates expected diagnostics to reflect the new failing case. |
You can also share your feedback on Copilot code review. Take the survey.
Merge activity
|
67b2156 to
d78c55d
Compare
Merging this PR will not alter performance
Comparing Footnotes
|

fixes #20456