From 2aa763c803a79dae09ebb48a7abe4a0adc66c5a3 Mon Sep 17 00:00:00 2001 From: Tapan Prakash Date: Wed, 23 Oct 2024 21:35:01 +0530 Subject: [PATCH] feat(linter): warn unmatched rule names (#6782) Fixes https://github.com/oxc-project/oxc/issues/6763 --- crates/oxc_linter/src/config/rules.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/oxc_linter/src/config/rules.rs b/crates/oxc_linter/src/config/rules.rs index ae51d9f885cdc..f0f07a36c9807 100644 --- a/crates/oxc_linter/src/config/rules.rs +++ b/crates/oxc_linter/src/config/rules.rs @@ -59,11 +59,12 @@ impl IntoIterator for OxlintRules { } impl OxlintRules { - #[allow(clippy::option_if_let_else)] + #[allow(clippy::option_if_let_else, clippy::print_stdout)] pub(crate) fn override_rules(&self, rules_for_override: &mut RuleSet, all_rules: &[RuleEnum]) { use itertools::Itertools; let mut rules_to_replace: Vec = vec![]; let mut rules_to_remove: Vec = vec![]; + let mut rules_not_matched: Vec<&str> = vec![]; // Rules can have the same name but different plugin names let lookup = self.iter().into_group_map_by(|r| r.rule_name.as_str()); @@ -87,6 +88,8 @@ impl OxlintRules { let config = rule_config.config.clone().unwrap_or_default(); let rule = rule.read_json(config); rules_to_replace.push(RuleWithSeverity::new(rule, severity)); + } else { + rules_not_matched.push(rule_name); } } AllowWarnDeny::Allow => { @@ -96,6 +99,8 @@ impl OxlintRules { { let rule = rule.clone(); rules_to_remove.push(rule); + } else { + rules_not_matched.push(rule_name); } } } @@ -127,6 +132,13 @@ impl OxlintRules { for rule in rules_to_replace { rules_for_override.replace(rule); } + + if !rules_not_matched.is_empty() { + println!("The following rules do not match the currently supported rules:"); + for rule in rules_not_matched { + println!("{rule}"); + } + } } }