Skip to content

Commit ea91957

Browse files
gaearonromaindso
authored andcommitted
Make error/warning output more useful (facebook#2161)
1 parent da300a8 commit ea91957

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

packages/react-dev-utils/eslintFormatter.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ function formatter(results) {
3030
}
3131

3232
let line = message.line || 0;
33-
let position = chalk.dim(`Line ${line}:`);
33+
let position = chalk.bold('Line ' + line + ':');
3434
return [
3535
'',
3636
position,
3737
messageType,
3838
message.message.replace(/\.$/, ''),
39-
chalk.cyan(message.ruleId || ''),
39+
chalk.underline(message.ruleId || ''),
4040
];
4141
});
4242

@@ -47,7 +47,8 @@ function formatter(results) {
4747

4848
// add color to messageTypes
4949
messages.forEach(m => {
50-
m[2] = m[2] === 'error' ? chalk.red(m[2]) : chalk.yellow(m[2]);
50+
m[3] = m[2] === 'error' ? chalk.red(m[3]) : chalk.yellow(m[3]);
51+
m.splice(2, 1);
5152
});
5253

5354
let outputTable = table(messages, {

packages/react-dev-utils/formatWebpackMessages.js

+1-11
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,7 @@ function formatMessage(message, isError) {
8686
);
8787
}
8888

89-
// Make filename nicer.
90-
var slashIndex = Math.max(
91-
lines[0].lastIndexOf('/'),
92-
lines[0].lastIndexOf('\\')
93-
);
94-
var fileName = lines[0].substring(slashIndex + 1);
95-
var path = lines[0].substring(0, slashIndex + 1);
96-
lines[0] = chalk.dim(isError ? 'Found errors in ' : 'Found warnings in ') +
97-
path +
98-
(isError ? chalk.red : chalk.yellow)(fileName) +
99-
chalk.dim(':');
89+
lines[0] = chalk.inverse(lines[0]);
10090

10191
// Reassemble the message.
10292
message = lines.join('\n');

packages/react-scripts/scripts/utils/createWebpackCompiler.js

+6-10
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,14 @@ module.exports = function createWebpackCompiler(config, onReadyCallback) {
103103

104104
// Teach some ESLint tricks.
105105
console.log(
106-
chalk.dim(
107-
'Search for the ' +
108-
chalk.cyan('rule keywords') +
109-
' to learn more about each warning.'
110-
)
106+
'Search for the ' +
107+
chalk.underline('rule keywords') +
108+
' to learn more about each warning.'
111109
);
112110
console.log(
113-
chalk.dim(
114-
'To ignore, add ' +
115-
chalk.yellow('// eslint-disable-next-line') +
116-
' to the previous line.'
117-
)
111+
'To ignore, add ' +
112+
chalk.yellow('// eslint-disable-next-line') +
113+
' to the previous line.'
118114
);
119115
console.log();
120116
}

0 commit comments

Comments
 (0)