Skip to content

Commit

Permalink
Fix: no-useless-constructor crash on bodyless constructor (fixes #13830
Browse files Browse the repository at this point in the history
…) (#13842)
  • Loading branch information
AriPerkkio committed Nov 18, 2020
1 parent eda0aa1 commit d2239a1
Show file tree
Hide file tree
Showing 3 changed files with 431 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/rules/no-useless-constructor.js
Expand Up @@ -162,6 +162,14 @@ module.exports = {
return;
}

/*
* Prevent crashing on parsers which do not require class constructor
* to have a body, e.g. typescript and flow
*/
if (!node.value.body) {
return;
}

const body = node.value.body.body;
const ctorParams = node.value.params;
const superClass = node.parent.parent.superClass;
Expand Down

0 comments on commit d2239a1

Please sign in to comment.