Skip to content

fix(linter/prefer-for-of): false positive with diff member expression#13201

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/08-18-fix_linter_prefer-for-of_false_positive_with_diff_member_expression
Aug 19, 2025
Merged

fix(linter/prefer-for-of): false positive with diff member expression#13201
graphite-app[bot] merged 1 commit intomainfrom
c/08-18-fix_linter_prefer-for-of_false_positive_with_diff_member_expression

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Aug 18, 2025

fixes #13200

@camc314 camc314 marked this pull request as ready for review August 18, 2025 21:22
Copilot AI review requested due to automatic review settings August 18, 2025 21:22
@github-actions github-actions bot added A-linter Area - Linter C-bug Category - Bug labels Aug 18, 2025
Copy link
Contributor Author

camc314 commented Aug 18, 2025


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.

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 a false positive in the prefer-for-of linter rule where it incorrectly flagged for-loops that access different objects with similar member expression patterns. The fix improves the comparison logic to accurately determine if the same array is being accessed in both the loop condition and body.

  • Enhanced expression comparison to use is_same_expression utility instead of simple string matching
  • Modified the rule to track both array name and expression for more accurate analysis
  • Added comprehensive test cases for deeply nested object access patterns

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
crates/oxc_linter/src/rules/typescript/prefer_for_of.rs Enhanced the core logic to properly compare member expressions using AST-based comparison instead of string matching
crates/oxc_linter/src/snapshots/typescript_prefer_for_of.snap Added snapshot test outputs for new test cases involving deeply nested object access

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@codspeed-hq
Copy link

codspeed-hq bot commented Aug 18, 2025

CodSpeed Instrumentation Performance Report

Merging #13201 will not alter performance

Comparing c/08-18-fix_linter_prefer-for-of_false_positive_with_diff_member_expression (163dbea) with main (76a9865)1

Summary

✅ 34 untouched benchmarks

Footnotes

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

@camc314 camc314 force-pushed the c/08-18-fix_linter_prefer-for-of_false_positive_with_diff_member_expression branch from 023fac1 to 3b6ab99 Compare August 18, 2025 21:31
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Aug 19, 2025
Copy link
Contributor Author

camc314 commented Aug 19, 2025

Merge activity

@graphite-app graphite-app bot force-pushed the c/08-18-fix_linter_prefer-for-of_false_positive_with_diff_member_expression branch from 3b6ab99 to 163dbea Compare August 19, 2025 16:48
@graphite-app graphite-app bot merged commit 163dbea into main Aug 19, 2025
24 checks passed
@graphite-app graphite-app bot deleted the c/08-18-fix_linter_prefer-for-of_false_positive_with_diff_member_expression branch August 19, 2025 16:52
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 19, 2025
This was referenced Aug 26, 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/prefer-for-of: False positive

2 participants