Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax prefer-destructuring rule #89

Merged
merged 1 commit into from
Nov 3, 2021

Conversation

njoyard
Copy link
Contributor

@njoyard njoyard commented Oct 7, 2021

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

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:

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

// Correct
let { foo } = obj
let { foo: bar } = obj
bar = obj.foo
```
@njoyard njoyard requested a review from a team as a code owner October 7, 2021 12:32
@MrChocolatine MrChocolatine merged commit b2bbc5e into master Nov 3, 2021
@MrChocolatine MrChocolatine deleted the fix/relax-prefer-restructuring branch November 3, 2021 13:16
@ndekeister-us ndekeister-us mentioned this pull request May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants