Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/config/config_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl ConfigStoreBuilder {

let (extends, extends_paths) = resolve_oxlintrc_config(extends_oxlintrc)?;

oxlintrc = oxlintrc.merge(&extends);
oxlintrc = oxlintrc.merge(extends);
extended_paths.extend(extends_paths);
}

Expand Down
21 changes: 16 additions & 5 deletions crates/oxc_linter/src/config/oxlintrc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,22 @@ impl Oxlintrc {
serde_json::to_string_pretty(&schema).unwrap()
}

/// Merges two [Oxlintrc] files together
/// [Self] takes priority over `other`
/// Merges two [Oxlintrc] files together.
///
/// [Self] takes priority over `other` - if both configs define the same property,
/// the value from [Self] wins.
///
/// # Example
///
/// ```
/// // If self has: { "rules": { "no-console": "error" } }
/// // and other has: { "rules": { "no-console": "warn", "no-debugger": "error" } }
/// // Result will be: { "rules": { "no-console": "error", "no-debugger": "error" } }
/// // (self's "no-console" setting wins)
/// ```
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

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

The code block in this documentation example should specify a language tag or use ignore to prevent rustdoc from attempting to compile it as a Rust test. The current format will cause doc test failures.

Suggested fix:

/// # Example
///
/// ```ignore
/// // If self has: { "rules": { "no-console": "error" } }
/// // and other has: { "rules": { "no-console": "warn", "no-debugger": "error" } }
/// // Result will be: { "rules": { "no-console": "error", "no-debugger": "error" } }
/// // (self's "no-console" setting wins)
/// ```

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot fix this, what's there currently doesn't really make sense. You've put a code block, with just comments inside. Perhaps use inline code block for just the json? or something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 1857911. Replaced the code block with inline code blocks for the JSON examples to make the documentation clearer.

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

let rules = self
Expand All @@ -242,7 +253,7 @@ impl Oxlintrc {
let env = self.env.clone();
let globals = self.globals.clone();

let mut overrides = other.overrides.clone();
let mut overrides = other.overrides;
overrides.extend(self.overrides.clone());

let plugins = match (self.plugins, other.plugins) {
Expand Down