diff --git a/crates/oxc_linter/src/rules/import/namespace.rs b/crates/oxc_linter/src/rules/import/namespace.rs index 46caa77c7b2c4..ced56dc305bf9 100644 --- a/crates/oxc_linter/src/rules/import/namespace.rs +++ b/crates/oxc_linter/src/rules/import/namespace.rs @@ -224,6 +224,21 @@ impl Rule for Namespace { }); } } + + fn should_run(&self, ctx: &crate::context::ContextHost) -> bool { + if !ctx.module_record().has_module_syntax { + return false; + } + if ctx.module_record().import_entries.iter().any(|entry| { + matches!( + entry.import_name, + ImportImportName::NamespaceObject | ImportImportName::Name(_) + ) + }) { + return true; + } + true + } } /// If the name is a namespace object in imported module, return the module request name.