@@ -333,12 +333,28 @@ describe("bin/eslint.js", () => {
333
333
return Promise . all ( [ exitCodeAssertion , outputAssertion ] ) ;
334
334
} ) ;
335
335
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
+
336
352
it ( "prints the error message pointing to line of code" , ( ) => {
337
353
const invalidConfig = `${ __dirname } /../fixtures/bin/.eslintrc.yml` ;
338
354
const child = runESLint ( [ "--no-ignore" , invalidConfig ] ) ;
339
355
const exitCodeAssertion = assertExitCode ( child , 2 ) ;
340
356
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" ;
342
358
343
359
assert . strictEqual ( output . stdout , "" ) ;
344
360
assert . include ( output . stderr , expectedSubstring ) ;
0 commit comments