no-nested-ternary
Disallow nested ternary expressions
❄️ Frozen
This rule is currently frozen and is not accepting changes.
Nesting ternary expressions can make code more difficult to understand.
var foo = bar ? baz : qux === quxx ? bing : bam;
Rule Details
The no-nested-ternary
rule disallows nested ternary expressions.
Examples of incorrect code for this rule:
Open in Playground
/*eslint no-nested-ternary: "error"*/
var thing = ;
;
Examples of correct code for this rule:
Open in Playground
/*eslint no-nested-ternary: "error"*/
var thing = foo ? bar : foobar;
var thing;
if (foo) {
thing = bar;
} else if (baz === qux) {
thing = quxx;
} else {
thing = foobar;
}
Related Rules
Version
This rule was introduced in ESLint v0.2.0.