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
----------
23 changes: 15 additions & 8 deletions crates/oxc_linter/src/config/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,21 @@ impl OxlintRules {
let severity = rule_config.severity;

if LintPlugins::try_from(plugin_name).is_ok() {
let rule = rules_map.get(&plugin_name).copied().or_else(|| {
all_rules
.iter()
.find(|r| r.name() == rule_name && r.plugin_name() == plugin_name)
});
if let Some(rule) = rule {
rules_to_replace.push((rule.read_json(config), severity));
}
let rule = rules_map.get(&plugin_name).copied().or_else(|| {
all_rules
.iter()
.find(|r| r.name() == rule_name && r.plugin_name() == plugin_name)
});
if let Some(rule) = rule {
rules_to_replace.push((rule.read_json(config), severity));
} else {
// Warn about configuring a builtin rule while the plugin is not enabled.
// This helps users detect misconfigurations like "promise/param-names" while having "plugins": []
warnings.push(format!(
"WARNING: rule '{}/{}' is configured but the '{}' plugin is not enabled. Enable the plugin in the 'plugins' list (e.g. \"plugins\": [\"{}\"]) or remove the rule from your config.",
plugin_name, rule_name, plugin_name, plugin_name
));
}
} 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.
Expand Down
Loading