diff --git a/lib/cli-engine/config-array-factory.js b/lib/cli-engine/config-array-factory.js index 46b4e740516..782bb1d148f 100644 --- a/lib/cli-engine/config-array-factory.js +++ b/lib/cli-engine/config-array-factory.js @@ -224,15 +224,16 @@ function loadPackageJSONConfigFile(filePath) { /** * Creates an error to notify about a missing config to extend from. * @param {string} configName The name of the missing config. + * @param {string} importerName The name of the config that imported the missing config * @returns {Error} The error object to throw * @private */ -function configMissingError(configName) { +function configMissingError(configName, importerName) { return Object.assign( new Error(`Failed to load config "${configName}" to extend from.`), { messageTemplate: "extend-config-missing", - messageData: { configName } + messageData: { configName, importerName } } ); } @@ -637,7 +638,7 @@ class ConfigArrayFactory { return this._loadConfigData(eslintAllPath, name); } - throw configMissingError(extendName); + throw configMissingError(extendName, importerName); } /** @@ -670,7 +671,7 @@ class ConfigArrayFactory { ); } - throw plugin.error || configMissingError(extendName); + throw plugin.error || configMissingError(extendName, importerPath); } /** @@ -704,7 +705,7 @@ class ConfigArrayFactory { } catch (error) { /* istanbul ignore else */ if (error && error.code === "MODULE_NOT_FOUND") { - throw configMissingError(extendName); + throw configMissingError(extendName, importerPath); } throw error; } diff --git a/messages/extend-config-missing.txt b/messages/extend-config-missing.txt index 38e64581970..0411819ec4e 100644 --- a/messages/extend-config-missing.txt +++ b/messages/extend-config-missing.txt @@ -1,3 +1,5 @@ ESLint couldn't find the config "<%- configName %>" to extend from. Please check that the name of the config is correct. +The config "<%- configName %>" was referenced from the config file in "<%- importerName %>". + If you still have problems, please stop by https://gitter.im/eslint/eslint to chat with the team. diff --git a/tests/lib/cli-engine/cli-engine.js b/tests/lib/cli-engine/cli-engine.js index 0e5e179b1dc..cb9221bbf80 100644 --- a/tests/lib/cli-engine/cli-engine.js +++ b/tests/lib/cli-engine/cli-engine.js @@ -3338,7 +3338,8 @@ describe("CLIEngine", () => { } catch (err) { assert.strictEqual(err.messageTemplate, "extend-config-missing"); assert.deepStrictEqual(err.messageData, { - configName: "nonexistent-config" + configName: "nonexistent-config", + importerName: getFixturePath("module-not-found", "extends-js", ".eslintrc.yml") }); return; }