Skip to content

Commit

Permalink
feat: lintOnSave no longer causes compilation to fail
Browse files Browse the repository at this point in the history
close #817
  • Loading branch information
yyx990803 committed Feb 12, 2018
1 parent 9410442 commit 9040df8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
4 changes: 3 additions & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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
})
})
4 changes: 2 additions & 2 deletions packages/@vue/cli-plugin-eslint/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/@vue/cli-plugin-eslint/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}))
})
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-plugin-typescript/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/@vue/cli-service/lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -76,7 +76,7 @@ exports.defaults = () => ({
},

// whether to use eslint-loader
lintOnSave: false,
lintOnSave: true,

devServer: {
/*
Expand Down

0 comments on commit 9040df8

Please sign in to comment.