no-nested-ternary
eslint
No autofix
eslint.config.js
export default [
{
rules: {
"no-nested-ternary": "error",
},
},
];const thing = foo ? bar : baz === qux ? quxx : foobar;
foo ? baz === qux ? quxx() : foobar() : bar();const thing = foo ? bar : foobar;
let otherThing;
if (foo) {
otherThing = bar;
} else if (baz === qux) {
otherThing = quxx;
} else {
otherThing = foobar;
}Examples from the ESLint documentation.
no-nested-ternary
eslint
export default [
{
rules: {
"no-nested-ternary": "error",
},
},
];no-nested-ternary
eslint plugin · style
{
"rules": {
"no-nested-ternary": "error"
}
}style/noNestedTernary
style · since 1.9.3
{
"linter": {
"rules": {
"style": {
"noNestedTernary": "error"
}
}
}
}Disallow nested ternary expressions.
Enforce a maximum number of classes per file
Enforce default parameters to be last
Disallow variable declarations from shadowing variables declared in the outer scope
Require default cases in switch statements