File tree 2 files changed +7
-4
lines changed
2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,8 @@ const createRequire: (filename: string) => (modName: string) => any =
19
19
return mod . exports ;
20
20
} ) ;
21
21
22
- let espreeCache : BasicParserObject | null = null ;
22
+ let espreeCache : ( BasicParserObject & { latestEcmaVersion : number } ) | null =
23
+ null ;
23
24
24
25
/** Checks if given path is linter path */
25
26
function isLinterPath ( p : string ) : boolean {
@@ -35,7 +36,7 @@ function isLinterPath(p: string): boolean {
35
36
* Load `espree` from the loaded ESLint.
36
37
* If the loaded ESLint was not found, just returns `require("espree")`.
37
38
*/
38
- export function getEspree ( ) : BasicParserObject {
39
+ export function getEspree ( ) : BasicParserObject & { latestEcmaVersion : number } {
39
40
if ( ! espreeCache ) {
40
41
// Lookup the loaded eslint
41
42
const linterPath = Object . keys ( require . cache || { } ) . find ( isLinterPath ) ;
Original file line number Diff line number Diff line change @@ -241,9 +241,11 @@ function parseAttributeMustache(state: State):
241
241
if ( state . eat ( "}" ) ) {
242
242
const end = endCandidate ;
243
243
try {
244
+ const espree = getEspree ( ) ;
245
+
244
246
const expression = (
245
- getEspree ( ) . parse ( state . code . slice ( start , end ) , {
246
- ecmaVersion : "latest" ,
247
+ espree . parse ( state . code . slice ( start , end ) , {
248
+ ecmaVersion : espree . latestEcmaVersion ,
247
249
} ) . body [ 0 ] as ESTree . ExpressionStatement
248
250
) . expression ;
249
251
delete expression . range ;
You can’t perform that action at this time.
0 commit comments