fix: do not exit with 1 on lint warnings (fix #872)

This commit is contained in:
Evan You
2018-03-06 10:29:44 -05:00
parent 7cb01d0633
commit b162cab1dc

View File

@@ -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))