mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-02-11 09:28:29 -06:00
BREAKING CHANGE: the "vueLoader" option has been removed. To modify vue-loader options, use chainWebpack then `config.module.rule(vue).use(vue-loader).tap()`. vue-loader has been upgraded to v15 and expects different options from v14.
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
module.exports = (api, { lintOnSave }) => {
|
|
if (lintOnSave) {
|
|
const options = require('./eslintOptions')(api)
|
|
api.chainWebpack(webpackConfig => {
|
|
webpackConfig.module
|
|
.rule('eslint')
|
|
.pre()
|
|
.exclude
|
|
.add(/node_modules/)
|
|
.add(require('path').dirname(require.resolve('@vue/cli-service')))
|
|
.end()
|
|
.test(/\.(vue|(j|t)sx?)$/)
|
|
.use('eslint-loader')
|
|
.loader('eslint-loader')
|
|
.options(Object.assign(options, {
|
|
emitWarning: lintOnSave !== 'error',
|
|
formatter: require('eslint/lib/formatters/codeframe')
|
|
}))
|
|
})
|
|
}
|
|
|
|
api.registerCommand('lint', {
|
|
description: 'lint and fix source files',
|
|
usage: 'vue-cli-service lint [options] [...files]',
|
|
options: {
|
|
'--format [formatter]': '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')(args, api)
|
|
})
|
|
}
|