Skip to content

Latest commit

 

History

History
34 lines (23 loc) · 877 Bytes

no-useless-fallback-in-spread.md

File metadata and controls

34 lines (23 loc) · 877 Bytes

Disallow useless fallback when spreading in object literals

💼 This rule is enabled in the ✅ recommended config.

🔧 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.

Fail

const object = {...(foo || {})};
const object = {...(foo ?? {})};

Pass

const object = {...foo};
const object = {...(foo && {})};
const array = [...(foo || [])];