Skip to content

Conversation

@camchenry
Copy link
Member

@camchenry camchenry commented Oct 19, 2025

Allows update expressions when they are within a for-loop update/test.

@github-actions github-actions bot added A-linter Area - Linter C-bug Category - Bug labels Oct 19, 2025
Copy link
Member Author


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 hot fixes, skip the queue and merge this PR next

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.

@camchenry camchenry marked this pull request as ready for review October 19, 2025 00:57
@camchenry camchenry requested a review from camc314 as a code owner October 19, 2025 00:57
Copilot AI review requested due to automatic review settings October 19, 2025 00:57
Copy link
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

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_update to 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-hq
Copy link

codspeed-hq bot commented Oct 19, 2025

CodSpeed Performance Report

Merging #14766 will not alter performance

Comparing 10-18-fix_linter_no-unused-vars_allow_updates_in_for_loop_test_update (00010e0) with main (c6395c7)1

Summary

✅ 4 untouched
⏩ 33 skipped2

Footnotes

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

  2. 33 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.

@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Oct 20, 2025
Copy link
Contributor

camc314 commented Oct 20, 2025

Merge activity

…14766)

- Fixes #14765

Allows update expressions when they are within a for-loop update/test.
@graphite-app graphite-app bot force-pushed the 10-18-fix_linter_no-unused-vars_allow_updates_in_for_loop_test_update branch from 00010e0 to ad12974 Compare October 20, 2025 08:26
@graphite-app graphite-app bot merged commit ad12974 into main Oct 20, 2025
20 checks passed
@graphite-app graphite-app bot deleted the 10-18-fix_linter_no-unused-vars_allow_updates_in_for_loop_test_update branch October 20, 2025 08:30
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Oct 20, 2025
@camc314 camc314 self-assigned this Oct 20, 2025
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: no-unused-vars does not follow tail-first loop

3 participants