sindresorhus/eslint-plugin-unicorn
Rule proposal: `consistent-conditional-object-spread`
Chiusa
#2363 aperta il 21 mag 2024
help wantednew rule
Metriche repository
- Star
- (5022 stelle)
- Metriche merge PR
- (Merge medio 1g 16h) (399 PR mergiate in 30 g)
Descrizione
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