@@ -13,34 +13,47 @@ class Linter {
13
13
14
14
checkPaths ( pathsToCheck ) {
15
15
pathsToCheck . forEach ( ( pathToCheck ) => {
16
- this . checkPath ( pathToCheck )
16
+ if ( pathToCheck . substr ( - 3 ) === 'vue' ) {
17
+ this . lintFile ( pathToCheck , this . walkerEndHandler . bind ( this ) )
18
+ } else {
19
+ this . checkPath ( pathToCheck )
20
+ }
17
21
} )
18
22
}
19
23
20
24
checkPath ( arg ) {
21
25
const walker = walk . walk ( arg , { followLinks : false } )
22
26
walker . on ( 'file' , this . walkerFileHandler . bind ( this ) )
23
27
walker . on ( 'end' , this . walkerEndHandler . bind ( this ) )
28
+ walker . on ( 'errors' , this . walkerErrorsHandler . bind ( this ) )
29
+ }
30
+
31
+ walkerErrorsHandler ( root , nodeStatsArray , next ) {
32
+ console . error ( 'Linting Error: Invalid sass linting path.' )
33
+ console . log ( nodeStatsArray )
34
+ next ( )
24
35
}
25
36
26
37
walkerFileHandler ( root , fileStat , next ) {
27
38
const filename = `${ root } /${ fileStat . name } `
28
-
29
39
if ( filename . substr ( - 3 ) !== 'vue' ) {
30
40
return next ( )
31
41
}
42
+ this . lintFile ( path . resolve ( root , fileStat . name ) , next )
43
+ }
32
44
33
- fs . readFile ( path . resolve ( root , fileStat . name ) , ( error , fileData ) => {
45
+ lintFile ( filePath , next ) {
46
+ fs . readFile ( filePath , ( error , fileData ) => {
34
47
if ( error ) {
35
- return console . log ( error )
48
+ return console . error ( error )
36
49
}
37
50
38
51
const fileTemplates = this . extractFileTemplates ( fileData )
39
52
40
53
fileTemplates . forEach ( ( template ) => {
41
54
const fileErrors = sassLint . lintText ( {
42
55
text : template . content ,
43
- filename : filename ,
56
+ filename : filePath ,
44
57
format : 'scss'
45
58
} )
46
59
0 commit comments