Skip to content

Conversation

@wagenet
Copy link
Contributor

@wagenet wagenet commented Nov 17, 2025

Follow up to #14939.

@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 17, 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.

@wagenet wagenet changed the title Follow-up to config extends fixes feat(linter) Follow-up to config extends fixes Nov 17, 2025
@github-actions github-actions bot added the A-linter Area - Linter label Nov 17, 2025
@wagenet wagenet marked this pull request as ready for review November 17, 2025 23:21
@wagenet wagenet requested a review from camc314 as a code owner November 17, 2025 23:21
Copilot AI review requested due to automatic review settings November 17, 2025 23:21
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 refines the configuration merging logic for Oxlintrc files, improving clarity around merge priority and eliminating unnecessary clones for better performance. The changes follow up on previous config extends fixes (#14939).

Key Changes:

  • Improved documentation for the merge method to clearly explain merge priority
  • Changed merge method signature to take ownership of other parameter instead of borrowing
  • Added comprehensive test coverage for extends order precedence

Reviewed Changes

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

File Description
crates/oxc_linter/src/config/oxlintrc.rs Enhanced documentation and optimized merge method to take ownership of other parameter
crates/oxc_linter/src/config/config_builder.rs Updated merge call site and added test for extends array precedence
crates/oxc_linter/fixtures/extends_config/rules_multiple/extends_order_test.json Added test fixture for validating extends order behavior

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

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 17, 2025

CodSpeed Performance Report

Merging #15818 will not alter performance

Comparing wagenet:extends-follow-up (b785dac) with main (c167dfa)1

Summary

✅ 4 untouched
⏩ 33 skipped2

Footnotes

  1. No successful run was found on main (fbf0fd4) during the generation of this report, so c167dfa was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

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

@wagenet wagenet changed the title feat(linter) Follow-up to config extends fixes feat(linter): Follow-up to config extends fixes Nov 18, 2025
@github-actions github-actions bot added the C-enhancement Category - New feature or request label Nov 18, 2025
Copy link
Member

@overlookmotel overlookmotel left a comment

Choose a reason for hiding this comment

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

Good stuff. Sorry to come back with more suggestions.

Since you've done the work of fixing the problem, I think it's ideal to make this new correct implementation as clear as possible, to make sure it's used correctly and that we don't accidentally break it again!

Comment on lines +1288 to +1291
// This test uses fixtures that set the same rule to different values:
// - allow_all.json: sets "no-console" to "off"
// - warn_all.json: sets "no-console" to "warn"
// - deny_all.json: sets "no-console" to "error"
Copy link
Member

Choose a reason for hiding this comment

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

The text fixture does make sure that the last wins over the first 2. But it'd be ideal to also check all the other combinations (including no clashes). Something like:

// first.json
{
  "rules": { "rule_A": "off", "rule_C": "off", "rule_D": "off", "rule_G": "off" }
}
// second.json
{
  "rules": { "rule_A": "warn", "rule_B": "warn", "rule_D": "warn", "rule_F": "warn" }
}
// third.json
{
  "rules": { "rule_A": "error", "rule_B": "error", "rule_C": "error", "rule_E": "error" }
}
// main.json
{
  "extends": [
    "./first.json",
    "./second.json",
    "./third.json"
  ]
}

Merged config should be equivalent to:

{
  "rules": {
    "rule_A": "error", // `third` wins over both `first` and `second`
    "rule_B": "error", // `third` wins over `second`
    "rule_C": "error", // `third` wins over `first`
    "rule_D": "warn",  // `second` wins over `first`
    "rule_E": "error", // `third` wins when no clash
    "rule_F": "warn",  // `second` wins when no clash
    "rule_G": "off",   // `first` wins when no clash
  },
}

That's rather convoluted, but since we're trying to fix this for once and for all, I think it's worthwhile covering all cases.

Comment on lines +226 to +229
/// // base.json: { "rules": { "eqeqeq": "error" } }
/// // current.json: { "rules": { "eqeqeq": "warn", "no-console": "error" } }
/// // After merge: { "rules": { "eqeqeq": "warn", "no-console": "error" } }
/// // ^ current.json's "warn" wins over base.json's "error"
Copy link
Member

@overlookmotel overlookmotel Nov 18, 2025

Choose a reason for hiding this comment

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

I think this would clarify which is which:

Suggested change
/// // base.json: { "rules": { "eqeqeq": "error" } }
/// // current.json: { "rules": { "eqeqeq": "warn", "no-console": "error" } }
/// // After merge: { "rules": { "eqeqeq": "warn", "no-console": "error" } }
/// // ^ current.json's "warn" wins over base.json's "error"
/// // self.json: { "rules": { "eqeqeq": "error", "no-debugger": "error" } }
/// // other.json: { "rules": { "eqeqeq": "warn", "no-console": "warn" } }
/// // After merge: { "rules": { "eqeqeq": "error", "no-debugger": "error", "no-console": "warn" } }
/// // ^ self.json's "error" for `eqeqeq` wins over other.json's "warn"

#[must_use]
pub fn merge(&self, other: &Oxlintrc) -> Oxlintrc {
let mut categories = other.categories.clone();
pub fn merge(&self, other: Oxlintrc) -> Oxlintrc {
Copy link
Member

Choose a reason for hiding this comment

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

Shall we rename this method to merge_onto? self.merge_onto(other) I think makes it clearer at the call site that self takes priority.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants