fimbullinter / wotan

Pluggable TypeScript and JavaScript linter
Apache License 2.0
282 stars 23 forks source link

Add rule to detect duplicate (computed) properties #344

Open ajafff opened 6 years ago

ajafff commented 6 years ago
const A = 'a';
const x = {[A]: 1, [A]: 2}; // duplicate property 'a'
const y = {a: 1, [A]: 2}; // duplicate property 'a'
const z = {[A]: 1, a: 2} // duplicate property 'a'

The compiler doesn't emit an error here. See https://github.com/Microsoft/TypeScript/issues/25758

This can probably be merged with no-duplicate-spread-property to a more general no-duplicate-property rule. Maybe this is already checked, but only on object literals that contain object spread.

ajafff commented 6 years ago

Turns out this is in fact already checked by no-duplicate-spread-property for object literals that contain object spread. So this simply needs to check more object literals.