Skip to content

Commit

Permalink
feat(linter): warn unmatched rule names (oxc-project#6782)
Browse files Browse the repository at this point in the history
  • Loading branch information
tapanprakasht authored Oct 23, 2024
1 parent fdd69e4 commit 2aa763c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion crates/oxc_linter/src/config/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RuleWithSeverity> = vec![];
let mut rules_to_remove: Vec<RuleWithSeverity> = 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());
Expand All @@ -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 => {
Expand All @@ -96,6 +99,8 @@ impl OxlintRules {
{
let rule = rule.clone();
rules_to_remove.push(rule);
} else {
rules_not_matched.push(rule_name);
}
}
}
Expand Down Expand Up @@ -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}");
}
}
}
}

Expand Down

0 comments on commit 2aa763c

Please sign in to comment.