Skip to content

Commit d094270

Browse files
committed
fix
1 parent dc9a565 commit d094270

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Diff for: src/parser/espree.ts

+3-2
Original file line numberDiff line numberDiff 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 */
2526
function 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);

Diff for: src/parser/html.ts

+4-2
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)