diff --git a/.yarnrc.yml b/.yarnrc.yml index 31238e931..4416bfbf5 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -1,4 +1,4 @@ -approvedGitRepositories: null +approvedGitRepositories: "**" compressionLevel: mixed diff --git a/package.json b/package.json index b98b92766..31bcd232e 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,7 @@ "mdast-util-from-markdown": "2.0.3", "mdast-util-gfm": "3.1.0", "mdast-util-math": "3.0.0", - "meriyah": "7.2.0", + "meriyah": "7.3.0", "micromark-extension-gfm": "3.0.0", "micromark-extension-math": "3.1.0", "micromark-util-character": "2.1.1", diff --git a/scripts/build/packages/prettier.js b/scripts/build/packages/prettier.js index 67b83bf11..1ff9d60b6 100644 --- a/scripts/build/packages/prettier.js +++ b/scripts/build/packages/prettier.js @@ -532,11 +532,34 @@ const pluginFiles = [ { input: "src/plugins/meriyah.js", replaceModule: [ - // We don't use value of JSXText { module: resolveEsmModulePath("meriyah"), - find: "parser.tokenValue = decodeHTMLStrict(raw);", - replacement: "parser.tokenValue = raw;", + process(text) { + // `structuredClone` is used to clone node + text = outdent` + const structuredClone = + globalThis.structuredClone ?? + ((node) => ({ ...node, range: [...node.range] })); + + ${text} + `; + + // We don't use value of JSXText + text = text.replace( + "const decodeMap = ", + "const decodeMap = undefined &&", + ); + text = text.replace( + "const entities = ", + "const entities = undefined &&", + ); + text = text.replaceAll( + "parser.tokenValue = decodeHTMLStrict(raw);", + "parser.tokenValue = raw;", + ); + + return text; + }, }, ], }, diff --git a/scripts/build/transform/index.js b/scripts/build/transform/index.js index c44ec24c2..34a2ce332 100644 --- a/scripts/build/transform/index.js +++ b/scripts/build/transform/index.js @@ -28,7 +28,7 @@ const packageTransforms = new Map([ transforms["method-at"], ["@glimmer/syntax", "angular-estree-parser", "espree"], ], - [transforms["object-has-own"], ["@babel/parser", "meriyah", "graphql"]], + [transforms["object-has-own"], ["@babel/parser", "graphql"]], [transforms["string-raw"], ["camelcase", "@angular/compiler", "js-yaml"]], [transforms["method-is-well-formed"], ["meriyah"]], /* spell-checker: enable */ diff --git a/tests/config/format-test/failed-format-tests.js b/tests/config/format-test/failed-format-tests.js index bbc8b42ee..3dcb2737c 100644 --- a/tests/config/format-test/failed-format-tests.js +++ b/tests/config/format-test/failed-format-tests.js @@ -58,10 +58,7 @@ const disabledTests = new Map( acorn: [ "js/explicit-resource-management/valid-await-using-asi-assignment.js", ], - meriyah: [ - // Parsing to different ASTs - "js/decorators/member-expression.js", - ], + meriyah: [], "babel-ts": [ "typescript/conformance/types/moduleDeclaration/kind-detection.ts", // https://github.com/babel/babel/pull/17659 diff --git a/tests/config/install-prettier.js b/tests/config/install-prettier.js index 91619d6d6..015a254dc 100644 --- a/tests/config/install-prettier.js +++ b/tests/config/install-prettier.js @@ -119,6 +119,13 @@ function installPrettier(packageDirectory) { runNpmClient(["install", packed, "--engine-strict"]); break; case "pnpm": + runNpmClient([ + "config", + "set", + "blockExoticSubdeps", + "false", + "--location=project", + ]); // fails engine mismatch runNpmClient(["add", packed, "--engine-strict"]); break; diff --git a/tests/format/js/_errors_/deferred-import-evaluation/__snapshots__/format.test.js.snap b/tests/format/js/_errors_/deferred-import-evaluation/__snapshots__/format.test.js.snap index 928f5a18a..190466ecf 100644 --- a/tests/format/js/_errors_/deferred-import-evaluation/__snapshots__/format.test.js.snap +++ b/tests/format/js/_errors_/deferred-import-evaluation/__snapshots__/format.test.js.snap @@ -51,11 +51,11 @@ import defer x from "x"; `; exports[`no-default.js format[meriyah] 1`] = ` -"Expected 'from' (1:14) +"'import defer' must be followed by a namespace import (1:14) > 1 | import defer x from "x"; | ^ 2 | -Cause: [1:13-1:14]: Expected 'from'" +Cause: [1:13-1:14]: 'import defer' must be followed by a namespace import" `; exports[`no-default.js format[oxc] 1`] = ` @@ -145,11 +145,11 @@ import defer { x } from "x"; `; exports[`no-named.js format[meriyah] 1`] = ` -"Expected 'from' (1:14) +"'import defer' must be followed by a namespace import (1:14) > 1 | import defer { x } from "x"; | ^ 2 | -Cause: [1:13-1:14]: Expected 'from'" +Cause: [1:13-1:14]: 'import defer' must be followed by a namespace import" `; exports[`no-named.js format[oxc] 1`] = ` @@ -233,10 +233,10 @@ import defer { x } from "x"; `; exports[`snippet: #0 format[meriyah] 1`] = ` -"Expected 'from' (1:14) +"'import defer' must be followed by a namespace import (1:14) > 1 | import defer { x } from "x"; | ^ -Cause: [1:13-1:14]: Expected 'from'" +Cause: [1:13-1:14]: 'import defer' must be followed by a namespace import" `; exports[`snippet: #0 format[oxc] 1`] = ` @@ -315,10 +315,10 @@ import defer x from "x"; `; exports[`snippet: #1 format[meriyah] 1`] = ` -"Expected 'from' (1:14) +"'import defer' must be followed by a namespace import (1:14) > 1 | import defer x from "x"; | ^ -Cause: [1:13-1:14]: Expected 'from'" +Cause: [1:13-1:14]: 'import defer' must be followed by a namespace import" `; exports[`snippet: #1 format[oxc] 1`] = ` diff --git a/tests/format/js/babel-plugins/__snapshots__/format.test.js.snap b/tests/format/js/babel-plugins/__snapshots__/format.test.js.snap index 739f2a17e..bc5452851 100644 --- a/tests/format/js/babel-plugins/__snapshots__/format.test.js.snap +++ b/tests/format/js/babel-plugins/__snapshots__/format.test.js.snap @@ -598,14 +598,6 @@ exports[`deferred-import-evaluation.js format[espree] 1`] = ` Cause: Unexpected token *" `; -exports[`deferred-import-evaluation.js format[meriyah] 1`] = ` -"Expected 'from' (1:14) -> 1 | import defer * as ns from "x"; - | ^ - 2 | -Cause: [1:13-1:14]: Expected 'from'" -`; - exports[`destructuring-private.js format 1`] = ` ====================================options===================================== parsers: ["babel", "babel-ts", "babel-flow"] @@ -2481,15 +2473,6 @@ exports[`source-phase-imports.js format[espree] 1`] = ` Cause: Unexpected token fooSource" `; -exports[`source-phase-imports.js format[meriyah] 1`] = ` -"Expected 'from' (1:15) -> 1 | import source fooSource from "foo"; - | ^^^^^^^^^ - 2 | import.source("x"); - 3 | -Cause: [1:14-1:23]: Expected 'from'" -`; - exports[`throw-expressions.js format 1`] = ` ====================================options===================================== parsers: ["babel", "babel-ts", "babel-flow"] diff --git a/tests/format/js/babel-plugins/format.test.js b/tests/format/js/babel-plugins/format.test.js index 32b3f64c7..be82247d9 100644 --- a/tests/format/js/babel-plugins/format.test.js +++ b/tests/format/js/babel-plugins/format.test.js @@ -67,8 +67,6 @@ runFormatTest(import.meta, ["babel", "babel-ts", "babel-flow"], { "v8intrinsic.js", "module-blocks.js", "async-do-expressions.js", - "source-phase-imports.js", - "deferred-import-evaluation.js", "optional-chaining-assignment.js", "discard-binding.js", ], diff --git a/tests/format/js/deferred-import-evaluation/__snapshots__/format.test.js.snap b/tests/format/js/deferred-import-evaluation/__snapshots__/format.test.js.snap index 0b538c77f..95fa02772 100644 --- a/tests/format/js/deferred-import-evaluation/__snapshots__/format.test.js.snap +++ b/tests/format/js/deferred-import-evaluation/__snapshots__/format.test.js.snap @@ -50,14 +50,6 @@ import.defer("foo"); ^" `; -exports[`dynamic-import.js format[meriyah] 1`] = ` -"The only valid meta property for import is 'import.meta' (1:8) -> 1 | import.defer("foo"); - | ^^^^^ - 2 | -Cause: [1:7-1:12]: The only valid meta property for import is 'import.meta'" -`; - exports[`dynamic-import-attributes-expression.js format 1`] = ` ====================================options===================================== parsers: ["babel", "typescript", "flow"] @@ -108,14 +100,6 @@ import.defer("x", { with: { attr: "val" } }); ^" `; -exports[`dynamic-import-attributes-expression.js format[meriyah] 1`] = ` -"The only valid meta property for import is 'import.meta' (1:8) -> 1 | import.defer("x", { with: { attr: "val" } }); - | ^^^^^ - 2 | -Cause: [1:7-1:12]: The only valid meta property for import is 'import.meta'" -`; - exports[`import-defer.js format 1`] = ` ====================================options===================================== parsers: ["babel", "typescript", "flow"] @@ -163,14 +147,6 @@ import defer * as ns from "x"; ^" `; -exports[`import-defer.js format[meriyah] 1`] = ` -"Expected 'from' (1:14) -> 1 | import defer * as ns from "x"; - | ^ - 2 | -Cause: [1:13-1:14]: Expected 'from'" -`; - exports[`import-defer-attributes-declaration.js format 1`] = ` ====================================options===================================== parsers: ["babel", "typescript", "flow"] @@ -217,11 +193,3 @@ Cause: 'from' expected (1:13) import defer * as ns from "x" with { attr: "val" }; ^" `; - -exports[`import-defer-attributes-declaration.js format[meriyah] 1`] = ` -"Expected 'from' (1:14) -> 1 | import defer * as ns from "x" with { attr: "val" }; - | ^ - 2 | -Cause: [1:13-1:14]: Expected 'from'" -`; diff --git a/tests/format/js/deferred-import-evaluation/format.test.js b/tests/format/js/deferred-import-evaluation/format.test.js index a0bcd3eaa..f1497bf5b 100644 --- a/tests/format/js/deferred-import-evaluation/format.test.js +++ b/tests/format/js/deferred-import-evaluation/format.test.js @@ -9,7 +9,6 @@ runFormatTest(import.meta, ["babel", "typescript", "flow"], { errors: { acorn: importDeferTests, espree: importDeferTests, - meriyah: importDeferTests, flow: importDeferTests, hermes: importDeferTests, }, diff --git a/tests/format/js/dynamic-import/__snapshots__/format.test.js.snap b/tests/format/js/dynamic-import/__snapshots__/format.test.js.snap index 05d949c40..8d72c454d 100644 --- a/tests/format/js/dynamic-import/__snapshots__/format.test.js.snap +++ b/tests/format/js/dynamic-import/__snapshots__/format.test.js.snap @@ -83,16 +83,6 @@ import.source(\`data:text/javascript, ^" `; -exports[`import-phase.js format[meriyah] 1`] = ` -"The only valid meta property for import is 'import.meta' (1:8) -> 1 | import.source(\`data:text/javascript, - | ^^^^^^ - 2 | console.log("RUN"); - 3 | \`) - 4 | -Cause: [1:7-1:13]: The only valid meta property for import is 'import.meta'" -`; - exports[`template-literal.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] diff --git a/tests/format/js/dynamic-import/format.test.js b/tests/format/js/dynamic-import/format.test.js index 3c75120ca..f1c4bf8bb 100644 --- a/tests/format/js/dynamic-import/format.test.js +++ b/tests/format/js/dynamic-import/format.test.js @@ -4,6 +4,5 @@ runFormatTest(import.meta, ["babel", "flow", "typescript"], { hermes: ["template-literal.js", "import-phase.js"], acorn: ["import-phase.js"], espree: ["import-phase.js"], - meriyah: ["import-phase.js"], }, }); diff --git a/tests/format/js/import/long-module-name/__snapshots__/format.test.js.snap b/tests/format/js/import/long-module-name/__snapshots__/format.test.js.snap index d58103137..4176b7670 100644 --- a/tests/format/js/import/long-module-name/__snapshots__/format.test.js.snap +++ b/tests/format/js/import/long-module-name/__snapshots__/format.test.js.snap @@ -66,16 +66,6 @@ import.defer("./a/long/long/long/long/long/long/long/long/long/long/long/long/pa ^" `; -exports[`import-defer.js format[meriyah] 1`] = ` -"The only valid meta property for import is 'import.meta' (1:8) -> 1 | import.defer("./a/long/long/long/long/long/long/long/long/long/long/long/long/path/to/module"); - | ^^^^^ - 2 | import.defer( - 3 | // Comment - 4 | "./a/long/long/long/long/long/long/long/long/long/long/long/long/path/to/module" -Cause: [1:7-1:12]: The only valid meta property for import is 'import.meta'" -`; - exports[`import-expression.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] @@ -165,13 +155,3 @@ note: start of member expression (1:0) import.source("./a/long/long/long/long/long/long/long/long/long/long/long/long/path/to/module"); ^" `; - -exports[`import-source.js format[meriyah] 1`] = ` -"The only valid meta property for import is 'import.meta' (1:8) -> 1 | import.source("./a/long/long/long/long/long/long/long/long/long/long/long/long/path/to/module"); - | ^^^^^^ - 2 | import.source( - 3 | // Comment - 4 | "./a/long/long/long/long/long/long/long/long/long/long/long/long/path/to/module" -Cause: [1:7-1:13]: The only valid meta property for import is 'import.meta'" -`; diff --git a/tests/format/js/import/long-module-name/format.test.js b/tests/format/js/import/long-module-name/format.test.js index f4444ee96..e38e83822 100644 --- a/tests/format/js/import/long-module-name/format.test.js +++ b/tests/format/js/import/long-module-name/format.test.js @@ -2,7 +2,6 @@ runFormatTest(import.meta, ["babel", "flow", "typescript"], { errors: { acorn: ["import-defer.js", "import-source.js"], espree: ["import-defer.js", "import-source.js"], - meriyah: ["import-defer.js", "import-source.js"], flow: ["import-defer.js", "import-source.js"], hermes: ["import-defer.js", "import-source.js"], }, diff --git a/tests/format/js/source-phase-imports/__snapshots__/format.test.js.snap b/tests/format/js/source-phase-imports/__snapshots__/format.test.js.snap index c05e0be2e..7d0b15cd8 100644 --- a/tests/format/js/source-phase-imports/__snapshots__/format.test.js.snap +++ b/tests/format/js/source-phase-imports/__snapshots__/format.test.js.snap @@ -42,14 +42,6 @@ exports[`import-source.js format[espree] 1`] = ` Cause: Unexpected token x" `; -exports[`import-source.js format[meriyah] 1`] = ` -"Expected 'from' (1:15) -> 1 | import source x from "x"; - | ^ - 2 | -Cause: [1:14-1:15]: Expected 'from'" -`; - exports[`import-source-attributes-declaration.js format 1`] = ` ====================================options===================================== parsers: ["babel"] @@ -79,14 +71,6 @@ exports[`import-source-attributes-declaration.js format[espree] 1`] = ` Cause: Unexpected token s" `; -exports[`import-source-attributes-declaration.js format[meriyah] 1`] = ` -"Expected 'from' (1:15) -> 1 | import source s from "x" with { attr: "val" }; - | ^ - 2 | -Cause: [1:14-1:15]: Expected 'from'" -`; - exports[`import-source-attributes-expression.js format 1`] = ` ====================================options===================================== parsers: ["babel"] @@ -116,14 +100,6 @@ exports[`import-source-attributes-expression.js format[espree] 1`] = ` Cause: The only valid meta property for import is 'import.meta'" `; -exports[`import-source-attributes-expression.js format[meriyah] 1`] = ` -"The only valid meta property for import is 'import.meta' (1:8) -> 1 | import.source("x", { with: { attr: "val" } }); - | ^^^^^^ - 2 | -Cause: [1:7-1:13]: The only valid meta property for import is 'import.meta'" -`; - exports[`import-source-binding-from.js format 1`] = ` ====================================options===================================== parsers: ["babel"] @@ -153,14 +129,6 @@ exports[`import-source-binding-from.js format[espree] 1`] = ` Cause: Unexpected token from" `; -exports[`import-source-binding-from.js format[meriyah] 1`] = ` -"Import source must be string (1:20) -> 1 | import source from from "x"; - | ^^^^ - 2 | -Cause: [1:19-1:23]: Import source must be string" -`; - exports[`import-source-binding-source.js format 1`] = ` ====================================options===================================== parsers: ["babel"] @@ -190,14 +158,6 @@ exports[`import-source-binding-source.js format[espree] 1`] = ` Cause: Unexpected token source" `; -exports[`import-source-binding-source.js format[meriyah] 1`] = ` -"Expected 'from' (1:15) -> 1 | import source source from "x"; - | ^^^^^^ - 2 | -Cause: [1:14-1:20]: Expected 'from'" -`; - exports[`import-source-dynamic-import.js format 1`] = ` ====================================options===================================== parsers: ["babel"] @@ -227,14 +187,6 @@ exports[`import-source-dynamic-import.js format[espree] 1`] = ` Cause: The only valid meta property for import is 'import.meta'" `; -exports[`import-source-dynamic-import.js format[meriyah] 1`] = ` -"The only valid meta property for import is 'import.meta' (1:8) -> 1 | import.source("foo"); - | ^^^^^^ - 2 | -Cause: [1:7-1:13]: The only valid meta property for import is 'import.meta'" -`; - exports[`no-named.js format[__babel_estree] 1`] = ` "Only \`import source x from "./module"\` is valid. (1:17) > 1 | import source { x } from "x"; @@ -268,11 +220,11 @@ Cause: Unexpected token {" `; exports[`no-named.js format[meriyah] 1`] = ` -"Expected 'from' (1:15) +"'import source' must be followed by a default import (1:15) > 1 | import source { x } from "x"; | ^ 2 | -Cause: [1:14-1:15]: Expected 'from'" +Cause: [1:14-1:15]: 'import source' must be followed by a default import" `; exports[`no-named.js format[oxc] 1`] = ` @@ -322,11 +274,11 @@ Cause: Unexpected token *" `; exports[`no-namespace.js format[meriyah] 1`] = ` -"Expected 'from' (1:15) +"'import source' must be followed by a default import (1:15) > 1 | import source * as x from "x"; | ^ 2 | -Cause: [1:14-1:15]: Expected 'from'" +Cause: [1:14-1:15]: 'import source' must be followed by a default import" `; exports[`no-namespace.js format[oxc] 1`] = ` diff --git a/tests/format/js/source-phase-imports/format.test.js b/tests/format/js/source-phase-imports/format.test.js index c9db4cdfd..5bc93eff9 100644 --- a/tests/format/js/source-phase-imports/format.test.js +++ b/tests/format/js/source-phase-imports/format.test.js @@ -12,7 +12,7 @@ runFormatTest(import.meta, ["babel"], { errors: { acorn: [...importSourceTests, ...invalidSyntaxTests], espree: [...importSourceTests, ...invalidSyntaxTests], - meriyah: [...importSourceTests, ...invalidSyntaxTests], + meriyah: invalidSyntaxTests, oxc: invalidSyntaxTests, "oxc-ts": invalidSyntaxTests, yuku: invalidSyntaxTests, diff --git a/yarn.lock b/yarn.lock index 3ce27d353..29c6df07e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6990,10 +6990,10 @@ __metadata: languageName: node linkType: hard -"meriyah@npm:7.2.0": - version: 7.2.0 - resolution: "meriyah@npm:7.2.0" - checksum: 10/27730efc5524ef0dca0419b73b503b5486cf1535fb689a9c16224367e45df7c9f1dea0d6d354dbc002185feba642f95fae4e0ee8f2912b06a0a6a36686122a1c +"meriyah@npm:7.3.0": + version: 7.3.0 + resolution: "meriyah@npm:7.3.0" + checksum: 10/fbaafd1cd1fcb7bec62d275e00617a768bdec0694e761848f194ff4850dbbab10663dd69d107821268bb898db6a395c593de6e18d37e967a50444e0978be79f6 languageName: node linkType: hard @@ -8297,7 +8297,7 @@ __metadata: mdast-util-from-markdown: "npm:2.0.3" mdast-util-gfm: "npm:3.1.0" mdast-util-math: "npm:3.0.0" - meriyah: "npm:7.2.0" + meriyah: "npm:7.3.0" micromark-extension-gfm: "npm:3.0.0" micromark-extension-math: "npm:3.1.0" micromark-util-character: "npm:2.1.1"