Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
eslint: Downgrade linter errors to warnings in development (#1216)
Browse files Browse the repository at this point in the history
To reduce the noise in the webpack-dev-server overlay (which defaults
to showing errors only and is going to be enabled soon in #1131),
and to also ensure hot reloading isn't prevented.

See:
https://github.com/webpack-contrib/eslint-loader#options
  • Loading branch information
edmorley committed Nov 20, 2018
1 parent 660a5ad commit e9c73a6
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/airbnb-base/test/airbnb_test.js
Expand Up @@ -117,6 +117,7 @@ test('sets defaults when no options passed', t => {
},
cache: true,
cwd: api.options.root,
emitWarning: false,
failOnError: true,
formatter: require.resolve('eslint/lib/formatters/codeframe'),
useEslintrc: false
Expand Down Expand Up @@ -216,6 +217,7 @@ test('merges options with defaults', t => {
},
cache: true,
cwd: api.options.root,
emitWarning: false,
failOnError: true,
formatter: require.resolve('eslint/lib/formatters/codeframe'),
reportUnusedDisableDirectives: true,
Expand Down
2 changes: 2 additions & 0 deletions packages/airbnb/test/airbnb_test.js
Expand Up @@ -121,6 +121,7 @@ test('sets defaults when no options passed', t => {
},
cache: true,
cwd: api.options.root,
emitWarning: false,
failOnError: true,
formatter: require.resolve('eslint/lib/formatters/codeframe'),
useEslintrc: false
Expand Down Expand Up @@ -220,6 +221,7 @@ test('merges options with defaults', t => {
},
cache: true,
cwd: api.options.root,
emitWarning: false,
failOnError: true,
formatter: require.resolve('eslint/lib/formatters/codeframe'),
reportUnusedDisableDirectives: true,
Expand Down
8 changes: 7 additions & 1 deletion packages/eslint/README.md
Expand Up @@ -51,7 +51,13 @@ neutrino.use(eslint, {
// https://github.com/webpack-contrib/eslint-loader#options
// https://eslint.org/docs/developer-guide/nodejs-api#cliengine
cache: true,
// Make errors fatal not just for 'production' but also 'test'.
// Downgrade errors to warnings when in development, to reduce the noise in
// the webpack-dev-server overlay (which defaults to showing errors only),
// and to also ensure hot reloading isn't prevented.
emitWarning: process.env.NODE_ENV === 'development',
// Make errors fatal for 'production' and 'test'.
// However note that even when `false` webpack still fails the build:
// https://github.com/webpack-contrib/eslint-loader/issues/257
failOnError: process.env.NODE_ENV !== 'development',
cwd: neutrino.options.root,
useEslintrc: false,
Expand Down
8 changes: 7 additions & 1 deletion packages/eslint/index.js
Expand Up @@ -113,7 +113,13 @@ module.exports = (neutrino, { test, include, exclude, eslint = {} } = {}) => {
// https://eslint.org/docs/developer-guide/nodejs-api#cliengine
cache: true,
cwd: neutrino.options.root,
// Make errors fatal not just for 'production' but also 'test'.
// Downgrade errors to warnings when in development, to reduce the noise in
// the webpack-dev-server overlay (which defaults to showing errors only),
// and to also ensure hot reloading isn't prevented.
emitWarning: process.env.NODE_ENV === 'development',
// Make errors fatal for 'production' and 'test'.
// However note that even when `false` webpack still fails the build:
// https://github.com/webpack-contrib/eslint-loader/issues/257
failOnError: process.env.NODE_ENV !== 'development',
// Can be the name of a built-in ESLint formatter or the module/path of an external one.
formatter: 'codeframe',
Expand Down
3 changes: 3 additions & 0 deletions packages/eslint/test/middleware_test.js
Expand Up @@ -142,6 +142,7 @@ test('sets defaults when no options passed', t => {
},
cache: true,
cwd: api.options.root,
emitWarning: false,
failOnError: true,
formatter: require.resolve('eslint/lib/formatters/codeframe'),
useEslintrc: false
Expand Down Expand Up @@ -264,6 +265,7 @@ test('merges options with defaults', t => {
},
cache: true,
cwd: api.options.root,
emitWarning: false,
envs: ['jest'],
failOnError: true,
formatter: require.resolve('eslint/lib/formatters/codeframe'),
Expand Down Expand Up @@ -336,6 +338,7 @@ test('sets only loader-specific defaults if useEslintrc true', t => {
baseConfig: {},
cache: true,
cwd: api.options.root,
emitWarning: false,
failOnError: true,
formatter: require.resolve('eslint/lib/formatters/codeframe'),
useEslintrc: true
Expand Down
2 changes: 2 additions & 0 deletions packages/standardjs/test/standardjs_test.js
Expand Up @@ -121,6 +121,7 @@ test('sets defaults when no options passed', t => {
},
cache: true,
cwd: api.options.root,
emitWarning: false,
failOnError: true,
formatter: require.resolve('eslint/lib/formatters/codeframe'),
useEslintrc: false
Expand Down Expand Up @@ -216,6 +217,7 @@ test('merges options with defaults', t => {
},
cache: true,
cwd: api.options.root,
emitWarning: false,
failOnError: true,
formatter: require.resolve('eslint/lib/formatters/codeframe'),
reportUnusedDisableDirectives: true,
Expand Down

0 comments on commit e9c73a6

Please sign in to comment.