-
-
Notifications
You must be signed in to change notification settings - Fork 722
fix(linter): no-unused-vars: allow updates in for loop test/update
#14766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(linter): no-unused-vars: allow updates in for loop test/update
#14766
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes the no-unused-vars linter rule to correctly handle variables used in for-loop test and update expressions. Previously, variables that were only incremented/decremented in for-loop conditions were incorrectly flagged as unused.
Key changes:
- Added logic to detect when update expressions occur within for-loop test or update sections
- Implemented helper method
is_in_for_loop_test_or_updateto check node ancestry - Added test cases covering various for-loop patterns with update expressions
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/eslint/no_unused_vars/usage.rs | Added check to allow update expressions in for-loop test/update sections and helper method to detect this context |
| crates/oxc_linter/src/rules/eslint/no_unused_vars/tests/oxc.rs | Added test cases for valid for-loop patterns and a failing case for truly unused variables |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
CodSpeed Performance ReportMerging #14766 will not alter performanceComparing Summary
Footnotes
|
Merge activity
|
00010e0 to
ad12974
Compare

no-unused-varsdoes not follow tail-first loop #14765Allows update expressions when they are within a for-loop update/test.