disallowNestedTernaries

Disallows nested ternaries.

Types: Boolean, Object

Values: true or an Object that contains a maxLevel property equal to an integer indicating the maximum levels of nesting to be allowed.

Examples

"disallowNestedTernaries": true

// or

"disallowNestedTernaries": { "maxLevel": 1 }
Valid for modes true and "maxLevel": 1
var foo = (a === b) ? 1 : 2;
Invalid for mode true, but valid for "maxLevel": 1
var foo = (a === b)
  ? (a === c)
    ? 1
    : 2
  : (b === c)
    ? 3
    : 4;
Invalid for modes true and "maxLevel": 1
var foo = (a === b)
  ? (a === c)
    ? (c === d)
      ? 5
      : 6
    : 2
  : (b === c)
    ? 3
    : 4;
Rule source
Test source