Skip to content

Commit a92e84e

Browse files
committed
refactor(linter/plugins): discard ExternalLinter if no JS plugins registered
1 parent 5dc82ff commit a92e84e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

apps/oxlint/src/lint.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ impl LintRunner {
234234
}
235235
.with_filters(&filters);
236236

237+
// If no external rules, discard `ExternalLinter`
238+
let mut external_linter = self.external_linter;
239+
if external_plugin_store.is_empty() {
240+
external_linter = None;
241+
}
242+
237243
if let Some(basic_config_file) = oxlintrc_for_print {
238244
let config_file = config_builder.resolve_final_config_file(basic_config_file);
239245
if misc_options.print_config {
@@ -324,7 +330,7 @@ impl LintRunner {
324330
}
325331
}
326332

327-
let linter = Linter::new(LintOptions::default(), config_store, self.external_linter)
333+
let linter = Linter::new(LintOptions::default(), config_store, external_linter)
328334
.with_fix(fix_options.fix_kind())
329335
.with_report_unused_directives(report_unused_directives);
330336

crates/oxc_linter/src/external_plugin_store.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ pub struct ExternalPluginStore {
2222
}
2323

2424
impl ExternalPluginStore {
25+
/// Returns `true` if no external plugins have been loaded.
26+
pub fn is_empty(&self) -> bool {
27+
self.plugins.is_empty()
28+
}
29+
2530
pub fn is_plugin_registered(&self, plugin_path: &str) -> bool {
2631
self.registered_plugin_paths.contains(plugin_path)
2732
}

0 commit comments

Comments
 (0)