diff --git a/lib/rules/no-catch-shadow.js b/lib/rules/no-catch-shadow.js index 907792278fc..f7abc931cc1 100644 --- a/lib/rules/no-catch-shadow.js +++ b/lib/rules/no-catch-shadow.js @@ -53,7 +53,7 @@ module.exports = { return { - CatchClause(node) { + "CatchClause[param!=null]"(node) { let scope = context.getScope(); /* diff --git a/lib/rules/no-shadow-restricted-names.js b/lib/rules/no-shadow-restricted-names.js index 7b92521b072..865cee46ad7 100644 --- a/lib/rules/no-shadow-restricted-names.js +++ b/lib/rules/no-shadow-restricted-names.js @@ -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); } }; diff --git a/tests/lib/rules/no-catch-shadow.js b/tests/lib/rules/no-catch-shadow.js index cd6c3f32b63..c04927ec1dd 100644 --- a/tests/lib/rules/no-catch-shadow.js +++ b/tests/lib/rules/no-catch-shadow.js @@ -40,6 +40,10 @@ ruleTester.run("no-catch-shadow", rule, { { code: "try {} catch (error) {}", env: { shelljs: false } + }, + { + code: "try {} catch {}", + parserOptions: { ecmaVersion: 2019 } } ], invalid: [ diff --git a/tests/lib/rules/no-shadow-restricted-names.js b/tests/lib/rules/no-shadow-restricted-names.js index d3b84906e76..4655bf715df 100644 --- a/tests/lib/rules/no-shadow-restricted-names.js +++ b/tests/lib/rules/no-shadow-restricted-names.js @@ -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: [ {