@@ -79,17 +79,26 @@ export class EslintRunner extends RushStackCompilerBase<ILintRunnerConfig> {
7979 'src/**/*.{ts,tsx}'
8080 ] ;
8181
82+ const stdoutBuffer : string [ ] = [ ] ;
83+
8284 return this . _cmdRunner . runCmd ( {
8385 args : args ,
86+ // ESLint errors are logged to stdout
87+ onError : ( data : Buffer ) => {
88+ this . _terminal . writeErrorLine ( `Unexpected STDERR output from ESLint: ${ data . toString ( ) } ` )
89+ } ,
8490 onData : ( data : Buffer ) => {
85- const dataStr : string = data . toString ( ) . trim ( ) ;
86- const eslintErrorLogFn : WriteFileIssueFunction = this . _taskOptions . displayAsError
87- ? this . _taskOptions . fileError
88- : this . _taskOptions . fileWarning ;
91+ stdoutBuffer . push ( data . toString ( ) ) ;
92+ } ,
93+ onClose : ( code : number , hasErrors : boolean , resolve : ( ) => void , reject : ( error : Error ) => void ) => {
94+ const dataStr : string = stdoutBuffer . join ( '' ) ;
8995
90- // ESLint errors are logged to stdout
9196 try {
9297 const eslintFileResults : IEslintFileResult [ ] = JSON . parse ( dataStr ) ;
98+
99+ const eslintErrorLogFn : WriteFileIssueFunction = this . _taskOptions . displayAsError
100+ ? this . _taskOptions . fileError
101+ : this . _taskOptions . fileWarning ;
93102 for ( const eslintFileResult of eslintFileResults ) {
94103 const pathFromRoot : string = path . relative ( this . _standardBuildFolders . projectFolderPath ,
95104 eslintFileResult . filePath ) ;
@@ -109,8 +118,7 @@ export class EslintRunner extends RushStackCompilerBase<ILintRunnerConfig> {
109118 // displayAsError value
110119 this . _terminal . writeErrorLine ( dataStr ) ;
111120 }
112- } ,
113- onClose : ( code : number , hasErrors : boolean , resolve : ( ) => void , reject : ( error : Error ) => void ) => {
121+
114122 if ( this . _taskOptions . displayAsError && ( code !== 0 || hasErrors ) ) {
115123 reject ( new Error ( `exited with code ${ code } ` ) ) ;
116124 } else {
0 commit comments