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

no-undef false positive with es6 destructuring and defaults. #2214

Closed
mythmon opened this issue Apr 1, 2015 · 4 comments

Comments

Projects
None yet
3 participants
@mythmon
Copy link

commented Apr 1, 2015

With this code

function foo() {
  var [a, b=4] = [1, 2];
  return {a, b};
}

and this .eslintrc

{
  "ecmaFeatures": {
    "destructuring": true
  }
}

I get the error 3:13 error 'b' is not defined no-undef. If the default value for b is removed, the error doesn't happen.

@nzakas

This comment has been minimized.

Copy link
Member

commented Apr 2, 2015

Might be an escope issue, will have to take a look.

@pola88

This comment has been minimized.

Copy link

commented Apr 9, 2015

Hey guys,

Something new about this? I have the same problem but I add the default values in the function params.

Example:

function(options = {}) {
....
}

Thanks,
@nzakas

This comment has been minimized.

Copy link
Member

commented Apr 11, 2015

Working on this.

@nzakas

This comment has been minimized.

Copy link
Member

commented Apr 11, 2015

This appears to have been fixed with the latest escope changes. Just adding a test to watch for regressions in the future.

@nzakas nzakas closed this in 3499071 Apr 11, 2015

nzakas added a commit that referenced this issue Apr 11, 2015

Merge pull request #2289 from eslint/issue2214
Update: Add test for no-undef (fixes #2214)

@eslint eslint bot locked and limited conversation to collaborators Feb 7, 2018

@eslint eslint bot added the archived due to age label Feb 7, 2018

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