From c7224958efa2995642b1b867b2025268f1a3e63a Mon Sep 17 00:00:00 2001 From: camc314 <18101008+camc314@users.noreply.github.com> Date: Sun, 29 Mar 2026 20:06:41 +0000 Subject: [PATCH] docs(linter): update JS Plugins + LS references (#20843) --- crates/oxc_linter/src/config/config_builder.rs | 7 ++++--- crates/oxc_linter/src/config/rules.rs | 9 ++------- crates/oxc_linter/src/external_plugin_store.rs | 1 - 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/crates/oxc_linter/src/config/config_builder.rs b/crates/oxc_linter/src/config/config_builder.rs index 3173aa4441cdb..51aa730deacdd 100644 --- a/crates/oxc_linter/src/config/config_builder.rs +++ b/crates/oxc_linter/src/config/config_builder.rs @@ -216,9 +216,10 @@ impl ConfigStoreBuilder { } } - // If external plugins are not enabled (language server), then skip loading JS plugins. - // This is so that a project can use JS plugins via `oxlint` CLI, and language server - // will just silently ignore them - rather than crashing. + // Only attempt to load external JS plugins when external plugins are enabled, + // i.e., when the external JS linter is available/initialized. If the store is + // disabled, configs that reference external plugins are accepted but the plugins + // themselves are not loaded, to avoid failing config parsing. if !external_plugins.is_empty() && external_plugin_store.is_enabled() { let Some(external_linter) = external_linter else { #[expect(clippy::missing_panics_doc, reason = "infallible")] diff --git a/crates/oxc_linter/src/config/rules.rs b/crates/oxc_linter/src/config/rules.rs index 9e776767ecf73..3cb3dfe4373e7 100644 --- a/crates/oxc_linter/src/config/rules.rs +++ b/crates/oxc_linter/src/config/rules.rs @@ -189,13 +189,8 @@ impl OxlintRules { }); } } else { - // If JS plugins are disabled (language server), assume plugin name refers to a JS plugin, - // and that rule name is valid for that plugin. - // But language server doesn't support JS plugins, so ignore the rule. - // - // This unfortunately means we can't catch genuinely invalid plugin names in language server - // (e.g. typos like `unicon/filename-case`). But we can't avoid this as the name of a JS plugin - // can only be known by loading it, which language server can't do at present. + // Plugin name is not a built-in plugin. If external plugins are enabled, + // try to resolve it as an external JS plugin; otherwise ignore it. if external_plugin_store.is_enabled() { match external_plugin_store.lookup_rule_id(plugin_name, rule_name) { Ok(external_rule_id) => { diff --git a/crates/oxc_linter/src/external_plugin_store.rs b/crates/oxc_linter/src/external_plugin_store.rs index bc8be4fca2a34..ea3b2d2d5dd34 100644 --- a/crates/oxc_linter/src/external_plugin_store.rs +++ b/crates/oxc_linter/src/external_plugin_store.rs @@ -45,7 +45,6 @@ pub struct ExternalPluginStore { /// The rule ID is also stored, so that can merge options with the rule's default options on JS side. options: IndexVec)>, - /// `true` for `oxlint`, `false` for language server is_enabled: bool, }