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

eslint: Downgrade linter errors to warnings in development #1216

Merged
merged 1 commit into from Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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