@@ -387,6 +387,36 @@ describe("bin/eslint.js", () => {
387387 return Promise . all ( [ exitCodeAssertion , outputAssertion ] ) ;
388388 } ) ;
389389
390+ // https://github.com/eslint/eslint/issues/17560
391+ describe ( "does not print duplicate errors in the event of a crash" , ( ) => {
392+
393+ it ( "when there is an invalid config read from a config file" , ( ) => {
394+ const config = path . join ( __dirname , "../fixtures/bin/eslint.config-invalid.js" ) ;
395+ const child = runESLint ( [ "--config" , config , "conf" , "tools" ] ) ;
396+ const exitCodeAssertion = assertExitCode ( child , 2 ) ;
397+ const outputAssertion = getOutput ( child ) . then ( output => {
398+
399+ // The error text should appear exactly once in stderr
400+ assert . strictEqual ( output . stderr . match ( / A c o n f i g o b j e c t i s u s i n g t h e " g l o b a l s " k e y / gu) . length , 1 ) ;
401+ } ) ;
402+
403+ return Promise . all ( [ exitCodeAssertion , outputAssertion ] ) ;
404+ } ) ;
405+
406+ it ( "when there is an error in the next tick" , ( ) => {
407+ const config = path . join ( __dirname , "../fixtures/bin/eslint.config-tick-throws.js" ) ;
408+ const child = runESLint ( [ "--config" , config , "Makefile.js" ] ) ;
409+ const exitCodeAssertion = assertExitCode ( child , 2 ) ;
410+ const outputAssertion = getOutput ( child ) . then ( output => {
411+
412+ // The error text should appear exactly once in stderr
413+ assert . strictEqual ( output . stderr . match ( / t e s t _ e r r o r _ s t a c k / gu) . length , 1 ) ;
414+ } ) ;
415+
416+ return Promise . all ( [ exitCodeAssertion , outputAssertion ] ) ;
417+ } ) ;
418+ } ) ;
419+
390420 it ( "prints the error message pointing to line of code" , ( ) => {
391421 const invalidConfig = path . join ( __dirname , "../fixtures/bin/eslint.config.js" ) ;
392422 const child = runESLint ( [ "--no-ignore" , "-c" , invalidConfig ] ) ;
0 commit comments