menu
no-nested-ternary
Disallow nested ternary expressions
A ternary nested directly inside another ternary forces multiple conditions and results into a grouping determined by operator associativity. Instead, you SHOULD use explicit control flow for each condition and result.
Reported
1function classify(value: int32): string {2 return value > 0 ? "positive" : value < 0 ? "negative" : "zero";3}Accepted
1function classify(value: int32): string {2 if (value > 0) {3 return "positive";4 }5 if (value < 0) {6 return "negative";7 }8 return "zero";9}