Skip to content

linter: cannot disable no-nested-ternary rule anymore #8485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jeremy-dupre opened this issue Jan 14, 2025 · 7 comments · Fixed by #8600
Closed

linter: cannot disable no-nested-ternary rule anymore #8485

jeremy-dupre opened this issue Jan 14, 2025 · 7 comments · Fixed by #8600
Labels
A-linter Area - Linter C-bug Category - Bug

Comments

@jeremy-dupre
Copy link

jeremy-dupre commented Jan 14, 2025

What version of Oxlint are you using?

0.15.6

What command did you run?

oxlint -c .oxlintrc.json src

What does your .oxlint.json config file look like?

{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"env": {
"browser": true,
"es2024": true
},
"settings": {},
"plugins": ["oxc", "typescript", "unicorn"],
"categories": {
"correctness": "error",
"perf": "error",
"suspicious": "error",
"restriction": "error",
"style": "warn",
"pedantic": "warn",
"nursery": "off"
},
"rules": {
"no-nested-ternary": "off",
"eslint/no-nested-ternary": "off",
"unicorn/no-nested-ternary": "off"
}
}

What happened?

Since the new 'eslint/no-nested-ternary' rule appeared in 0.15.x (duplicating/replacing the previous unicorn/no-nested-ternary rule?), it seems it cannot be deactivated anymore. With the above setup the rule is still active and generates warning.
It was not the case in 0.14.x

@jeremy-dupre jeremy-dupre added A-linter Area - Linter C-bug Category - Bug labels Jan 14, 2025
@shulaoda
Copy link
Member

shulaoda commented Jan 18, 2025

Related to #5714

Should we change it?

// NOTE: this logic means there's no way to disable ESLint
// correctness rules. I think that's fine for now.

@1zumii
Copy link
Contributor

1zumii commented Jan 19, 2025

@shulaoda
i found that eslint/no-nested-ternary rule is set as RuleCategory::Style

maybe not the filter condition caused this issue?

NoNestedTernary,
eslint,
style,

@shulaoda
Copy link
Member

@shulaoda i found that eslint/no-nested-ternary rule is set as RuleCategory::Style

maybe not the filter condition caused this issue?

oxc/crates/oxc_linter/src/rules/eslint/no_nested_ternary.rs

Lines 41 to 43 in c15af02

 NoNestedTernary, 
 eslint, 
 style,

Yes, I made a mistake.

@1zumii
Copy link
Contributor

1zumii commented Jan 19, 2025

i guess problem is in this branch, only remove one of these rules with same name.

result that unicorn's rule is removed, but eslint's rule still remains.

} else if rule_configs.iter().all(|r| r.severity.is_allow()) {
if let Some(rule) = rules_for_override.iter().find(|r| r.name() == *name) {
rules_to_remove.push(rule.clone());
}

@arnriu arnriu marked this as a duplicate of #8747 Jan 27, 2025
@arnriu
Copy link

arnriu commented Jan 27, 2025

Have same problem. See my closed ticket 👆🏻 if you need to see my config and tests.

@joshderochervlk-simplisafe

Hi, the fix for this works if I have the rule set to "off" for both, or one set to "error" and the other "off", but if I set one to "warn" and the other to "off" the one configured to "warn" shows up as an error.

// works
"eslint/no-nested-ternary": "off",
"unicorn/no-nested-ternary": "off"

// works
"eslint/no-nested-ternary": "error",
"unicorn/no-nested-ternary": "off"

// Shows an error for eslint(no-nested-ternary)
"eslint/no-nested-ternary": "warn",
"unicorn/no-nested-ternary": "off"

@shulaoda
Copy link
Member

shulaoda commented Feb 3, 2025

Hi, the fix for this works if I have the rule set to "off" for both, or one set to "error" and the other "off", but if I set one to "warn" and the other to "off" the one configured to "warn" shows up as an error.

// works
"eslint/no-nested-ternary": "off",
"unicorn/no-nested-ternary": "off"

// works
"eslint/no-nested-ternary": "error",
"unicorn/no-nested-ternary": "off"

// Shows an error for eslint(no-nested-ternary)
"eslint/no-nested-ternary": "warn",
"unicorn/no-nested-ternary": "off"

Hi, it has been fixed in #8840. We just need to wait for its release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linter Area - Linter C-bug Category - Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants