From 514d40c054283f63a8e9445b22e7905411118165 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Wed, 9 Jul 2025 09:24:29 +0000 Subject: [PATCH] perf(linter): do not create `Resolver` unless required (#12142) Follow-on after #11980. Skip creating a `Resolver` unless there are JS plugins which need to be resolved. Creating a `Resolver` is not so expensive, but it's not super-cheap either. --- crates/oxc_linter/src/config/config_builder.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/oxc_linter/src/config/config_builder.rs b/crates/oxc_linter/src/config/config_builder.rs index d25a5f9efa7fb..9235b04076985 100644 --- a/crates/oxc_linter/src/config/config_builder.rs +++ b/crates/oxc_linter/src/config/config_builder.rs @@ -139,14 +139,16 @@ impl ConfigStoreBuilder { let (oxlintrc, extended_paths) = resolve_oxlintrc_config(oxlintrc)?; if let Some(plugins) = oxlintrc.plugins.as_ref() { - let resolver = oxc_resolver::Resolver::new(ResolveOptions::default()); - for plugin_name in &plugins.external { - Self::load_external_plugin( - &oxlintrc.path, - plugin_name, - external_linter, - &resolver, - )?; + if !plugins.external.is_empty() { + let resolver = oxc_resolver::Resolver::new(ResolveOptions::default()); + for plugin_name in &plugins.external { + Self::load_external_plugin( + &oxlintrc.path, + plugin_name, + external_linter, + &resolver, + )?; + } } } let plugins = oxlintrc.plugins.unwrap_or_default();