@@ -56,28 +56,30 @@ export function parseForESLint(code: string, options: any): AST.ESLintExtendedPr
56
56
tokens : true ,
57
57
} , options || { } )
58
58
59
+ let result : AST . ESLintExtendedProgram
59
60
if ( ! isVueFile ( code , options ) ) {
60
- return parseScript ( code , options )
61
+ result = parseScript ( code , options )
61
62
}
63
+ else {
64
+ const tokenizer = new HTMLTokenizer ( code )
65
+ const rootAST = new HTMLParser ( tokenizer , options ) . parse ( )
66
+ const locationCalcurator = new LocationCalculator ( tokenizer . gaps , tokenizer . lineTerminators )
67
+ const script = rootAST . children . find ( isScriptElement ) as AST . VElement | undefined // https://github.com/Microsoft/TypeScript/issues/7657
68
+ const template = rootAST . children . find ( isTemplateElement ) as AST . VElement | undefined
69
+ const concreteInfo : AST . HasConcreteInfo = {
70
+ tokens : rootAST . tokens ,
71
+ comments : rootAST . comments ,
72
+ errors : rootAST . errors ,
73
+ }
62
74
63
- const tokenizer = new HTMLTokenizer ( code )
64
- const rootAST = new HTMLParser ( tokenizer , options ) . parse ( )
65
- const locationCalcurator = new LocationCalculator ( tokenizer . gaps , tokenizer . lineTerminators )
66
- const script = rootAST . children . find ( isScriptElement ) as AST . VElement | undefined // https://github.com/Microsoft/TypeScript/issues/7657
67
- const template = rootAST . children . find ( isTemplateElement ) as AST . VElement | undefined
68
- const result = ( script != null )
69
- ? parseScriptElement ( script , locationCalcurator , options )
70
- : parseScript ( "" , options )
71
- const concreteInfo : AST . HasConcreteInfo = {
72
- tokens : rootAST . tokens ,
73
- comments : rootAST . comments ,
74
- errors : rootAST . errors ,
75
+ result = ( script != null )
76
+ ? parseScriptElement ( script , locationCalcurator , options )
77
+ : parseScript ( "" , options )
78
+ result . ast . templateBody = ( template != null )
79
+ ? Object . assign ( template , concreteInfo )
80
+ : undefined
75
81
}
76
- const templateBody = ( template != null )
77
- ? Object . assign ( template , concreteInfo )
78
- : undefined
79
82
80
- result . ast . templateBody = templateBody
81
83
result . services = Object . assign ( result . services || { } , services . define ( result . ast ) )
82
84
83
85
return result
0 commit comments