Skip to content
Permalink
Browse files

Fix: improve diagnostics for shareable-config-missing errors (#11880)

  • Loading branch information...
not-an-aardvark committed Jun 25, 2019
1 parent 566b7aa commit 056c2aaf39a5f8d06de24f06946dda95032a0361
@@ -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;
}
@@ -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.
@@ -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;
}

0 comments on commit 056c2aa

Please sign in to comment.
You can’t perform that action at this time.