sindresorhus/eslint-plugin-unicorn
Rule proposal: `consistent-conditional-object-spread`
Closed
#2,363 opened on May 21, 2024
help wantednew rule
Repository metrics
- Stars
- (5,022 stars)
- PR merge metrics
- (Avg merge 1d 16h) (399 merged PRs in 30d)
Description
Description
When spreading an object conditionally, we have two style: ? : and &&. I prefer user consistently to use &&.
Pass
const name = Math.random() > 0.5 'foo' : undefined;
const student = {age: 12, ...(name&&{name})};
Fail
const name = Math.random() > 0.5 'foo' : undefined;
const student = {age: 12, ...(name ? {name} : {})};
Proposed rule name
consistent-conditional-object-spread
Additional Info
No response