Closed
Description
Description
When spreading a ternary in array, we can use both
[
element1,
...(a ? [b, c] : []),
]
and
[
element1,
...(a ? [b, c] : ''),
]
but it's bad to have different style in one project, should enforce consistent style.
Personally, I slightly prefer to use empty array when the consequent is array, but empty string should be cheaper. I hope this rule default to enforce use the same type for "consequent" and "alternate".
Fail
[
element1,
...(a ? [b, c] : ''), // use `[]` since "consequent" is array
]
[
element1,
...(a ? 'bc' : []), // should use `""` since "consequent" is string
]
Pass
[
element1,
...(a ? [b, c] : []), // use `[]` since "consequent" is array
]
[
element1,
...(a ? 'bc' : ''), // should use `""` since "consequent" is string
]