Skip to content

fix(linter/no-unused-vars): handle non-null assertion in update expressions#17281

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/12-22-fix_linter_no-unused-vars_handle_non-null_assertion_in_update_expressions
Dec 22, 2025
Merged

fix(linter/no-unused-vars): handle non-null assertion in update expressions#17281
graphite-app[bot] merged 1 commit intomainfrom
c/12-22-fix_linter_no-unused-vars_handle_non-null_assertion_in_update_expressions

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Dec 22, 2025

Fixes #17280

@github-actions github-actions bot added A-linter Area - Linter C-bug Category - Bug labels Dec 22, 2025
@camc314 camc314 self-assigned this Dec 22, 2025
Copy link
Contributor Author

camc314 commented Dec 22, 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.

@camc314 camc314 marked this pull request as ready for review December 22, 2025 16:48
Copilot AI review requested due to automatic review settings December 22, 2025 16:48
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Dec 22, 2025
Copy link
Contributor Author

camc314 commented Dec 22, 2025

Merge activity

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

@graphite-app graphite-app bot force-pushed the c/12-22-fix_linter_no-unused-vars_handle_non-null_assertion_in_update_expressions branch from c4be6de to 79b83b0 Compare December 22, 2025 16:54
@codspeed-hq
Copy link

codspeed-hq bot commented Dec 22, 2025

CodSpeed Performance Report

Merging #17281 will not alter performance

Comparing c/12-22-fix_linter_no-unused-vars_handle_non-null_assertion_in_update_expressions (c4be6de) with main (7074353)

Summary

✅ 4 untouched
⏩ 41 skipped1

Footnotes

  1. 41 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.

@graphite-app graphite-app bot merged commit 79b83b0 into main Dec 22, 2025
20 checks passed
@graphite-app graphite-app bot deleted the c/12-22-fix_linter_no-unused-vars_handle_non-null_assertion_in_update_expressions branch December 22, 2025 16:59
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 22, 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: eslint(no-unused-vars) false-positive when using non-null assertion

2 participants