diff --git a/lib/config/plugins.js b/lib/config/plugins.js index 73c8a7daf26b..58477d1e1397 100644 --- a/lib/config/plugins.js +++ b/lib/config/plugins.js @@ -114,6 +114,16 @@ module.exports = { longName = pluginNamespace + PLUGIN_NAME_PREFIX + pluginNameWithoutPrefix; let plugin = null; + if (pluginName.match(/\s+/)) { + const whitespaceError = new Error("Whitespace found in plugin name eslint-plugin-" + pluginNameWithoutPrefix); + + whitespaceError.messageTemplate = "whitespace-found"; + whitespaceError.messageData = { + pluginName: pluginNameWithoutPrefix + }; + throw whitespaceError; + } + if (!plugins[shortName]) { try { plugin = require(longName); diff --git a/messages/whitespace-found.txt b/messages/whitespace-found.txt new file mode 100644 index 000000000000..7746f3533708 --- /dev/null +++ b/messages/whitespace-found.txt @@ -0,0 +1,3 @@ +ESLint couldn't find the plugin "eslint-plugin-<%- pluginName %>". It looks like there is whitespace in the plugin name. + +If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team. diff --git a/tests/lib/config/plugins.js b/tests/lib/config/plugins.js index ef88c948b93b..58881f927f7c 100644 --- a/tests/lib/config/plugins.js +++ b/tests/lib/config/plugins.js @@ -85,6 +85,12 @@ describe("Plugins", function() { assert.deepEqual(Rules.get("example/qux"), plugin.rules.qux); }); + it("should throw an error when a plugin has whitespace", function() { + assert.throws(function() { + StubbedPlugins.load("whitespace "); + }, /Whitespace found in plugin name/); + }); + it("should throw an error when a plugin doesn't exist", function() { assert.throws(function() { StubbedPlugins.load("nonexistentplugin");