Skip to content

Commit

Permalink
Chore: improve crash reporting (fixes eslint#11304)
Browse files Browse the repository at this point in the history
Add line number to the output in the event of a rule crash
  • Loading branch information
Alex Zherdev committed Mar 2, 2019
1 parent 341140f commit 35b722f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/linter.js
Expand Up @@ -747,10 +747,15 @@ function runRules(sourceCode, configuredRules, ruleMapper, parserOptions, parser
nodeQueue.forEach(traversalInfo => {
currentNode = traversalInfo.node;

if (traversalInfo.isEntering) {
eventGenerator.enterNode(currentNode);
} else {
eventGenerator.leaveNode(currentNode);
try {
if (traversalInfo.isEntering) {
eventGenerator.enterNode(currentNode);
} else {
eventGenerator.leaveNode(currentNode);
}
} catch (err) {
err.currentNode = currentNode;
throw err;
}
});

Expand Down Expand Up @@ -903,6 +908,9 @@ module.exports = class Linter {
} catch (err) {
debug("An error occurred while traversing");
debug("Filename:", options.filename);
if (err.currentNode) {
debug("Line:", err.currentNode.loc.start.line);
}
debug("Parser Options:", parserOptions);
debug("Parser Path:", parserName);
debug("Settings:", settings);
Expand Down

0 comments on commit 35b722f

Please sign in to comment.