Skip to content
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: -c .oxlintrc.json test.js
working directory: fixtures/report_rule_without_enabled_plugin
----------
WARNING: rule 'promise/param-names' is configured but the 'promise' plugin is not enabled. Enable the plugin in the 'plugins' list (e.g. "plugins": ["promise"]) or remove the rule from your config.
Found 0 warnings and 0 errors.
Finished in <variable>ms on 1 file with 89 rules using 1 threads.
----------
CLI result: LintSucceeded
----------
32 changes: 29 additions & 3 deletions crates/oxc_linter/src/config/config_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ pub struct ConfigStoreBuilder {
config: LintConfig,
categories: OxlintCategories,
overrides: OxlintOverrides,
// Collected non-fatal warnings encountered while building the config (e.g. disabled plugin referenced)
pub(super) warnings: Vec<String>,

// Collect all `extends` file paths for the language server.
// The server will tell the clients to watch for the extends files.
Expand All @@ -58,7 +60,15 @@ impl ConfigStoreBuilder {
let overrides = OxlintOverrides::default();
let extended_paths = Vec::new();

Self { rules, external_rules, config, categories, overrides, extended_paths }
Self {
rules,
external_rules,
config,
categories,
overrides,
extended_paths,
warnings: Vec::new(),
}
}

/// Warn on all rules in all plugins and categories, including those in `nursery`.
Expand All @@ -72,7 +82,15 @@ impl ConfigStoreBuilder {
let rules = RULES.iter().map(|rule| (rule.clone(), AllowWarnDeny::Warn)).collect();
let external_rules = FxHashMap::default();
let extended_paths = Vec::new();
Self { rules, external_rules, config, categories, overrides, extended_paths }
Self {
rules,
external_rules,
config,
categories,
overrides,
extended_paths,
warnings: Vec::new(),
}
}

/// Create a [`ConfigStoreBuilder`] from a loaded or manually built [`Oxlintrc`].
Expand Down Expand Up @@ -214,6 +232,7 @@ impl ConfigStoreBuilder {
config,
categories,
overrides: oxlintrc.overrides,
warnings: Vec::new(),
extended_paths,
};

Expand All @@ -231,6 +250,7 @@ impl ConfigStoreBuilder {
&mut builder.external_rules,
&all_rules,
external_plugin_store,
&mut builder.warnings,
)
.map_err(ConfigBuilderError::ExternalRuleLookupError)?;
}
Expand Down Expand Up @@ -336,6 +356,11 @@ impl ConfigStoreBuilder {
self.get_all_rules_for_plugins(None)
}

/// Return any collected warnings produced while building the config.
pub fn warnings(&self) -> &Vec<String> {
&self.warnings
}

fn get_all_rules_for_plugins(&self, override_plugins: Option<LintPlugins>) -> Vec<RuleEnum> {
let mut builtin_plugins = if let Some(override_plugins) = override_plugins {
self.config.plugins | override_plugins
Expand Down Expand Up @@ -420,7 +445,7 @@ impl ConfigStoreBuilder {
}

fn resolve_overrides(
&self,
&mut self,
overrides: OxlintOverrides,
external_plugin_store: &ExternalPluginStore,
) -> Result<ResolvedOxlintOverrides, ExternalRuleLookupError> {
Expand All @@ -440,6 +465,7 @@ impl ConfigStoreBuilder {
&mut external_rules_map,
&all_rules,
external_plugin_store,
&mut self.warnings,
)?;

// Convert to vectors
Expand Down
Loading
Loading