Skip to content

Commit

Permalink
Improve error message for missing parser
Browse files Browse the repository at this point in the history
  • Loading branch information
not-an-aardvark committed Feb 13, 2019
1 parent 75b6907 commit 7051641
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions lib/config/config-file.js
Expand Up @@ -481,11 +481,10 @@ function loadObject(configObject, configContext, configPath, configFullName) {
if (err.code === "MODULE_NOT_FOUND" && config.parser === "espree") {
config.parser = require.resolve("espree");
} else {
err.message += `\nFailed to resolve parser '${config.parser}' declared in '${configPath}'.`;
throw err;
}
}

// FIXME: add exception for "espree", add appropriate error message
}

const ruleMap = configContext.ruleMap;
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/config/config-file.js
Expand Up @@ -141,7 +141,7 @@ describe("ConfigFile", () => {
extends: "plugin:enable-nonexistent-parser/bar",
rules: { eqeqeq: 2 }
}, configContext, "/whatever");
}, /Cannot find module 'nonexistent-parser'/);
}, /Failed to resolve parser 'nonexistent-parser' declared in '[\w-/.:\\]+'.\nReferenced from: \/whatever/);
});

it("should fall back to default parser when a config called 'espree' is not found", () => {
Expand Down

0 comments on commit 7051641

Please sign in to comment.