eslint/no-nested-ternary Style
What it does
Disallow nested ternary expressions.
Why is this bad?
Nested ternary expressions make code harder to read and understand. Nesting of these expressions can lead to complex logic that is difficult to understand.
Examples
Examples of incorrect code for this rule:
js
const result = condition1 ? (condition2 ? "a" : "b") : "c";Examples of correct code for this rule:
js
let result;
if (condition1) {
result = condition2 ? "a" : "b";
} else {
result = "c";
}How to use
To enable this rule using the config file or in the CLI, you can use:
json
{
"rules": {
"no-nested-ternary": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
rules: {
"no-nested-ternary": "error",
},
});bash
oxlint --deny no-nested-ternaryVersion
This rule was added in v0.15.4.
