Repository: eslint/eslint (js)

Issue:
Support new syntax features in ES2019
The following two proposals have arrived at Stage 4.

- [Optional catch binding](https://github.com/tc39/proposal-optional-catch-binding) ... https://github.com/tc39/proposals/commit/83f2325bbf9804052cf371d3fdcd2a9b420715c4
- [JSON superset](https://github.com/tc39/proposal-json-superset) ... https://github.com/tc39/proposals/commit/22c787bf5a7df5453a273ac851716dd8cd4f0a29

We can start to support those in espree and core rules.

Status of upstream:

- ESTree: https://github.com/estree/estree/pull/189
- Acorn: 5.6.0 is released :tada:
- Espree: https://github.com/eslint/espree/pull/380


Pull request description:
Upgrade: espree@next (fixes #10392)
<!--
    ESLint adheres to the [JS Foundation Code of Conduct](https://js.foundation/community/code-of-conduct).
-->

**What is the purpose of this pull request? (put an "X" next to item)**

Fixes #10392.

[X] Bug fix
~~[X] Other, please explain: Upgrade `espree` to support ES2019 syntax.~~

**What changes did you make? (Give an overview)**

~~**Note**: this PR depends on `eslint/espree#upgrade-acorn-5.6` branch.~~

~~This PR upgrades `espree` to support ES2019 syntax.~~
This PR fixes the bug that it crashes on optional `catch` binding syntax in some core rules.
I searched rules with `/\.param\b/` then I fixed found two rules.

**Is there anything you'd like reviewers to focus on?**

Nothing in particular.


Patch:
diff --git a/lib/rules/no-catch-shadow.js b/lib/rules/no-catch-shadow.js
index 907792278..f7abc931c 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 7b92521b0..865cee46a 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);
             }
         };


Test patch:
diff --git a/tests/lib/rules/no-catch-shadow.js b/tests/lib/rules/no-catch-shadow.js
index cd6c3f32b..c04927ec1 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 d3b84906e..4655bf715 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: [
         {