@@ -29,7 +29,7 @@ module.exports = function lint (args = {}, api, silent) {
29
29
if ( isVueFile ( file ) ) {
30
30
const parts = vueFileCache . get ( path . normalize ( file ) )
31
31
if ( parts ) {
32
- parts . content = content ;
32
+ parts . content = content
33
33
const { before, after } = parts
34
34
content = `${ before } \n${ content . trim ( ) } \n${ after } `
35
35
}
@@ -43,19 +43,18 @@ module.exports = function lint (args = {}, api, silent) {
43
43
}
44
44
45
45
const parseTSFromVueFile = file => {
46
-
47
46
// If the file has already been cached, don't read the file again. Use the cache instead.
48
47
if ( vueFileCache . has ( file ) ) {
49
- return vueFileCache . get ( file ) . content ;
48
+ return vueFileCache . get ( file )
50
49
}
51
-
50
+
52
51
const content = fs . readFileSync ( file , 'utf-8' )
53
52
const { script } = vueCompiler . parseComponent ( content , { pad : 'line' } )
54
53
if ( script && / ^ t s x ? $ / . test ( script . lang ) ) {
55
54
vueFileCache . set ( file , {
56
55
before : content . slice ( 0 , script . start ) ,
57
56
after : content . slice ( script . end ) ,
58
- content : script . content ,
57
+ content : script . content
59
58
} )
60
59
return script
61
60
}
@@ -70,7 +69,7 @@ module.exports = function lint (args = {}, api, silent) {
70
69
program . getSourceFile = function ( file , languageVersion , onError ) {
71
70
if ( isVueFile ( file ) ) {
72
71
const { content, lang = 'js' } = parseTSFromVueFile ( file ) || { content : '' , lang : 'js' }
73
- const contentLang = ts . ScriptKind [ lang . toUpperCase ( ) ] ;
72
+ const contentLang = ts . ScriptKind [ lang . toUpperCase ( ) ]
74
73
return ts . createSourceFile ( file , content , languageVersion , true , contentLang )
75
74
} else {
76
75
return getSourceFile . call ( this , file , languageVersion , onError )
0 commit comments