From debc4dea5da30843db1a156f044a431aed2a061b Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Thu, 11 May 2017 13:52:01 +0100 Subject: [PATCH] Omit ESLint warnings when there are ESLint errors --- packages/react-dev-utils/formatWebpackMessages.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/react-dev-utils/formatWebpackMessages.js b/packages/react-dev-utils/formatWebpackMessages.js index 84d22e526d1..075342f2ddd 100644 --- a/packages/react-dev-utils/formatWebpackMessages.js +++ b/packages/react-dev-utils/formatWebpackMessages.js @@ -84,7 +84,7 @@ function formatMessage(message, isError) { "$1 '$4' does not contain an export named '$3'." ); } - + // TODO: Ideally we should write a custom ESLint formatter instead. // If the second line already includes a filename, and it's a warning, @@ -122,6 +122,18 @@ function formatMessage(message, isError) { return true; }); + var ESLINT_WARNING_LABEL = String.fromCharCode(27) + + '[33m' + + 'warning' + + String.fromCharCode(27) + + '[39m'; + // If there were errors, omit any warnings. + if (isError) { + lines = lines.filter(function(line) { + return line.indexOf(ESLINT_WARNING_LABEL) === -1; + }); + } + // Prepend filename with an explanation. lines[0] = // Underline