mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
fix(linter): keep rules disabled if the rule is not enabled in the config (#2031)
relates #1969
This commit is contained in:
parent
3490111c56
commit
68606c4d6d
4 changed files with 28 additions and 9 deletions
5
crates/oxc_cli/fixtures/no_console_off/eslintrc.json
Normal file
5
crates/oxc_cli/fixtures/no_console_off/eslintrc.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"rules": {
|
||||
"no-console": "off"
|
||||
}
|
||||
}
|
||||
1
crates/oxc_cli/fixtures/no_console_off/test.js
Normal file
1
crates/oxc_cli/fixtures/no_console_off/test.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
console.log()
|
||||
|
|
@ -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 = &[
|
||||
|
|
|
|||
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue