Codebase list eslint / 360dbe4
Update: Improve error message when extend config missing (fixes #6115) (#8100) alberto authored 7 years ago Gyandeep Singh committed 7 years ago
3 changed file(s) with 45 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
389389 debug(`Loading ${parentPath}`);
390390 return ConfigOps.merge(load(parentPath, false, relativeTo), previousValue);
391391 } catch (e) {
392 if (parentPath.indexOf("plugin:") === 0 || parentPath.indexOf("eslint:") === 0) {
393 e.message = `Failed to load config "${parentPath}" to extend from.`;
394 e.messageTemplate = "extend-config-missing";
395 e.messageData = {
396 configName: parentPath
397 };
398 }
392399
393400 /*
394401 * If the file referenced by `extends` failed to load, add the path
0 ESLint couldn't find the config "<%- configName %>" to extend from. Please check that the name of the config is correct.
1
2 If you still have problems, please stop by https://gitter.im/eslint/eslint to chat with the team.
198198
199199 });
200200
201 it("should throw an error when extends config is not found", () => {
201 it("should throw an error when extends config module is not found", () => {
202202
203203 const configDeps = {
204204 "../util/module-resolver": createStubModuleResolver({})
212212 rules: { eqeqeq: 2 }
213213 }, "/whatever");
214214 }, /Cannot find module 'eslint-config-foo'/);
215
216 });
217
218 it("should throw an error when an eslint config is not found", () => {
219
220 const configDeps = {
221 "../util/module-resolver": createStubModuleResolver({})
222 };
223
224 const StubbedConfigFile = proxyquire("../../../lib/config/config-file", configDeps);
225
226 assert.throws(() => {
227 StubbedConfigFile.applyExtends({
228 extends: "eslint:foo",
229 rules: { eqeqeq: 2 }
230 }, "/whatever");
231 }, /Failed to load config "eslint:foo" to extend from./);
232
233 });
234
235 it("should throw an error when a plugin config is not found", () => {
236
237 const configDeps = {
238 "../util/module-resolver": createStubModuleResolver({})
239 };
240
241 const StubbedConfigFile = proxyquire("../../../lib/config/config-file", configDeps);
242
243 assert.throws(() => {
244 StubbedConfigFile.applyExtends({
245 extends: "plugin:foo",
246 rules: { eqeqeq: 2 }
247 }, "/whatever");
248 }, /Failed to load config "plugin:foo" to extend from./);
215249
216250 });
217251