Skip to content

Commit

Permalink
fix(linter): fix unwanted plugin rules being enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Apr 22, 2024
1 parent b29aabd commit a5a7351
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions crates/oxc_linter/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,19 @@ impl LintOptions {
AllowWarnDeny::Deny | AllowWarnDeny::Warn => {
match maybe_category {
Some(category) => rules.extend(
RULES.iter().filter(|rule| rule.category() == category).cloned(),
all_rules.iter().filter(|rule| rule.category() == category).cloned(),
),
None => {
if name_or_category == "all" {
rules.extend(all_rules.iter().cloned());
rules.extend(
all_rules
.iter()
.filter(|rule| rule.category() != RuleCategory::Nursery)
.cloned(),
);
} else {
rules.extend(
RULES
all_rules
.iter()
.filter(|rule| rule.name() == name_or_category)
.cloned(),
Expand Down Expand Up @@ -232,19 +237,14 @@ impl LintOptions {
fn get_filtered_rules(&self) -> Vec<RuleEnum> {
RULES
.iter()
.filter(|rule| {
if rule.category() == RuleCategory::Nursery {
return false;
}
match rule.plugin_name() {
IMPORT_PLUGIN_NAME if !self.import_plugin => false,
JSDOC_PLUGIN_NAME if !self.jsdoc_plugin => false,
JEST_PLUGIN_NAME if !self.jest_plugin => false,
JSX_A11Y_PLUGIN_NAME if !self.jsx_a11y_plugin => false,
NEXTJS_PLUGIN_NAME if !self.nextjs_plugin => false,
REACT_PERF_PLUGIN_NAME if !self.react_perf_plugin => false,
_ => true,
}
.filter(|rule| match rule.plugin_name() {
IMPORT_PLUGIN_NAME if !self.import_plugin => false,
JSDOC_PLUGIN_NAME if !self.jsdoc_plugin => false,
JEST_PLUGIN_NAME if !self.jest_plugin => false,
JSX_A11Y_PLUGIN_NAME if !self.jsx_a11y_plugin => false,
NEXTJS_PLUGIN_NAME if !self.nextjs_plugin => false,
REACT_PERF_PLUGIN_NAME if !self.react_perf_plugin => false,
_ => true,
})
.cloned()
.collect::<Vec<_>>()
Expand Down

0 comments on commit a5a7351

Please sign in to comment.