|
16 | 16 | // This is quite hacky and hopefully won't be needed when Webpack fixes this.
|
17 | 17 | // https://github.com/webpack/webpack/issues/2878
|
18 | 18 |
|
| 19 | +var chalk = require('chalk'); |
19 | 20 | var friendlySyntaxErrorLabel = 'Syntax error:';
|
20 | 21 |
|
21 | 22 | function isLikelyASyntaxError(message) {
|
@@ -85,65 +86,8 @@ function formatMessage(message, isError) {
|
85 | 86 | );
|
86 | 87 | }
|
87 | 88 |
|
88 |
| - // TODO: Ideally we should write a custom ESLint formatter instead. |
89 |
| - |
90 |
| - // If the second line already includes a filename, and it's a warning, |
91 |
| - // this is likely coming from ESLint. Skip it because Webpack also prints it. |
92 |
| - // Let's omit that in this case. |
93 |
| - var BEGIN_ESLINT_FILENAME = String.fromCharCode(27) + '[4m'; |
94 |
| - // Also filter out ESLint summaries for each file |
95 |
| - var BEGIN_ESLINT_WARNING_SUMMARY = String.fromCharCode(27) + |
96 |
| - '[33m' + |
97 |
| - String.fromCharCode(27) + |
98 |
| - '[1m' + |
99 |
| - String.fromCharCode(10006); |
100 |
| - var BEGIN_ESLINT_ERROR_SUMMARY = String.fromCharCode(27) + |
101 |
| - '[31m' + |
102 |
| - String.fromCharCode(27) + |
103 |
| - '[1m' + |
104 |
| - String.fromCharCode(10006); |
105 |
| - // ESLint puts separators like this between groups. We don't need them: |
106 |
| - var ESLINT_EMPTY_SEPARATOR = String.fromCharCode(27) + |
107 |
| - '[22m' + |
108 |
| - String.fromCharCode(27) + |
109 |
| - '[39m'; |
110 |
| - // Go! |
111 |
| - lines = lines.filter(function(line) { |
112 |
| - if (line === ESLINT_EMPTY_SEPARATOR) { |
113 |
| - return false; |
114 |
| - } |
115 |
| - if ( |
116 |
| - line.indexOf(BEGIN_ESLINT_FILENAME) === 0 || |
117 |
| - line.indexOf(BEGIN_ESLINT_WARNING_SUMMARY) === 0 || |
118 |
| - line.indexOf(BEGIN_ESLINT_ERROR_SUMMARY) === 0 |
119 |
| - ) { |
120 |
| - return false; |
121 |
| - } |
122 |
| - return true; |
123 |
| - }); |
124 |
| - |
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 |
| - |
137 | 89 | // Prepend filename with an explanation.
|
138 |
| - lines[0] = |
139 |
| - // Underline |
140 |
| - String.fromCharCode(27) + |
141 |
| - '[4m' + |
142 |
| - // Filename |
143 |
| - lines[0] + |
144 |
| - // End underline |
145 |
| - String.fromCharCode(27) + |
146 |
| - '[24m' + |
| 90 | + lines[0] = chalk.underline(lines[0]) + |
147 | 91 | (isError ? ' contains errors.' : ' contains warnings.');
|
148 | 92 |
|
149 | 93 | // Reassemble the message.
|
|
0 commit comments