mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-01-25 16:48:56 -06:00
33 lines
994 B
JavaScript
33 lines
994 B
JavaScript
module.exports = (api, { lintOnSave }) => {
|
|
if (lintOnSave) {
|
|
const options = require('./eslintOptions')
|
|
api.chainWebpack(webpackConfig => {
|
|
webpackConfig.module
|
|
.rule('eslint')
|
|
.pre()
|
|
.include
|
|
.add(api.resolve('src'))
|
|
.add(api.resolve('test'))
|
|
.end()
|
|
.test(/\.(vue|jsx?)$/)
|
|
.use('eslint-loader')
|
|
.loader('eslint-loader')
|
|
.options(Object.assign(options, {
|
|
formatter: require('eslint/lib/formatters/codeframe')
|
|
}))
|
|
})
|
|
}
|
|
|
|
api.registerCommand('lint', {
|
|
descriptions: 'lint source files',
|
|
usage: 'vue-cli-service lint [options] [...files]',
|
|
options: {
|
|
'--format': 'specify formatter (default: codeframe)',
|
|
'--no-fix': 'do not fix errors'
|
|
},
|
|
details: 'For more options, see https://eslint.org/docs/user-guide/command-line-interface#options'
|
|
}, args => {
|
|
require('./lint')(api.resolve('.'), args)
|
|
})
|
|
}
|