@@ -7,19 +7,25 @@ module.exports = function lint (args = {}, api) {
7
7
const { log, done } = require ( '@vue/cli-shared-utils' )
8
8
9
9
const files = args . _ && args . _ . length ? args . _ : [ 'src' , 'tests' , '*.js' ]
10
+ const argsConfig = normalizeConfig ( args )
10
11
const config = Object . assign ( { } , options , {
11
12
fix : true ,
12
13
cwd
13
- } , normalizeConfig ( args ) )
14
+ } , argsConfig )
14
15
const engine = new CLIEngine ( config )
15
16
const report = engine . executeOnFiles ( files )
16
17
const formatter = engine . getFormatter ( args . format || 'codeframe' )
17
18
18
19
if ( config . fix ) {
19
20
CLIEngine . outputFixes ( report )
20
21
}
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
21
27
22
- if ( ! report . errorCount ) {
28
+ if ( ! isErrorsExceeded && ! isWarningsExceeded ) {
23
29
if ( ! args . silent ) {
24
30
const hasFixed = report . results . some ( f => f . output )
25
31
if ( hasFixed ) {
@@ -32,14 +38,20 @@ module.exports = function lint (args = {}, api) {
32
38
} )
33
39
log ( )
34
40
}
35
- if ( report . warningCount ) {
41
+ if ( report . warningCount || report . errorCount ) {
36
42
console . log ( formatter ( report . results ) )
37
43
} else {
38
44
done ( hasFixed ? `All lint errors auto-fixed.` : `No lint errors found!` )
39
45
}
40
46
}
41
47
} else {
42
48
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
+ }
43
55
process . exit ( 1 )
44
56
}
45
57
}
0 commit comments