Skip to content

Commit

Permalink
Chore: Remove dependency on is-resolvable (#11128)
Browse files Browse the repository at this point in the history
As is-resolvable is essentially a fancy if statement, and it is only used in one file, it seems unnecessary to include it as a dependency.

(I've become paranoid due to what recently happened to [event-stream](dominictarr/event-stream#116) and other similar issues)
  • Loading branch information
Matt Grande authored and aladdin-add committed Nov 29, 2018
1 parent bc50dc7 commit 5d451c5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
17 changes: 15 additions & 2 deletions lib/config.js
Expand Up @@ -15,8 +15,7 @@ const path = require("path"),
ConfigFile = require("./config/config-file"),
ConfigCache = require("./config/config-cache"),
Plugins = require("./config/plugins"),
FileFinder = require("./util/file-finder"),
isResolvable = require("is-resolvable");
FileFinder = require("./util/file-finder");

const debug = require("debug")("eslint:config");

Expand All @@ -41,6 +40,20 @@ function hasRules(options) {
return options.rules && Object.keys(options.rules).length > 0;
}

/**
* Determines if a module is can be resolved.
* @param {string} moduleId The ID (name) of the module
* @returns {boolean} True if it is resolvable; False otherwise.
*/
function isResolvable(moduleId) {
try {
require.resolve(moduleId);
return true;
} catch (err) {
return false;
}
}

//------------------------------------------------------------------------------
// API
//------------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -54,7 +54,6 @@
"ignore": "^4.0.6",
"imurmurhash": "^0.1.4",
"inquirer": "^6.1.0",
"is-resolvable": "^1.1.0",
"js-yaml": "^3.12.0",
"json-stable-stringify-without-jsonify": "^1.0.1",
"levn": "^0.3.0",
Expand Down

0 comments on commit 5d451c5

Please sign in to comment.