Repository: eslint/eslint
Pull request #11066 (2018-11-08 05:18:26)

Upgrade: require-uncached renamed to import-fresh
<!--
    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)**

[ ] Documentation update
[ ] Bug fix ([template](https://raw.githubusercontent.com/eslint/eslint/master/templates/bug-report.md))
[ ] New rule ([template](https://raw.githubusercontent.com/eslint/eslint/master/templates/rule-proposal.md))
[ ] Changes an existing rule ([template](https://raw.githubusercontent.com/eslint/eslint/master/templates/rule-change-proposal.md))
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[x] Other, please explain:
`require-uncached` has been renamed to `import-fresh` for a while.
<!--
    If the item you've checked above has a template, please paste the template questions below and answer them. (If this pull request is addressing an issue, you can just paste a link to the issue here instead.)
-->

<!--
    Please ensure your pull request is ready:

    - Read the pull request guide (https://eslint.org/docs/developer-guide/contributing/pull-requests)
    - Include tests for this change
    - Update documentation for this change (if appropriate)
-->

<!--
    The following is required for all pull requests:
-->

**What changes did you make? (Give an overview)**
`require-uncached` => `import-fresh`

**Is there anything you'd like reviewers to focus on?**

no.



Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0af200dcb..eb63794e1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+v5.11.1 - December 26, 2018
+
+* [`de79f10`](https://github.com/eslint/eslint/commit/de79f1026b7035f0296d7876f1db64f225cca1b8) Fix: handle optional catch bindings in no-useless-catch (#11205) (Colin Ihrig)
+
 v5.11.0 - December 22, 2018
 
 * [`b4395f6`](https://github.com/eslint/eslint/commit/b4395f671442a7e0be956382c24cce38025a6df6) New: add option `first` for VariableDeclarator in indent (fixes #8976) (#11193) (Pig Fang)
diff --git a/lib/config/config-file.js b/lib/config/config-file.js
index d09b36688..dde79cb40 100644
--- a/lib/config/config-file.js
+++ b/lib/config/config-file.js
@@ -18,7 +18,7 @@ const fs = require("fs"),
     pathIsInside = require("path-is-inside"),
     stripComments = require("strip-json-comments"),
     stringify = require("json-stable-stringify-without-jsonify"),
-    requireUncached = require("require-uncached");
+    importFresh = require("import-fresh");
 
 const debug = require("debug")("eslint:config-file");
 
@@ -156,7 +156,7 @@ function loadLegacyConfigFile(filePath) {
 function loadJSConfigFile(filePath) {
     debug(`Loading JS config file: ${filePath}`);
     try {
-        return requireUncached(filePath);
+        return importFresh(filePath);
     } catch (e) {
         debug(`Error reading JavaScript file: ${filePath}`);
         e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`;
diff --git a/lib/rules/no-useless-catch.js b/lib/rules/no-useless-catch.js
index 3211ed2c7..e4284cfb4 100644
--- a/lib/rules/no-useless-catch.js
+++ b/lib/rules/no-useless-catch.js
@@ -27,6 +27,7 @@ module.exports = {
         return {
             CatchClause(node) {
                 if (
+                    node.param &&
                     node.param.type === "Identifier" &&
                     node.body.body.length &&
                     node.body.body[0].type === "ThrowStatement" &&
diff --git a/package.json b/package.json
index 010f716d4..bf356703e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "eslint",
-  "version": "5.11.0",
+  "version": "5.11.1",
   "author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
   "description": "An AST-based pattern checker for JavaScript.",
   "bin": {
@@ -52,6 +52,7 @@
     "glob": "^7.1.2",
     "globals": "^11.7.0",
     "ignore": "^4.0.6",
+    "import-fresh": "^3.0.0",
     "imurmurhash": "^0.1.4",
     "inquirer": "^6.1.0",
     "js-yaml": "^3.12.0",
@@ -66,7 +67,6 @@
     "pluralize": "^7.0.0",
     "progress": "^2.0.0",
     "regexpp": "^2.0.1",
-    "require-uncached": "^1.0.3",
     "semver": "^5.5.1",
     "strip-ansi": "^4.0.0",
     "strip-json-comments": "^2.0.1",


Test patch:
diff --git a/tests/lib/config/config-file.js b/tests/lib/config/config-file.js
index 21fd94583..944ed8426 100644
--- a/tests/lib/config/config-file.js
+++ b/tests/lib/config/config-file.js
@@ -181,7 +181,7 @@ describe("ConfigFile", () => {
 
                 // Hacky: need to override isFile for each call for testing
                 "../util/module-resolver": createStubModuleResolver({ "eslint-config-foo": resolvedPath }),
-                "require-uncached"(filename) {
+                "import-fresh"(filename) {
                     return configDeps[filename];
                 }
             };
@@ -265,7 +265,7 @@ describe("ConfigFile", () => {
                 "../util/module-resolver": createStubModuleResolver({
                     "eslint-plugin-test": resolvedPath
                 }),
-                "require-uncached"(filename) {
+                "import-fresh"(filename) {
                     return configDeps[filename];
                 }
             };
@@ -296,7 +296,7 @@ describe("ConfigFile", () => {
                 "../util/module-resolver": createStubModuleResolver({
                     "eslint-plugin-test": resolvedPath
                 }),
-                "require-uncached"(filename) {
+                "import-fresh"(filename) {
                     return configDeps[filename];
                 }
             };
@@ -331,7 +331,7 @@ describe("ConfigFile", () => {
                     "eslint-config-foo": resolvedPaths[0],
                     "eslint-config-bar": resolvedPaths[1]
                 }),
-                "require-uncached"(filename) {
+                "import-fresh"(filename) {
                     return configDeps[filename];
                 }
             };
@@ -932,7 +932,7 @@ describe("ConfigFile", () => {
                 const resolvedPath = path.resolve(PROJECT_PATH, "./node_modules/eslint-plugin-test/index.js");
 
                 const configDeps = {
-                    "require-uncached"(filename) {
+                    "import-fresh"(filename) {
                         return configDeps[filename];
                     }
                 };
diff --git a/tests/lib/rules/no-useless-catch.js b/tests/lib/rules/no-useless-catch.js
index 8c1a7118e..93989a403 100644
--- a/tests/lib/rules/no-useless-catch.js
+++ b/tests/lib/rules/no-useless-catch.js
@@ -103,6 +103,16 @@ ruleTester.run("no-useless-catch", rule, {
                 }
             `,
             parserOptions: { ecmaVersion: 8 }
+        },
+        {
+            code: `
+                try {
+                    throw new Error('foo');
+                } catch {
+                    throw new Error('foo');
+                }
+            `,
+            parserOptions: { ecmaVersion: 2019 }
         }
 
     ],