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

Array destructuring #129

Closed
sebdeckers opened this issue May 8, 2015 · 8 comments

Comments

@sebdeckers
Copy link

commented May 8, 2015

Seems like this syntax triggers a false positive, or maybe my ES6 understanding is lacking.

Input

let [a, b = {}] = [1, 2]
a
b

Output

3:0: 'b' is not defined. (no-undef)
@Flet

This comment has been minimized.

Copy link
Member

commented May 8, 2015

I dont think b = {} is valid.
Putting it into Firefox console yields:

let [a, b = {}] = [1, 2]
SyntaxError: missing variable name

But this works

let [a, b] = [1, 2]
@sebdeckers

This comment has been minimized.

Copy link
Author

commented May 8, 2015

In Firefox, default values for destructuring assignments are not yet implemented: var { x = 3 } = {} and var [foo = "bar"] = []. See bug 932080 and also bug 1018628 for destructured default values in functions.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment

@feross

This comment has been minimized.

Copy link
Member

commented May 8, 2015

Cool, thanks for debugging this.

@feross feross closed this May 8, 2015

@dcousens

This comment has been minimized.

Copy link
Member

commented May 8, 2015

@feross so wait, is the conclusion that it is an eslint issue?

@sebdeckers

This comment has been minimized.

Copy link
Author

commented May 9, 2015

@feross Why was this closed? 😕

Could be related to eslint/eslint#2405

@Flet

This comment has been minimized.

Copy link
Member

commented May 9, 2015

Reopening :)
I think @CBas was just showing me that default assignment for destructing arguments is not in Firefox yet. :) Thanks for the info btw!

That eslint issue links to the real issue which is in escope estools/escope#33

@Flet Flet reopened this May 9, 2015

@feross

This comment has been minimized.

Copy link
Member

commented May 9, 2015

Ah, sorry I misunderstood what this issue was about. ;) Thanks for re-opening @Flet.

@feross

This comment has been minimized.

Copy link
Member

commented Jul 8, 2015

This issue is fixed. Not sure which version it was fixed in, but there's no longer an error when linting:

let [a, b = {}] = [1, 2]
a
b

Nice!

@feross feross closed this Jul 8, 2015

@lock lock bot locked as resolved and limited conversation to collaborators May 11, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
4 participants
You can’t perform that action at this time.