Skip to content

Commit

Permalink
Disregard any ESLint stderr to calculate exit code
Browse files Browse the repository at this point in the history
Since the goal of eslines is to downgrade errors on non-modified lines,
we can't count on eslint's exit code. Previously, we assumed that if
eslint outputs something on its stderr, this means it encountered some
other error. It turned out to be a bad assumption, as the following
example illustrates.

Currently, the eslint-plugin-react outputs some warning in the stderr
channel interfirm/eslint-config-interfirm#57
ESLint will output that errors in the stderr but if it doesn't find any
lint issues it will report zero as its exit code. In our case,
although eslines will exit 0 as well, we'd return 1 because
we heard ESLint reported something in the stderr channel.
  • Loading branch information
oandregal committed Sep 8, 2017
1 parent 80eed8f commit a0cf437
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ eslint.stdout.on( 'data', ( data ) => {
eslines.stdin.write( data );
});

var eslintStdErr = 0;
eslint.stderr.on( 'data', ( data ) => {
eslintStdErr = 1;
process.stderr.write( data );
});

Expand All @@ -47,13 +45,5 @@ eslines.stderr.on( 'data', ( data ) => {
});

eslines.on( 'close', ( code ) => {
// since the goal of eslines is to downgrade errors
// on non-modified lines, we can't count on eslint's
// exit code, but we assume that if eslint output
// something on its stderr, this means it encountered
// some other error
if ( eslintStdErr === 1 ) {
process.exit( 1 );
}
process.exit( code );
});

0 comments on commit a0cf437

Please sign in to comment.