💼 This rule is enabled in the ✅ recommended
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' : ''),
];