diff --git a/apps/oxlint/test/fixtures/load_paths/.oxlintrc.json b/apps/oxlint/test/fixtures/load_paths/.oxlintrc.json index 6feb262f80dd2..bb64a807ee6b5 100644 --- a/apps/oxlint/test/fixtures/load_paths/.oxlintrc.json +++ b/apps/oxlint/test/fixtures/load_paths/.oxlintrc.json @@ -8,7 +8,8 @@ "./plugins/plugin6.mts", "./plugins/plugin7", "plugin8", - "plugin9" + "plugin9", + "plugin10" ], "rules": { "plugin1/no-debugger": "error", @@ -19,6 +20,7 @@ "plugin6/no-debugger": "error", "plugin7/no-debugger": "error", "plugin8/no-debugger": "error", - "plugin9/no-debugger": "error" + "plugin9/no-debugger": "error", + "plugin10/no-debugger": "error" } } diff --git a/apps/oxlint/test/fixtures/load_paths/node_modules/plugin10/index.cjs b/apps/oxlint/test/fixtures/load_paths/node_modules/plugin10/index.cjs new file mode 100644 index 0000000000000..bbe364bee89b1 --- /dev/null +++ b/apps/oxlint/test/fixtures/load_paths/node_modules/plugin10/index.cjs @@ -0,0 +1,21 @@ +'use strict'; + +module.exports = { + meta: { + name: "plugin10", + }, + rules: { + "no-debugger": { + create(context) { + return { + DebuggerStatement(debuggerStatement) { + context.report({ + message: "Unexpected Debugger Statement", + node: debuggerStatement, + }); + }, + }; + }, + }, + }, +}; diff --git a/apps/oxlint/test/fixtures/load_paths/node_modules/plugin10/index.js b/apps/oxlint/test/fixtures/load_paths/node_modules/plugin10/index.js new file mode 100644 index 0000000000000..ee5a1a0ce4252 --- /dev/null +++ b/apps/oxlint/test/fixtures/load_paths/node_modules/plugin10/index.js @@ -0,0 +1,19 @@ +export default { + meta: { + name: "plugin10", + }, + rules: { + "no-debugger": { + create(context) { + return { + DebuggerStatement(debuggerStatement) { + context.report({ + message: "Unexpected Debugger Statement", + node: debuggerStatement, + }); + }, + }; + }, + }, + }, +}; diff --git a/apps/oxlint/test/fixtures/load_paths/node_modules/plugin10/package.json b/apps/oxlint/test/fixtures/load_paths/node_modules/plugin10/package.json new file mode 100644 index 0000000000000..1ef304dcda024 --- /dev/null +++ b/apps/oxlint/test/fixtures/load_paths/node_modules/plugin10/package.json @@ -0,0 +1,10 @@ +{ + "name": "plugin10", + "type": "module", + "exports": { + ".": { + "import": "./index.js", + "require": "./index.cjs" + } + } +} diff --git a/apps/oxlint/test/fixtures/load_paths/output.snap.md b/apps/oxlint/test/fixtures/load_paths/output.snap.md index 30e941bf52591..4779f03d15b3b 100644 --- a/apps/oxlint/test/fixtures/load_paths/output.snap.md +++ b/apps/oxlint/test/fixtures/load_paths/output.snap.md @@ -16,6 +16,12 @@ : ^^^^^^^^^ `---- + x plugin10(no-debugger): Unexpected Debugger Statement + ,-[files/index.js:1:1] + 1 | debugger; + : ^^^^^^^^^ + `---- + x plugin2(no-debugger): Unexpected Debugger Statement ,-[files/index.js:1:1] 1 | debugger; @@ -64,7 +70,7 @@ : ^^^^^^^^^ `---- -Found 1 warning and 9 errors. +Found 1 warning and 10 errors. Finished in Xms on 1 file using X threads. ``` diff --git a/crates/oxc_linter/src/config/config_builder.rs b/crates/oxc_linter/src/config/config_builder.rs index 6d81043e89de1..78319fcdccf27 100644 --- a/crates/oxc_linter/src/config/config_builder.rs +++ b/crates/oxc_linter/src/config/config_builder.rs @@ -4,7 +4,7 @@ use std::{ }; use itertools::Itertools; -use oxc_resolver::Resolver; +use oxc_resolver::{ResolveOptions, Resolver}; use rustc_hash::{FxHashMap, FxHashSet}; use oxc_span::{CompactStr, format_compact_str}; @@ -169,7 +169,11 @@ impl ConfigStoreBuilder { return Err(ConfigBuilderError::NoExternalLinterConfigured { plugin_specifier }); }; - let resolver = Resolver::default(); + let resolver = Resolver::new(ResolveOptions { + main_fields: vec!["module".into(), "main".into()], + condition_names: vec!["module".into(), "import".into()], + ..Default::default() + }); #[expect(clippy::missing_panics_doc, reason = "oxlintrc.path is always a file path")] let oxlintrc_dir = oxlintrc.path.parent().unwrap();