Permalink
Browse files

Fix: crash on optional catch binding (#10429)

  • Loading branch information...
mysticatea committed Jun 13, 2018
1 parent de4dba9 commit e0a0418fef214e0c548d2ddb02e98182e625f93a
@@ -53,7 +53,7 @@ module.exports = {
return {
CatchClause(node) {
"CatchClause[param!=null]"(node) {
let scope = context.getScope();
/*
@@ -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);
}
};
@@ -40,6 +40,10 @@ ruleTester.run("no-catch-shadow", rule, {
{
code: "try {} catch (error) {}",
env: { shelljs: false }
},
{
code: "try {} catch {}",
parserOptions: { ecmaVersion: 2019 }
}
],
invalid: [
@@ -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: [
{

0 comments on commit e0a0418

Please sign in to comment.