mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
feat(linter): warn unmatched rule names (#6782)
Fixes https://github.com/oxc-project/oxc/issues/6763
This commit is contained in:
parent
fdd69e4b3f
commit
2aa763c803
1 changed files with 13 additions and 1 deletions
|
|
@ -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());
|
||||
|
|
@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue