Skip to content

Conversation

@0xReLogic
Copy link

Summary

This PR adds support for the maxWarnings configuration option in .oxlintrc.json files, allowing users to specify a warning threshold that will cause the linter to exit with a non-zero code.

Changes

  • Added max_warnings field to Oxlintrc struct in crates/oxc_linter/src/config/oxlintrc.rs
  • Wired max_warnings through the config system to DiagnosticService
  • CLI --max-warnings flag takes precedence over config file value
  • Added validation to prevent maxWarnings in nested config files (raises error as specified)
  • Added unit tests for parsing and merging behavior

Example Usage

{
  "maxWarnings": 0
}

Testing

  • ✅ All new unit tests pass
  • ✅ Existing tests pass (except unrelated tsgolint tests)
  • ✅ Config parsing works correctly
  • ✅ Merge behavior works as expected
  • ✅ Nested config validation works

Closes #15020

Add support for maxWarnings configuration option in .oxlintrc.json
to control exit code behavior based on warning count.

- Add max_warnings field to Oxlintrc struct
- Wire max_warnings through config system to DiagnosticService
- CLI --max-warnings flag takes precedence over config value
- Add validation to prevent maxWarnings in nested configs
- Add unit tests for maxWarnings parsing and merging

Closes oxc-project#15020
Copilot AI review requested due to automatic review settings October 30, 2025 09:24
@0xReLogic 0xReLogic requested a review from camc314 as a code owner October 30, 2025 09:24
@graphite-app
Copy link
Contributor

graphite-app bot commented Oct 30, 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.

@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI C-enhancement Category - New feature or request labels Oct 30, 2025
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 adds support for configuring a maxWarnings threshold in the .oxlintrc.json configuration file. This allows projects to enforce a maximum number of warnings before the linter exits with an error status, complementing the existing CLI flag --max-warnings.

Key changes:

  • Added max_warnings field to the Oxlintrc struct with JSON serialization support
  • Updated the merge logic to handle max_warnings configuration inheritance
  • Modified the diagnostic service initialization to prioritize CLI flag over config file value
  • Added validation to prevent maxWarnings from being used in nested configuration files

Reviewed Changes

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

File Description
crates/oxc_linter/src/config/oxlintrc.rs Adds max_warnings field to the Oxlintrc struct, updates merge logic to handle the new field, and includes comprehensive tests for serialization and merging behavior
apps/oxlint/src/lint.rs Integrates config-based max_warnings with CLI flag, adds validation to reject maxWarnings in nested configs, and updates diagnostic service initialization to use the merged value

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

Thanks for working on this!

Can we add some integration tests for this.

The test cases (real files) should go in apps/oxlint/src/fixtures, and the test fn should go in apps/oxlint/src/lint.rs

@0xReLogic
Copy link
Author

0xReLogic commented Oct 30, 2025

Hi @camc314 Already added integration tests as requested. The tests cover:

  • maxWarnings: 0 configuration (fails when warnings are present)
  • maxWarnings threshold exceeded scenario
  • maxWarnings threshold not exceeded scenario
  • CLI flag overriding config file value
  • Nested config validation (error when maxWarnings is in nested config)

All tests pass and snapshots have been created.

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 C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

oxlint: oxlintrc config for turn all warnings into errors

2 participants