File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 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 =
1919 return mod . exports ;
2020 } ) ;
2121
22- let espreeCache : BasicParserObject | null = null ;
22+ let espreeCache : ( BasicParserObject & { latestEcmaVersion : number } ) | null =
23+ null ;
2324
2425/** Checks if given path is linter path */
2526function isLinterPath ( p : string ) : boolean {
@@ -35,7 +36,7 @@ function isLinterPath(p: string): boolean {
3536 * Load `espree` from the loaded ESLint.
3637 * If the loaded ESLint was not found, just returns `require("espree")`.
3738 */
38- export function getEspree ( ) : BasicParserObject {
39+ export function getEspree ( ) : BasicParserObject & { latestEcmaVersion : number } {
3940 if ( ! espreeCache ) {
4041 // Lookup the loaded eslint
4142 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):
241241 if ( state . eat ( "}" ) ) {
242242 const end = endCandidate ;
243243 try {
244+ const espree = getEspree ( ) ;
245+
244246 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 ,
247249 } ) . body [ 0 ] as ESTree . ExpressionStatement
248250 ) . expression ;
249251 delete expression . range ;
You can’t perform that action at this time.
0 commit comments