Skip to content

Commit

Permalink
Fix: crash on optional catch binding (#10429)
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed Jun 13, 2018
1 parent de4dba9 commit e0a0418
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/rules/no-catch-shadow.js
Expand Up @@ -53,7 +53,7 @@ module.exports = {

return {

CatchClause(node) {
"CatchClause[param!=null]"(node) {
let scope = context.getScope();

/*
Expand Down
15 changes: 3 additions & 12 deletions lib/rules/no-shadow-restricted-names.js
Expand Up @@ -46,22 +46,13 @@ module.exports = {
VariableDeclarator(node) {
checkForViolation(node.id);
},
ArrowFunctionExpression(node) {
[].map.call(node.params, checkForViolation);
},
FunctionExpression(node) {
if (node.id) {
checkForViolation(node.id);
}
[].map.call(node.params, checkForViolation);
},
FunctionDeclaration(node) {
":function"(node) {
if (node.id) {
checkForViolation(node.id);
[].map.call(node.params, checkForViolation);
}
node.params.forEach(checkForViolation);
},
CatchClause(node) {
"CatchClause[param!=null]"(node) {
checkForViolation(node.param);
}
};
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/rules/no-catch-shadow.js
Expand Up @@ -40,6 +40,10 @@ ruleTester.run("no-catch-shadow", rule, {
{
code: "try {} catch (error) {}",
env: { shelljs: false }
},
{
code: "try {} catch {}",
parserOptions: { ecmaVersion: 2019 }
}
],
invalid: [
Expand Down
6 changes: 5 additions & 1 deletion tests/lib/rules/no-shadow-restricted-names.js
Expand Up @@ -20,7 +20,11 @@ ruleTester.run("no-shadow-restricted-names", rule, {
"!function foo(bar){ var baz; }",
"!function(bar){ var baz; }",
"try {} catch(e) {}",
{ code: "export default function() {}", parserOptions: { sourceType: "module" } }
{ code: "export default function() {}", parserOptions: { sourceType: "module" } },
{
code: "try {} catch {}",
parserOptions: { ecmaVersion: 2019 }
}
],
invalid: [
{
Expand Down

0 comments on commit e0a0418

Please sign in to comment.