diff --git a/crates/oxc_linter/src/rules/import/namespace.rs b/crates/oxc_linter/src/rules/import/namespace.rs index e4ac697919168..74431454a1b3a 100644 --- a/crates/oxc_linter/src/rules/import/namespace.rs +++ b/crates/oxc_linter/src/rules/import/namespace.rs @@ -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; }; diff --git a/crates/oxc_linter/src/service/runtime.rs b/crates/oxc_linter/src/service/runtime.rs index 87ba57824759e..8014df9f582fc 100644 --- a/crates/oxc_linter/src/service/runtime.rs +++ b/crates/oxc_linter/src/service/runtime.rs @@ -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()