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

block-scoped-var throws an error if missing parameter in destructuring #2111

Closed
dahjelle opened this issue Mar 19, 2015 · 3 comments
Closed
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules

Comments

@dahjelle
Copy link
Contributor

Running eslint on the following file:

var foo = function([, bar]) {
  return bar;
};

throws this error

.../eslint/lib/rules/block-scoped-var.js:142
                    declarations.push(element.name);
                                             ^
TypeError: Cannot read property 'name' of null
    at .../eslint/lib/rules/block-scoped-var.js:142:46
    at Array.forEach (native)
    at declareByNodeType (.../eslint/lib/rules/block-scoped-var.js:141:31)
    at .../eslint/lib/rules/block-scoped-var.js:157:13
    at Array.forEach (native)
    at EventEmitter.functionHandler (.../eslint/lib/rules/block-scoped-var.js:156:21)
    at EventEmitter.emit (events.js:117:20)
    at Controller.controller.traverse.enter (.../eslint/lib/eslint.js:735:25)
    at Controller.__execute (.../eslint/node_modules/estraverse/estraverse.js:393:31)
    at Controller.traverse (.../eslint/node_modules/estraverse/estraverse.js:491:28)

I'm running eslint v0.17.1 with the following .eslintrc (with strict and no-unused-vars turned off for clarity)

{
  "env": {
    "es6": true
  },
  "rules": {
    "strict": 0,
    "no-unused-vars": 0,
    "block-scoped-var": 2
  }
}

I imagine it should show a lint error (or perhaps another rule should), but I don't think it should crash.

@nzakas nzakas added bug ESLint is working incorrectly rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion labels Mar 19, 2015
@nzakas
Copy link
Member

nzakas commented Mar 19, 2015

Thanks, we will get that fixed.

@dahjelle
Copy link
Contributor Author

Awesome—thanks!

@nzakas
Copy link
Member

nzakas commented Mar 28, 2015

Working on this.

@nzakas nzakas closed this as completed in 03aa564 Mar 28, 2015
nzakas added a commit that referenced this issue Mar 28, 2015
Fix: Don't crash on empty array pattern item (fixes #2111)
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 7, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

2 participants