Skip to content

Commit

Permalink
fix: do not exit with 1 on lint warnings (fix #872)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Mar 6, 2018
1 parent 7cb01d0 commit b162cab
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions packages/@vue/cli-plugin-eslint/lint.js
Original file line number Diff line number Diff line change
@@ -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']) {
Expand All @@ -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))
Expand Down

0 comments on commit b162cab

Please sign in to comment.