Skip to content

Commit

Permalink
Tweak error and warning output (facebook#2152)
Browse files Browse the repository at this point in the history
* Tweak error and warning output

* Add a colon
  • Loading branch information
gaearon authored and romaindso committed Jul 10, 2017
1 parent d53939f commit 598c26a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/react-dev-utils/eslintFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function formatter(results) {
position,
messageType,
message.message.replace(/\.$/, ''),
chalk.dim(message.ruleId || ''),
chalk.cyan(message.ruleId || ''),
];
});

Expand Down
14 changes: 11 additions & 3 deletions packages/react-dev-utils/formatWebpackMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,17 @@ function formatMessage(message, isError) {
);
}

// Prepend filename with an explanation.
lines[0] = chalk.underline(lines[0]) +
(isError ? ' contains errors.' : ' contains warnings.');
// Make filename nicer.
var slashIndex = Math.max(
lines[0].lastIndexOf('/'),
lines[0].lastIndexOf('\\')
);
var fileName = lines[0].substring(slashIndex + 1);
var path = lines[0].substring(0, slashIndex + 1);
lines[0] = chalk.dim(isError ? 'Found errors in ' : 'Found warnings in ') +
path +
(isError ? chalk.red : chalk.yellow)(fileName) +
chalk.dim(':');

// Reassemble the message.
message = lines.join('\n');
Expand Down
17 changes: 11 additions & 6 deletions packages/react-scripts/scripts/utils/createWebpackCompiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,20 @@ module.exports = function createWebpackCompiler(config, onReadyCallback) {

// Teach some ESLint tricks.
console.log(
'Search the ' +
chalk.dim('keywords') +
' from the right column to learn more.'
chalk.dim(
'Search for the ' +
chalk.cyan('rule keywords') +
' to learn more about each warning.'
)
);
console.log(
'To ignore, add ' +
chalk.yellow('// eslint-disable-next-line') +
' to the line before.'
chalk.dim(
'To ignore, add ' +
chalk.yellow('// eslint-disable-next-line') +
' to the previous line.'
)
);
console.log();
}
});

Expand Down

0 comments on commit 598c26a

Please sign in to comment.