diff --git a/apps/oxlint/fixtures/extends_config/empty_config.json b/apps/oxlint/fixtures/extends_config/empty_config.json deleted file mode 100644 index 0967ef424bce6..0000000000000 --- a/apps/oxlint/fixtures/extends_config/empty_config.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/crates/oxc_linter/fixtures/extends_config/console.js b/crates/oxc_linter/fixtures/extends_config/console.js new file mode 100644 index 0000000000000..14c198cadb60d --- /dev/null +++ b/crates/oxc_linter/fixtures/extends_config/console.js @@ -0,0 +1 @@ +console.log("test"); diff --git a/apps/oxlint/fixtures/extends_config/extends_invalid_config.json b/crates/oxc_linter/fixtures/extends_config/extends_invalid_config.json similarity index 100% rename from apps/oxlint/fixtures/extends_config/extends_invalid_config.json rename to crates/oxc_linter/fixtures/extends_config/extends_invalid_config.json diff --git a/crates/oxc_linter/fixtures/extends_config/extends_rules_config.json b/crates/oxc_linter/fixtures/extends_config/extends_rules_config.json new file mode 100644 index 0000000000000..c0d39c617ccd5 --- /dev/null +++ b/crates/oxc_linter/fixtures/extends_config/extends_rules_config.json @@ -0,0 +1,3 @@ +{ + "extends": ["./rules_config.json"] +} diff --git a/apps/oxlint/fixtures/extends_config/invalid_config.json b/crates/oxc_linter/fixtures/extends_config/invalid_config.json similarity index 100% rename from apps/oxlint/fixtures/extends_config/invalid_config.json rename to crates/oxc_linter/fixtures/extends_config/invalid_config.json diff --git a/crates/oxc_linter/fixtures/extends_config/overrides/.oxlintrc.json b/crates/oxc_linter/fixtures/extends_config/overrides/.oxlintrc.json new file mode 100644 index 0000000000000..cb4ff12307233 --- /dev/null +++ b/crates/oxc_linter/fixtures/extends_config/overrides/.oxlintrc.json @@ -0,0 +1,6 @@ +{ + "extends": ["jsx.json", "./typescript.json"], + "rules": { + "no-unused-vars": "off" + } +} diff --git a/crates/oxc_linter/fixtures/extends_config/overrides/jsx.json b/crates/oxc_linter/fixtures/extends_config/overrides/jsx.json new file mode 100644 index 0000000000000..0a20cfab61de2 --- /dev/null +++ b/crates/oxc_linter/fixtures/extends_config/overrides/jsx.json @@ -0,0 +1,11 @@ +{ + "plugins": ["jsx-a11y"], + "overrides": [ + { + "files": ["*.{jsx,tsx}"], + "rules": { + "jsx-a11y/anchor-ambiguous-text": "error" + } + } + ] +} diff --git a/crates/oxc_linter/fixtures/extends_config/overrides/test.ts b/crates/oxc_linter/fixtures/extends_config/overrides/test.ts new file mode 100644 index 0000000000000..47f1b9a1591dd --- /dev/null +++ b/crates/oxc_linter/fixtures/extends_config/overrides/test.ts @@ -0,0 +1 @@ +const x: any = 3; diff --git a/crates/oxc_linter/fixtures/extends_config/overrides/test.tsx b/crates/oxc_linter/fixtures/extends_config/overrides/test.tsx new file mode 100644 index 0000000000000..0129f4e1ce044 --- /dev/null +++ b/crates/oxc_linter/fixtures/extends_config/overrides/test.tsx @@ -0,0 +1,3 @@ +function component(): any { + return click here; +} diff --git a/crates/oxc_linter/fixtures/extends_config/overrides/typescript.json b/crates/oxc_linter/fixtures/extends_config/overrides/typescript.json new file mode 100644 index 0000000000000..57918a285d238 --- /dev/null +++ b/crates/oxc_linter/fixtures/extends_config/overrides/typescript.json @@ -0,0 +1,11 @@ +{ + "overrides": [ + { + "files": ["*.{ts,tsx}"], + "plugins": ["typescript"], + "rules": { + "@typescript-eslint/no-explicit-any": "error" + } + } + ] +} diff --git a/apps/oxlint/fixtures/extends_config/plugins/jest.json b/crates/oxc_linter/fixtures/extends_config/plugins/jest.json similarity index 100% rename from apps/oxlint/fixtures/extends_config/plugins/jest.json rename to crates/oxc_linter/fixtures/extends_config/plugins/jest.json diff --git a/apps/oxlint/fixtures/extends_config/plugins/react.json b/crates/oxc_linter/fixtures/extends_config/plugins/react.json similarity index 100% rename from apps/oxlint/fixtures/extends_config/plugins/react.json rename to crates/oxc_linter/fixtures/extends_config/plugins/react.json diff --git a/crates/oxc_linter/fixtures/extends_config/rules_config.json b/crates/oxc_linter/fixtures/extends_config/rules_config.json new file mode 100644 index 0000000000000..b9e3db9d4e252 --- /dev/null +++ b/crates/oxc_linter/fixtures/extends_config/rules_config.json @@ -0,0 +1,7 @@ +{ + "rules": { + "no-debugger": "off", + "no-console": "error", + "unicorn/no-null": "error" + } +} diff --git a/apps/oxlint/fixtures/extends_config/rules_multiple/allow_all.json b/crates/oxc_linter/fixtures/extends_config/rules_multiple/allow_all.json similarity index 100% rename from apps/oxlint/fixtures/extends_config/rules_multiple/allow_all.json rename to crates/oxc_linter/fixtures/extends_config/rules_multiple/allow_all.json diff --git a/apps/oxlint/fixtures/extends_config/rules_multiple/deny_all.json b/crates/oxc_linter/fixtures/extends_config/rules_multiple/deny_all.json similarity index 100% rename from apps/oxlint/fixtures/extends_config/rules_multiple/deny_all.json rename to crates/oxc_linter/fixtures/extends_config/rules_multiple/deny_all.json diff --git a/apps/oxlint/fixtures/extends_config/rules_multiple/warn_all.json b/crates/oxc_linter/fixtures/extends_config/rules_multiple/warn_all.json similarity index 100% rename from apps/oxlint/fixtures/extends_config/rules_multiple/warn_all.json rename to crates/oxc_linter/fixtures/extends_config/rules_multiple/warn_all.json diff --git a/crates/oxc_linter/src/config/config_builder.rs b/crates/oxc_linter/src/config/config_builder.rs index 0d98aa0ab680f..d7b6240a37bdf 100644 --- a/crates/oxc_linter/src/config/config_builder.rs +++ b/crates/oxc_linter/src/config/config_builder.rs @@ -744,13 +744,12 @@ mod test { #[test] fn test_extends_rules_single() { - let base_config = - config_store_from_path("../../apps/oxlint/fixtures/extends_config/rules_config.json"); + let base_config = config_store_from_path("fixtures/extends_config/rules_config.json"); let derived_config = config_store_from_str( r#" { "extends": [ - "../../apps/oxlint/fixtures/extends_config/rules_config.json" + "fixtures/extends_config/rules_config.json" ] } "#, @@ -762,7 +761,7 @@ mod test { r#" { "extends": [ - "../../apps/oxlint/fixtures/extends_config/rules_config.json" + "fixtures/extends_config/rules_config.json" ], "rules": { "no-debugger": "warn", @@ -806,9 +805,9 @@ mod test { r#" { "extends": [ - "../../apps/oxlint/fixtures/extends_config/rules_multiple/allow_all.json", - "../../apps/oxlint/fixtures/extends_config/rules_multiple/deny_all.json", - "../../apps/oxlint/fixtures/extends_config/rules_multiple/warn_all.json" + "fixtures/extends_config/rules_multiple/allow_all.json", + "fixtures/extends_config/rules_multiple/deny_all.json", + "fixtures/extends_config/rules_multiple/warn_all.json" ] } "#, @@ -819,9 +818,9 @@ mod test { r#" { "extends": [ - "../../apps/oxlint/fixtures/extends_config/rules_multiple/allow_all.json", - "../../apps/oxlint/fixtures/extends_config/rules_multiple/warn_all.json", - "../../apps/oxlint/fixtures/extends_config/rules_multiple/deny_all.json" + "fixtures/extends_config/rules_multiple/allow_all.json", + "fixtures/extends_config/rules_multiple/warn_all.json", + "fixtures/extends_config/rules_multiple/deny_all.json" ] } "#, @@ -832,9 +831,9 @@ mod test { r#" { "extends": [ - "../../apps/oxlint/fixtures/extends_config/rules_multiple/warn_all.json", - "../../apps/oxlint/fixtures/extends_config/rules_multiple/deny_all.json", - "../../apps/oxlint/fixtures/extends_config/rules_multiple/allow_all.json" + "fixtures/extends_config/rules_multiple/warn_all.json", + "fixtures/extends_config/rules_multiple/deny_all.json", + "fixtures/extends_config/rules_multiple/allow_all.json" ] } "#, @@ -846,8 +845,8 @@ mod test { r#" { "extends": [ - "../../apps/oxlint/fixtures/extends_config/rules_multiple/deny_all.json", - "../../apps/oxlint/fixtures/extends_config/rules_multiple/allow_all.json" + "fixtures/extends_config/rules_multiple/deny_all.json", + "fixtures/extends_config/rules_multiple/allow_all.json" ], "rules": { "no-var": "warn", @@ -882,7 +881,7 @@ mod test { let invalid_config = ConfigStoreBuilder::from_oxlintrc( true, Oxlintrc::from_file(&PathBuf::from( - "../../apps/oxlint/fixtures/extends_config/extends_invalid_config.json", + "fixtures/extends_config/extends_invalid_config.json", )) .unwrap(), ); @@ -900,8 +899,8 @@ mod test { r#" { "extends": [ - "../../apps/oxlint/fixtures/extends_config/plugins/jest.json", - "../../apps/oxlint/fixtures/extends_config/plugins/react.json" + "fixtures/extends_config/plugins/jest.json", + "fixtures/extends_config/plugins/react.json" ] } "#, @@ -915,8 +914,8 @@ mod test { r#" { "extends": [ - "../../apps/oxlint/fixtures/extends_config/plugins/jest.json", - "../../apps/oxlint/fixtures/extends_config/plugins/react.json" + "fixtures/extends_config/plugins/jest.json", + "fixtures/extends_config/plugins/react.json" ], "plugins": ["typescript"] } @@ -933,8 +932,8 @@ mod test { r#" { "extends": [ - "../../apps/oxlint/fixtures/extends_config/plugins/jest.json", - "../../apps/oxlint/fixtures/extends_config/plugins/react.json" + "fixtures/extends_config/plugins/jest.json", + "fixtures/extends_config/plugins/react.json" ], "plugins": [] }