no-nested-ternary
不允許巢狀三元運算式
❄️ 已凍結
此規則目前已凍結,且不接受功能請求。
巢狀三元運算式會使程式碼更難以理解。
const foo = bar ? baz : qux === quxx ? bing : bam;
規則詳情
no-nested-ternary
規則不允許巢狀三元運算式。
此規則的錯誤程式碼範例
在遊樂場開啟
/*eslint no-nested-ternary: "error"*/
const thing = ;
;
此規則的正確程式碼範例
在遊樂場開啟
/*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;
}
相關規則
版本
此規則在 ESLint v0.2.0 中引入。