Skip to content

Commit 74e52f3

Browse files
authored
fix(linter/plugins): resolve JS plugins with ESM condition names (#14541)
- Closes: #14503
1 parent 452d128 commit 74e52f3

File tree

6 files changed

+67
-5
lines changed

6 files changed

+67
-5
lines changed

apps/oxlint/test/fixtures/load_paths/.oxlintrc.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"./plugins/plugin6.mts",
99
"./plugins/plugin7",
1010
"plugin8",
11-
"plugin9"
11+
"plugin9",
12+
"plugin10"
1213
],
1314
"rules": {
1415
"plugin1/no-debugger": "error",
@@ -19,6 +20,7 @@
1920
"plugin6/no-debugger": "error",
2021
"plugin7/no-debugger": "error",
2122
"plugin8/no-debugger": "error",
22-
"plugin9/no-debugger": "error"
23+
"plugin9/no-debugger": "error",
24+
"plugin10/no-debugger": "error"
2325
}
2426
}

apps/oxlint/test/fixtures/load_paths/node_modules/plugin10/index.cjs

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/oxlint/test/fixtures/load_paths/node_modules/plugin10/index.js

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/oxlint/test/fixtures/load_paths/node_modules/plugin10/package.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/oxlint/test/fixtures/load_paths/output.snap.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
: ^^^^^^^^^
1717
`----
1818
19+
x plugin10(no-debugger): Unexpected Debugger Statement
20+
,-[files/index.js:1:1]
21+
1 | debugger;
22+
: ^^^^^^^^^
23+
`----
24+
1925
x plugin2(no-debugger): Unexpected Debugger Statement
2026
,-[files/index.js:1:1]
2127
1 | debugger;
@@ -64,7 +70,7 @@
6470
: ^^^^^^^^^
6571
`----
6672
67-
Found 1 warning and 9 errors.
73+
Found 1 warning and 10 errors.
6874
Finished in Xms on 1 file using X threads.
6975
```
7076

crates/oxc_linter/src/config/config_builder.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::{
44
};
55

66
use itertools::Itertools;
7-
use oxc_resolver::Resolver;
7+
use oxc_resolver::{ResolveOptions, Resolver};
88
use rustc_hash::{FxHashMap, FxHashSet};
99

1010
use oxc_span::{CompactStr, format_compact_str};
@@ -169,7 +169,11 @@ impl ConfigStoreBuilder {
169169
return Err(ConfigBuilderError::NoExternalLinterConfigured { plugin_specifier });
170170
};
171171

172-
let resolver = Resolver::default();
172+
let resolver = Resolver::new(ResolveOptions {
173+
main_fields: vec!["module".into(), "main".into()],
174+
condition_names: vec!["module".into(), "import".into()],
175+
..Default::default()
176+
});
173177

174178
#[expect(clippy::missing_panics_doc, reason = "oxlintrc.path is always a file path")]
175179
let oxlintrc_dir = oxlintrc.path.parent().unwrap();

0 commit comments

Comments
 (0)