sindresorhus/eslint-plugin-unicorn
Rule proposal: `consistent-conditional-object-spread`
クローズ
#2,363 opened on 2024/05/21
help wantednew rule
Repository metrics
- Stars
- (5,022 個のスター)
- PR merge metrics
- (平均マージ 4h 30m) (30d で 26 merged PRs)
説明
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