peopledoc / eslint-config-peopledoc

ESLint config for PeopleDoc frontend projects
MIT License
1 stars 1 forks source link

Relax prefer-destructuring rule #89

Closed njoyard closed 2 years ago

njoyard commented 3 years ago

Currently, prefer-destructuring is always enforced.

// Incorrect
let foo = obj.foo
let bar = obj.foo
bar = obj.foo

// Correct
let { foo } = obj
let { foo: bar } = obj
;({ foo: bar } = obj)

The last correct line is neither nice nor easy to read. This PR proposes relaxing the rule for assignments, leaving it on for declarations only:

// Incorrect
let foo = obj.foo
let bar = obj.foo

// Correct
let { foo } = obj
let { foo: bar } = obj
bar = obj.foo