diff --git a/apps/oxlint/fixtures/overrides_with_plugin/.oxlintrc.json b/apps/oxlint/fixtures/overrides_with_plugin/.oxlintrc.json new file mode 100644 index 0000000000000..febf7a7f2bbe2 --- /dev/null +++ b/apps/oxlint/fixtures/overrides_with_plugin/.oxlintrc.json @@ -0,0 +1,13 @@ +{ + "overrides": [ + { + "files": ["*.test.ts"], + "plugins": ["jest", "vitest"], + "rules": { + "jest/valid-title": "deny", + "no-unused-vars": "off" + } + } + ] + } + \ No newline at end of file diff --git a/apps/oxlint/fixtures/overrides_with_plugin/index.test.ts b/apps/oxlint/fixtures/overrides_with_plugin/index.test.ts new file mode 100644 index 0000000000000..b8a63407093bd --- /dev/null +++ b/apps/oxlint/fixtures/overrides_with_plugin/index.test.ts @@ -0,0 +1,7 @@ +describe("", () => { + // + + it("", () => {}); +}); + +const foo = 123; diff --git a/apps/oxlint/fixtures/overrides_with_plugin/index.ts b/apps/oxlint/fixtures/overrides_with_plugin/index.ts new file mode 100644 index 0000000000000..472e4584238a4 --- /dev/null +++ b/apps/oxlint/fixtures/overrides_with_plugin/index.ts @@ -0,0 +1 @@ +const foo = 123; diff --git a/apps/oxlint/src/lint.rs b/apps/oxlint/src/lint.rs index b1f1184f41709..827b55bfd9709 100644 --- a/apps/oxlint/src/lint.rs +++ b/apps/oxlint/src/lint.rs @@ -1165,4 +1165,10 @@ mod test { let args = &["-c", ".oxlintrc.json"]; Tester::new().with_cwd("fixtures/issue_11054".into()).test_and_snapshot(args); } + + #[test] + fn test_plugins_in_overrides_enabled_correctly() { + let args = &["-c", ".oxlintrc.json"]; + Tester::new().with_cwd("fixtures/overrides_with_plugin".into()).test_and_snapshot(args); + } } diff --git a/apps/oxlint/src/snapshots/fixtures__overrides_with_plugin_-c .oxlintrc.json@oxlint.snap b/apps/oxlint/src/snapshots/fixtures__overrides_with_plugin_-c .oxlintrc.json@oxlint.snap new file mode 100644 index 0000000000000..fb6df87b9015f --- /dev/null +++ b/apps/oxlint/src/snapshots/fixtures__overrides_with_plugin_-c .oxlintrc.json@oxlint.snap @@ -0,0 +1,38 @@ +--- +source: apps/oxlint/src/tester.rs +--- +########## +arguments: -c .oxlintrc.json +working directory: fixtures/overrides_with_plugin +---------- + + x ]8;;https://oxc.rs/docs/guide/usage/linter/rules/jest/valid-title.html\eslint-plugin-jest(valid-title)]8;;\: "Should not have an empty title" + ,-[index.test.ts:1:10] + 1 | describe("", () => { + : ^^ + 2 | // + `---- + help: "Write a meaningful title for your test" + + ! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unused-vars.html\eslint(no-unused-vars)]8;;\: Variable 'foo' is declared but never used. Unused variables should start with a '_'. + ,-[index.ts:1:7] + 1 | const foo = 123; + : ^|^ + : `-- 'foo' is declared here + `---- + help: Consider removing this declaration. + + x ]8;;https://oxc.rs/docs/guide/usage/linter/rules/jest/valid-title.html\eslint-plugin-jest(valid-title)]8;;\: "Should not have an empty title" + ,-[index.test.ts:4:6] + 3 | + 4 | it("", () => {}); + : ^^ + 5 | }); + `---- + help: "Write a meaningful title for your test" + +Found 1 warning and 2 errors. +Finished in ms on 2 files with 101 rules using 1 threads. +---------- +CLI result: LintFoundErrors +---------- diff --git a/crates/oxc_linter/src/config/config_store.rs b/crates/oxc_linter/src/config/config_store.rs index 9c75e4c117dbc..fd9175009ce53 100644 --- a/crates/oxc_linter/src/config/config_store.rs +++ b/crates/oxc_linter/src/config/config_store.rs @@ -88,6 +88,13 @@ impl Config { let mut env = self.base.config.env.clone(); let mut globals = self.base.config.globals.clone(); let mut plugins = self.base.config.plugins; + + for override_config in overrides_to_apply.clone() { + if let Some(override_plugins) = override_config.plugins { + plugins |= override_plugins; + } + } + let mut rules = self .base .rules @@ -107,10 +114,6 @@ impl Config { override_config.rules.override_rules(&mut rules, &all_rules); } - if let Some(override_plugins) = override_config.plugins { - plugins |= override_plugins; - } - if let Some(override_env) = &override_config.env { override_env.override_envs(&mut env); }