diff --git a/crates/oxc_cli/fixtures/no_console_off/eslintrc.json b/crates/oxc_cli/fixtures/no_console_off/eslintrc.json new file mode 100644 index 0000000000000..d5ba8f9d9ca87 --- /dev/null +++ b/crates/oxc_cli/fixtures/no_console_off/eslintrc.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-console": "off" + } +} diff --git a/crates/oxc_cli/fixtures/no_console_off/test.js b/crates/oxc_cli/fixtures/no_console_off/test.js new file mode 100644 index 0000000000000..0f4e35a4a0c5e --- /dev/null +++ b/crates/oxc_cli/fixtures/no_console_off/test.js @@ -0,0 +1 @@ +console.log() diff --git a/crates/oxc_cli/src/lint/mod.rs b/crates/oxc_cli/src/lint/mod.rs index 98cdc74d2d65a..66452b9f4d14a 100644 --- a/crates/oxc_cli/src/lint/mod.rs +++ b/crates/oxc_cli/src/lint/mod.rs @@ -363,6 +363,16 @@ mod test { assert_eq!(result.number_of_errors, 0); } + #[test] + fn no_console_off() { + let args = + &["-c", "fixtures/no_console_off/eslintrc.json", "fixtures/no_console_off/test.js"]; + let result = test(args); + assert_eq!(result.number_of_files, 1); + assert_eq!(result.number_of_warnings, 0); + assert_eq!(result.number_of_errors, 0); + } + #[test] fn typescript_eslint() { let args = &[ diff --git a/crates/oxc_linter/src/config/mod.rs b/crates/oxc_linter/src/config/mod.rs index 192267da8e276..0a257899314f5 100644 --- a/crates/oxc_linter/src/config/mod.rs +++ b/crates/oxc_linter/src/config/mod.rs @@ -88,20 +88,23 @@ impl ESLintConfig { let rule_config = &rule_configs[0]; let rule_name = &rule_config.rule_name; let plugin_name = &rule_config.plugin_name; - if let Some(rule) = rules_for_override.iter().find(|r| r.name() == rule_name) { - match rule_config.severity { - AllowWarnDeny::Warn | AllowWarnDeny::Deny => { + match rule_config.severity { + AllowWarnDeny::Warn | AllowWarnDeny::Deny => { + if let Some(rule) = all_rules + .iter() + .find(|r| r.name() == rule_name && r.plugin_name() == plugin_name) + { rules_to_replace.push(rule.read_json(rule_config.config.clone())); } - AllowWarnDeny::Allow => { + } + AllowWarnDeny::Allow => { + if let Some(rule) = rules_for_override + .iter() + .find(|r| r.name() == rule_name && r.plugin_name() == plugin_name) + { rules_to_remove.push(rule.clone()); } } - } else if let Some(rule) = all_rules - .iter() - .find(|r| r.plugin_name() == plugin_name && r.name() == rule_name) - { - rules_to_replace.push(rule.read_json(rule_config.config.clone())); } } _ => {