Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update: Remove dependency on is-resolvable #11128

Merged
merged 1 commit into from Nov 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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