diff --git a/docs/config.md b/docs/config.md index 6bbf771c08..75a994ab8f 100644 --- a/docs/config.md +++ b/docs/config.md @@ -17,7 +17,9 @@ module.exports = { outputDir: 'dist', // whether to use eslint-loader for lint on save. - lintOnSave: false, + // valid values: true | false | 'error' + // when set to 'error', lint errors will cause compilation to fail. + lintOnSave: true, // use the full build with in-browser compiler? // https://vuejs.org/v2/guide/installation.html#Runtime-Compiler-vs-Runtime-only diff --git a/packages/@vue/cli-plugin-eslint/__tests__/eslintGenerator.spec.js b/packages/@vue/cli-plugin-eslint/__tests__/eslintGenerator.spec.js index b4d6308921..0959abc0ff 100644 --- a/packages/@vue/cli-plugin-eslint/__tests__/eslintGenerator.spec.js +++ b/packages/@vue/cli-plugin-eslint/__tests__/eslintGenerator.spec.js @@ -98,10 +98,8 @@ test('lint on save', async () => { lintOn: 'save' } }) - - expect(pkg.vue).toEqual({ - lintOnSave: true - }) + // lintOnSave defaults to true so no need for the vue config + expect(pkg.vue).toBeFalsy() }) test('lint on commit', async () => { @@ -118,4 +116,7 @@ test('lint on commit', async () => { '*.js': ['vue-cli-service lint', 'git add'], '*.vue': ['vue-cli-service lint', 'git add'] }) + expect(pkg.vue).toEqual({ + lintOnSave: false + }) }) diff --git a/packages/@vue/cli-plugin-eslint/generator.js b/packages/@vue/cli-plugin-eslint/generator.js index 095f1804d9..f3e2a46a2e 100644 --- a/packages/@vue/cli-plugin-eslint/generator.js +++ b/packages/@vue/cli-plugin-eslint/generator.js @@ -42,9 +42,9 @@ module.exports = (api, { config, lintOn = [] }) => { }) } - if (lintOn.includes('save')) { + if (!lintOn.includes('save')) { pkg.vue = { - lintOnSave: true // eslint-loader configured in runtime plugin + lintOnSave: false // eslint-loader configured in runtime plugin } } diff --git a/packages/@vue/cli-plugin-eslint/index.js b/packages/@vue/cli-plugin-eslint/index.js index 5a0f466026..c5439a13a8 100644 --- a/packages/@vue/cli-plugin-eslint/index.js +++ b/packages/@vue/cli-plugin-eslint/index.js @@ -13,6 +13,7 @@ module.exports = (api, { lintOnSave }) => { .use('eslint-loader') .loader('eslint-loader') .options(Object.assign(options, { + emitWarning: lintOnSave !== 'error', formatter: require('eslint/lib/formatters/codeframe') })) }) diff --git a/packages/@vue/cli-plugin-typescript/index.js b/packages/@vue/cli-plugin-typescript/index.js index c19f78c37d..6e691a4c6f 100644 --- a/packages/@vue/cli-plugin-typescript/index.js +++ b/packages/@vue/cli-plugin-typescript/index.js @@ -81,7 +81,7 @@ module.exports = (api, { .plugin('fork-ts-checker') .use(require('fork-ts-checker-webpack-plugin'), [{ vue: true, - tslint: lintOnSave, + tslint: lintOnSave !== false, formatter: 'codeframe', // https://github.com/TypeStrong/ts-loader#happypackmode-boolean-defaultfalse checkSyntacticErrors: useThreads diff --git a/packages/@vue/cli-service/lib/options.js b/packages/@vue/cli-service/lib/options.js index f0fb882a17..0100ce7333 100644 --- a/packages/@vue/cli-service/lib/options.js +++ b/packages/@vue/cli-service/lib/options.js @@ -33,7 +33,7 @@ const schema = createSchema(joi => joi.object({ ), // known runtime options for built-in plugins - lintOnSave: joi.boolean(), + lintOnSave: joi.any().valid([true, false, 'error']), pwa: joi.object(), // 3rd party plugin options @@ -76,7 +76,7 @@ exports.defaults = () => ({ }, // whether to use eslint-loader - lintOnSave: false, + lintOnSave: true, devServer: { /*