diff --git a/bin/eslint.js b/bin/eslint.js index adc07c2e75c..e51121ec6af 100755 --- a/bin/eslint.js +++ b/bin/eslint.js @@ -48,7 +48,6 @@ process.once("uncaughtException", err => { console.error(`\nESLint: ${pkg.version}.\n${template(err.messageData || {})}`); } else { - console.error(err.message); console.error(err.stack); } diff --git a/tests/bin/eslint.js b/tests/bin/eslint.js index 75e7c2c4b7c..7749b12f107 100644 --- a/tests/bin/eslint.js +++ b/tests/bin/eslint.js @@ -333,12 +333,28 @@ describe("bin/eslint.js", () => { return Promise.all([exitCodeAssertion, outputAssertion]); }); + it("prints the error message exactly once to stderr in the event of a crash", () => { + const child = runESLint(["--rule=no-restricted-syntax:[error, 'Invalid Selector [[[']", "Makefile.js"]); + const exitCodeAssertion = assertExitCode(child, 2); + const outputAssertion = getOutput(child).then(output => { + const expectedSubstring = "Syntax error in selector"; + + assert.strictEqual(output.stdout, ""); + assert.include(output.stderr, expectedSubstring); + + // The message should appear exactly once in stderr + assert.strictEqual(output.stderr.indexOf(expectedSubstring), output.stderr.lastIndexOf(expectedSubstring)); + }); + + return Promise.all([exitCodeAssertion, outputAssertion]); + }); + it("prints the error message pointing to line of code", () => { const invalidConfig = `${__dirname}/../fixtures/bin/.eslintrc.yml`; const child = runESLint(["--no-ignore", invalidConfig]); const exitCodeAssertion = assertExitCode(child, 2); const outputAssertion = getOutput(child).then(output => { - const expectedSubstring = "Error: bad indentation of a mapping entry at line"; + const expectedSubstring = ": bad indentation of a mapping entry at line"; assert.strictEqual(output.stdout, ""); assert.include(output.stderr, expectedSubstring);