Skip to content

Commit

Permalink
fix(linter): only resolve esm files for import plugin (#7720)
Browse files Browse the repository at this point in the history
closes #7696

cjs files do not work at all.
  • Loading branch information
Boshen committed Dec 7, 2024
1 parent 5e6053f commit ad27b20
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions crates/oxc_linter/src/rules/import/namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ impl Rule for Namespace {
}
};

if !module.has_module_syntax {
return;
}

let Some(symbol_id) = ctx.scopes().get_root_binding(entry.local_name.name()) else {
return;
};
Expand Down
3 changes: 2 additions & 1 deletion crates/oxc_linter/src/service/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ impl Runtime {
});
Resolver::new(ResolveOptions {
extensions: VALID_EXTENSIONS.iter().map(|ext| format!(".{ext}")).collect(),
condition_names: vec!["module".into(), "require".into()],
main_fields: vec!["module".into(), "main".into()],
condition_names: vec!["module".into(), "import".into()],
extension_alias,
tsconfig,
..ResolveOptions::default()
Expand Down

0 comments on commit ad27b20

Please sign in to comment.