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

[Bug] catch-error-name rule does not work with optional catch binding #186

Closed
ehmicky opened this issue Aug 26, 2018 · 0 comments · Fixed by #187
Closed

[Bug] catch-error-name rule does not work with optional catch binding #186

ehmicky opened this issue Aug 26, 2018 · 0 comments · Fixed by #187

Comments

@ehmicky
Copy link

ehmicky commented Aug 26, 2018

The following code using the latest ES optional catch binding (supported by latest Acorn, Espree and ESLint):

try {
  throw new Error('message');
} catch {
  console.log('failed');
}

fails with the catch-error-name rule:

Cannot read property 'name' of null
TypeError: Cannot read property 'name' of null
    at CatchClause (/node_modules/eslint-plugin-unicorn/rules/catch-error-name.js:88:19)
    at listeners.(anonymous function).forEach.listener (/node_modules/eslint/lib/util/safe-emitter.js:45:58)
    at Array.forEach (<anonymous>)
    at Object.emit (/node_modules/eslint/lib/util/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (/node_modules/eslint/lib/util/node-event-generator.js:280:22)
    at NodeEventGenerator.enterNode (/node_modules/eslint/lib/util/node-event-generator.js:294:14)
    at CodePathAnalyzer.enterNode (/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:632:23)
    at nodeQueue.forEach.traversalInfo (/node_modules/eslint/lib/linter.js:860:28)
    at Array.forEach (<anonymous>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants