Skip to content

Commit

Permalink
Update: Improve error message for fatal fixer errors (#13120)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradzacher committed Apr 3, 2020
1 parent 7551f0c commit 17e2fe4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/rule-tester/rule-tester.js
Expand Up @@ -563,7 +563,12 @@ class RuleTester {
output = SourceCodeFixer.applyFixes(code, messages).output;
const errorMessageInFix = linter.verify(output, config, filename).find(m => m.fatal);

assert(!errorMessageInFix, `A fatal parsing error occurred in autofix: ${errorMessageInFix && errorMessageInFix.message}`);
assert(!errorMessageInFix, [
"A fatal parsing error occurred in autofix.",
`Error: ${errorMessageInFix && errorMessageInFix.message}`,
"Autofix output:",
output
].join("\n"));
} else {
output = code;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/rule-tester/rule-tester.js
Expand Up @@ -1829,7 +1829,7 @@ describe("RuleTester", () => {
invalid: []
}
);
}, /A fatal parsing error occurred in autofix/u);
}, /A fatal parsing error occurred in autofix.\nError: .+\nAutofix output:\n.+/u);
});

describe("sanitize test cases", () => {
Expand Down

0 comments on commit 17e2fe4

Please sign in to comment.