Update: Improve error message when extend config missing (fixes #6115) (#8100)
alberto authored 7 years ago
Gyandeep Singh committed 7 years ago
389 | 389 |
debug(`Loading ${parentPath}`);
|
390 | 390 |
return ConfigOps.merge(load(parentPath, false, relativeTo), previousValue);
|
391 | 391 |
} 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 |
}
|
392 | 399 |
|
393 | 400 |
/*
|
394 | 401 |
* 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.
|
198 | 198 |
|
199 | 199 |
});
|
200 | 200 |
|
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", () => {
|
202 | 202 |
|
203 | 203 |
const configDeps = {
|
204 | 204 |
"../util/module-resolver": createStubModuleResolver({})
|
|
212 | 212 |
rules: { eqeqeq: 2 }
|
213 | 213 |
}, "/whatever");
|
214 | 214 |
}, /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./);
|
215 | 249 |
|
216 | 250 |
});
|
217 | 251 |
|