Permalink
Browse files

Update: Better error message for plugins (refs #5221)

  • Loading branch information...
nzakas committed Feb 19, 2016
1 parent 40fec58 commit 8f6c2e7ac69eaba1413cde9ff33da16f0b1c60ac
Showing with 35 additions and 2 deletions.
  1. +20 −1 bin/eslint.js
  2. +4 −0 lib/config/plugins.js
  3. +9 −0 messages/plugin-missing.txt
  4. +2 −1 package.json
View
@@ -29,12 +29,31 @@ if (debug) {
// now we can safely include the other modules that use debug
var concat = require("concat-stream"),
cli = require("../lib/cli");
cli = require("../lib/cli"),
path = require("path"),
fs = require("fs");
//------------------------------------------------------------------------------
// Execution
//------------------------------------------------------------------------------
process.on("uncaughtException", function(err){
// lazy load
var lodash = require("lodash");
if (typeof err.messageTemplate === "string" && err.messageTemplate.length > 0) {
var template = lodash.template(fs.readFileSync(path.resolve(__dirname, "../messages/" + err.messageTemplate + ".txt"), "utf-8"));
console.log("\nOops! Something went wrong! :(");
console.log("\n" + template(err.messageData || {}));
} else {
console.log(err.message);
console.log(err.stack);
}
process.exit(1);
});
if (useStdIn) {
process.stdin.pipe(concat({ encoding: "string" }, function(text) {
try {
View
@@ -117,6 +117,10 @@ module.exports = {
} catch (err) {
debug("Failed to load plugin eslint-plugin-" + pluginNameWithoutPrefix + ". Proceeding without it.");
err.message = "Failed to load plugin " + pluginName + ": " + err.message;
err.messageTemplate = "plugin-missing";
err.messageData = {
pluginName: pluginNameWithoutPrefix
};
throw err;
}
@@ -0,0 +1,9 @@
ESLint couldn't find the plugin "eslint-plugin-<%- pluginName %>". This can happen for a couple different reasons:
1. If ESLint is installed globally, then make sure eslint-plugin-<%- pluginName %> is also installed globally. A globally-installed ESLint cannot find a locally-installed plugin.
2. If ESLint is installed locally, then it's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
npm i eslint-plugin-<%- pluginName %>@latest --save-dev
If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team.
View
@@ -26,7 +26,8 @@
"README.md",
"bin",
"conf",
"lib"
"lib",
"messages"
],
"repository": {
"type": "git",

0 comments on commit 8f6c2e7

Please sign in to comment.