Skip to content

feat(linter/no-underscore-dangle): add allowInUsingDeclarations option#22483

Merged
camc314 merged 4 commits into
oxc-project:mainfrom
leno23:fix/no-underscore-dangle-using
May 18, 2026
Merged

feat(linter/no-underscore-dangle): add allowInUsingDeclarations option#22483
camc314 merged 4 commits into
oxc-project:mainfrom
leno23:fix/no-underscore-dangle-using

Conversation

@leno23

@leno23 leno23 commented May 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add an allowAfterUsing option to eslint/no-underscore-dangle
  • treat using and await using declarators as their own binding context
  • add pass/fail coverage and update the rule snapshot

Fixes #22322.

Test Plan

  • cargo fmt --package oxc_linter
  • cargo lintgen
  • cargo test -p oxc_linter no_underscore_dangle::test -- --nocapture

AI usage disclosure

This PR was prepared with assistance from Hermes Agent. I reviewed the diff and test results before submission.

@camc314 camc314 added the A-linter Area - Linter label May 18, 2026
@camc314 camc314 changed the title fix(linter): allow underscores in using declarations fix(linter/no-underscore-dangle): add option to allow underscores in using declarations May 18, 2026
@camc314 camc314 changed the title fix(linter/no-underscore-dangle): add option to allow underscores in using declarations feat(linter/no-underscore-dangle): add option to allow underscores in using declarations May 18, 2026
@camc314 camc314 marked this pull request as ready for review May 18, 2026 09:05
@camc314 camc314 self-requested a review as a code owner May 18, 2026 09:05
Copilot AI review requested due to automatic review settings May 18, 2026 09:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new allowAfterUsing option to the eslint/no-underscore-dangle rule so that leading underscores on using/await using declarators (used in TC39 Explicit Resource Management) are not flagged.

Changes:

  • Adds allow_after_using (default false) to NoUnderscoreDangleConfig.
  • Introduces a new BindingContext::Using variant, detected in binding_context via VariableDeclarationKind::is_using().
  • Adds pass/fail test cases and updates the snapshot for the new diagnostics.

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_underscore_dangle.rs Adds option, binding context branch for using/await using, and tests.
crates/oxc_linter/src/snapshots/eslint_no_underscore_dangle.snap Updates snapshot with diagnostics for new fail cases.

@camc314 camc314 self-assigned this May 18, 2026
@camc314 camc314 changed the title feat(linter/no-underscore-dangle): add option to allow underscores in using declarations feat(linter/no-underscore-dangle): add allowInUsingDeclarations option May 18, 2026

@camc314 camc314 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks!

@camc314 camc314 merged commit 1ae291e into oxc-project:main May 18, 2026
30 checks passed
@codspeed-hq

codspeed-hq Bot commented May 18, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 4 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing leno23:fix/no-underscore-dangle-using (2016101) with main (0440b0f)2

Open in CodSpeed

Footnotes

  1. 47 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 (542ed19) during the generation of this report, so 0440b0f was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

camc314 pushed a commit that referenced this pull request May 18, 2026
# Oxlint
### 🚀 Features

- 1ae291e linter/no-underscore-dangle: Add `allowInUsingDeclarations`
option (#22483) (吴杨帆)
- 0440b0f linter/eslint: Implement `id-match` rule (#22379) (Vladislav
Sayapin)
- 65bf119 linter: Implement react no-object-type-as-default-prop
(#22481) (uhyo)
- 2a6ddce linter/eslint: Implement `no-implied-eval` rule (#22391)
(Vladislav Sayapin)
- d3a3c1d linter: Auto detect agents from CLI and transition to the
agent output format (#22068) (Jovi De Croock)
- 625758a linter/vitest: Implement padding-around-after-all-blocks rule
(#21788) (kapobajza)
- 37680b0 linter: Implement react no-unstable-nested-components (#22248)
(Jovi De Croock)
- d8d9c74 linter: Implement import/newline-after-import rule (#19142)
(Ryuya Yanagi)

### 🐛 Bug Fixes

- 3f59e03 linter: Only call rayon/miette/tracing inits once (#21899)
(Matiss Janis Aboltins)
- 602dfd6 linter/promise/no-return-wrap: Detect Promise calls in all
branches (#22474) (zennnnnnn11)
- e182aee linter: Allow dialogs and popovers for no_autofocus (#22289)
(mehm8128)
- 7ffb710 linter/jest/vitest: Jest/no-standalone-expect ignores
additionalTestBlockFunctions option for jest/vitest hooks (#22477)
(kapobajza)
- c6f2d3f linter: Add more expression support for iframe-has-title
(#22460) (mehm8128)
- 5747ff1 linter: Avoid enabling jest with vitest plugin (#22499)
(camc314)
- 863984f linter/no-find-dom-node: Run on all files (#22479) (bab)

### ⚡ Performance

- 2afef79 linter: Optimize `no-loop-func` (#22491) (camchenry)
- 4c9ca72 oxlint: Align walker thread count with rayon pool (#22494)
(Boshen)

### 📚 Documentation

- f7967c7 linter/id-match: Clarify `onlyDeclarations` config docs
(#22523) (camc314)
- 1e0c97f linter: Fix closing code block in documentation for
`padding-around-after-all-blocks` rule. (#22513) (connorshea)
- a9049fd linter: Exclude directly provide autoFocus to dialog pattern
(#22510) (mehm8128)
# Oxfmt
### 🐛 Bug Fixes

- 8ee946f formatter/sort_imports: Use label to classify lines (#22512)
(leaysgur)
- 8c1da44 formatter: Normalize destructuring keys in DCR (#22478)
(camc314)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linter(no-underscore-dangle): add allowAfterUsing option for explicit resource management bindings

3 participants