From 493e5a699631d5f4daa4aaa70a82dd00a1cae9b4 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Tue, 16 May 2017 23:35:14 +0100 Subject: [PATCH] Tweak lint rules (#2186) --- packages/eslint-config-react-app/index.js | 2 ++ packages/react-dev-utils/eslintFormatter.js | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-react-app/index.js b/packages/eslint-config-react-app/index.js index 9d876042c..42aa9db2c 100644 --- a/packages/eslint-config-react-app/index.js +++ b/packages/eslint-config-react-app/index.js @@ -235,6 +235,8 @@ module.exports = { ], // https://github.com/benmosher/eslint-plugin-import/tree/master/docs/rules + 'import/first': 'error', + 'import/no-amd': 'error', 'import/no-webpack-loader-syntax': 'error', // https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules diff --git a/packages/react-dev-utils/eslintFormatter.js b/packages/react-dev-utils/eslintFormatter.js index a051b9c5b..674f2f06d 100644 --- a/packages/react-dev-utils/eslintFormatter.js +++ b/packages/react-dev-utils/eslintFormatter.js @@ -12,6 +12,7 @@ function isError(message) { function formatter(results) { let output = '\n'; + let hasErrors = false; results.forEach(result => { let messages = result.messages; @@ -19,7 +20,6 @@ function formatter(results) { return; } - let hasErrors = false; messages = messages.map(message => { let messageType; if (isError(message)) { @@ -61,6 +61,19 @@ function formatter(results) { output += `${outputTable}\n\n`; }); + if (hasErrors) { + // Unlike with warnings, we have to do it here. + // We have similar code in react-scripts for warnings, + // but warnings can appear in multiple files so we only + // print it once at the end. For errors, however, we print + // it here because we always show at most one error, and + // we can only be sure it's an ESLint error before exiting + // this function. + output += 'Search for the ' + + chalk.underline(chalk.red('rule keywords')) + + ' to learn more about each error.'; + } + return output; } -- GitLab