Skip to content

fix(linter/no-unused-vars): handle loop-carried self-reassignments#20457

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/03-17-fix_linter_no-unused-vars_handle_loop-carried_self-reassignments
Mar 17, 2026
Merged

fix(linter/no-unused-vars): handle loop-carried self-reassignments#20457
graphite-app[bot] merged 1 commit intomainfrom
c/03-17-fix_linter_no-unused-vars_handle_loop-carried_self-reassignments

Conversation

@camc314
Copy link
Copy Markdown
Contributor

@camc314 camc314 commented Mar 17, 2026

fixes #20456

@camc314 camc314 marked this pull request as ready for review March 17, 2026 14:33
Copilot AI review requested due to automatic review settings March 17, 2026 14:33
Copy link
Copy Markdown
Contributor Author

camc314 commented Mar 17, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of 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.

@github-actions github-actions bot added A-linter Area - Linter C-bug Category - Bug labels Mar 17, 2026
@camc314 camc314 self-assigned this Mar 17, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_reassignment logic 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.

@graphite-app
Copy link
Copy Markdown
Contributor

graphite-app bot commented Mar 17, 2026

Merge activity

@graphite-app graphite-app bot force-pushed the c/03-17-fix_linter_no-unused-vars_handle_loop-carried_self-reassignments branch from 67b2156 to d78c55d Compare March 17, 2026 14:39
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 17, 2026

Merging this PR will not alter performance

✅ 4 untouched benchmarks
⏩ 52 skipped benchmarks1


Comparing c/03-17-fix_linter_no-unused-vars_handle_loop-carried_self-reassignments (d78c55d) with main (71628e6)2

Open in CodSpeed

Footnotes

  1. 52 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (d78c55d) during the generation of this report, so 71628e6 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@graphite-app graphite-app bot merged commit d78c55d into main Mar 17, 2026
21 checks passed
@graphite-app graphite-app bot deleted the c/03-17-fix_linter_no-unused-vars_handle_loop-carried_self-reassignments branch March 17, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linter: false positive for no-unused-vars with self re-assignment inside loop

2 participants