Skip to content

Commit 9d52541

Browse files
nzakasaladdin-add
authored andcommittedSep 20, 2018
Fix: Remove duplicate error message on crash (fixes #8964) (#10865)
1 parent 4eb9a49 commit 9d52541

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed
 

‎bin/eslint.js

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ process.once("uncaughtException", err => {
4848
console.error(`\nESLint: ${pkg.version}.\n${template(err.messageData || {})}`);
4949
} else {
5050

51-
console.error(err.message);
5251
console.error(err.stack);
5352
}
5453

‎tests/bin/eslint.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,28 @@ describe("bin/eslint.js", () => {
333333
return Promise.all([exitCodeAssertion, outputAssertion]);
334334
});
335335

336+
it("prints the error message exactly once to stderr in the event of a crash", () => {
337+
const child = runESLint(["--rule=no-restricted-syntax:[error, 'Invalid Selector [[[']", "Makefile.js"]);
338+
const exitCodeAssertion = assertExitCode(child, 2);
339+
const outputAssertion = getOutput(child).then(output => {
340+
const expectedSubstring = "Syntax error in selector";
341+
342+
assert.strictEqual(output.stdout, "");
343+
assert.include(output.stderr, expectedSubstring);
344+
345+
// The message should appear exactly once in stderr
346+
assert.strictEqual(output.stderr.indexOf(expectedSubstring), output.stderr.lastIndexOf(expectedSubstring));
347+
});
348+
349+
return Promise.all([exitCodeAssertion, outputAssertion]);
350+
});
351+
336352
it("prints the error message pointing to line of code", () => {
337353
const invalidConfig = `${__dirname}/../fixtures/bin/.eslintrc.yml`;
338354
const child = runESLint(["--no-ignore", invalidConfig]);
339355
const exitCodeAssertion = assertExitCode(child, 2);
340356
const outputAssertion = getOutput(child).then(output => {
341-
const expectedSubstring = "Error: bad indentation of a mapping entry at line";
357+
const expectedSubstring = ": bad indentation of a mapping entry at line";
342358

343359
assert.strictEqual(output.stdout, "");
344360
assert.include(output.stderr, expectedSubstring);

0 commit comments

Comments
 (0)
Please sign in to comment.