unicorn/no-nested-ternary
eslint-plugin-unicorn
Safe autofix
eslint.config.js
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/no-nested-ternary": "error",
},
},
];const foo = i > 5 ? i < 100 ? true : false : true;const foo = i > 5 ? true : (i < 100 ? true : (i < 1000 ? true : false));const foo = i > 5 ? (i < 100 ? true : false) : true;const foo = i > 5 || i < 100 || i < 1000;Examples from the ESLint documentation.
unicorn/no-nested-ternary
eslint-plugin-unicorn
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/no-nested-ternary": "error",
},
},
];unicorn/no-nested-ternary
unicorn plugin · style
{
"rules": {
"unicorn/no-nested-ternary": "error"
}
}style/noNestedTernary
style · since 1.9.3
{
"linter": {
"rules": {
"style": {
"noNestedTernary": "error"
}
}
}
}Disallow nested ternary expressions
Enforce explicitly comparing the length or size property of a value.
Require streaming decoding of fetch-body chunks with TextDecoder.
Require boolean-returning Proxy traps to return booleans.