1
1
module . exports = function lint ( args = { } , api ) {
2
+ const path = require ( 'path' )
3
+ const chalk = require ( 'chalk' )
2
4
const cwd = api . resolve ( '.' )
3
5
const { CLIEngine } = require ( 'eslint' )
4
6
const options = require ( './eslintOptions' ) ( api )
5
- const { done } = require ( '@vue/cli-shared-utils' )
7
+ const { log , done } = require ( '@vue/cli-shared-utils' )
6
8
7
9
const files = args . _ && args . _ . length ? args . _ : [ 'src' , 'tests' , '*.js' ]
8
10
if ( args [ 'no-fix' ] ) {
@@ -21,10 +23,24 @@ module.exports = function lint (args = {}, api) {
21
23
CLIEngine . outputFixes ( report )
22
24
}
23
25
24
- if ( ! report . errorCount && ! report . warningCount ) {
26
+ if ( ! report . errorCount ) {
25
27
if ( ! args . silent ) {
26
28
const hasFixed = report . results . some ( f => f . output )
27
- done ( hasFixed ? `All lint errors auto-fixed.` : `No lint errors found!` )
29
+ if ( hasFixed ) {
30
+ log ( `The following files have been auto-fixed:` )
31
+ log ( )
32
+ report . results . forEach ( f => {
33
+ if ( f . output ) {
34
+ log ( ` ${ chalk . blue ( path . relative ( cwd , f . filePath ) ) } ` )
35
+ }
36
+ } )
37
+ log ( )
38
+ }
39
+ if ( report . warningCount ) {
40
+ console . log ( formatter ( report . results ) )
41
+ } else {
42
+ done ( hasFixed ? `All lint errors auto-fixed.` : `No lint errors found!` )
43
+ }
28
44
}
29
45
} else {
30
46
console . log ( formatter ( report . results ) )
0 commit comments