diff --git a/.gitignore b/.gitignore index 80b13514..6ea559ee 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ /index.* /npm-debug.log /test.js +/test/fixtures/espree-v8/node_modules diff --git a/package.json b/package.json index fe41b507..31a085b7 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,10 @@ "debug": "^4.1.1", "eslint-scope": "^5.1.1", "eslint-visitor-keys": "^1.1.0", - "espree": "^8.0.0", + "espree": "^6.2.1", "esquery": "^1.4.0", "lodash": "^4.17.21", - "semver": "^7.3.5" + "semver": "^6.3.0" }, "devDependencies": { "@mysticatea/eslint-plugin": "^13.0.0", diff --git a/scripts/update-fixtures-ast.js b/scripts/update-fixtures-ast.js index 11ad1d36..234405f0 100644 --- a/scripts/update-fixtures-ast.js +++ b/scripts/update-fixtures-ast.js @@ -13,6 +13,7 @@ const fs = require("fs") const path = require("path") const parser = require("../") const escope = require("eslint-scope") +const semver = require("semver") //------------------------------------------------------------------------------ // Helpers @@ -22,7 +23,7 @@ const ROOT = path.join(__dirname, "../test/fixtures/ast") const TARGETS = fs.readdirSync(ROOT) const PARSER_OPTIONS = { comment: true, - ecmaVersion: 2022, + ecmaVersion: 2020, loc: true, range: true, tokens: true, @@ -201,6 +202,18 @@ function analyze(ast, parserOptions) { //------------------------------------------------------------------------------ for (const name of TARGETS) { + const requirementsPath = path.join(ROOT, `${name}/requirements.json`) + const requirements = fs.existsSync(requirementsPath) + ? JSON.parse(fs.readFileSync(requirementsPath, "utf8")) + : {} + if ( + Object.entries(requirements).some(([pkgName, pkgVersion]) => { + const pkg = require(`${pkgName}/package.json`) + return !semver.satisfies(pkg.version, pkgVersion) + }) + ) { + continue + } const sourcePath = path.join(ROOT, `${name}/source.vue`) const optionsPath = path.join(ROOT, `${name}/parser-options.json`) const astPath = path.join(ROOT, `${name}/ast.json`) diff --git a/src/common/create-require.ts b/src/common/create-require.ts new file mode 100644 index 00000000..0891ab33 --- /dev/null +++ b/src/common/create-require.ts @@ -0,0 +1,18 @@ +import Module from "module" +import path from "path" +export const createRequire: (filename: string) => (modname: string) => any = + // Added in v12.2.0 + (Module as any).createRequire || + // Added in v10.12.0, but deprecated in v12.2.0. + // eslint-disable-next-line @mysticatea/node/no-deprecated-api + Module.createRequireFromPath || + // Polyfill - This is not executed on the tests on node@>=10. + /* istanbul ignore next */ + ((modname) => { + const mod = new Module(modname) + + mod.filename = modname + mod.paths = (Module as any)._nodeModulePaths(path.dirname(modname)) + ;(mod as any)._compile("module.exports = require;", modname) + return mod.exports + }) diff --git a/src/common/espree.ts b/src/common/espree.ts index b59464bc..b1c0b0c2 100644 --- a/src/common/espree.ts +++ b/src/common/espree.ts @@ -2,8 +2,10 @@ import type { ESLintExtendedProgram, ESLintProgram } from "../ast" import type { ParserOptions } from "../common/parser-options" import { getLinterRequire } from "./linter-require" // @ts-expect-error -- ignore -import * as espree from "espree" +import * as dependencyEspree from "espree" import { lte, lt } from "semver" +import { createRequire } from "./create-require" +import path from "path" /** * The interface of a result of ESLint custom parser. @@ -17,54 +19,47 @@ export interface ESLintCustomParser { parse(code: string, options: any): ESLintCustomParserResult parseForESLint?(code: string, options: any): ESLintCustomParserResult } -type OldEspree = ESLintCustomParser & { - latestEcmaVersion?: number - version: string -} type Espree = ESLintCustomParser & { - latestEcmaVersion: number + latestEcmaVersion?: number version: string } -let espreeCache: OldEspree | Espree | null = null +let espreeCache: Espree | null = null /** * Gets the espree that the given ecmaVersion can parse. */ export function getEspreeFromEcmaVersion( ecmaVersion: ParserOptions["ecmaVersion"], -): OldEspree | Espree { +): Espree { const linterEspree = getEspreeFromLinter() - if ( - linterEspree.version != null && - lte(espree.version, linterEspree.version) - ) { - // linterEspree is newest - return linterEspree - } if (ecmaVersion == null) { return linterEspree } if (ecmaVersion === "latest") { - return espree + return getNewestEspree() } - if (normalizeEcmaVersion(ecmaVersion) <= getLinterLatestEcmaVersion()) { + if ( + normalizeEcmaVersion(ecmaVersion) <= getLatestEcmaVersion(linterEspree) + ) { return linterEspree } - return espree + const userEspree = getEspreeFromUser() + if (normalizeEcmaVersion(ecmaVersion) <= getLatestEcmaVersion(userEspree)) { + return userEspree + } + return linterEspree +} - function getLinterLatestEcmaVersion() { - if (linterEspree.latestEcmaVersion == null) { - for (const { v, latest } of [ - { v: "6.1.0", latest: 2020 }, - { v: "4.0.0", latest: 2019 }, - ]) { - if (lte(v, linterEspree.version)) { - return latest - } - } - return 2018 - } - return normalizeEcmaVersion(linterEspree.latestEcmaVersion) +/** + * Load `espree` from the user dir. + */ +export function getEspreeFromUser(): Espree { + try { + const cwd = process.cwd() + const relativeTo = path.join(cwd, "__placeholder__.js") + return createRequire(relativeTo)("espree") + } catch { + return getEspreeFromLinter() } } @@ -72,11 +67,11 @@ export function getEspreeFromEcmaVersion( * Load `espree` from the loaded ESLint. * If the loaded ESLint was not found, just returns `require("espree")`. */ -export function getEspreeFromLinter(): Espree | OldEspree { +export function getEspreeFromLinter(): Espree { if (!espreeCache) { espreeCache = getLinterRequire()?.("espree") if (!espreeCache) { - espreeCache = espree + espreeCache = dependencyEspree } } @@ -87,14 +82,19 @@ export function getEspreeFromLinter(): Espree | OldEspree { * Load the newest `espree` from the loaded ESLint or dependency. */ function getNewestEspree(): Espree { + let newest = dependencyEspree const linterEspree = getEspreeFromLinter() if ( - linterEspree.version == null || - lte(linterEspree.version, espree.version) + linterEspree.version != null && + lte(newest.version, linterEspree.version) ) { - return espree + newest = linterEspree } - return linterEspree as Espree + const userEspree = getEspreeFromUser() + if (userEspree.version != null && lte(newest.version, userEspree.version)) { + newest = userEspree + } + return newest } export function getEcmaVersionIfUseEspree( @@ -106,7 +106,7 @@ export function getEcmaVersionIfUseEspree( } if (parserOptions.ecmaVersion === "latest") { - return normalizeEcmaVersion(getNewestEspree().latestEcmaVersion) + return normalizeEcmaVersion(getLatestEcmaVersion(getNewestEspree())) } if (parserOptions.ecmaVersion == null) { const defVer = getDefaultEcmaVersion() @@ -120,7 +120,7 @@ function getDefaultEcmaVersion(): number { return 5 } // Perhaps the version 9 will change the default to "latest". - return normalizeEcmaVersion(getNewestEspree().latestEcmaVersion) + return normalizeEcmaVersion(getLatestEcmaVersion(getNewestEspree())) } /** @@ -132,3 +132,18 @@ function normalizeEcmaVersion(version: number) { } return version } + +function getLatestEcmaVersion(espree: Espree) { + if (espree.latestEcmaVersion == null) { + for (const { v, latest } of [ + { v: "6.1.0", latest: 2020 }, + { v: "4.0.0", latest: 2019 }, + ]) { + if (lte(v, espree.version)) { + return latest + } + } + return 2018 + } + return normalizeEcmaVersion(espree.latestEcmaVersion) +} diff --git a/src/common/linter-require.ts b/src/common/linter-require.ts index 22cd8526..54fecba1 100644 --- a/src/common/linter-require.ts +++ b/src/common/linter-require.ts @@ -1,22 +1,5 @@ -import Module from "module" import path from "path" - -const createRequire: (filename: string) => (modname: string) => any = - // Added in v12.2.0 - (Module as any).createRequire || - // Added in v10.12.0, but deprecated in v12.2.0. - // eslint-disable-next-line @mysticatea/node/no-deprecated-api - Module.createRequireFromPath || - // Polyfill - This is not executed on the tests on node@>=10. - /* istanbul ignore next */ - ((modname) => { - const mod = new Module(modname) - - mod.filename = modname - mod.paths = (Module as any)._nodeModulePaths(path.dirname(modname)) - ;(mod as any)._compile("module.exports = require;", modname) - return mod.exports - }) +import { createRequire } from "./create-require" function isLinterPath(p: string): boolean { return ( diff --git a/src/script/index.ts b/src/script/index.ts index fb7ca746..914ba6ba 100644 --- a/src/script/index.ts +++ b/src/script/index.ts @@ -44,8 +44,9 @@ import { } from "./scope-analyzer" import type { ESLintCustomParser } from "../common/espree" import { - getEspreeFromEcmaVersion, getEcmaVersionIfUseEspree, + getEspreeFromUser, + getEspreeFromEcmaVersion, } from "../common/espree" import type { ParserOptions } from "../common/parser-options" import { @@ -521,6 +522,14 @@ export interface ExpressionParseResult { variables: Variable[] } +function loadParser(parser: string) { + if (parser !== "espree") { + // eslint-disable-next-line @mysticatea/ts/no-require-imports + return require(parser) + } + return getEspreeFromUser() +} + /** * Parse the given source code. * @@ -534,9 +543,9 @@ export function parseScript( ): ESLintExtendedProgram { const parser: ESLintCustomParser = typeof parserOptions.parser === "string" - ? // eslint-disable-next-line @mysticatea/ts/no-require-imports - require(parserOptions.parser) + ? loadParser(parserOptions.parser) : getEspreeFromEcmaVersion(parserOptions.ecmaVersion) + const result: any = typeof parser.parseForESLint === "function" ? parser.parseForESLint(code, parserOptions) diff --git a/test/ast.js b/test/ast.js index 5d535d69..48a9b58a 100644 --- a/test/ast.js +++ b/test/ast.js @@ -26,7 +26,7 @@ const ROOT = path.join(__dirname, "fixtures/ast") const TARGETS = fs.readdirSync(ROOT) const PARSER_OPTIONS = { comment: true, - ecmaVersion: 2022, + ecmaVersion: 2020, loc: true, range: true, tokens: true, @@ -100,7 +100,7 @@ function getTree(source, parserOptions) { source, { parser: PARSER, - parserOptions: Object.assign({ ecmaVersion: 2022 }, parserOptions), + parserOptions: Object.assign({ ecmaVersion: 2020 }, parserOptions), rules: { maketree: "error" }, }, undefined, diff --git a/test/espree.js b/test/espree.js index 637942d8..f51a7d1f 100644 --- a/test/espree.js +++ b/test/espree.js @@ -6,11 +6,11 @@ const path = require("path") * Spawn a child process to run `childMain()`. */ function parentMain() { - const { spawn } = require("child_process") + const { spawn, execSync } = require("child_process") describe("Loading espree from ESLint", () => { it("should load espree from the ESLint location.", (done) => { - spawn(process.execPath, [__filename, "--child"], { + spawn(process.execPath, [__filename, "--child1"], { stdio: "inherit", }) .on("error", done) @@ -20,13 +20,44 @@ function parentMain() { : done() ) }) + it("should load espree from the ESLint location.", (done) => { + spawn(process.execPath, [__filename, "--child1"], { + stdio: "inherit", + }) + .on("error", done) + .on("exit", (code) => + code + ? done(new Error(`Exited with non-zero: ${code}`)) + : done() + ) + }) + it("should load espree from the user location.", (done) => { + const originalCwd = process.cwd() + try { + process.chdir(path.join(__dirname, "./fixtures/espree-v8")) + execSync("npm i", { + stdio: "inherit", + }) + spawn(process.execPath, [__filename, "--child2"], { + stdio: "inherit", + }) + .on("error", done) + .on("exit", (code) => + code + ? done(new Error(`Exited with non-zero: ${code}`)) + : done() + ) + } finally { + process.chdir(originalCwd) + } + }) }) } /** * Check this parser loads the `espree` from the location of the loaded ESLint. */ -function childMain() { +function childMain1() { const assert = require("assert") const { Linter } = require("./fixtures/eslint") const linter = new Linter() @@ -49,12 +80,42 @@ function childMain() { ) } +/** + * Check this parser loads the `espree` from the location of the user dir. + */ +function childMain2() { + const assert = require("assert") + const { Linter } = require("./fixtures/eslint") + const linter = new Linter() + linter.defineParser("vue-eslint-parser", require("../src")) + + const result = linter.verify( + "", + { + parser: "vue-eslint-parser", + parserOptions: { + parser: "espree", + ecmaVersion: 2022, + sourceType: "module", + }, + }, + { filename: "a.vue" } + ) + assert.strictEqual( + result.length, + 0, + "espree should be loaded from the fixtures/espree-v8" + ) +} + function isEspreePath(p) { return p.includes(`${path.sep}node_modules${path.sep}espree${path.sep}`) } -if (process.argv.includes("--child")) { - childMain() +if (process.argv.includes("--child1")) { + childMain1() +} else if (process.argv.includes("--child2")) { + childMain2() } else { parentMain() } diff --git a/test/fixtures/ast/end-of-line01/ast.json b/test/fixtures/ast/end-of-line01/ast.json index 600e0aaf..94e76dd0 100644 --- a/test/fixtures/ast/end-of-line01/ast.json +++ b/test/fixtures/ast/end-of-line01/ast.json @@ -1,7 +1,7 @@ { "type": "Program", - "start": 192, - "end": 203, + "start": 191, + "end": 204, "loc": { "start": { "line": 16, diff --git a/test/fixtures/ast/end-of-line02/ast.json b/test/fixtures/ast/end-of-line02/ast.json index a4a1bead..86473657 100644 --- a/test/fixtures/ast/end-of-line02/ast.json +++ b/test/fixtures/ast/end-of-line02/ast.json @@ -1,7 +1,7 @@ { "type": "Program", - "start": 9, - "end": 20, + "start": 8, + "end": 21, "loc": { "start": { "line": 2, diff --git a/test/fixtures/ast/multiple-scripts-10/ast.json b/test/fixtures/ast/multiple-scripts-10/ast.json index d885cac3..3c4c1d15 100644 --- a/test/fixtures/ast/multiple-scripts-10/ast.json +++ b/test/fixtures/ast/multiple-scripts-10/ast.json @@ -1,6 +1,6 @@ { "type": "Program", - "start": 9, + "start": 8, "end": 57, "loc": { "start": { diff --git a/test/fixtures/ast/multiple-scripts-2/ast.json b/test/fixtures/ast/multiple-scripts-2/ast.json index 86f3e690..3a94a274 100644 --- a/test/fixtures/ast/multiple-scripts-2/ast.json +++ b/test/fixtures/ast/multiple-scripts-2/ast.json @@ -1,6 +1,6 @@ { "type": "Program", - "start": 9, + "start": 8, "end": 106, "loc": { "start": { diff --git a/test/fixtures/ast/multiple-scripts-3/ast.json b/test/fixtures/ast/multiple-scripts-3/ast.json index 82eb0fa4..85552110 100644 --- a/test/fixtures/ast/multiple-scripts-3/ast.json +++ b/test/fixtures/ast/multiple-scripts-3/ast.json @@ -1,6 +1,6 @@ { "type": "Program", - "start": 9, + "start": 8, "end": 91, "loc": { "start": { diff --git a/test/fixtures/ast/multiple-scripts-4/ast.json b/test/fixtures/ast/multiple-scripts-4/ast.json index 03a1f108..84d2d8cf 100644 --- a/test/fixtures/ast/multiple-scripts-4/ast.json +++ b/test/fixtures/ast/multiple-scripts-4/ast.json @@ -1,7 +1,7 @@ { "type": "Program", - "start": 9, - "end": 17, + "start": 8, + "end": 18, "loc": { "start": { "line": 2, diff --git a/test/fixtures/ast/multiple-scripts-5/ast.json b/test/fixtures/ast/multiple-scripts-5/ast.json index 2eb697cd..0c0ff3e9 100644 --- a/test/fixtures/ast/multiple-scripts-5/ast.json +++ b/test/fixtures/ast/multiple-scripts-5/ast.json @@ -1,6 +1,6 @@ { "type": "Program", - "start": 9, + "start": 8, "end": 145, "loc": { "start": { diff --git a/test/fixtures/ast/multiple-scripts-6/ast.json b/test/fixtures/ast/multiple-scripts-6/ast.json index 4c6b2507..990e3f15 100644 --- a/test/fixtures/ast/multiple-scripts-6/ast.json +++ b/test/fixtures/ast/multiple-scripts-6/ast.json @@ -1,6 +1,6 @@ { "type": "Program", - "start": 48, + "start": 47, "end": 98, "loc": { "start": { diff --git a/test/fixtures/ast/multiple-scripts-7/ast.json b/test/fixtures/ast/multiple-scripts-7/ast.json index b8cf33d6..6689eb9a 100644 --- a/test/fixtures/ast/multiple-scripts-7/ast.json +++ b/test/fixtures/ast/multiple-scripts-7/ast.json @@ -1,6 +1,6 @@ { "type": "Program", - "start": 9, + "start": 8, "end": 178, "loc": { "start": { diff --git a/test/fixtures/ast/multiple-scripts-8/ast.json b/test/fixtures/ast/multiple-scripts-8/ast.json index c11f7b77..e1db17c9 100644 --- a/test/fixtures/ast/multiple-scripts-8/ast.json +++ b/test/fixtures/ast/multiple-scripts-8/ast.json @@ -1,6 +1,6 @@ { "type": "Program", - "start": 20, + "start": 8, "end": 340, "loc": { "start": { diff --git a/test/fixtures/ast/multiple-scripts-9/ast.json b/test/fixtures/ast/multiple-scripts-9/ast.json index 685d774d..b7c434d2 100644 --- a/test/fixtures/ast/multiple-scripts-9/ast.json +++ b/test/fixtures/ast/multiple-scripts-9/ast.json @@ -1,6 +1,6 @@ { "type": "Program", - "start": 31, + "start": 30, "end": 48, "loc": { "start": { diff --git a/test/fixtures/ast/multiple-scripts/ast.json b/test/fixtures/ast/multiple-scripts/ast.json index b55bc2c0..bdaec0c7 100644 --- a/test/fixtures/ast/multiple-scripts/ast.json +++ b/test/fixtures/ast/multiple-scripts/ast.json @@ -1,6 +1,6 @@ { "type": "Program", - "start": 9, + "start": 8, "end": 99, "loc": { "start": { diff --git a/test/fixtures/ast/script-setup-example01/ast.json b/test/fixtures/ast/script-setup-example01/ast.json index e4d8d462..833f298c 100644 --- a/test/fixtures/ast/script-setup-example01/ast.json +++ b/test/fixtures/ast/script-setup-example01/ast.json @@ -1,7 +1,7 @@ { "type": "Program", - "start": 79, - "end": 311, + "start": 14, + "end": 312, "loc": { "start": { "line": 3, diff --git a/test/fixtures/ast/script-setup-example02/ast.json b/test/fixtures/ast/script-setup-example02/ast.json index f7f9e75c..3bd5e31a 100644 --- a/test/fixtures/ast/script-setup-example02/ast.json +++ b/test/fixtures/ast/script-setup-example02/ast.json @@ -1,7 +1,7 @@ { "type": "Program", - "start": 44, - "end": 169, + "start": 14, + "end": 170, "loc": { "start": { "line": 3, diff --git a/test/fixtures/ast/script-setup-example04/ast.json b/test/fixtures/ast/script-setup-example04/ast.json index 637a4493..ba3b3717 100644 --- a/test/fixtures/ast/script-setup-example04/ast.json +++ b/test/fixtures/ast/script-setup-example04/ast.json @@ -1,7 +1,7 @@ { "type": "Program", - "start": 17, - "end": 37, + "start": 14, + "end": 38, "loc": { "start": { "line": 2, diff --git a/test/fixtures/ast/script-setup-example05/ast.json b/test/fixtures/ast/script-setup-example05/ast.json index d179c1df..3dfd5874 100644 --- a/test/fixtures/ast/script-setup-example05/ast.json +++ b/test/fixtures/ast/script-setup-example05/ast.json @@ -1,7 +1,7 @@ { "type": "Program", - "start": 17, - "end": 90, + "start": 14, + "end": 91, "loc": { "start": { "line": 2, diff --git a/test/fixtures/ast/script-setup-example06/ast.json b/test/fixtures/ast/script-setup-example06/ast.json index 9b8daba2..02f2b44a 100644 --- a/test/fixtures/ast/script-setup-example06/ast.json +++ b/test/fixtures/ast/script-setup-example06/ast.json @@ -1,7 +1,7 @@ { "type": "Program", - "start": 17, - "end": 74, + "start": 14, + "end": 75, "loc": { "start": { "line": 2, diff --git a/test/fixtures/ast/script-setup-example07/ast.json b/test/fixtures/ast/script-setup-example07/ast.json index 46ad7ed6..60322b5a 100644 --- a/test/fixtures/ast/script-setup-example07/ast.json +++ b/test/fixtures/ast/script-setup-example07/ast.json @@ -1,7 +1,7 @@ { "type": "Program", - "start": 17, - "end": 77, + "start": 14, + "end": 78, "loc": { "start": { "line": 2, diff --git a/test/fixtures/ast/script-setup-example08/ast.json b/test/fixtures/ast/script-setup-example08/ast.json index 0d64e4a4..1fa84352 100644 --- a/test/fixtures/ast/script-setup-example08/ast.json +++ b/test/fixtures/ast/script-setup-example08/ast.json @@ -1,7 +1,7 @@ { "type": "Program", - "start": 17, - "end": 116, + "start": 14, + "end": 133, "loc": { "start": { "line": 2, diff --git a/test/fixtures/ast/script-setup-example09/ast.json b/test/fixtures/ast/script-setup-example09/ast.json index 8cc45989..869f1f93 100644 --- a/test/fixtures/ast/script-setup-example09/ast.json +++ b/test/fixtures/ast/script-setup-example09/ast.json @@ -1,7 +1,7 @@ { "type": "Program", - "start": 17, - "end": 112, + "start": 14, + "end": 113, "loc": { "start": { "line": 2, diff --git a/test/fixtures/ast/script-setup-example12/parser-options.json b/test/fixtures/ast/script-setup-example12/parser-options.json index 9f047d2c..7535f8a6 100644 --- a/test/fixtures/ast/script-setup-example12/parser-options.json +++ b/test/fixtures/ast/script-setup-example12/parser-options.json @@ -1,4 +1,5 @@ { "sourceType": "module", - "ecmaVersion": 2022 + "ecmaVersion": 2022, + "parser": "espree" } diff --git a/test/fixtures/ast/script-setup-example12/requirements.json b/test/fixtures/ast/script-setup-example12/requirements.json new file mode 100644 index 00000000..e41b9f47 --- /dev/null +++ b/test/fixtures/ast/script-setup-example12/requirements.json @@ -0,0 +1,3 @@ +{ + "espree": "^8.0.0" +} \ No newline at end of file diff --git a/test/fixtures/ast/script-setup-example13/ast.json b/test/fixtures/ast/script-setup-example13/ast.json index 6a67da3b..22ef6b8a 100644 --- a/test/fixtures/ast/script-setup-example13/ast.json +++ b/test/fixtures/ast/script-setup-example13/ast.json @@ -1,7 +1,7 @@ { "type": "Program", - "start": 15, - "end": 71, + "start": 14, + "end": 72, "loc": { "start": { "line": 2, diff --git a/test/fixtures/ast/script-setup-example14/ast.json b/test/fixtures/ast/script-setup-example14/ast.json index 73f00c5d..03765608 100644 --- a/test/fixtures/ast/script-setup-example14/ast.json +++ b/test/fixtures/ast/script-setup-example14/ast.json @@ -1,6 +1,6 @@ { "type": "Program", - "start": 11, + "start": 8, "end": 168, "loc": { "start": { diff --git a/test/fixtures/ast/script-setup-example15/ast.json b/test/fixtures/ast/script-setup-example15/ast.json index fbaf0f38..7d2e71bd 100644 --- a/test/fixtures/ast/script-setup-example15/ast.json +++ b/test/fixtures/ast/script-setup-example15/ast.json @@ -1,6 +1,6 @@ { "type": "Program", - "start": 11, + "start": 8, "end": 154, "loc": { "start": { diff --git a/test/fixtures/ast/script-setup-top-level-await-with-latest/requirements.json b/test/fixtures/ast/script-setup-top-level-await-with-latest/requirements.json new file mode 100644 index 00000000..e41b9f47 --- /dev/null +++ b/test/fixtures/ast/script-setup-top-level-await-with-latest/requirements.json @@ -0,0 +1,3 @@ +{ + "espree": "^8.0.0" +} \ No newline at end of file diff --git a/test/fixtures/ast/script-setup-top-level-await/parser-options.json b/test/fixtures/ast/script-setup-top-level-await/parser-options.json index 2104ca43..9f047d2c 100644 --- a/test/fixtures/ast/script-setup-top-level-await/parser-options.json +++ b/test/fixtures/ast/script-setup-top-level-await/parser-options.json @@ -1,3 +1,4 @@ { - "sourceType": "module" + "sourceType": "module", + "ecmaVersion": 2022 } diff --git a/test/fixtures/ast/script-setup-top-level-await/requirements.json b/test/fixtures/ast/script-setup-top-level-await/requirements.json new file mode 100644 index 00000000..e41b9f47 --- /dev/null +++ b/test/fixtures/ast/script-setup-top-level-await/requirements.json @@ -0,0 +1,3 @@ +{ + "espree": "^8.0.0" +} \ No newline at end of file diff --git a/test/fixtures/ast/script-setup/ast.json b/test/fixtures/ast/script-setup/ast.json index 7ae70685..a946b6b1 100644 --- a/test/fixtures/ast/script-setup/ast.json +++ b/test/fixtures/ast/script-setup/ast.json @@ -1,7 +1,7 @@ { "type": "Program", - "start": 15, - "end": 28, + "start": 14, + "end": 29, "loc": { "start": { "line": 2, diff --git a/test/fixtures/ast/svg-attrs-camel-case/ast.json b/test/fixtures/ast/svg-attrs-camel-case/ast.json index 1e3a6aa0..f1108188 100644 --- a/test/fixtures/ast/svg-attrs-camel-case/ast.json +++ b/test/fixtures/ast/svg-attrs-camel-case/ast.json @@ -1,7 +1,7 @@ { "type": "Program", - "start": 94, - "end": 113, + "start": 93, + "end": 114, "loc": { "start": { "line": 8, diff --git a/test/fixtures/ast/svg-attrs-colon/ast.json b/test/fixtures/ast/svg-attrs-colon/ast.json index b5a4c622..a3fbf386 100644 --- a/test/fixtures/ast/svg-attrs-colon/ast.json +++ b/test/fixtures/ast/svg-attrs-colon/ast.json @@ -1,7 +1,7 @@ { "type": "Program", - "start": 93, - "end": 112, + "start": 92, + "end": 113, "loc": { "start": { "line": 8, diff --git a/test/fixtures/ast/svg-namespace/ast.json b/test/fixtures/ast/svg-namespace/ast.json index 68f9c796..af1539d1 100644 --- a/test/fixtures/ast/svg-namespace/ast.json +++ b/test/fixtures/ast/svg-namespace/ast.json @@ -1,7 +1,7 @@ { "type": "Program", - "start": 150, - "end": 169, + "start": 149, + "end": 170, "loc": { "start": { "line": 8, diff --git a/test/fixtures/espree-v8/.npmrc b/test/fixtures/espree-v8/.npmrc new file mode 100644 index 00000000..c1ca392f --- /dev/null +++ b/test/fixtures/espree-v8/.npmrc @@ -0,0 +1 @@ +package-lock = false diff --git a/test/fixtures/espree-v8/package.json b/test/fixtures/espree-v8/package.json new file mode 100644 index 00000000..3091a7ab --- /dev/null +++ b/test/fixtures/espree-v8/package.json @@ -0,0 +1,8 @@ +{ + "name": "espree-v8-test", + "private": true, + "version": "1.0.0", + "dependencies": { + "espree": "^8.0.0" + } +}