Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
17 changes: 12 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,18 @@ 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.
///
/// For example, if `self` has `{ "rules": { "no-console": "error" } }` and `other` has
/// `{ "rules": { "no-console": "warn", "no-debugger": "error" } }`, the result will be
/// `{ "rules": { "no-console": "error", "no-debugger": "error" } }` (self's `"no-console"`
/// setting wins).
#[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 +249,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