Skip to content

Latest commit

Β 

History

History
33 lines (23 loc) Β· 927 Bytes

File metadata and controls

33 lines (23 loc) Β· 927 Bytes

Disallow useless fallback when spreading in object literals

πŸ’Ό This rule is enabled in the following configs: βœ… recommended, β˜‘οΈ unopinionated.

πŸ”§ This rule is automatically fixable by the --fix CLI option.

Spreading falsy values in object literals won't add any unexpected properties, so it's unnecessary to add an empty object as fallback.

Examples

// ❌
const object = {...(foo || {})};

// ❌
const object = {...(foo ?? {})};

// βœ…
const object = {...foo};
// βœ…
const object = {...(foo && {})};
// βœ…
const array = [...(foo || [])];