πΌπ« This rule is enabled in the β
recommended config. This rule is disabled in the βοΈ unopinionated config.
π§ This rule is automatically fixable by the --fix CLI option.
When spreading a ternary in an array, we can use both [] and '' as fallbacks, but it's better to have consistent types in both branches.
// β
const array = [
a,
...(foo ? [b, c] : ''),
];
// β
const array = [
a,
...(foo ? 'bc' : []),
];
// β
const array = [
a,
...(foo ? [b, c] : []),
];
// β
const array = [
a,
...(foo ? 'bc' : ''),
];