mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-01-21 23:00:00 -06:00
fix: do not exit with 1 on lint warnings (fix #872)
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
module.exports = function lint (args = {}, api) {
|
||||
const path = require('path')
|
||||
const chalk = require('chalk')
|
||||
const cwd = api.resolve('.')
|
||||
const { CLIEngine } = require('eslint')
|
||||
const options = require('./eslintOptions')(api)
|
||||
const { done } = require('@vue/cli-shared-utils')
|
||||
const { log, done } = require('@vue/cli-shared-utils')
|
||||
|
||||
const files = args._ && args._.length ? args._ : ['src', 'tests', '*.js']
|
||||
if (args['no-fix']) {
|
||||
@@ -21,10 +23,24 @@ module.exports = function lint (args = {}, api) {
|
||||
CLIEngine.outputFixes(report)
|
||||
}
|
||||
|
||||
if (!report.errorCount && !report.warningCount) {
|
||||
if (!report.errorCount) {
|
||||
if (!args.silent) {
|
||||
const hasFixed = report.results.some(f => f.output)
|
||||
done(hasFixed ? `All lint errors auto-fixed.` : `No lint errors found!`)
|
||||
if (hasFixed) {
|
||||
log(`The following files have been auto-fixed:`)
|
||||
log()
|
||||
report.results.forEach(f => {
|
||||
if (f.output) {
|
||||
log(` ${chalk.blue(path.relative(cwd, f.filePath))}`)
|
||||
}
|
||||
})
|
||||
log()
|
||||
}
|
||||
if (report.warningCount) {
|
||||
console.log(formatter(report.results))
|
||||
} else {
|
||||
done(hasFixed ? `All lint errors auto-fixed.` : `No lint errors found!`)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log(formatter(report.results))
|
||||
|
||||
Reference in New Issue
Block a user