sindresorhus/eslint-plugin-unicorn
Rule proposal: `consistent-conditional-object-spread`
已關閉
#2,363 建立於 2024年5月21日
help wantednew rule
倉庫指標
- 星標
- (5,022 顆星)
- PR 合併指標
- (平均合併 4小時 30分鐘) (30 天內合併 26 個 PR)
描述
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