Skip to content

Commit 6959077

Browse files
authored
Omit ESLint warnings when there are ESLint errors (#2120)
1 parent 8d4604e commit 6959077

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/react-dev-utils/formatWebpackMessages.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function formatMessage(message, isError) {
8484
"$1 '$4' does not contain an export named '$3'."
8585
);
8686
}
87-
87+
8888
// TODO: Ideally we should write a custom ESLint formatter instead.
8989

9090
// If the second line already includes a filename, and it's a warning,
@@ -122,6 +122,18 @@ function formatMessage(message, isError) {
122122
return true;
123123
});
124124

125+
var ESLINT_WARNING_LABEL = String.fromCharCode(27) +
126+
'[33m' +
127+
'warning' +
128+
String.fromCharCode(27) +
129+
'[39m';
130+
// If there were errors, omit any warnings.
131+
if (isError) {
132+
lines = lines.filter(function(line) {
133+
return line.indexOf(ESLINT_WARNING_LABEL) === -1;
134+
});
135+
}
136+
125137
// Prepend filename with an explanation.
126138
lines[0] =
127139
// Underline

0 commit comments

Comments
 (0)