Skip to content

Commit 598c26a

Browse files
gaearonromaindso
authored andcommitted
Tweak error and warning output (facebook#2152)
* Tweak error and warning output * Add a colon
1 parent d53939f commit 598c26a

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

packages/react-dev-utils/eslintFormatter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function formatter(results) {
3737
position,
3838
messageType,
3939
message.message.replace(/\.$/, ''),
40-
chalk.dim(message.ruleId || ''),
40+
chalk.cyan(message.ruleId || ''),
4141
];
4242
});
4343

packages/react-dev-utils/formatWebpackMessages.js

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

89-
// Prepend filename with an explanation.
90-
lines[0] = chalk.underline(lines[0]) +
91-
(isError ? ' contains errors.' : ' contains warnings.');
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(':');
92100

93101
// Reassemble the message.
94102
message = lines.join('\n');

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

+11-6
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,20 @@ module.exports = function createWebpackCompiler(config, onReadyCallback) {
103103

104104
// Teach some ESLint tricks.
105105
console.log(
106-
'Search the ' +
107-
chalk.dim('keywords') +
108-
' from the right column to learn more.'
106+
chalk.dim(
107+
'Search for the ' +
108+
chalk.cyan('rule keywords') +
109+
' to learn more about each warning.'
110+
)
109111
);
110112
console.log(
111-
'To ignore, add ' +
112-
chalk.yellow('// eslint-disable-next-line') +
113-
' to the line before.'
113+
chalk.dim(
114+
'To ignore, add ' +
115+
chalk.yellow('// eslint-disable-next-line') +
116+
' to the previous line.'
117+
)
114118
);
119+
console.log();
115120
}
116121
});
117122

0 commit comments

Comments
 (0)