@@ -7,19 +7,25 @@ module.exports = function lint (args = {}, api) {
77 const { log, done } = require ( '@vue/cli-shared-utils' )
88
99 const files = args . _ && args . _ . length ? args . _ : [ 'src' , 'tests' , '*.js' ]
10+ const argsConfig = normalizeConfig ( args )
1011 const config = Object . assign ( { } , options , {
1112 fix : true ,
1213 cwd
13- } , normalizeConfig ( args ) )
14+ } , argsConfig )
1415 const engine = new CLIEngine ( config )
1516 const report = engine . executeOnFiles ( files )
1617 const formatter = engine . getFormatter ( args . format || 'codeframe' )
1718
1819 if ( config . fix ) {
1920 CLIEngine . outputFixes ( report )
2021 }
22+
23+ const maxErrors = argsConfig . maxErrors || 0
24+ const maxWarnings = typeof argsConfig . maxWarnings === 'number' ? argsConfig . maxWarnings : Infinity
25+ const isErrorsExceeded = report . errorCount > maxErrors
26+ const isWarningsExceeded = report . warningCount > maxWarnings
2127
22- if ( ! report . errorCount ) {
28+ if ( ! isErrorsExceeded && ! isWarningsExceeded ) {
2329 if ( ! args . silent ) {
2430 const hasFixed = report . results . some ( f => f . output )
2531 if ( hasFixed ) {
@@ -32,14 +38,20 @@ module.exports = function lint (args = {}, api) {
3238 } )
3339 log ( )
3440 }
35- if ( report . warningCount ) {
41+ if ( report . warningCount || report . errorCount ) {
3642 console . log ( formatter ( report . results ) )
3743 } else {
3844 done ( hasFixed ? `All lint errors auto-fixed.` : `No lint errors found!` )
3945 }
4046 }
4147 } else {
4248 console . log ( formatter ( report . results ) )
49+ if ( isErrorsExceed && typeof argsConfig . maxErrors === 'number' ) {
50+ log ( `Eslint found too many errors (maximum: ${ argsConfig . maxErrors } ).` )
51+ }
52+ if ( isWarningsExceed ) {
53+ log ( `Eslint found too many warnings (maximum: ${ argsConfig . maxWarnings } ).` )
54+ }
4355 process . exit ( 1 )
4456 }
4557}
0 commit comments