Skip to content

Commit 9040df8

Browse files
committed
feat: lintOnSave no longer causes compilation to fail
close #817
1 parent 9410442 commit 9040df8

File tree

6 files changed

+14
-10
lines changed

6 files changed

+14
-10
lines changed

Diff for: docs/config.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ module.exports = {
1717
outputDir: 'dist',
1818

1919
// whether to use eslint-loader for lint on save.
20-
lintOnSave: false,
20+
// valid values: true | false | 'error'
21+
// when set to 'error', lint errors will cause compilation to fail.
22+
lintOnSave: true,
2123

2224
// use the full build with in-browser compiler?
2325
// https://vuejs.org/v2/guide/installation.html#Runtime-Compiler-vs-Runtime-only

Diff for: packages/@vue/cli-plugin-eslint/__tests__/eslintGenerator.spec.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,8 @@ test('lint on save', async () => {
9898
lintOn: 'save'
9999
}
100100
})
101-
102-
expect(pkg.vue).toEqual({
103-
lintOnSave: true
104-
})
101+
// lintOnSave defaults to true so no need for the vue config
102+
expect(pkg.vue).toBeFalsy()
105103
})
106104

107105
test('lint on commit', async () => {
@@ -118,4 +116,7 @@ test('lint on commit', async () => {
118116
'*.js': ['vue-cli-service lint', 'git add'],
119117
'*.vue': ['vue-cli-service lint', 'git add']
120118
})
119+
expect(pkg.vue).toEqual({
120+
lintOnSave: false
121+
})
121122
})

Diff for: packages/@vue/cli-plugin-eslint/generator.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ module.exports = (api, { config, lintOn = [] }) => {
4242
})
4343
}
4444

45-
if (lintOn.includes('save')) {
45+
if (!lintOn.includes('save')) {
4646
pkg.vue = {
47-
lintOnSave: true // eslint-loader configured in runtime plugin
47+
lintOnSave: false // eslint-loader configured in runtime plugin
4848
}
4949
}
5050

Diff for: packages/@vue/cli-plugin-eslint/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module.exports = (api, { lintOnSave }) => {
1313
.use('eslint-loader')
1414
.loader('eslint-loader')
1515
.options(Object.assign(options, {
16+
emitWarning: lintOnSave !== 'error',
1617
formatter: require('eslint/lib/formatters/codeframe')
1718
}))
1819
})

Diff for: packages/@vue/cli-plugin-typescript/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ module.exports = (api, {
8181
.plugin('fork-ts-checker')
8282
.use(require('fork-ts-checker-webpack-plugin'), [{
8383
vue: true,
84-
tslint: lintOnSave,
84+
tslint: lintOnSave !== false,
8585
formatter: 'codeframe',
8686
// https://github.com/TypeStrong/ts-loader#happypackmode-boolean-defaultfalse
8787
checkSyntacticErrors: useThreads

Diff for: packages/@vue/cli-service/lib/options.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const schema = createSchema(joi => joi.object({
3333
),
3434

3535
// known runtime options for built-in plugins
36-
lintOnSave: joi.boolean(),
36+
lintOnSave: joi.any().valid([true, false, 'error']),
3737
pwa: joi.object(),
3838

3939
// 3rd party plugin options
@@ -76,7 +76,7 @@ exports.defaults = () => ({
7676
},
7777

7878
// whether to use eslint-loader
79-
lintOnSave: false,
79+
lintOnSave: true,
8080

8181
devServer: {
8282
/*

0 commit comments

Comments
 (0)