fix(linter/no-unused-vars): handle non-null assertion in update expressions#17281
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. |
Merge activity
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the no-unused-vars linter rule where TypeScript non-null assertions and type assertions in update expressions were incorrectly causing variables to be flagged as unused.
Key Changes:
- Enhanced the update expression handling to unwrap TypeScript type-related wrappers (non-null assertions, type assertions, etc.) before checking if the argument is a member expression
- Added comprehensive test coverage for non-null assertions (
!) and type assertions (as) in both prefix and postfix 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 |
Updated logic to unwrap TypeScript wrappers when checking if an update expression argument is a member expression, preventing false positives |
crates/oxc_linter/src/rules/eslint/no_unused_vars/tests/oxc.rs |
Added 4 test cases covering various combinations of non-null assertions and type assertions with update expressions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c4be6de to
79b83b0
Compare
CodSpeed Performance ReportMerging #17281 will not alter performanceComparing Summary
Footnotes
|

Fixes #17280