Skip to content

Commit dd97c19

Browse files
committed
perf(linter): import/namespace: only run when there is module syntax and import entries
1 parent 243dd56 commit dd97c19

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

crates/oxc_linter/src/rules/import/namespace.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,21 @@ impl Rule for Namespace {
224224
});
225225
}
226226
}
227+
228+
fn should_run(&self, ctx: &crate::context::ContextHost) -> bool {
229+
if !ctx.module_record().has_module_syntax {
230+
return false;
231+
}
232+
if ctx.module_record().import_entries.iter().any(|entry| {
233+
matches!(
234+
entry.import_name,
235+
ImportImportName::NamespaceObject | ImportImportName::Name(_)
236+
)
237+
}) {
238+
return true;
239+
}
240+
true
241+
}
227242
}
228243

229244
/// If the name is a namespace object in imported module, return the module request name.

0 commit comments

Comments
 (0)