Disallow nested ternary expressions
This rule is currently frozen and is not accepting feature requests.
Nesting ternary expressions can make code more difficult to understand.
const foo = bar ? baz : qux === quxx ? bing : bam;
The no-nested-ternary rule disallows nested ternary expressions.
Examples of incorrect code for this rule:
/*eslint no-nested-ternary: "error"*/
const thing = ;
;
Examples of correct code for this rule:
/*eslint no-nested-ternary: "error"*/
const thing = foo ? bar : foobar;
let otherThing;
if (foo) {
otherThing = bar;
} else if (baz === qux) {
otherThing = quxx;
} else {
otherThing = foobar;
}
This rule has no options.
This rule was introduced in ESLint v0.2.0.
© OpenJS Foundation and other contributors
Licensed under the MIT License.
https://eslint.org/docs/latest/rules/no-nested-ternary