Skip to content

feat(linter): add options.reportUnusedDisableDirectives to config file#19799

Merged
camc314 merged 8 commits intooxc-project:mainfrom
wagenet:unused-disables-flag
Mar 3, 2026
Merged

feat(linter): add options.reportUnusedDisableDirectives to config file#19799
camc314 merged 8 commits intooxc-project:mainfrom
wagenet:unused-disables-flag

Conversation

@wagenet
Copy link
Contributor

@wagenet wagenet commented Feb 27, 2026

See #15972.

Summary

  • Adds options.reportUnusedDisableDirectives to .oxlintrc.json, following the same pattern as typeAware (feat(linter): introduce typeAware as config options #19614) and typeCheck (feat(linter): introduce typeCheck config option #19764)
  • Root-config-only — nested configs are rejected with a clear diagnostic error
  • CLI --report-unused-disable-directives / --report-unused-disable-directives-severity take precedence over the config file value when both are set
  • Schema (npm/oxlint/configuration_schema.json), TypeScript types (config.generated.ts), and website snapshots regenerated

Test plan

  • Unit tests in oxlintrc.rs: deserialization, is_empty, merge
  • Unit tests in config_store.rs: accessor returns value / None by default
  • Unit tests in config_loader.rs: nested config rejection
  • Integration tests in config_builder.rs: extends inheritance and override precedence
  • cargo test -p oxc_linter && cargo test -p oxlint

Note on AI usage

This PR was implemented with Claude Code assistance and has been reviewed and tested by the contributor.

🤖 Generated with Claude Code

@wagenet wagenet requested a review from camc314 as a code owner February 27, 2026 00:47
Copilot AI review requested due to automatic review settings February 27, 2026 00:47
@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI A-linter-plugins Area - Linter JS plugins C-enhancement Category - New feature or request labels Feb 27, 2026
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

Adds a new root-only .oxlintrc.json option to configure reporting of unused disable directives, aligning CLI flags with config-file driven behavior and regenerating the public schema/type artifacts.

Changes:

  • Introduces options.reportUnusedDisableDirectives (Allow/Warn/Deny) in Rust config types, schema, and generated TS types/docs.
  • Enforces “root-config-only” by rejecting nested configs that set the option with a dedicated diagnostic.
  • Wires config into the CLI runner so CLI flags take precedence over config values.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tasks/website_linter/src/snapshots/schema_markdown.snap Updates rendered schema docs snapshot to include the new option.
tasks/website_linter/src/snapshots/schema_json.snap Updates rendered schema JSON snapshot to include the new option.
npm/oxlint/configuration_schema.json Adds schema property for options.reportUnusedDisableDirectives.
crates/oxc_linter/src/config/oxlintrc.rs Adds the option to OxlintOptions, supports merge/is_empty, and adds unit tests for deserialization/merge.
crates/oxc_linter/src/config/config_store.rs Adds a ConfigStore accessor for the new option plus unit tests.
crates/oxc_linter/src/config/config_builder.rs Adds a ConfigStoreBuilder accessor and tests for extends/override behavior.
crates/oxc_linter/fixtures/extends_config/options/report_unused_disable_directives_warn.json New fixture for extends testing (warn).
crates/oxc_linter/fixtures/extends_config/options/report_unused_disable_directives_error.json New fixture for extends testing (error).
crates/oxc_linter/fixtures/extends_config/options/report_unused_disable_directives_allow.json New fixture for extends testing (allow/off).
apps/oxlint/src/lint.rs Uses config value as fallback when CLI flags aren’t set (CLI takes precedence).
apps/oxlint/src/config_loader.rs Rejects nested configs that set options.reportUnusedDisableDirectives, with tests + diagnostic helper.
apps/oxlint/src-js/package/config.generated.ts Regenerates TS config types to include reportUnusedDisableDirectives.

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 27, 2026

Merging this PR will not alter performance

✅ 4 untouched benchmarks
⏩ 52 skipped benchmarks1


Comparing wagenet:unused-disables-flag (3ad58c1) with main (6c0e0b5)2

Open in CodSpeed

Footnotes

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

@camc314 camc314 self-assigned this Feb 27, 2026
Copilot AI added a commit to wagenet/oxc that referenced this pull request Feb 27, 2026
…egration tests

Co-authored-by: wagenet <9835+wagenet@users.noreply.github.com>
@Mister-Hope
Copy link

Mister-Hope commented Mar 2, 2026

I see the typecheck option was added in the latest version, which was released minutes ago.

When can this option be supported?

@camc314
Copy link
Contributor

camc314 commented Mar 2, 2026

@Mister-Hope please bear with me - this was only opened on Friday.

@camc314 camc314 force-pushed the unused-disables-flag branch from 6c810fb to 01cb9d7 Compare March 2, 2026 14:06
camc314 pushed a commit to wagenet/oxc that referenced this pull request Mar 2, 2026
…egration tests

Co-authored-by: wagenet <9835+wagenet@users.noreply.github.com>
wagenet and others added 6 commits March 2, 2026 20:22
Closes oxc-project#15972. Adds `options.reportUnusedDisableDirectives` to
`.oxlintrc.json`, following the same pattern as `typeAware` (oxc-project#19614)
and `typeCheck` (oxc-project#19764).

- Root-config-only (nested configs are rejected with a clear error)
- CLI `--report-unused-disable-directives[-severity]` takes precedence
  over the config file value
- Schema, TypeScript types, and website snapshots regenerated

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…egration tests

Co-authored-by: wagenet <9835+wagenet@users.noreply.github.com>
@camc314 camc314 force-pushed the unused-disables-flag branch from c066c16 to b896bcf Compare March 2, 2026 20:29
Copy link
Contributor

@camc314 camc314 left a comment

Choose a reason for hiding this comment

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

Thank you!

@camc314 camc314 merged commit 61bf388 into oxc-project:main Mar 3, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-linter Area - Linter A-linter-plugins Area - Linter JS plugins C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants