diff --git a/.github/workflows/update-babel-plugin-tests.yml b/.github/workflows/update-babel-plugin-tests.yml
new file mode 100644
index 000000000..a9b6646f3
--- /dev/null
+++ b/.github/workflows/update-babel-plugin-tests.yml
@@ -0,0 +1,41 @@
+name: Update Babel plugin tests
+
+on:
+ workflow_dispatch:
+ schedule:
+ # “At 00:00 on day-of-month 1 in July.” https://crontab.guru/#0_0_1_7_*
+ - cron: "0 0 1 7 *"
+
+permissions:
+ pull-requests: write
+ contents: write
+
+jobs:
+ run:
+ name: Update Babel plugin tests
+ if: github.event_name != 'schedule' || github.repository == 'prettier/prettier'
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+
+ - name: Setup Node.js
+ uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
+ with:
+ cache: "yarn"
+
+ - name: Install Dependencies
+ run: yarn install --immutable
+
+ - name: Run script
+ run: node scripts/update-babel-plugin-tests.js
+
+ - name: Set current date env
+ run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> "$GITHUB_ENV"
+
+ - uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
+ with:
+ commit-message: Update Babel plugin tests (${{ env.CURRENT_DATE }})
+ branch: automated-cleanup-cspell-${{ env.CURRENT_DATE }}
+ branch-suffix: timestamp
+ title: Update Babel plugin tests (${{ env.CURRENT_DATE }})
diff --git a/scripts/update-babel-plugin-tests.js b/scripts/update-babel-plugin-tests.js
new file mode 100644
index 000000000..ee6f24e43
--- /dev/null
+++ b/scripts/update-babel-plugin-tests.js
@@ -0,0 +1,148 @@
+#!/usr/bin/env node
+
+import assert from "node:assert/strict";
+import fs from "node:fs/promises";
+import dashify from "dashify";
+import { fromMarkdown } from "mdast-util-from-markdown";
+import { gfmFromMarkdown } from "mdast-util-gfm";
+import { gfm as gfmSyntax } from "micromark-extension-gfm";
+import { outdent } from "outdent";
+
+const testDirectory = new URL(
+ "../tests/format/js/babel-plugins/",
+ import.meta.url,
+);
+const docUrl =
+ "https://raw.githubusercontent.com/babel/website/HEAD/docs/parser.md";
+const cacheFile = new URL("../.tmp/babel-parser-plugins.md", import.meta.url);
+
+async function getDoc() {
+ let stat;
+
+ try {
+ stat = await fs.stat(cacheFile);
+ } catch {
+ // No op
+ }
+
+ if (stat) {
+ if (Date.now() - stat.mtimeMs < /* 60 minutes */ 60 * 60 * 1000) {
+ return fs.readFile(cacheFile, "utf8");
+ }
+
+ await fs.rm(cacheFile);
+ }
+
+ const response = await fetch(docUrl);
+
+ if (!response.ok) {
+ throw new Error(`Fetch '${docUrl}' failed.`);
+ }
+
+ const text = await response.text();
+
+ await fs.writeFile(cacheFile, text);
+
+ return text;
+}
+
+function* parseCodeExample(nodes) {
+ for (let index = 0; index < nodes.length; index++) {
+ const node = nodes[index];
+ if (node.type === "inlineCode") {
+ yield node.value;
+ } else if (node.type === "html" && node.value === "") {
+ const valueNode = nodes[++index];
+ const closingTagNode = nodes[++index];
+ assert.equal(closingTagNode.type, "html");
+ assert.equal(closingTagNode.value, "");
+
+ assert.equal(valueNode.type, "text");
+ yield valueNode.value;
+ } else {
+ assert.equal(node.type, "text");
+ assert.equal(node.value.trim(), ",");
+ }
+ }
+}
+
+function* parsePluginTable(text) {
+ const tree = fromMarkdown(text, {
+ extensions: [gfmSyntax()],
+ mdastExtensions: [gfmFromMarkdown()],
+ });
+
+ assert.equal(tree.children.length, 1);
+ assert.equal(tree.children[0].type, "table");
+
+ const table = tree.children[0];
+
+ assert.ok(table.children.length > 2);
+
+ for (const row of table.children.slice(1)) {
+ const [nameCell, exampleCell] = row.children;
+
+ assert.equal(nameCell.children[0].type, "inlineCode");
+ const name = nameCell.children[0].value;
+ assert.ok(/^[a-z\d]+$/i.test(name), name);
+
+ const comment = text
+ .slice(nameCell.position.start.offset + 1, nameCell.position.end.offset)
+ .trim();
+
+ yield {
+ name,
+ comment,
+ examples: parseCodeExample(exampleCell.children).toArray(),
+ };
+ }
+}
+
+async function clean() {
+ const files = await fs.readdir(testDirectory);
+
+ await Promise.all(
+ files
+ .filter(
+ (file) => !(file === "format.test.js" || file === "__snapshots__"),
+ )
+ .map((file) => fs.rm(new URL(file, testDirectory))),
+ );
+}
+
+function* getExamples(text) {
+ const matches = text.matchAll(
+ /(?<=\n)\| Name\s* \| Code Example \s* \|\n.*?(?=\n\n)/gs,
+ );
+
+ for (const [text] of matches) {
+ for (const { name, comment, examples } of parsePluginTable(text)) {
+ for (const [index, code] of examples.entries()) {
+ const filename = `${dashify(name)}${index === 0 ? "" : `-${index + 1}`}.js`;
+ yield { filename, name, comment, code };
+ }
+ }
+ }
+}
+
+async function updateBabelPluginTests() {
+ const text = await getDoc();
+
+ await Promise.all(
+ getExamples(text).map(({ filename, comment, code }) =>
+ fs.writeFile(
+ new URL(filename, testDirectory),
+ outdent`
+ /*
+ ${comment}
+ */
+
+ ${code}
+ ` + "\n",
+ ),
+ ),
+ );
+}
+
+await clean();
+await updateBabelPluginTests();
diff --git a/src/language-js/parse/babel.js b/src/language-js/parse/babel.js
index b2f550ecd..5de430d32 100644
--- a/src/language-js/parse/babel.js
+++ b/src/language-js/parse/babel.js
@@ -31,8 +31,14 @@ const parseOptions = {
createParenthesizedExpressions: true,
attachComment: false,
plugins: [
- // When adding a plugin, please add a test in `tests/format/js/babel-plugins`,
- // To remove plugins, remove it here and run `yarn test tests/format/js/babel-plugins` to verify
+ /*
+ Add a plugin:
+ Please make sure a simple syntax test added in `tests/format/js/babel-plugins/`,
+ Run `node scripts/update-babel-plugin-tests.js` will add examples
+ from https://babel.dev/docs/babel-parser#plugins
+ Remove a plugin:
+ Remove it here and run `yarn test tests/format/js/babel-plugins` to verify
+ */
"doExpressions",
"exportDefaultFrom",
"functionBind",
diff --git a/tests/config/format-test/failed-format-tests.js b/tests/config/format-test/failed-format-tests.js
index 073e4ea55..d7258adf9 100644
--- a/tests/config/format-test/failed-format-tests.js
+++ b/tests/config/format-test/failed-format-tests.js
@@ -61,6 +61,7 @@ const disabledTests = new Map(
"js/await-expression/like-call.js",
"jsx/top-level-await/test.jsx",
],
+ "babel-flow": ["js/babel-plugins/flow-comments.js"],
typescript: [],
yaml: [
// Bug: https://github.com/eemeli/yaml/issues/646
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 bc5452851..3c774fb4d 100644
--- a/tests/format/js/babel-plugins/__snapshots__/format.test.js.snap
+++ b/tests/format/js/babel-plugins/__snapshots__/format.test.js.snap
@@ -5,9 +5,17 @@ exports[`async-do-expressions.js format 1`] = `
parsers: ["babel", "babel-ts", "babel-flow"]
printWidth: 80 (default) |
=====================================input======================================
-async do { await requestAPI().json() };
+/*
+\`asyncDoExpressions\` ([proposal](https://github.com/tc39/proposal-async-do-expressions))
+*/
+
+async do { await requestAPI().json() }
=====================================output=====================================
+/*
+\`asyncDoExpressions\` ([proposal](https://github.com/tc39/proposal-async-do-expressions))
+*/
+
(async do {
await requestAPI().json();
});
@@ -16,427 +24,51 @@ async do { await requestAPI().json() };
`;
exports[`async-do-expressions.js format[acorn] 1`] = `
-"Unexpected token (1:7)
-> 1 | async do { await requestAPI().json() };
+"Unexpected token (5:7)
+ 3 | */
+ 4 |
+> 5 | async do { await requestAPI().json() }
| ^
- 2 |
-Cause: Unexpected token (1:6)"
+ 6 |
+Cause: Unexpected token (5:6)"
`;
exports[`async-do-expressions.js format[espree] 1`] = `
-"Unexpected token do (1:7)
-> 1 | async do { await requestAPI().json() };
+"Unexpected token do (5:7)
+ 3 | */
+ 4 |
+> 5 | async do { await requestAPI().json() }
| ^
- 2 |
+ 6 |
Cause: Unexpected token do"
`;
exports[`async-do-expressions.js format[meriyah] 1`] = `
-"Unexpected token: 'do' (1:7)
-> 1 | async do { await requestAPI().json() };
+"Unexpected token: 'do' (5:7)
+ 3 | */
+ 4 |
+> 5 | async do { await requestAPI().json() }
| ^^
- 2 |
-Cause: [1:6-1:8]: Unexpected token: 'do'"
+ 6 |
+Cause: [5:6-5:8]: Unexpected token: 'do'"
`;
exports[`async-do-expressions.js format[oxc] 1`] = `
-"Expected a semicolon or an implicit semicolon after a statement, but found none (1:6)
-> 1 | async do { await requestAPI().json() };
+"Expected a semicolon or an implicit semicolon after a statement, but found none (5:6)
+ 3 | */
+ 4 |
+> 5 | async do { await requestAPI().json() }
| ^
- 2 |"
+ 6 |"
`;
exports[`async-do-expressions.js format[yuku] 1`] = `
-"Expected a semicolon or an implicit semicolon after a statement, but found 'do' (1:7)
-> 1 | async do { await requestAPI().json() };
+"Expected a semicolon or an implicit semicolon after a statement, but found 'do' (5:7)
+ 3 | */
+ 4 |
+> 5 | async do { await requestAPI().json() }
| ^^
- 2 |"
-`;
-
-exports[`async-generators.js format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-// https://babeljs.io/docs/babel-plugin-proposal-async-generator-functions
-
-async function* agf() {
- await 1;
- yield 2;
-}
-
-=====================================output=====================================
-// https://babeljs.io/docs/babel-plugin-proposal-async-generator-functions
-
-async function* agf() {
- await 1;
- yield 2;
-}
-
-================================================================================
-`;
-
-exports[`bigint.js format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-// https://github.com/tc39/proposal-bigint
-
-const previousMaxSafe = BigInt(Number.MAX_SAFE_INTEGER);
-// ↪ 9007199254740991
-
-const maxPlusOne = previousMaxSafe + 1n;
-// ↪ 9007199254740992n
-
-const theFuture = previousMaxSafe + 2n;
-// ↪ 9007199254740993n, this works now!
-
-const multi = previousMaxSafe * 2n;
-// ↪ 18014398509481982n
-
-// \`–\` is not minus sign,
-// SIC https://github.com/tc39/proposal-bigint#operators
-// const subtr = multi – 10n;
-// ↪ 18014398509481972n
-
-const mod = multi % 10n;
-// ↪ 2n
-
-const bigN = 2n ** 54n;
-// ↪ 18014398509481984n
-
-bigN * -1n
-// ↪ –18014398509481984n
-
-0n === 0
-// ↪ false
-
-0n == 0
-// ↪ true
-
-1n < 2
-// ↪ true
-
-2n > 1
-// ↪ true
-
-2 > 2
-// ↪ false
-
-2n > 2
-// ↪ false
-
-2n >= 2
-// ↪ true
-
-const mixed = [4n, 6, -12n, 10, 4, 0, 0n];
-// ↪ [4n, 6, -12n, 10, 4, 0, 0n]
-
-mixed.sort();
-// ↪ [-12n, 0, 0n, 10, 4n, 4, 6]
-
-if (0n) {
- console.log('Hello from the if!');
-} else {
- console.log('Hello from the else!');
-}
-
-// ↪ "Hello from the else!"
-
-0n || 12n
-// ↪ 12n
-
-0n && 12n
-// ↪ 0n
-
-Boolean(0n)
-// ↪ false
-
-Boolean(12n)
-// ↪ true
-
-!12n
-// ↪ false
-
-!0n
-// ↪ true
-
-const view = new BigInt64Array(4);
-// ↪ [0n, 0n, 0n, 0n]
-view.length;
-// ↪ 4
-view[0];
-// ↪ 0n
-view[0] = 42n;
-view[0];
-// ↪ 42n
-
-// Highest possible BigInt value that can be represented as a
-// signed 64-bit integer.
-const max = 2n ** (64n - 1n) - 1n;
-view[0] = max;
-view[0];
-// ↪ 9_223_372_036_854_775_807n
-view[0] = max + 1n;
-view[0];
-// ↪ -9_223_372_036_854_775_808n
-// ^ negative because of overflow
-
-1n + 2
-// ↪ TypeError: Cannot mix BigInt and other types, use explicit conversions
-
-1n * 2
-// ↪ TypeError: Cannot mix BigInt and other types, use explicit conversions
-
-+1n
-// ↪ TypeError: Cannot convert a BigInt value to a number
-
-Number(1n)
-// ↪ 1
-
-1n + '2'
-// ↪ "12"
-
-'2' + 1n
-// ↪ "21"
-
-const badPrecision = BigInt(9007199254740993);
-// ↪9007199254740992n
-
-const goodPrecision = BigInt('9007199254740993');
-// ↪9007199254740993n
-
-const alsoGoodPrecision = 9007199254740993n;
-// ↪9007199254740993n
-
-=====================================output=====================================
-// https://github.com/tc39/proposal-bigint
-
-const previousMaxSafe = BigInt(Number.MAX_SAFE_INTEGER);
-// ↪ 9007199254740991
-
-const maxPlusOne = previousMaxSafe + 1n;
-// ↪ 9007199254740992n
-
-const theFuture = previousMaxSafe + 2n;
-// ↪ 9007199254740993n, this works now!
-
-const multi = previousMaxSafe * 2n;
-// ↪ 18014398509481982n
-
-// \`–\` is not minus sign,
-// SIC https://github.com/tc39/proposal-bigint#operators
-// const subtr = multi – 10n;
-// ↪ 18014398509481972n
-
-const mod = multi % 10n;
-// ↪ 2n
-
-const bigN = 2n ** 54n;
-// ↪ 18014398509481984n
-
-bigN * -1n;
-// ↪ –18014398509481984n
-
-0n === 0;
-// ↪ false
-
-0n == 0;
-// ↪ true
-
-1n < 2;
-// ↪ true
-
-2n > 1;
-// ↪ true
-
-2 > 2;
-// ↪ false
-
-2n > 2;
-// ↪ false
-
-2n >= 2;
-// ↪ true
-
-const mixed = [4n, 6, -12n, 10, 4, 0, 0n];
-// ↪ [4n, 6, -12n, 10, 4, 0, 0n]
-
-mixed.sort();
-// ↪ [-12n, 0, 0n, 10, 4n, 4, 6]
-
-if (0n) {
- console.log("Hello from the if!");
-} else {
- console.log("Hello from the else!");
-}
-
-// ↪ "Hello from the else!"
-
-0n || 12n;
-// ↪ 12n
-
-0n && 12n;
-// ↪ 0n
-
-Boolean(0n);
-// ↪ false
-
-Boolean(12n);
-// ↪ true
-
-!12n;
-// ↪ false
-
-!0n;
-// ↪ true
-
-const view = new BigInt64Array(4);
-// ↪ [0n, 0n, 0n, 0n]
-view.length;
-// ↪ 4
-view[0];
-// ↪ 0n
-view[0] = 42n;
-view[0];
-// ↪ 42n
-
-// Highest possible BigInt value that can be represented as a
-// signed 64-bit integer.
-const max = 2n ** (64n - 1n) - 1n;
-view[0] = max;
-view[0];
-// ↪ 9_223_372_036_854_775_807n
-view[0] = max + 1n;
-view[0];
-// ↪ -9_223_372_036_854_775_808n
-// ^ negative because of overflow
-
-1n + 2;
-// ↪ TypeError: Cannot mix BigInt and other types, use explicit conversions
-
-1n * 2 +
- // ↪ TypeError: Cannot mix BigInt and other types, use explicit conversions
-
- 1n;
-// ↪ TypeError: Cannot convert a BigInt value to a number
-
-Number(1n);
-// ↪ 1
-
-1n + "2";
-// ↪ "12"
-
-"2" + 1n;
-// ↪ "21"
-
-const badPrecision = BigInt(9007199254740993);
-// ↪9007199254740992n
-
-const goodPrecision = BigInt("9007199254740993");
-// ↪9007199254740993n
-
-const alsoGoodPrecision = 9007199254740993n;
-// ↪9007199254740993n
-
-================================================================================
-`;
-
-exports[`class-properties.js format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-// https://babeljs.io/docs/babel-plugin-proposal-class-properties
-
-class Bork {
- //Property initializer syntax
- instanceProperty = "bork";
- boundFunction = () => {
- return this.instanceProperty;
- };
-
- //Static class properties
- static staticProperty = "babelIsCool";
- static staticFunction = function() {
- return Bork.staticProperty;
- };
- }
-
- let myBork = new Bork;
-
- //Property initializers are not on the prototype.
- console.log(myBork.__proto__.boundFunction); // > undefined
-
- //Bound functions are bound to the class instance.
- console.log(myBork.boundFunction.call(undefined)); // > "bork"
-
- //Static function exists on the class.
- console.log(Bork.staticFunction()); // > "babelIsCool"
-
-=====================================output=====================================
-// https://babeljs.io/docs/babel-plugin-proposal-class-properties
-
-class Bork {
- //Property initializer syntax
- instanceProperty = "bork";
- boundFunction = () => {
- return this.instanceProperty;
- };
-
- //Static class properties
- static staticProperty = "babelIsCool";
- static staticFunction = function () {
- return Bork.staticProperty;
- };
-}
-
-let myBork = new Bork();
-
-//Property initializers are not on the prototype.
-console.log(myBork.__proto__.boundFunction); // > undefined
-
-//Bound functions are bound to the class instance.
-console.log(myBork.boundFunction.call(undefined)); // > "bork"
-
-//Static function exists on the class.
-console.log(Bork.staticFunction()); // > "babelIsCool"
-
-================================================================================
-`;
-
-exports[`class-static-block.js format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-class C {
- static #x = 42;
- static y;
- static {
- try {
- this.y = doSomethingWith(this.#x);
- } catch {
- this.y = "unknown";
- }
- }
-}
-
-=====================================output=====================================
-class C {
- static #x = 42;
- static y;
- static {
- try {
- this.y = doSomethingWith(this.#x);
- } catch {
- this.y = "unknown";
- }
- }
-}
-
-================================================================================
+ 6 |"
`;
exports[`decorator-auto-accessors.js format 1`] = `
@@ -444,36 +76,42 @@ exports[`decorator-auto-accessors.js format 1`] = `
parsers: ["babel", "babel-ts", "babel-flow"]
printWidth: 80 (default) |
=====================================input======================================
-class C extends HTMLElement {
- accessor clicked = false;
-}
+/*
+\`decoratorAutoAccessors\` ([proposal](https://github.com/tc39/proposal-decorators))
+*/
+
+class Example { @reactive accessor myBool = false; }
=====================================output=====================================
-class C extends HTMLElement {
- accessor clicked = false;
+/*
+\`decoratorAutoAccessors\` ([proposal](https://github.com/tc39/proposal-decorators))
+*/
+
+class Example {
+ @reactive accessor myBool = false;
}
================================================================================
`;
exports[`decorator-auto-accessors.js format[acorn] 1`] = `
-"Unexpected token (2:12)
- 1 | class C extends HTMLElement {
-> 2 | accessor clicked = false;
- | ^
- 3 | }
+"Unexpected character '@' (5:17)
+ 3 | */
4 |
-Cause: Unexpected token (2:11)"
+> 5 | class Example { @reactive accessor myBool = false; }
+ | ^
+ 6 |
+Cause: Unexpected character '@' (5:16)"
`;
exports[`decorator-auto-accessors.js format[espree] 1`] = `
-"Unexpected token clicked (2:12)
- 1 | class C extends HTMLElement {
-> 2 | accessor clicked = false;
- | ^
- 3 | }
+"Unexpected character '@' (5:17)
+ 3 | */
4 |
-Cause: Unexpected token clicked"
+> 5 | class Example { @reactive accessor myBool = false; }
+ | ^
+ 6 |
+Cause: Unexpected character '@'"
`;
exports[`decorators.js format 1`] = `
@@ -481,91 +119,40 @@ exports[`decorators.js format 1`] = `
parsers: ["babel", "babel-ts", "babel-flow"]
printWidth: 80 (default) |
=====================================input======================================
-// https://babeljs.io/docs/babel-plugin-proposal-decorators
+/*
+\`decorators\` ([proposal](https://github.com/tc39/proposal-decorators))
\`decorators-legacy\`
+*/
-@annotation
-class MyClass { }
-
-function annotation(target) {
- target.annotated = true;
-}
-
-@isTestable(true)
-class MyClass { }
-
-function isTestable(value) {
- return function decorator(target) {
- target.isTestable = value;
- }
-}
-
-class C {
- @enumerable(false)
- method() { }
-}
-
-function enumerable(value) {
- return function (target, key, descriptor) {
- descriptor.enumerable = value;
- return descriptor;
- }
-}
+@a class A {}
=====================================output=====================================
-// https://babeljs.io/docs/babel-plugin-proposal-decorators
+/*
+\`decorators\` ([proposal](https://github.com/tc39/proposal-decorators))
\`decorators-legacy\`
+*/
-@annotation
-class MyClass {}
-
-function annotation(target) {
- target.annotated = true;
-}
-
-@isTestable(true)
-class MyClass {}
-
-function isTestable(value) {
- return function decorator(target) {
- target.isTestable = value;
- };
-}
-
-class C {
- @enumerable(false)
- method() {}
-}
-
-function enumerable(value) {
- return function (target, key, descriptor) {
- descriptor.enumerable = value;
- return descriptor;
- };
-}
+@a
+class A {}
================================================================================
`;
exports[`decorators.js format[acorn] 1`] = `
-"Unexpected character '@' (3:1)
- 1 | // https://babeljs.io/docs/babel-plugin-proposal-decorators
- 2 |
-> 3 | @annotation
+"Unexpected character '@' (5:1)
+ 3 | */
+ 4 |
+> 5 | @a class A {}
| ^
- 4 | class MyClass { }
- 5 |
- 6 | function annotation(target) {
-Cause: Unexpected character '@' (3:0)"
+ 6 |
+Cause: Unexpected character '@' (5:0)"
`;
exports[`decorators.js format[espree] 1`] = `
-"Unexpected character '@' (3:1)
- 1 | // https://babeljs.io/docs/babel-plugin-proposal-decorators
- 2 |
-> 3 | @annotation
+"Unexpected character '@' (5:1)
+ 3 | */
+ 4 |
+> 5 | @a class A {}
| ^
- 4 | class MyClass { }
- 5 |
- 6 | function annotation(target) {
+ 6 |
Cause: Unexpected character '@'"
`;
@@ -574,27 +161,39 @@ exports[`deferred-import-evaluation.js format 1`] = `
parsers: ["babel", "babel-ts", "babel-flow"]
printWidth: 80 (default) |
=====================================input======================================
-import defer * as ns from "x";
+/*
+\`deferredImportEvaluation\` ([proposal](https://github.com/tc39/proposal-defer-import-eval))
+*/
+
+import defer * as ns from "dep";
=====================================output=====================================
-import defer * as ns from "x";
+/*
+\`deferredImportEvaluation\` ([proposal](https://github.com/tc39/proposal-defer-import-eval))
+*/
+
+import defer * as ns from "dep";
================================================================================
`;
exports[`deferred-import-evaluation.js format[acorn] 1`] = `
-"Unexpected token (1:14)
-> 1 | import defer * as ns from "x";
+"Unexpected token (5:14)
+ 3 | */
+ 4 |
+> 5 | import defer * as ns from "dep";
| ^
- 2 |
-Cause: Unexpected token (1:13)"
+ 6 |
+Cause: Unexpected token (5:13)"
`;
exports[`deferred-import-evaluation.js format[espree] 1`] = `
-"Unexpected token * (1:14)
-> 1 | import defer * as ns from "x";
+"Unexpected token * (5:14)
+ 3 | */
+ 4 |
+> 5 | import defer * as ns from "dep";
| ^
- 2 |
+ 6 |
Cause: Unexpected token *"
`;
@@ -603,30 +202,21 @@ exports[`destructuring-private.js format 1`] = `
parsers: ["babel", "babel-ts", "babel-flow"]
printWidth: 80 (default) |
=====================================input======================================
-class Foo {
- #x = 1;
- constructor() {
- console.log(this.#x); // => 1
- const { #x: x } = this;
- console.log(x); // => 1
- }
- equals({ #x: otherX }) {
- const { #x: currentX } = this;
- return currentX === otherX;
- }
-}
+/*
+\`destructuringPrivate\` ([proposal](https://github.com/tc39/proposal-destructuring-private))
+*/
+
+class Example { #x = 1; method() { const { #x: x } = this; } }
=====================================output=====================================
-class Foo {
+/*
+\`destructuringPrivate\` ([proposal](https://github.com/tc39/proposal-destructuring-private))
+*/
+
+class Example {
#x = 1;
- constructor() {
- console.log(this.#x); // => 1
+ method() {
const { #x: x } = this;
- console.log(x); // => 1
- }
- equals({ #x: otherX }) {
- const { #x: currentX } = this;
- return currentX === otherX;
}
}
@@ -634,61 +224,51 @@ class Foo {
`;
exports[`destructuring-private.js format[acorn] 1`] = `
-"Unexpected token (5:13)
- 3 | constructor() {
- 4 | console.log(this.#x); // => 1
-> 5 | const { #x: x } = this;
- | ^
- 6 | console.log(x); // => 1
- 7 | }
- 8 | equals({ #x: otherX }) {
-Cause: Unexpected token (5:12)"
+"Unexpected token (5:44)
+ 3 | */
+ 4 |
+> 5 | class Example { #x = 1; method() { const { #x: x } = this; } }
+ | ^
+ 6 |
+Cause: Unexpected token (5:43)"
`;
exports[`destructuring-private.js format[espree] 1`] = `
-"Unexpected token #x (5:13)
- 3 | constructor() {
- 4 | console.log(this.#x); // => 1
-> 5 | const { #x: x } = this;
- | ^
- 6 | console.log(x); // => 1
- 7 | }
- 8 | equals({ #x: otherX }) {
+"Unexpected token #x (5:44)
+ 3 | */
+ 4 |
+> 5 | class Example { #x = 1; method() { const { #x: x } = this; } }
+ | ^
+ 6 |
Cause: Unexpected token #x"
`;
exports[`destructuring-private.js format[meriyah] 1`] = `
-"Unexpected token: 'PrivateField' (5:13)
- 3 | constructor() {
- 4 | console.log(this.#x); // => 1
-> 5 | const { #x: x } = this;
- | ^
- 6 | console.log(x); // => 1
- 7 | }
- 8 | equals({ #x: otherX }) {
-Cause: [5:12-5:13]: Unexpected token: 'PrivateField'"
+"Unexpected token: 'PrivateField' (5:44)
+ 3 | */
+ 4 |
+> 5 | class Example { #x = 1; method() { const { #x: x } = this; } }
+ | ^
+ 6 |
+Cause: [5:43-5:44]: Unexpected token: 'PrivateField'"
`;
exports[`destructuring-private.js format[oxc] 1`] = `
-"Private identifier '#x' is not allowed in property names (5:13)
- 3 | constructor() {
- 4 | console.log(this.#x); // => 1
-> 5 | const { #x: x } = this;
- | ^^
- 6 | console.log(x); // => 1
- 7 | }
- 8 | equals({ #x: otherX }) {"
+"Private identifier '#x' is not allowed in property names (5:44)
+ 3 | */
+ 4 |
+> 5 | class Example { #x = 1; method() { const { #x: x } = this; } }
+ | ^^
+ 6 |"
`;
exports[`destructuring-private.js format[yuku] 1`] = `
-"Unexpected token '#x' as property key (5:13)
- 3 | constructor() {
- 4 | console.log(this.#x); // => 1
-> 5 | const { #x: x } = this;
- | ^^
- 6 | console.log(x); // => 1
- 7 | }
- 8 | equals({ #x: otherX }) {"
+"Unexpected token '#x' as property key (5:44)
+ 3 | */
+ 4 |
+> 5 | class Example { #x = 1; method() { const { #x: x } = this; } }
+ | ^^
+ 6 |"
`;
exports[`discard-binding.js format 1`] = `
@@ -696,50 +276,68 @@ exports[`discard-binding.js format 1`] = `
parsers: ["babel", "babel-ts", "babel-flow"]
printWidth: 80 (default) |
=====================================input======================================
-const [a, void] = iter;
+/*
+\`discardBinding\` ([proposal](https://github.com/tc39/proposal-discard-binding))
+*/
+
+using void = new Lock(mutex)
=====================================output=====================================
-const [a, void] = iter;
+/*
+\`discardBinding\` ([proposal](https://github.com/tc39/proposal-discard-binding))
+*/
+
+using void = new Lock(mutex);
================================================================================
`;
exports[`discard-binding.js format[acorn] 1`] = `
-"Unexpected keyword 'void' (1:11)
-> 1 | const [a, void] = iter;
- | ^
- 2 |
-Cause: Unexpected keyword 'void' (1:10)"
+"Unexpected keyword 'void' (5:7)
+ 3 | */
+ 4 |
+> 5 | using void = new Lock(mutex)
+ | ^
+ 6 |
+Cause: Unexpected keyword 'void' (5:6)"
`;
exports[`discard-binding.js format[espree] 1`] = `
-"Unexpected keyword 'void' (1:11)
-> 1 | const [a, void] = iter;
- | ^
- 2 |
+"Unexpected keyword 'void' (5:7)
+ 3 | */
+ 4 |
+> 5 | using void = new Lock(mutex)
+ | ^
+ 6 |
Cause: Unexpected keyword 'void'"
`;
exports[`discard-binding.js format[meriyah] 1`] = `
-"Unexpected token: ']' (1:15)
-> 1 | const [a, void] = iter;
- | ^
- 2 |
-Cause: [1:14-1:15]: Unexpected token: ']'"
+"Unexpected token: 'void' (5:7)
+ 3 | */
+ 4 |
+> 5 | using void = new Lock(mutex)
+ | ^^^^
+ 6 |
+Cause: [5:6-5:10]: Unexpected token: 'void'"
`;
exports[`discard-binding.js format[oxc] 1`] = `
-"Identifier expected. 'void' is a reserved word that cannot be used here. (1:11)
-> 1 | const [a, void] = iter;
- | ^^^^
- 2 |"
+"Expected a semicolon or an implicit semicolon after a statement, but found none (5:6)
+ 3 | */
+ 4 |
+> 5 | using void = new Lock(mutex)
+ | ^
+ 6 |"
`;
exports[`discard-binding.js format[yuku] 1`] = `
-"Unexpected token ']' (1:15)
-> 1 | const [a, void] = iter;
- | ^
- 2 |"
+"Expected a semicolon or an implicit semicolon after a statement, but found 'void' (5:7)
+ 3 | */
+ 4 |
+> 5 | using void = new Lock(mutex)
+ | ^^^^
+ 6 |"
`;
exports[`do-expressions.js format 1`] = `
@@ -747,152 +345,72 @@ exports[`do-expressions.js format 1`] = `
parsers: ["babel", "babel-ts", "babel-flow"]
printWidth: 80 (default) |
=====================================input======================================
-// https://babeljs.io/docs/babel-plugin-proposal-do-expressions
+/*
+\`doExpressions\` ([proposal](https://github.com/tc39/proposal-do-expressions))
+*/
-let a = do {
- if(x > 10) {
- 'big';
- } else {
- 'small';
- }
-};
-// is equivalent to:
-let a = x > 10 ? 'big' : 'small';
+var a = do { if (true) { 'hi'; } };
=====================================output=====================================
-// https://babeljs.io/docs/babel-plugin-proposal-do-expressions
+/*
+\`doExpressions\` ([proposal](https://github.com/tc39/proposal-do-expressions))
+*/
-let a = do {
- if (x > 10) {
- ("big");
- } else {
- ("small");
+var a = do {
+ if (true) {
+ ("hi");
}
};
-// is equivalent to:
-let a = x > 10 ? "big" : "small";
================================================================================
`;
exports[`do-expressions.js format[acorn] 1`] = `
-"Unexpected token (3:9)
- 1 | // https://babeljs.io/docs/babel-plugin-proposal-do-expressions
- 2 |
-> 3 | let a = do {
+"Unexpected token (5:9)
+ 3 | */
+ 4 |
+> 5 | var a = do { if (true) { 'hi'; } };
| ^
- 4 | if(x > 10) {
- 5 | 'big';
- 6 | } else {
-Cause: Unexpected token (3:8)"
+ 6 |
+Cause: Unexpected token (5:8)"
`;
exports[`do-expressions.js format[espree] 1`] = `
-"Unexpected token do (3:9)
- 1 | // https://babeljs.io/docs/babel-plugin-proposal-do-expressions
- 2 |
-> 3 | let a = do {
+"Unexpected token do (5:9)
+ 3 | */
+ 4 |
+> 5 | var a = do { if (true) { 'hi'; } };
| ^
- 4 | if(x > 10) {
- 5 | 'big';
- 6 | } else {
+ 6 |
Cause: Unexpected token do"
`;
exports[`do-expressions.js format[meriyah] 1`] = `
-"Unexpected token: 'do' (3:9)
- 1 | // https://babeljs.io/docs/babel-plugin-proposal-do-expressions
- 2 |
-> 3 | let a = do {
+"Unexpected token: 'do' (5:9)
+ 3 | */
+ 4 |
+> 5 | var a = do { if (true) { 'hi'; } };
| ^^
- 4 | if(x > 10) {
- 5 | 'big';
- 6 | } else {
-Cause: [3:8-3:10]: Unexpected token: 'do'"
+ 6 |
+Cause: [5:8-5:10]: Unexpected token: 'do'"
`;
exports[`do-expressions.js format[oxc] 1`] = `
-"Unexpected token (3:9)
- 1 | // https://babeljs.io/docs/babel-plugin-proposal-do-expressions
- 2 |
-> 3 | let a = do {
+"Unexpected token (5:9)
+ 3 | */
+ 4 |
+> 5 | var a = do { if (true) { 'hi'; } };
| ^^
- 4 | if(x > 10) {
- 5 | 'big';
- 6 | } else {"
+ 6 |"
`;
exports[`do-expressions.js format[yuku] 1`] = `
-"'do' is reserved and cannot be used as an identifier (3:9)
- 1 | // https://babeljs.io/docs/babel-plugin-proposal-do-expressions
- 2 |
-> 3 | let a = do {
+"'do' is reserved and cannot be used as an identifier (5:9)
+ 3 | */
+ 4 |
+> 5 | var a = do { if (true) { 'hi'; } };
| ^^
- 4 | if(x > 10) {
- 5 | 'big';
- 6 | } else {"
-`;
-
-exports[`dynamic-import.js format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-// https://babeljs.io/docs/babel-plugin-syntax-dynamic-import
-
-// There is no example code on babel website
-
-import('./prettier.mjs');
-import(prettier);
-import('./prettier.mjs').then(module => console.log(module));
-import(prettier).then(module => console.log(module));
-
-=====================================output=====================================
-// https://babeljs.io/docs/babel-plugin-syntax-dynamic-import
-
-// There is no example code on babel website
-
-import("./prettier.mjs");
-import(prettier);
-import("./prettier.mjs").then((module) => console.log(module));
-import(prettier).then((module) => console.log(module));
-
-================================================================================
-`;
-
-exports[`explicit-resource-management.js format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-function * g() {
- using handle = acquireFileHandle(); // block-scoped critical resource
-} // cleanup
-
-{
- using obj = g(); // block-scoped declaration
- const r = obj.next();
-} // calls finally blocks in \`g\`
-
-{
- await using obj = g();
-}
-
-=====================================output=====================================
-function* g() {
- using handle = acquireFileHandle(); // block-scoped critical resource
-} // cleanup
-
-{
- using obj = g(); // block-scoped declaration
- const r = obj.next();
-} // calls finally blocks in \`g\`
-
-{
- await using obj = g();
-}
-
-================================================================================
+ 6 |"
`;
exports[`export-default-from.js format 1`] = `
@@ -900,13 +418,16 @@ exports[`export-default-from.js format 1`] = `
parsers: ["babel", "babel-ts", "babel-flow"]
printWidth: 80 (default) |
=====================================input======================================
-// https://babeljs.io/docs/babel-plugin-proposal-export-default-from
+/*
+\`exportDefaultFrom\` ([proposal](https://github.com/tc39/ecmascript-export-default-from))
+*/
-
-export v from 'mod';
+export v from "mod"
=====================================output=====================================
-// https://babeljs.io/docs/babel-plugin-proposal-export-default-from
+/*
+\`exportDefaultFrom\` ([proposal](https://github.com/tc39/ecmascript-export-default-from))
+*/
export v from "mod";
@@ -914,68 +435,51 @@ export v from "mod";
`;
exports[`export-default-from.js format[acorn] 1`] = `
-"Unexpected token (4:8)
- 2 |
- 3 |
-> 4 | export v from 'mod';
+"Unexpected token (5:8)
+ 3 | */
+ 4 |
+> 5 | export v from "mod"
| ^
- 5 |
-Cause: Unexpected token (4:7)"
+ 6 |
+Cause: Unexpected token (5:7)"
`;
exports[`export-default-from.js format[espree] 1`] = `
-"Unexpected token v (4:8)
- 2 |
- 3 |
-> 4 | export v from 'mod';
+"Unexpected token v (5:8)
+ 3 | */
+ 4 |
+> 5 | export v from "mod"
| ^
- 5 |
+ 6 |
Cause: Unexpected token v"
`;
exports[`export-default-from.js format[meriyah] 1`] = `
-"Unexpected token: 'identifier' (4:8)
- 2 |
- 3 |
-> 4 | export v from 'mod';
+"Unexpected token: 'identifier' (5:8)
+ 3 | */
+ 4 |
+> 5 | export v from "mod"
| ^
- 5 |
-Cause: [4:7-4:8]: Unexpected token: 'identifier'"
+ 6 |
+Cause: [5:7-5:8]: Unexpected token: 'identifier'"
`;
exports[`export-default-from.js format[oxc] 1`] = `
-"Unexpected token (4:8)
- 2 |
- 3 |
-> 4 | export v from 'mod';
+"Unexpected token (5:8)
+ 3 | */
+ 4 |
+> 5 | export v from "mod"
| ^
- 5 |"
+ 6 |"
`;
exports[`export-default-from.js format[yuku] 1`] = `
-"Expected declaration after 'export', but found 'v' (4:8)
- 2 |
- 3 |
-> 4 | export v from 'mod';
+"Expected declaration after 'export', but found 'v' (5:8)
+ 3 | */
+ 4 |
+> 5 | export v from "mod"
| ^
- 5 |"
-`;
-
-exports[`export-namespace-from.js format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-// https://babeljs.io/docs/babel-plugin-proposal-export-namespace-from
-
-export * as ns from 'mod';
-
-=====================================output=====================================
-// https://babeljs.io/docs/babel-plugin-proposal-export-namespace-from
-
-export * as ns from "mod";
-
-================================================================================
+ 6 |"
`;
exports[`flow.js format 1`] = `
@@ -983,84 +487,109 @@ exports[`flow.js format 1`] = `
parsers: ["babel", "babel-ts", "babel-flow"]
printWidth: 80 (default) |
=====================================input======================================
-// https://babeljs.io/docs/babel-preset-flow
+/*
+\`flow\` ([repo](https://github.com/facebook/flow))
+*/
-function foo(one: any, two: number, three?): string {}
+var a: string = "";
=====================================output=====================================
-// https://babeljs.io/docs/babel-preset-flow
+/*
+\`flow\` ([repo](https://github.com/facebook/flow))
+*/
-function foo(one: any, two: number, three?): string {}
+var a: string = "";
================================================================================
`;
exports[`flow.js format[__babel_estree] 1`] = `
-"Unexpected token, expected "," (3:17)
- 1 | // https://babeljs.io/docs/babel-preset-flow
- 2 |
-> 3 | function foo(one: any, two: number, three?): string {}
- | ^
+"Unexpected token (5:6)
+ 3 | */
4 |
-Cause: Unexpected token, expected "," (3:16)"
+> 5 | var a: string = "";
+ | ^
+ 6 |
+Cause: Unexpected token (5:5)"
`;
exports[`flow.js format[acorn] 1`] = `
-"Unexpected token (3:17)
- 1 | // https://babeljs.io/docs/babel-preset-flow
- 2 |
-> 3 | function foo(one: any, two: number, three?): string {}
- | ^
+"Unexpected token (5:6)
+ 3 | */
4 |
-Cause: Unexpected token (3:16)"
+> 5 | var a: string = "";
+ | ^
+ 6 |
+Cause: Unexpected token (5:5)"
`;
exports[`flow.js format[babel] 1`] = `
-"Unexpected token, expected "," (3:17)
- 1 | // https://babeljs.io/docs/babel-preset-flow
- 2 |
-> 3 | function foo(one: any, two: number, three?): string {}
- | ^
+"Unexpected token (5:6)
+ 3 | */
4 |
-Cause: Unexpected token, expected "," (3:16)"
+> 5 | var a: string = "";
+ | ^
+ 6 |
+Cause: Unexpected token (5:5)"
`;
exports[`flow.js format[espree] 1`] = `
-"Unexpected token : (3:17)
- 1 | // https://babeljs.io/docs/babel-preset-flow
- 2 |
-> 3 | function foo(one: any, two: number, three?): string {}
- | ^
+"Unexpected token : (5:6)
+ 3 | */
4 |
+> 5 | var a: string = "";
+ | ^
+ 6 |
Cause: Unexpected token :"
`;
exports[`flow.js format[meriyah] 1`] = `
-"Expected ')' (3:17)
- 1 | // https://babeljs.io/docs/babel-preset-flow
- 2 |
-> 3 | function foo(one: any, two: number, three?): string {}
- | ^
+"Unexpected token: ':' (5:6)
+ 3 | */
4 |
-Cause: [3:16-3:17]: Expected ')'"
+> 5 | var a: string = "";
+ | ^
+ 6 |
+Cause: [5:5-5:6]: Unexpected token: ':'"
`;
exports[`flow.js format[oxc] 1`] = `
-"Expected \`,\` or \`)\` but found \`:\` (3:17)
- 1 | // https://babeljs.io/docs/babel-preset-flow
- 2 |
-> 3 | function foo(one: any, two: number, three?): string {}
- | ^
- 4 |"
+"Expected a semicolon or an implicit semicolon after a statement, but found none (5:6)
+ 3 | */
+ 4 |
+> 5 | var a: string = "";
+ | ^
+ 6 |"
`;
exports[`flow.js format[yuku] 1`] = `
-"Expected ')' to close parameter list, but found ':' (3:17)
- 1 | // https://babeljs.io/docs/babel-preset-flow
- 2 |
-> 3 | function foo(one: any, two: number, three?): string {}
- | ^
- 4 |"
+"Expected a semicolon or an implicit semicolon after a statement, but found ':' (5:6)
+ 3 | */
+ 4 |
+> 5 | var a: string = "";
+ | ^
+ 6 |"
+`;
+
+exports[`flow-comments.js format 1`] = `
+====================================options=====================================
+parsers: ["babel", "babel-ts", "babel-flow"]
+ printWidth: 80 (default) |
+=====================================input======================================
+/*
+\`flowComments\` ([docs](https://flow.org/en/docs/types/comments/))
+*/
+
+/*:: type Foo = {...}; */
+
+=====================================output=====================================
+/*
+\`flowComments\` ([docs](https://flow.org/en/docs/types/comments/))
+*/
+
+/*:: type Foo = {...}; */
+
+================================================================================
`;
exports[`function-bind.js format 1`] = `
@@ -1068,100 +597,136 @@ exports[`function-bind.js format 1`] = `
parsers: ["babel", "babel-ts", "babel-flow"]
printWidth: 80 (default) |
=====================================input======================================
-// https://babeljs.io/docs/babel-plugin-proposal-function-bind
+/*
+\`functionBind\` ([proposal](https://github.com/zenparsing/es-function-bind))
+*/
-obj::func
-// is equivalent to:
-func.bind(obj)
-
-::obj.func
-// is equivalent to:
-obj.func.bind(obj)
-
-obj::func(val)
-// is equivalent to:
-func.call(obj, val)
-
-::obj.func(val)
-// is equivalent to:
-obj.func.call(obj, val)
+a::b
=====================================output=====================================
-// https://babeljs.io/docs/babel-plugin-proposal-function-bind
+/*
+\`functionBind\` ([proposal](https://github.com/zenparsing/es-function-bind))
+*/
-obj::func;
-// is equivalent to:
-func.bind(obj)::obj.func;
-// is equivalent to:
-obj.func.bind(obj);
-
-obj::func(val);
-// is equivalent to:
-func
- .call(obj, val)
-
- ::obj.func(val);
-// is equivalent to:
-obj.func.call(obj, val);
+a::b;
================================================================================
`;
exports[`function-bind.js format[acorn] 1`] = `
-"Unexpected token (3:5)
- 1 | // https://babeljs.io/docs/babel-plugin-proposal-function-bind
- 2 |
-> 3 | obj::func
- | ^
- 4 | // is equivalent to:
- 5 | func.bind(obj)
+"Unexpected token (5:3)
+ 3 | */
+ 4 |
+> 5 | a::b
+ | ^
6 |
-Cause: Unexpected token (3:4)"
+Cause: Unexpected token (5:2)"
`;
exports[`function-bind.js format[espree] 1`] = `
-"Unexpected token : (3:5)
- 1 | // https://babeljs.io/docs/babel-plugin-proposal-function-bind
- 2 |
-> 3 | obj::func
- | ^
- 4 | // is equivalent to:
- 5 | func.bind(obj)
+"Unexpected token : (5:3)
+ 3 | */
+ 4 |
+> 5 | a::b
+ | ^
6 |
Cause: Unexpected token :"
`;
exports[`function-bind.js format[meriyah] 1`] = `
-"Unexpected token: ':' (3:5)
- 1 | // https://babeljs.io/docs/babel-plugin-proposal-function-bind
- 2 |
-> 3 | obj::func
- | ^
- 4 | // is equivalent to:
- 5 | func.bind(obj)
+"Unexpected token: ':' (5:3)
+ 3 | */
+ 4 |
+> 5 | a::b
+ | ^
6 |
-Cause: [3:4-3:5]: Unexpected token: ':'"
+Cause: [5:2-5:3]: Unexpected token: ':'"
`;
exports[`function-bind.js format[oxc] 1`] = `
-"Unexpected token (3:5)
- 1 | // https://babeljs.io/docs/babel-plugin-proposal-function-bind
- 2 |
-> 3 | obj::func
- | ^
- 4 | // is equivalent to:
- 5 | func.bind(obj)
+"Unexpected token (5:3)
+ 3 | */
+ 4 |
+> 5 | a::b
+ | ^
6 |"
`;
exports[`function-bind.js format[yuku] 1`] = `
-"Unexpected token ':' (3:5)
- 1 | // https://babeljs.io/docs/babel-plugin-proposal-function-bind
- 2 |
-> 3 | obj::func
- | ^
- 4 | // is equivalent to:
- 5 | func.bind(obj)
+"Unexpected token ':' (5:3)
+ 3 | */
+ 4 |
+> 5 | a::b
+ | ^
+ 6 |"
+`;
+
+exports[`function-bind-2.js format 1`] = `
+====================================options=====================================
+parsers: ["babel", "babel-ts", "babel-flow"]
+ printWidth: 80 (default) |
+=====================================input======================================
+/*
+\`functionBind\` ([proposal](https://github.com/zenparsing/es-function-bind))
+*/
+
+::console.log
+
+=====================================output=====================================
+/*
+\`functionBind\` ([proposal](https://github.com/zenparsing/es-function-bind))
+*/
+
+::console.log;
+
+================================================================================
+`;
+
+exports[`function-bind-2.js format[acorn] 1`] = `
+"Unexpected token (5:1)
+ 3 | */
+ 4 |
+> 5 | ::console.log
+ | ^
+ 6 |
+Cause: Unexpected token (5:0)"
+`;
+
+exports[`function-bind-2.js format[espree] 1`] = `
+"Unexpected token : (5:1)
+ 3 | */
+ 4 |
+> 5 | ::console.log
+ | ^
+ 6 |
+Cause: Unexpected token :"
+`;
+
+exports[`function-bind-2.js format[meriyah] 1`] = `
+"Unexpected token: ':' (5:1)
+ 3 | */
+ 4 |
+> 5 | ::console.log
+ | ^
+ 6 |
+Cause: [5:0-5:1]: Unexpected token: ':'"
+`;
+
+exports[`function-bind-2.js format[oxc] 1`] = `
+"Unexpected token (5:1)
+ 3 | */
+ 4 |
+> 5 | ::console.log
+ | ^
+ 6 |"
+`;
+
+exports[`function-bind-2.js format[yuku] 1`] = `
+"Unexpected token ':' (5:1)
+ 3 | */
+ 4 |
+> 5 | ::console.log
+ | ^
6 |"
`;
@@ -1170,174 +735,70 @@ exports[`function-sent.js format 1`] = `
parsers: ["babel", "babel-ts", "babel-flow"]
printWidth: 80 (default) |
=====================================input======================================
-// https://babeljs.io/docs/babel-plugin-proposal-function-sent
+/*
+\`functionSent\` ([proposal](https://github.com/tc39/proposal-function.sent))
+*/
-function* generator() {
- console.log("Sent", function.sent);
- console.log("Yield", yield);
-}
-
-const iterator = generator();
-iterator.next(1); // Logs "Sent 1"
-iterator.next(2); // Logs "Yield 2"
+function* g() { function.sent }
=====================================output=====================================
-// https://babeljs.io/docs/babel-plugin-proposal-function-sent
+/*
+\`functionSent\` ([proposal](https://github.com/tc39/proposal-function.sent))
+*/
-function* generator() {
- console.log("Sent", function.sent);
- console.log("Yield", yield);
+function* g() {
+ function.sent;
}
-const iterator = generator();
-iterator.next(1); // Logs "Sent 1"
-iterator.next(2); // Logs "Yield 2"
-
================================================================================
`;
exports[`function-sent.js format[acorn] 1`] = `
-"Unexpected token (4:33)
- 2 |
- 3 | function* generator() {
-> 4 | console.log("Sent", function.sent);
- | ^
- 5 | console.log("Yield", yield);
- 6 | }
- 7 |
-Cause: Unexpected token (4:32)"
+"Unexpected token (5:25)
+ 3 | */
+ 4 |
+> 5 | function* g() { function.sent }
+ | ^
+ 6 |
+Cause: Unexpected token (5:24)"
`;
exports[`function-sent.js format[espree] 1`] = `
-"Unexpected token . (4:33)
- 2 |
- 3 | function* generator() {
-> 4 | console.log("Sent", function.sent);
- | ^
- 5 | console.log("Yield", yield);
- 6 | }
- 7 |
+"Unexpected token . (5:25)
+ 3 | */
+ 4 |
+> 5 | function* g() { function.sent }
+ | ^
+ 6 |
Cause: Unexpected token ."
`;
exports[`function-sent.js format[meriyah] 1`] = `
-"Expected '(' (4:33)
- 2 |
- 3 | function* generator() {
-> 4 | console.log("Sent", function.sent);
- | ^
- 5 | console.log("Yield", yield);
- 6 | }
- 7 |
-Cause: [4:32-4:33]: Expected '('"
+"Unexpected token: '.' (5:25)
+ 3 | */
+ 4 |
+> 5 | function* g() { function.sent }
+ | ^
+ 6 |
+Cause: [5:24-5:25]: Unexpected token: '.'"
`;
exports[`function-sent.js format[oxc] 1`] = `
-"Expected \`(\` but found \`.\` (4:33)
- 2 |
- 3 | function* generator() {
-> 4 | console.log("Sent", function.sent);
- | ^
- 5 | console.log("Yield", yield);
- 6 | }
- 7 |"
+"Expected \`(\` but found \`.\` (5:25)
+ 3 | */
+ 4 |
+> 5 | function* g() { function.sent }
+ | ^
+ 6 |"
`;
exports[`function-sent.js format[yuku] 1`] = `
-"Expected '(' to start parameter list, but found '.' (4:33)
- 2 |
- 3 | function* generator() {
-> 4 | console.log("Sent", function.sent);
- | ^
- 5 | console.log("Yield", yield);
- 6 | }
- 7 |"
-`;
-
-exports[`import-assertions-dynamic.js format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-import("./foo.json", { assert: { type: "json" } });
-
-=====================================output=====================================
-import("./foo.json", { assert: { type: "json" } });
-
-================================================================================
-`;
-
-exports[`import-attributes-dynamic.js format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-import("./foo.json", { with: { type: "json" } });
-
-=====================================output=====================================
-import("./foo.json", { with: { type: "json" } });
-
-================================================================================
-`;
-
-exports[`import-attributes-static.js format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-import json from "./foo.json" with { type: "json" };
-
-=====================================output=====================================
-import json from "./foo.json" with { type: "json" };
-
-================================================================================
-`;
-
-exports[`import-meta.js format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-// https://babeljs.io/docs/babel-plugin-syntax-import-meta
-
-// Enabled by default https://github.com/babel/babel/pull/11406
-
-// from https://github.com/tc39/proposal-import-meta
-
-(async () => {
- const response = await fetch(new URL("../hamsters.jpg", import.meta.url));
- const blob = await response.blob();
-
- const size = import.meta.scriptElement.dataset.size || 300;
-
- const image = new Image();
- image.src = URL.createObjectURL(blob);
- image.width = image.height = size;
-
- document.body.appendChild(image);
-})();
-
-=====================================output=====================================
-// https://babeljs.io/docs/babel-plugin-syntax-import-meta
-
-// Enabled by default https://github.com/babel/babel/pull/11406
-
-// from https://github.com/tc39/proposal-import-meta
-
-(async () => {
- const response = await fetch(new URL("../hamsters.jpg", import.meta.url));
- const blob = await response.blob();
-
- const size = import.meta.scriptElement.dataset.size || 300;
-
- const image = new Image();
- image.src = URL.createObjectURL(blob);
- image.width = image.height = size;
-
- document.body.appendChild(image);
-})();
-
-================================================================================
+"Function declaration requires a name (5:25)
+ 3 | */
+ 4 |
+> 5 | function* g() { function.sent }
+ | ^
+ 6 |"
`;
exports[`jsx.js format 1`] = `
@@ -1345,47 +806,18 @@ exports[`jsx.js format 1`] = `
parsers: ["babel", "babel-ts", "babel-flow"]
printWidth: 80 (default) |
=====================================input======================================
-// https://babeljs.io/docs/babel-plugin-syntax-jsx
+/*
+\`jsx\` ([repo](https://facebook.github.io/jsx/))
+*/
-var profile =
-

-
{[user.firstName, user.lastName].join(' ')}
-
;
+{s}
=====================================output=====================================
-// https://babeljs.io/docs/babel-plugin-syntax-jsx
+/*
+\`jsx\` ([repo](https://facebook.github.io/jsx/))
+*/
-var profile = (
-
-

-
{[user.firstName, user.lastName].join(" ")}
-
-);
-
-================================================================================
-`;
-
-exports[`logical-assignment-operators.js format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-// https://babeljs.io/docs/babel-plugin-proposal-logical-assignment-operators
-
-a ||= b;
-obj.a.b ||= c;
-
-a &&= b;
-obj.a.b &&= c;
-
-=====================================output=====================================
-// https://babeljs.io/docs/babel-plugin-proposal-logical-assignment-operators
-
-a ||= b;
-obj.a.b ||= c;
-
-a &&= b;
-obj.a.b &&= c;
+{s};
================================================================================
`;
@@ -1395,436 +827,139 @@ exports[`module-blocks.js format 1`] = `
parsers: ["babel", "babel-ts", "babel-flow"]
printWidth: 80 (default) |
=====================================input======================================
-let m = module {
- export let m = 2;
- export let n = 3;
-};
+/*
+\`moduleBlocks\` ([proposal](https://github.com/tc39/proposal-js-module-blocks))
+*/
+
+let m = module { export let y = 1; };
=====================================output=====================================
+/*
+\`moduleBlocks\` ([proposal](https://github.com/tc39/proposal-js-module-blocks))
+*/
+
let m = module {
- export let m = 2;
- export let n = 3;
+ export let y = 1;
};
================================================================================
`;
exports[`module-blocks.js format[acorn] 1`] = `
-"Unexpected token (1:16)
-> 1 | let m = module {
+"Unexpected token (5:16)
+ 3 | */
+ 4 |
+> 5 | let m = module { export let y = 1; };
| ^
- 2 | export let m = 2;
- 3 | export let n = 3;
- 4 | };
-Cause: Unexpected token (1:15)"
+ 6 |
+Cause: Unexpected token (5:15)"
`;
exports[`module-blocks.js format[espree] 1`] = `
-"Unexpected token { (1:16)
-> 1 | let m = module {
+"Unexpected token { (5:16)
+ 3 | */
+ 4 |
+> 5 | let m = module { export let y = 1; };
| ^
- 2 | export let m = 2;
- 3 | export let n = 3;
- 4 | };
+ 6 |
Cause: Unexpected token {"
`;
exports[`module-blocks.js format[meriyah] 1`] = `
-"Unexpected token: '{' (1:16)
-> 1 | let m = module {
+"Unexpected token: '{' (5:16)
+ 3 | */
+ 4 |
+> 5 | let m = module { export let y = 1; };
| ^
- 2 | export let m = 2;
- 3 | export let n = 3;
- 4 | };
-Cause: [1:15-1:16]: Unexpected token: '{'"
+ 6 |
+Cause: [5:15-5:16]: Unexpected token: '{'"
`;
exports[`module-blocks.js format[oxc] 1`] = `
-"Expected a semicolon or an implicit semicolon after a statement, but found none (1:15)
-> 1 | let m = module {
+"Expected a semicolon or an implicit semicolon after a statement, but found none (5:15)
+ 3 | */
+ 4 |
+> 5 | let m = module { export let y = 1; };
| ^
- 2 | export let m = 2;
- 3 | export let n = 3;
- 4 | };"
+ 6 |"
`;
exports[`module-blocks.js format[yuku] 1`] = `
-"Expected a semicolon or an implicit semicolon after a statement, but found '{' (1:16)
-> 1 | let m = module {
+"Expected a semicolon or an implicit semicolon after a statement, but found '{' (5:16)
+ 3 | */
+ 4 |
+> 5 | let m = module { export let y = 1; };
| ^
- 2 | export let m = 2;
- 3 | export let n = 3;
- 4 | };"
+ 6 |"
`;
-exports[`module-string-names.js format 1`] = `
+exports[`optional-chaining-assign.js format 1`] = `
====================================options=====================================
parsers: ["babel", "babel-ts", "babel-flow"]
printWidth: 80 (default) |
=====================================input======================================
-import { "😄" as smile } from "./emojis.js";
-export { smile as "😄" } from "./emojis.js";
+/*
+\`optionalChainingAssign\` ([proposal](https://github.com/tc39/proposal-optional-chaining-assignment))
+*/
+
+x?.prop = 2
=====================================output=====================================
-import { "😄" as smile } from "./emojis.js";
-export { smile as "😄" } from "./emojis.js";
+/*
+\`optionalChainingAssign\` ([proposal](https://github.com/tc39/proposal-optional-chaining-assignment))
+*/
+
+x?.prop = 2;
================================================================================
`;
-exports[`nullish-coalescing-operator.js format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-// https://babeljs.io/docs/babel-plugin-proposal-nullish-coalescing-operator
-
-var foo = object.foo ?? "default";
-
-=====================================output=====================================
-// https://babeljs.io/docs/babel-plugin-proposal-nullish-coalescing-operator
-
-var foo = object.foo ?? "default";
-
-================================================================================
-`;
-
-exports[`numeric-separator.js format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-// https://babeljs.io/docs/babel-plugin-proposal-numeric-separator
-
-let budget = 1_000_000_000_000;
-
-// What is the value of \`budget\`? It's 1 trillion!
-//
-// Let's confirm:
-console.log(budget === 10 ** 12); // true
-
-let nibbles = 0b1010_0001_1000_0101;
-
-// Is bit 7 on? It sure is!
-// 0b1010_0001_1000_0101
-// ^
-//
-// We can double check:
-console.log(!!(nibbles & (1 << 7))); // true
-
-// Messages are sent as 24 bit values, but should be
-// treated as 3 distinct bytes:
-let message = 0xa0_b0_c0;
-
-// What's the value of the upper most byte? It's A0, or 160.
-// We can confirm that:
-let a = (message >> 16) & 0xff;
-console.log(a.toString(16), a); // a0, 160
-
-// What's the value of the middle byte? It's B0, or 176.
-// Let's just make sure...
-let b = (message >> 8) & 0xff;
-console.log(b.toString(16), b); // b0, 176
-
-// What's the value of the lower most byte? It's C0, or 192.
-// Again, let's prove that:
-let c = message & 0xff;
-console.log(c.toString(16), b); // c0, 192
-
-=====================================output=====================================
-// https://babeljs.io/docs/babel-plugin-proposal-numeric-separator
-
-let budget = 1_000_000_000_000;
-
-// What is the value of \`budget\`? It's 1 trillion!
-//
-// Let's confirm:
-console.log(budget === 10 ** 12); // true
-
-let nibbles = 0b1010_0001_1000_0101;
-
-// Is bit 7 on? It sure is!
-// 0b1010_0001_1000_0101
-// ^
-//
-// We can double check:
-console.log(!!(nibbles & (1 << 7))); // true
-
-// Messages are sent as 24 bit values, but should be
-// treated as 3 distinct bytes:
-let message = 0xa0_b0_c0;
-
-// What's the value of the upper most byte? It's A0, or 160.
-// We can confirm that:
-let a = (message >> 16) & 0xff;
-console.log(a.toString(16), a); // a0, 160
-
-// What's the value of the middle byte? It's B0, or 176.
-// Let's just make sure...
-let b = (message >> 8) & 0xff;
-console.log(b.toString(16), b); // b0, 176
-
-// What's the value of the lower most byte? It's C0, or 192.
-// Again, let's prove that:
-let c = message & 0xff;
-console.log(c.toString(16), b); // c0, 192
-
-================================================================================
-`;
-
-exports[`object-rest-spread.js format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-// https://babeljs.io/docs/babel-plugin-transform-object-rest-spread
-
-let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };
-console.log(x); // 1
-console.log(y); // 2
-console.log(z); // { a: 3, b: 4 }
-
-let n = { x, y, ...z };
-console.log(n); // { x: 1, y: 2, a: 3, b: 4 }
-
-=====================================output=====================================
-// https://babeljs.io/docs/babel-plugin-transform-object-rest-spread
-
-let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };
-console.log(x); // 1
-console.log(y); // 2
-console.log(z); // { a: 3, b: 4 }
-
-let n = { x, y, ...z };
-console.log(n); // { x: 1, y: 2, a: 3, b: 4 }
-
-================================================================================
-`;
-
-exports[`optional-catch-binding.js format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-// https://babeljs.io/docs/babel-plugin-proposal-optional-catch-binding
-
-try {
- throw 0;
-} catch {
- doSomethingWhichDoesNotCareAboutTheValueThrown();
-}
-
-try {
- throw 0;
-} catch {
- doSomethingWhichDoesNotCareAboutTheValueThrown();
-} finally {
- doSomeCleanup();
-}
-
-=====================================output=====================================
-// https://babeljs.io/docs/babel-plugin-proposal-optional-catch-binding
-
-try {
- throw 0;
-} catch {
- doSomethingWhichDoesNotCareAboutTheValueThrown();
-}
-
-try {
- throw 0;
-} catch {
- doSomethingWhichDoesNotCareAboutTheValueThrown();
-} finally {
- doSomeCleanup();
-}
-
-================================================================================
-`;
-
-exports[`optional-chaining.js format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-// https://babeljs.io/docs/babel-plugin-proposal-optional-chaining
-
-const obj = {
- foo: {
- bar: {
- baz: 42,
- },
- },
-};
-
-const baz = obj?.foo?.bar?.baz; // 42
-
-const safe = obj?.qux?.baz; // undefined
-
-// Optional chaining and normal chaining can be intermixed
-obj?.foo.bar?.baz; // Only access \`foo\` if \`obj\` exists, and \`baz\` if
- // \`bar\` exists
-
-// Example usage with bracket notation:
-obj?.['foo']?.bar?.baz // 42
-
-const obj2 = {
- foo: {
- bar: {
- baz() {
- return 42;
- },
- },
- },
-};
-
-const baz2 = obj?.foo?.bar?.baz(); // 42
-
-const safe3 = obj?.qux?.baz(); // undefined
-const safe4 = obj?.foo.bar.qux?.(); // undefined
-
-const willThrow = obj?.foo.bar.qux(); // Error: not a function
-
-// Top function can be called directly, too.
-function test() {
- return 42;
-}
-test?.(); // 42
-
-exists?.(); // undefined
-
-const obj3 = {
- foo: {
- bar: {
- baz: class {
- },
- },
- },
-};
-
-const obj4 = {
- foo: {
- bar: {}
- },
-};
-
-const ret = delete obj?.foo?.bar?.baz; // true
-
-=====================================output=====================================
-// https://babeljs.io/docs/babel-plugin-proposal-optional-chaining
-
-const obj = {
- foo: {
- bar: {
- baz: 42,
- },
- },
-};
-
-const baz = obj?.foo?.bar?.baz; // 42
-
-const safe = obj?.qux?.baz; // undefined
-
-// Optional chaining and normal chaining can be intermixed
-obj?.foo.bar?.baz; // Only access \`foo\` if \`obj\` exists, and \`baz\` if
-// \`bar\` exists
-
-// Example usage with bracket notation:
-obj?.["foo"]?.bar?.baz; // 42
-
-const obj2 = {
- foo: {
- bar: {
- baz() {
- return 42;
- },
- },
- },
-};
-
-const baz2 = obj?.foo?.bar?.baz(); // 42
-
-const safe3 = obj?.qux?.baz(); // undefined
-const safe4 = obj?.foo.bar.qux?.(); // undefined
-
-const willThrow = obj?.foo.bar.qux(); // Error: not a function
-
-// Top function can be called directly, too.
-function test() {
- return 42;
-}
-test?.(); // 42
-
-exists?.(); // undefined
-
-const obj3 = {
- foo: {
- bar: {
- baz: class {},
- },
- },
-};
-
-const obj4 = {
- foo: {
- bar: {},
- },
-};
-
-const ret = delete obj?.foo?.bar?.baz; // true
-
-================================================================================
-`;
-
-exports[`optional-chaining-assignment.js format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-maybeAnObj?.prop = theValue;
-
-=====================================output=====================================
-maybeAnObj?.prop = theValue;
-
-================================================================================
-`;
-
-exports[`optional-chaining-assignment.js format[acorn] 1`] = `
-"Optional chaining cannot appear in left-hand side (1:1)
-> 1 | maybeAnObj?.prop = theValue;
+exports[`optional-chaining-assign.js format[acorn] 1`] = `
+"Optional chaining cannot appear in left-hand side (5:1)
+ 3 | */
+ 4 |
+> 5 | x?.prop = 2
| ^
- 2 |
-Cause: Optional chaining cannot appear in left-hand side (1:0)"
+ 6 |
+Cause: Optional chaining cannot appear in left-hand side (5:0)"
`;
-exports[`optional-chaining-assignment.js format[espree] 1`] = `
-"Optional chaining cannot appear in left-hand side (1:1)
-> 1 | maybeAnObj?.prop = theValue;
+exports[`optional-chaining-assign.js format[espree] 1`] = `
+"Optional chaining cannot appear in left-hand side (5:1)
+ 3 | */
+ 4 |
+> 5 | x?.prop = 2
| ^
- 2 |
+ 6 |
Cause: Optional chaining cannot appear in left-hand side"
`;
-exports[`optional-chaining-assignment.js format[meriyah] 1`] = `
-"Invalid left-hand side in assignment (1:18)
-> 1 | maybeAnObj?.prop = theValue;
- | ^
- 2 |
-Cause: [1:17-1:18]: Invalid left-hand side in assignment"
+exports[`optional-chaining-assign.js format[meriyah] 1`] = `
+"Invalid left-hand side in assignment (5:9)
+ 3 | */
+ 4 |
+> 5 | x?.prop = 2
+ | ^
+ 6 |
+Cause: [5:8-5:9]: Invalid left-hand side in assignment"
`;
-exports[`optional-chaining-assignment.js format[oxc] 1`] = `
-"Cannot assign to this expression (1:1)
-> 1 | maybeAnObj?.prop = theValue;
- | ^^^^^^^^^^^^^^^^
- 2 |"
+exports[`optional-chaining-assign.js format[oxc] 1`] = `
+"Cannot assign to this expression (5:1)
+ 3 | */
+ 4 |
+> 5 | x?.prop = 2
+ | ^^^^^^^
+ 6 |"
`;
-exports[`optional-chaining-assignment.js format[yuku] 1`] = `
-"Optional chaining is not allowed in assignment pattern (1:1)
-> 1 | maybeAnObj?.prop = theValue;
- | ^^^^^^^^^^^^^^^^
- 2 |"
+exports[`optional-chaining-assign.js format[yuku] 1`] = `
+"Optional chaining is not allowed in assignment pattern (5:1)
+ 3 | */
+ 4 |
+> 5 | x?.prop = 2
+ | ^^^^^^^
+ 6 |"
`;
exports[`partial-application.js format 1`] = `
@@ -1832,612 +967,137 @@ exports[`partial-application.js format 1`] = `
parsers: ["babel", "babel-ts", "babel-flow"]
printWidth: 80 (default) |
=====================================input======================================
-// https://babeljs.io/docs/babel-plugin-proposal-partial-application
+/*
+\`partialApplication\` ([proposal](https://github.com/babel/proposals/issues/32))
+*/
-function add(x, y) { return x + y; }
-
-const addOne = add(1, ?); // apply from the left
-addOne(2); // 3
-
-const addTen = add(?, 10); // apply from the right
-addTen(2); // 12
-
-let newScore = player.score
- |> add(7, ?)
- |> clamp(0, 100, ?); // shallow stack, the pipe to \`clamp\` is the same frame as the pipe to \`add\`.
-
-f(x, ?) // partial application from left
-f(?, x) // partial application from right
-f(?, x, ?) // partial application for any arg
-o.f(x, ?) // partial application from left
-o.f(?, x) // partial application from right
-o.f(?, x, ?) // partial application for any arg
-super.f(?) // partial application allowed for call on |SuperProperty|
+f(?, a)
=====================================output=====================================
-// https://babeljs.io/docs/babel-plugin-proposal-partial-application
+/*
+\`partialApplication\` ([proposal](https://github.com/babel/proposals/issues/32))
+*/
-function add(x, y) {
- return x + y;
-}
-
-const addOne = add(1, ?); // apply from the left
-addOne(2); // 3
-
-const addTen = add(?, 10); // apply from the right
-addTen(2); // 12
-
-let newScore = player.score |> add(7, ?) |> clamp(0, 100, ?); // shallow stack, the pipe to \`clamp\` is the same frame as the pipe to \`add\`.
-
-f(x, ?); // partial application from left
-f(?, x); // partial application from right
-f(?, x, ?); // partial application for any arg
-o.f(x, ?); // partial application from left
-o.f(?, x); // partial application from right
-o.f(?, x, ?); // partial application for any arg
-super.f(?); // partial application allowed for call on |SuperProperty|
+f(?, a);
================================================================================
`;
exports[`partial-application.js format[acorn] 1`] = `
-"Unexpected token (5:23)
- 3 | function add(x, y) { return x + y; }
+"Unexpected token (5:3)
+ 3 | */
4 |
-> 5 | const addOne = add(1, ?); // apply from the left
- | ^
- 6 | addOne(2); // 3
- 7 |
- 8 | const addTen = add(?, 10); // apply from the right
-Cause: Unexpected token (5:22)"
+> 5 | f(?, a)
+ | ^
+ 6 |
+Cause: Unexpected token (5:2)"
`;
exports[`partial-application.js format[espree] 1`] = `
-"Unexpected token ? (5:23)
- 3 | function add(x, y) { return x + y; }
+"Unexpected token ? (5:3)
+ 3 | */
4 |
-> 5 | const addOne = add(1, ?); // apply from the left
- | ^
- 6 | addOne(2); // 3
- 7 |
- 8 | const addTen = add(?, 10); // apply from the right
+> 5 | f(?, a)
+ | ^
+ 6 |
Cause: Unexpected token ?"
`;
exports[`partial-application.js format[meriyah] 1`] = `
-"Unexpected token: '?' (5:23)
- 3 | function add(x, y) { return x + y; }
+"Unexpected token: '?' (5:3)
+ 3 | */
4 |
-> 5 | const addOne = add(1, ?); // apply from the left
- | ^
- 6 | addOne(2); // 3
- 7 |
- 8 | const addTen = add(?, 10); // apply from the right
-Cause: [5:22-5:23]: Unexpected token: '?'"
+> 5 | f(?, a)
+ | ^
+ 6 |
+Cause: [5:2-5:3]: Unexpected token: '?'"
`;
exports[`partial-application.js format[oxc] 1`] = `
-"Unexpected token (5:23)
- 3 | function add(x, y) { return x + y; }
+"Unexpected token (5:3)
+ 3 | */
4 |
-> 5 | const addOne = add(1, ?); // apply from the left
- | ^
- 6 | addOne(2); // 3
- 7 |
- 8 | const addTen = add(?, 10); // apply from the right"
+> 5 | f(?, a)
+ | ^
+ 6 |"
`;
exports[`partial-application.js format[yuku] 1`] = `
-"Unexpected token '?' (5:23)
- 3 | function add(x, y) { return x + y; }
+"Unexpected token '?' (5:3)
+ 3 | */
4 |
-> 5 | const addOne = add(1, ?); // apply from the left
- | ^
- 6 | addOne(2); // 3
- 7 |
- 8 | const addTen = add(?, 10); // apply from the right"
+> 5 | f(?, a)
+ | ^
+ 6 |"
`;
-exports[`pipeline-operator-fsharp.js format 1`] = `
+exports[`pipeline-operator.js format 1`] = `
====================================options=====================================
parsers: ["babel", "babel-ts", "babel-flow"]
printWidth: 80 (default) |
=====================================input======================================
-// https://babeljs.io/docs/babel-plugin-proposal-pipeline-operator
-// https://github.com/valtech-nyc/proposal-fsharp-pipelines
+/*
+\`pipelineOperator\` ([proposal](https://github.com/babel/proposals/issues/29))
+*/
-promise
- |> await
- |> x => doubleSay(x, ', ')
- |> capitalize
- |> x => x + '!'
- |> x => new User.Message(x)
- |> x => stream.write(x)
- |> await
- |> console.log;
-
-const result = exclaim(capitalize(doubleSay("hello")));
-result //=> "Hello, hello!"
-
-const result = "hello"
- |> doubleSay
- |> capitalize
- |> exclaim;
-
-result //=> "Hello, hello!"
-
-const person = { score: 25 };
-
-const newScore = person.score
- |> double
- |> n => add(7, n)
- |> n => boundScore(0, 100, n);
-
-newScore //=> 57
-
-// As opposed to:
-let newScore = boundScore(0, 100, add(7, double(person.score)));
+a |> b
=====================================output=====================================
-// https://babeljs.io/docs/babel-plugin-proposal-pipeline-operator
-// https://github.com/valtech-nyc/proposal-fsharp-pipelines
+/*
+\`pipelineOperator\` ([proposal](https://github.com/babel/proposals/issues/29))
+*/
-promise
- |> await
- |> (x) => doubleSay(x, ", ")
- |> capitalize
- |> (x) => x + "!"
- |> (x) => new User.Message(x)
- |> (x) => stream.write(x)
- |> await
- |> console.log;
-
-const result = exclaim(capitalize(doubleSay("hello")));
-result; //=> "Hello, hello!"
-
-const result = "hello" |> doubleSay |> capitalize |> exclaim;
-
-result; //=> "Hello, hello!"
-
-const person = { score: 25 };
-
-const newScore =
- person.score |> double |> (n) => add(7, n) |> (n) => boundScore(0, 100, n);
-
-newScore; //=> 57
-
-// As opposed to:
-let newScore = boundScore(0, 100, add(7, double(person.score)));
+a |> b;
================================================================================
`;
-exports[`pipeline-operator-fsharp.js format[acorn] 1`] = `
+exports[`pipeline-operator.js format[acorn] 1`] = `
"Unexpected token (5:4)
- 3 |
- 4 | promise
-> 5 | |> await
+ 3 | */
+ 4 |
+> 5 | a |> b
| ^
- 6 | |> x => doubleSay(x, ', ')
- 7 | |> capitalize
- 8 | |> x => x + '!'
+ 6 |
Cause: Unexpected token (5:3)"
`;
-exports[`pipeline-operator-fsharp.js format[espree] 1`] = `
+exports[`pipeline-operator.js format[espree] 1`] = `
"Unexpected token > (5:4)
- 3 |
- 4 | promise
-> 5 | |> await
+ 3 | */
+ 4 |
+> 5 | a |> b
| ^
- 6 | |> x => doubleSay(x, ', ')
- 7 | |> capitalize
- 8 | |> x => x + '!'
+ 6 |
Cause: Unexpected token >"
`;
-exports[`pipeline-operator-fsharp.js format[meriyah] 1`] = `
+exports[`pipeline-operator.js format[meriyah] 1`] = `
"Unexpected token: '>' (5:4)
- 3 |
- 4 | promise
-> 5 | |> await
+ 3 | */
+ 4 |
+> 5 | a |> b
| ^
- 6 | |> x => doubleSay(x, ', ')
- 7 | |> capitalize
- 8 | |> x => x + '!'
+ 6 |
Cause: [5:3-5:4]: Unexpected token: '>'"
`;
-exports[`pipeline-operator-fsharp.js format[oxc] 1`] = `
+exports[`pipeline-operator.js format[oxc] 1`] = `
"Unexpected token (5:4)
- 3 |
- 4 | promise
-> 5 | |> await
+ 3 | */
+ 4 |
+> 5 | a |> b
| ^
- 6 | |> x => doubleSay(x, ', ')
- 7 | |> capitalize
- 8 | |> x => x + '!'"
+ 6 |"
`;
-exports[`pipeline-operator-fsharp.js format[yuku] 1`] = `
+exports[`pipeline-operator.js format[yuku] 1`] = `
"Unexpected token '>' (5:4)
- 3 |
- 4 | promise
-> 5 | |> await
+ 3 | */
+ 4 |
+> 5 | a |> b
| ^
- 6 | |> x => doubleSay(x, ', ')
- 7 | |> capitalize
- 8 | |> x => x + '!'"
-`;
-
-exports[`pipeline-operator-hack.cjs format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-// https://babeljs.io/docs/babel-plugin-proposal-pipeline-operator
-// https://github.com/js-choi/proposal-hack-pipes
-
-return list
- |> take(prefix.length, %)
- |> equals(%, prefix);
-
-// (The % token isn't final; it might instead be @ or ? or #.)
-
-=====================================output=====================================
-// https://babeljs.io/docs/babel-plugin-proposal-pipeline-operator
-// https://github.com/js-choi/proposal-hack-pipes
-
-return list |> take(prefix.length, %) |> equals(%, prefix);
-
-// (The % token isn't final; it might instead be @ or ? or #.)
-
-================================================================================
-`;
-
-exports[`pipeline-operator-hack.cjs format[acorn] 1`] = `
-"Unexpected token (5:3)
- 3 |
- 4 | return list
-> 5 | |> take(prefix.length, %)
- | ^
- 6 | |> equals(%, prefix);
- 7 |
- 8 | // (The % token isn't final; it might instead be @ or ? or #.)
-Cause: Unexpected token (5:2)"
-`;
-
-exports[`pipeline-operator-hack.cjs format[espree] 1`] = `
-"Unexpected token > (5:3)
- 3 |
- 4 | return list
-> 5 | |> take(prefix.length, %)
- | ^
- 6 | |> equals(%, prefix);
- 7 |
- 8 | // (The % token isn't final; it might instead be @ or ? or #.)
-Cause: Unexpected token >"
-`;
-
-exports[`pipeline-operator-hack.cjs format[meriyah] 1`] = `
-"Unexpected token: '>' (5:3)
- 3 |
- 4 | return list
-> 5 | |> take(prefix.length, %)
- | ^
- 6 | |> equals(%, prefix);
- 7 |
- 8 | // (The % token isn't final; it might instead be @ or ? or #.)
-Cause: [5:2-5:3]: Unexpected token: '>'"
-`;
-
-exports[`pipeline-operator-hack.cjs format[oxc] 1`] = `
-"Unexpected token (5:3)
- 3 |
- 4 | return list
-> 5 | |> take(prefix.length, %)
- | ^
- 6 | |> equals(%, prefix);
- 7 |
- 8 | // (The % token isn't final; it might instead be @ or ? or #.)"
-`;
-
-exports[`pipeline-operator-hack.cjs format[yuku] 1`] = `
-"Unexpected token '>' (5:3)
- 3 |
- 4 | return list
-> 5 | |> take(prefix.length, %)
- | ^
- 6 | |> equals(%, prefix);
- 7 |
- 8 | // (The % token isn't final; it might instead be @ or ? or #.)"
-`;
-
-exports[`pipeline-operator-minimal.js format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-// https://babeljs.io/docs/babel-plugin-proposal-pipeline-operator
-// https://github.com/tc39/proposal-pipeline-operator/
-
-let result = exclaim(capitalize(doubleSay("hello")));
-result //=> "Hello, hello!"
-
-let result = "hello"
- |> doubleSay
- |> capitalize
- |> exclaim;
-
-result //=> "Hello, hello!"
-
-=====================================output=====================================
-// https://babeljs.io/docs/babel-plugin-proposal-pipeline-operator
-// https://github.com/tc39/proposal-pipeline-operator/
-
-let result = exclaim(capitalize(doubleSay("hello")));
-result; //=> "Hello, hello!"
-
-let result = "hello" |> doubleSay |> capitalize |> exclaim;
-
-result; //=> "Hello, hello!"
-
-================================================================================
-`;
-
-exports[`pipeline-operator-minimal.js format[acorn] 1`] = `
-"Identifier 'result' has already been declared (7:5)
- 5 | result //=> "Hello, hello!"
- 6 |
-> 7 | let result = "hello"
- | ^
- 8 | |> doubleSay
- 9 | |> capitalize
- 10 | |> exclaim;
-Cause: Identifier 'result' has already been declared (7:4)"
-`;
-
-exports[`pipeline-operator-minimal.js format[espree] 1`] = `
-"Identifier 'result' has already been declared (7:5)
- 5 | result //=> "Hello, hello!"
- 6 |
-> 7 | let result = "hello"
- | ^
- 8 | |> doubleSay
- 9 | |> capitalize
- 10 | |> exclaim;
-Cause: Identifier 'result' has already been declared"
-`;
-
-exports[`pipeline-operator-minimal.js format[meriyah] 1`] = `
-"Unexpected token: '>' (8:4)
- 6 |
- 7 | let result = "hello"
-> 8 | |> doubleSay
- | ^
- 9 | |> capitalize
- 10 | |> exclaim;
- 11 |
-Cause: [8:3-8:4]: Unexpected token: '>'"
-`;
-
-exports[`pipeline-operator-minimal.js format[oxc] 1`] = `
-"Unexpected token (8:4)
- 6 |
- 7 | let result = "hello"
-> 8 | |> doubleSay
- | ^
- 9 | |> capitalize
- 10 | |> exclaim;
- 11 |"
-`;
-
-exports[`pipeline-operator-minimal.js format[yuku] 1`] = `
-"Unexpected token '>' (8:4)
- 6 |
- 7 | let result = "hello"
-> 8 | |> doubleSay
- | ^
- 9 | |> capitalize
- 10 | |> exclaim;
- 11 |"
-`;
-
-exports[`private-fields-in-in.js format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-// https://github.com/tc39/proposal-private-fields-in-in
-
-class C {
- #brand;
-
- static isC(obj) {
- try {
- obj.#brand;
- return true;
- } catch {
- return false;
- }
- }
-}
-
-class C2 {
- #data = null; // populated later
-
- get #getter() {
- if (!this.#data) {
- throw new Error('no data yet!');
- }
- return this.#data;
- }
-
- static isC(obj) {
- try {
- obj.#getter;
- return true;
- } catch {
- return false; // oops! might have gotten here because \`#getter\` threw :-(
- }
- }
-}
-
-class C3 {
- #brand;
-
- #method() {}
-
- get #getter() {}
-
- static isC(obj) {
- return #brand in obj && #method in obj && #getter in obj;
- }
-}
-
-// Invalid https://github.com/tc39/proposal-private-fields-in-in#try-statement
-// class C {
-// #brand;
-
-// static isC(obj) {
-// return try obj.#brand;
-// }
-// }
-
-=====================================output=====================================
-// https://github.com/tc39/proposal-private-fields-in-in
-
-class C {
- #brand;
-
- static isC(obj) {
- try {
- obj.#brand;
- return true;
- } catch {
- return false;
- }
- }
-}
-
-class C2 {
- #data = null; // populated later
-
- get #getter() {
- if (!this.#data) {
- throw new Error("no data yet!");
- }
- return this.#data;
- }
-
- static isC(obj) {
- try {
- obj.#getter;
- return true;
- } catch {
- return false; // oops! might have gotten here because \`#getter\` threw :-(
- }
- }
-}
-
-class C3 {
- #brand;
-
- #method() {}
-
- get #getter() {}
-
- static isC(obj) {
- return #brand in obj && #method in obj && #getter in obj;
- }
-}
-
-// Invalid https://github.com/tc39/proposal-private-fields-in-in#try-statement
-// class C {
-// #brand;
-
-// static isC(obj) {
-// return try obj.#brand;
-// }
-// }
-
-================================================================================
-`;
-
-exports[`private-methods.js format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-// https://babeljs.io/docs/babel-plugin-proposal-private-methods
-
-// Test for \`classPrivateProperties\` and \`classPrivateMethods\`
-
-class Counter extends HTMLElement {
- #xValue = 0;
- #render() {}
-
- get #x() { return this.#xValue; }
- set #x(value) {
- this.#xValue = value;
- window.requestAnimationFrame(
- this.#render.bind(this));
- }
-
- #clicked() {
- this.#x++;
- }
-}
-
-=====================================output=====================================
-// https://babeljs.io/docs/babel-plugin-proposal-private-methods
-
-// Test for \`classPrivateProperties\` and \`classPrivateMethods\`
-
-class Counter extends HTMLElement {
- #xValue = 0;
- #render() {}
-
- get #x() {
- return this.#xValue;
- }
- set #x(value) {
- this.#xValue = value;
- window.requestAnimationFrame(this.#render.bind(this));
- }
-
- #clicked() {
- this.#x++;
- }
-}
-
-================================================================================
-`;
-
-exports[`regex-v-flag.js format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-/a/v;
-
-=====================================output=====================================
-/a/v;
-
-================================================================================
-`;
-
-exports[`regexp-modifiers.js format 1`] = `
-====================================options=====================================
-parsers: ["babel", "babel-ts", "babel-flow"]
- printWidth: 80 (default) |
-=====================================input======================================
-const re = /^(?i:[a-z])[a-z]$/;
-
-=====================================output=====================================
-const re = /^(?i:[a-z])[a-z]$/;
-
-================================================================================
+ 6 |"
`;
exports[`source-phase-imports.js format 1`] = `
@@ -2445,32 +1105,40 @@ exports[`source-phase-imports.js format 1`] = `
parsers: ["babel", "babel-ts", "babel-flow"]
printWidth: 80 (default) |
=====================================input======================================
-import source fooSource from "foo";
-import.source("x");
+/*
+\`sourcePhaseImports\` ([proposal](https://github.com/tc39/proposal-source-phase-imports))
+*/
+
+import source x from "./x"
=====================================output=====================================
-import source fooSource from "foo";
-import.source("x");
+/*
+\`sourcePhaseImports\` ([proposal](https://github.com/tc39/proposal-source-phase-imports))
+*/
+
+import source x from "./x";
================================================================================
`;
exports[`source-phase-imports.js format[acorn] 1`] = `
-"Unexpected token (1:15)
-> 1 | import source fooSource from "foo";
+"Unexpected token (5:15)
+ 3 | */
+ 4 |
+> 5 | import source x from "./x"
| ^
- 2 | import.source("x");
- 3 |
-Cause: Unexpected token (1:14)"
+ 6 |
+Cause: Unexpected token (5:14)"
`;
exports[`source-phase-imports.js format[espree] 1`] = `
-"Unexpected token fooSource (1:15)
-> 1 | import source fooSource from "foo";
+"Unexpected token x (5:15)
+ 3 | */
+ 4 |
+> 5 | import source x from "./x"
| ^
- 2 | import.source("x");
- 3 |
-Cause: Unexpected token fooSource"
+ 6 |
+Cause: Unexpected token x"
`;
exports[`throw-expressions.js format 1`] = `
@@ -2478,77 +1146,67 @@ exports[`throw-expressions.js format 1`] = `
parsers: ["babel", "babel-ts", "babel-flow"]
printWidth: 80 (default) |
=====================================input======================================
-// https://babeljs.io/docs/babel-plugin-proposal-throw-expressions
+/*
+\`throwExpressions\` ([proposal](https://github.com/babel/proposals/issues/23))
+*/
-function test(param = throw new Error('required!')) {
- const test = param === true || throw new Error('Falsy!');
-}
+() => throw new Error("")
=====================================output=====================================
-// https://babeljs.io/docs/babel-plugin-proposal-throw-expressions
+/*
+\`throwExpressions\` ([proposal](https://github.com/babel/proposals/issues/23))
+*/
-function test(param = throw new Error("required!")) {
- const test = param === true || throw new Error("Falsy!");
-}
+() => throw new Error("");
================================================================================
`;
exports[`throw-expressions.js format[acorn] 1`] = `
-"Unexpected token (3:23)
- 1 | // https://babeljs.io/docs/babel-plugin-proposal-throw-expressions
- 2 |
-> 3 | function test(param = throw new Error('required!')) {
- | ^
- 4 | const test = param === true || throw new Error('Falsy!');
- 5 | }
+"Unexpected token (5:7)
+ 3 | */
+ 4 |
+> 5 | () => throw new Error("")
+ | ^
6 |
-Cause: Unexpected token (3:22)"
+Cause: Unexpected token (5:6)"
`;
exports[`throw-expressions.js format[espree] 1`] = `
-"Unexpected token throw (3:23)
- 1 | // https://babeljs.io/docs/babel-plugin-proposal-throw-expressions
- 2 |
-> 3 | function test(param = throw new Error('required!')) {
- | ^
- 4 | const test = param === true || throw new Error('Falsy!');
- 5 | }
+"Unexpected token throw (5:7)
+ 3 | */
+ 4 |
+> 5 | () => throw new Error("")
+ | ^
6 |
Cause: Unexpected token throw"
`;
exports[`throw-expressions.js format[meriyah] 1`] = `
-"Unexpected token: 'throw' (3:23)
- 1 | // https://babeljs.io/docs/babel-plugin-proposal-throw-expressions
- 2 |
-> 3 | function test(param = throw new Error('required!')) {
- | ^^^^^
- 4 | const test = param === true || throw new Error('Falsy!');
- 5 | }
+"Unexpected token: 'throw' (5:7)
+ 3 | */
+ 4 |
+> 5 | () => throw new Error("")
+ | ^^^^^
6 |
-Cause: [3:22-3:27]: Unexpected token: 'throw'"
+Cause: [5:6-5:11]: Unexpected token: 'throw'"
`;
exports[`throw-expressions.js format[oxc] 1`] = `
-"Unexpected token (3:23)
- 1 | // https://babeljs.io/docs/babel-plugin-proposal-throw-expressions
- 2 |
-> 3 | function test(param = throw new Error('required!')) {
- | ^^^^^
- 4 | const test = param === true || throw new Error('Falsy!');
- 5 | }
+"Unexpected token (5:7)
+ 3 | */
+ 4 |
+> 5 | () => throw new Error("")
+ | ^^^^^
6 |"
`;
exports[`throw-expressions.js format[yuku] 1`] = `
-"'throw' is reserved and cannot be used as an identifier (3:23)
- 1 | // https://babeljs.io/docs/babel-plugin-proposal-throw-expressions
- 2 |
-> 3 | function test(param = throw new Error('required!')) {
- | ^^^^^
- 4 | const test = param === true || throw new Error('Falsy!');
- 5 | }
+"'throw' is reserved and cannot be used as an identifier (5:7)
+ 3 | */
+ 4 |
+> 5 | () => throw new Error("")
+ | ^^^^^
6 |"
`;
@@ -2557,84 +1215,88 @@ exports[`typescript.js format 1`] = `
parsers: ["babel", "babel-ts", "babel-flow"]
printWidth: 80 (default) |
=====================================input======================================
-// https://babeljs.io/docs/babel-preset-typescript
+/*
+\`typescript\` ([repo](https://github.com/Microsoft/TypeScript))
+*/
-const x: number = 0;
+var a: string = "";
=====================================output=====================================
-// https://babeljs.io/docs/babel-preset-typescript
+/*
+\`typescript\` ([repo](https://github.com/Microsoft/TypeScript))
+*/
-const x: number = 0;
+var a: string = "";
================================================================================
`;
exports[`typescript.js format[__babel_estree] 1`] = `
-"Unexpected token (3:8)
- 1 | // https://babeljs.io/docs/babel-preset-typescript
- 2 |
-> 3 | const x: number = 0;
- | ^
+"Unexpected token (5:6)
+ 3 | */
4 |
-Cause: Unexpected token (3:7)"
+> 5 | var a: string = "";
+ | ^
+ 6 |
+Cause: Unexpected token (5:5)"
`;
exports[`typescript.js format[acorn] 1`] = `
-"Unexpected token (3:8)
- 1 | // https://babeljs.io/docs/babel-preset-typescript
- 2 |
-> 3 | const x: number = 0;
- | ^
+"Unexpected token (5:6)
+ 3 | */
4 |
-Cause: Unexpected token (3:7)"
+> 5 | var a: string = "";
+ | ^
+ 6 |
+Cause: Unexpected token (5:5)"
`;
exports[`typescript.js format[babel] 1`] = `
-"Unexpected token (3:8)
- 1 | // https://babeljs.io/docs/babel-preset-typescript
- 2 |
-> 3 | const x: number = 0;
- | ^
+"Unexpected token (5:6)
+ 3 | */
4 |
-Cause: Unexpected token (3:7)"
+> 5 | var a: string = "";
+ | ^
+ 6 |
+Cause: Unexpected token (5:5)"
`;
exports[`typescript.js format[espree] 1`] = `
-"Unexpected token : (3:8)
- 1 | // https://babeljs.io/docs/babel-preset-typescript
- 2 |
-> 3 | const x: number = 0;
- | ^
+"Unexpected token : (5:6)
+ 3 | */
4 |
+> 5 | var a: string = "";
+ | ^
+ 6 |
Cause: Unexpected token :"
`;
exports[`typescript.js format[meriyah] 1`] = `
-"Missing initializer in const declaration (3:8)
- 1 | // https://babeljs.io/docs/babel-preset-typescript
- 2 |
-> 3 | const x: number = 0;
- | ^
+"Unexpected token: ':' (5:6)
+ 3 | */
4 |
-Cause: [3:7-3:8]: Missing initializer in const declaration"
+> 5 | var a: string = "";
+ | ^
+ 6 |
+Cause: [5:5-5:6]: Unexpected token: ':'"
`;
exports[`typescript.js format[oxc] 1`] = `
-"Missing initializer in const declaration (3:7)
- 1 | // https://babeljs.io/docs/babel-preset-typescript
- 2 |
-> 3 | const x: number = 0;
- | ^
- 4 |"
+"Expected a semicolon or an implicit semicolon after a statement, but found none (5:6)
+ 3 | */
+ 4 |
+> 5 | var a: string = "";
+ | ^
+ 6 |"
`;
exports[`typescript.js format[yuku] 1`] = `
-"'const' declarations must be initialized (3:7)
- 1 | // https://babeljs.io/docs/babel-preset-typescript
- 2 |
-> 3 | const x: number = 0;
- | ^
- 4 |"
+"Expected a semicolon or an implicit semicolon after a statement, but found ':' (5:6)
+ 3 | */
+ 4 |
+> 5 | var a: string = "";
+ | ^
+ 6 |"
`;
exports[`v8intrinsic.js format 1`] = `
@@ -2642,115 +1304,66 @@ exports[`v8intrinsic.js format 1`] = `
parsers: ["babel", "babel-ts", "babel-flow"]
printWidth: 80 (default) |
=====================================input======================================
-// https://github.com/babel/babel/pull/10148
+/*
+\`v8intrinsic\`
+*/
%DebugPrint(foo);
-
-// Invalid code https://github.com/JLHwung/babel/blob/c1a3cbfd65e08b7013fd6f8c62add8cb10b4b169/packages/babel-parser/test/fixtures/v8intrinsic/_errors/in-bind-expression/options.json
-// ::%DebugPrint(null)
-
-// Invalid code https://github.com/JLHwung/babel/blob/c1a3cbfd65e08b7013fd6f8c62add8cb10b4b169/packages/babel-parser/test/fixtures/v8intrinsic/_errors/in-member-expression/options.json
-// a.%DebugPrint();
-
-// Invalid code https://github.com/JLHwung/babel/blob/c1a3cbfd65e08b7013fd6f8c62add8cb10b4b169/packages/babel-parser/test/fixtures/v8intrinsic/_errors/not-in-call-expression/options.json
-// const i = %DebugPrint;
-// i(foo);
-
-// https://github.com/JLHwung/babel/blob/c1a3cbfd65e08b7013fd6f8c62add8cb10b4b169/packages/babel-parser/test/fixtures/v8intrinsic/_errors/not-in-call-expression/options.json
-// %DebugPrint?.(null)
-
-new %DebugPrint(null);
-
-function *foo() {
- yield %StringParseInt("42", 10)
-}
-
-foo%bar()
-
=====================================output=====================================
-// https://github.com/babel/babel/pull/10148
+/*
+\`v8intrinsic\`
+*/
%DebugPrint(foo);
-// Invalid code https://github.com/JLHwung/babel/blob/c1a3cbfd65e08b7013fd6f8c62add8cb10b4b169/packages/babel-parser/test/fixtures/v8intrinsic/_errors/in-bind-expression/options.json
-// ::%DebugPrint(null)
-
-// Invalid code https://github.com/JLHwung/babel/blob/c1a3cbfd65e08b7013fd6f8c62add8cb10b4b169/packages/babel-parser/test/fixtures/v8intrinsic/_errors/in-member-expression/options.json
-// a.%DebugPrint();
-
-// Invalid code https://github.com/JLHwung/babel/blob/c1a3cbfd65e08b7013fd6f8c62add8cb10b4b169/packages/babel-parser/test/fixtures/v8intrinsic/_errors/not-in-call-expression/options.json
-// const i = %DebugPrint;
-// i(foo);
-
-// https://github.com/JLHwung/babel/blob/c1a3cbfd65e08b7013fd6f8c62add8cb10b4b169/packages/babel-parser/test/fixtures/v8intrinsic/_errors/not-in-call-expression/options.json
-// %DebugPrint?.(null)
-
-new %DebugPrint(null);
-
-function* foo() {
- yield %StringParseInt("42", 10);
-}
-
-foo % bar();
-
================================================================================
`;
exports[`v8intrinsic.js format[acorn] 1`] = `
-"Unexpected token (3:1)
- 1 | // https://github.com/babel/babel/pull/10148
- 2 |
-> 3 | %DebugPrint(foo);
- | ^
+"Unexpected token (5:1)
+ 3 | */
4 |
- 5 |
- 6 | // Invalid code https://github.com/JLHwung/babel/blob/c1a3cbfd65e08b7013fd6f8c62add8cb10b4b169/packages/babel-parser/test/fixtures/v8intrinsic/_errors/in-bind-expression/options.json
-Cause: Unexpected token (3:0)"
+> 5 | %DebugPrint(foo);
+ | ^
+ 6 |
+Cause: Unexpected token (5:0)"
`;
exports[`v8intrinsic.js format[espree] 1`] = `
-"Unexpected token % (3:1)
- 1 | // https://github.com/babel/babel/pull/10148
- 2 |
-> 3 | %DebugPrint(foo);
- | ^
+"Unexpected token % (5:1)
+ 3 | */
4 |
- 5 |
- 6 | // Invalid code https://github.com/JLHwung/babel/blob/c1a3cbfd65e08b7013fd6f8c62add8cb10b4b169/packages/babel-parser/test/fixtures/v8intrinsic/_errors/in-bind-expression/options.json
+> 5 | %DebugPrint(foo);
+ | ^
+ 6 |
Cause: Unexpected token %"
`;
exports[`v8intrinsic.js format[meriyah] 1`] = `
-"Unexpected token: '%' (3:1)
- 1 | // https://github.com/babel/babel/pull/10148
- 2 |
-> 3 | %DebugPrint(foo);
- | ^
+"Unexpected token: '%' (5:1)
+ 3 | */
4 |
- 5 |
- 6 | // Invalid code https://github.com/JLHwung/babel/blob/c1a3cbfd65e08b7013fd6f8c62add8cb10b4b169/packages/babel-parser/test/fixtures/v8intrinsic/_errors/in-bind-expression/options.json
-Cause: [3:0-3:1]: Unexpected token: '%'"
+> 5 | %DebugPrint(foo);
+ | ^
+ 6 |
+Cause: [5:0-5:1]: Unexpected token: '%'"
`;
exports[`v8intrinsic.js format[oxc] 1`] = `
-"Unexpected token (3:1)
- 1 | // https://github.com/babel/babel/pull/10148
- 2 |
-> 3 | %DebugPrint(foo);
- | ^
+"Unexpected token (5:1)
+ 3 | */
4 |
- 5 |
- 6 | // Invalid code https://github.com/JLHwung/babel/blob/c1a3cbfd65e08b7013fd6f8c62add8cb10b4b169/packages/babel-parser/test/fixtures/v8intrinsic/_errors/in-bind-expression/options.json"
+> 5 | %DebugPrint(foo);
+ | ^
+ 6 |"
`;
exports[`v8intrinsic.js format[yuku] 1`] = `
-"Unexpected token '%' (3:1)
- 1 | // https://github.com/babel/babel/pull/10148
- 2 |
-> 3 | %DebugPrint(foo);
- | ^
+"Unexpected token '%' (5:1)
+ 3 | */
4 |
- 5 |
- 6 | // Invalid code https://github.com/JLHwung/babel/blob/c1a3cbfd65e08b7013fd6f8c62add8cb10b4b169/packages/babel-parser/test/fixtures/v8intrinsic/_errors/in-bind-expression/options.json"
+> 5 | %DebugPrint(foo);
+ | ^
+ 6 |"
`;
diff --git a/tests/format/js/babel-plugins/async-do-expressions.js b/tests/format/js/babel-plugins/async-do-expressions.js
index d6fdc93e1..872d70db5 100644
--- a/tests/format/js/babel-plugins/async-do-expressions.js
+++ b/tests/format/js/babel-plugins/async-do-expressions.js
@@ -1 +1,5 @@
-async do { await requestAPI().json() };
+/*
+`asyncDoExpressions` ([proposal](https://github.com/tc39/proposal-async-do-expressions))
+*/
+
+async do { await requestAPI().json() }
diff --git a/tests/format/js/babel-plugins/async-generators.js b/tests/format/js/babel-plugins/async-generators.js
deleted file mode 100644
index 841bf6f7f..000000000
--- a/tests/format/js/babel-plugins/async-generators.js
+++ /dev/null
@@ -1,6 +0,0 @@
-// https://babeljs.io/docs/babel-plugin-proposal-async-generator-functions
-
-async function* agf() {
- await 1;
- yield 2;
-}
diff --git a/tests/format/js/babel-plugins/bigint.js b/tests/format/js/babel-plugins/bigint.js
deleted file mode 100644
index 4f410f310..000000000
--- a/tests/format/js/babel-plugins/bigint.js
+++ /dev/null
@@ -1,128 +0,0 @@
-// https://github.com/tc39/proposal-bigint
-
-const previousMaxSafe = BigInt(Number.MAX_SAFE_INTEGER);
-// ↪ 9007199254740991
-
-const maxPlusOne = previousMaxSafe + 1n;
-// ↪ 9007199254740992n
-
-const theFuture = previousMaxSafe + 2n;
-// ↪ 9007199254740993n, this works now!
-
-const multi = previousMaxSafe * 2n;
-// ↪ 18014398509481982n
-
-// `–` is not minus sign,
-// SIC https://github.com/tc39/proposal-bigint#operators
-// const subtr = multi – 10n;
-// ↪ 18014398509481972n
-
-const mod = multi % 10n;
-// ↪ 2n
-
-const bigN = 2n ** 54n;
-// ↪ 18014398509481984n
-
-bigN * -1n
-// ↪ –18014398509481984n
-
-0n === 0
-// ↪ false
-
-0n == 0
-// ↪ true
-
-1n < 2
-// ↪ true
-
-2n > 1
-// ↪ true
-
-2 > 2
-// ↪ false
-
-2n > 2
-// ↪ false
-
-2n >= 2
-// ↪ true
-
-const mixed = [4n, 6, -12n, 10, 4, 0, 0n];
-// ↪ [4n, 6, -12n, 10, 4, 0, 0n]
-
-mixed.sort();
-// ↪ [-12n, 0, 0n, 10, 4n, 4, 6]
-
-if (0n) {
- console.log('Hello from the if!');
-} else {
- console.log('Hello from the else!');
-}
-
-// ↪ "Hello from the else!"
-
-0n || 12n
-// ↪ 12n
-
-0n && 12n
-// ↪ 0n
-
-Boolean(0n)
-// ↪ false
-
-Boolean(12n)
-// ↪ true
-
-!12n
-// ↪ false
-
-!0n
-// ↪ true
-
-const view = new BigInt64Array(4);
-// ↪ [0n, 0n, 0n, 0n]
-view.length;
-// ↪ 4
-view[0];
-// ↪ 0n
-view[0] = 42n;
-view[0];
-// ↪ 42n
-
-// Highest possible BigInt value that can be represented as a
-// signed 64-bit integer.
-const max = 2n ** (64n - 1n) - 1n;
-view[0] = max;
-view[0];
-// ↪ 9_223_372_036_854_775_807n
-view[0] = max + 1n;
-view[0];
-// ↪ -9_223_372_036_854_775_808n
-// ^ negative because of overflow
-
-1n + 2
-// ↪ TypeError: Cannot mix BigInt and other types, use explicit conversions
-
-1n * 2
-// ↪ TypeError: Cannot mix BigInt and other types, use explicit conversions
-
-+1n
-// ↪ TypeError: Cannot convert a BigInt value to a number
-
-Number(1n)
-// ↪ 1
-
-1n + '2'
-// ↪ "12"
-
-'2' + 1n
-// ↪ "21"
-
-const badPrecision = BigInt(9007199254740993);
-// ↪9007199254740992n
-
-const goodPrecision = BigInt('9007199254740993');
-// ↪9007199254740993n
-
-const alsoGoodPrecision = 9007199254740993n;
-// ↪9007199254740993n
diff --git a/tests/format/js/babel-plugins/class-properties.js b/tests/format/js/babel-plugins/class-properties.js
deleted file mode 100644
index c8b1c083b..000000000
--- a/tests/format/js/babel-plugins/class-properties.js
+++ /dev/null
@@ -1,26 +0,0 @@
-// https://babeljs.io/docs/babel-plugin-proposal-class-properties
-
-class Bork {
- //Property initializer syntax
- instanceProperty = "bork";
- boundFunction = () => {
- return this.instanceProperty;
- };
-
- //Static class properties
- static staticProperty = "babelIsCool";
- static staticFunction = function() {
- return Bork.staticProperty;
- };
- }
-
- let myBork = new Bork;
-
- //Property initializers are not on the prototype.
- console.log(myBork.__proto__.boundFunction); // > undefined
-
- //Bound functions are bound to the class instance.
- console.log(myBork.boundFunction.call(undefined)); // > "bork"
-
- //Static function exists on the class.
- console.log(Bork.staticFunction()); // > "babelIsCool"
diff --git a/tests/format/js/babel-plugins/class-static-block.js b/tests/format/js/babel-plugins/class-static-block.js
deleted file mode 100644
index a707b82ce..000000000
--- a/tests/format/js/babel-plugins/class-static-block.js
+++ /dev/null
@@ -1,11 +0,0 @@
-class C {
- static #x = 42;
- static y;
- static {
- try {
- this.y = doSomethingWith(this.#x);
- } catch {
- this.y = "unknown";
- }
- }
-}
diff --git a/tests/format/js/babel-plugins/decorator-auto-accessors.js b/tests/format/js/babel-plugins/decorator-auto-accessors.js
index f43e1474a..e6f482c52 100644
--- a/tests/format/js/babel-plugins/decorator-auto-accessors.js
+++ b/tests/format/js/babel-plugins/decorator-auto-accessors.js
@@ -1,3 +1,5 @@
-class C extends HTMLElement {
- accessor clicked = false;
-}
+/*
+`decoratorAutoAccessors` ([proposal](https://github.com/tc39/proposal-decorators))
+*/
+
+class Example { @reactive accessor myBool = false; }
diff --git a/tests/format/js/babel-plugins/decorators.js b/tests/format/js/babel-plugins/decorators.js
index 470f28340..cc522f923 100644
--- a/tests/format/js/babel-plugins/decorators.js
+++ b/tests/format/js/babel-plugins/decorators.js
@@ -1,29 +1,5 @@
-// https://babeljs.io/docs/babel-plugin-proposal-decorators
+/*
+`decorators` ([proposal](https://github.com/tc39/proposal-decorators))
`decorators-legacy`
+*/
-@annotation
-class MyClass { }
-
-function annotation(target) {
- target.annotated = true;
-}
-
-@isTestable(true)
-class MyClass { }
-
-function isTestable(value) {
- return function decorator(target) {
- target.isTestable = value;
- }
-}
-
-class C {
- @enumerable(false)
- method() { }
-}
-
-function enumerable(value) {
- return function (target, key, descriptor) {
- descriptor.enumerable = value;
- return descriptor;
- }
-}
+@a class A {}
diff --git a/tests/format/js/babel-plugins/deferred-import-evaluation.js b/tests/format/js/babel-plugins/deferred-import-evaluation.js
index 806ae2bb7..db7f6ea24 100644
--- a/tests/format/js/babel-plugins/deferred-import-evaluation.js
+++ b/tests/format/js/babel-plugins/deferred-import-evaluation.js
@@ -1 +1,5 @@
-import defer * as ns from "x";
+/*
+`deferredImportEvaluation` ([proposal](https://github.com/tc39/proposal-defer-import-eval))
+*/
+
+import defer * as ns from "dep";
diff --git a/tests/format/js/babel-plugins/destructuring-private.js b/tests/format/js/babel-plugins/destructuring-private.js
index 770de3df0..daa2e7142 100644
--- a/tests/format/js/babel-plugins/destructuring-private.js
+++ b/tests/format/js/babel-plugins/destructuring-private.js
@@ -1,12 +1,5 @@
-class Foo {
- #x = 1;
- constructor() {
- console.log(this.#x); // => 1
- const { #x: x } = this;
- console.log(x); // => 1
- }
- equals({ #x: otherX }) {
- const { #x: currentX } = this;
- return currentX === otherX;
- }
-}
+/*
+`destructuringPrivate` ([proposal](https://github.com/tc39/proposal-destructuring-private))
+*/
+
+class Example { #x = 1; method() { const { #x: x } = this; } }
diff --git a/tests/format/js/babel-plugins/discard-binding.js b/tests/format/js/babel-plugins/discard-binding.js
index 772e77c40..cc6d1a39e 100644
--- a/tests/format/js/babel-plugins/discard-binding.js
+++ b/tests/format/js/babel-plugins/discard-binding.js
@@ -1 +1,5 @@
-const [a, void] = iter;
+/*
+`discardBinding` ([proposal](https://github.com/tc39/proposal-discard-binding))
+*/
+
+using void = new Lock(mutex)
diff --git a/tests/format/js/babel-plugins/do-expressions.js b/tests/format/js/babel-plugins/do-expressions.js
index 13f276b14..34eb29349 100644
--- a/tests/format/js/babel-plugins/do-expressions.js
+++ b/tests/format/js/babel-plugins/do-expressions.js
@@ -1,11 +1,5 @@
-// https://babeljs.io/docs/babel-plugin-proposal-do-expressions
+/*
+`doExpressions` ([proposal](https://github.com/tc39/proposal-do-expressions))
+*/
-let a = do {
- if(x > 10) {
- 'big';
- } else {
- 'small';
- }
-};
-// is equivalent to:
-let a = x > 10 ? 'big' : 'small';
+var a = do { if (true) { 'hi'; } };
diff --git a/tests/format/js/babel-plugins/dynamic-import.js b/tests/format/js/babel-plugins/dynamic-import.js
deleted file mode 100644
index 8c891a02a..000000000
--- a/tests/format/js/babel-plugins/dynamic-import.js
+++ /dev/null
@@ -1,8 +0,0 @@
-// https://babeljs.io/docs/babel-plugin-syntax-dynamic-import
-
-// There is no example code on babel website
-
-import('./prettier.mjs');
-import(prettier);
-import('./prettier.mjs').then(module => console.log(module));
-import(prettier).then(module => console.log(module));
diff --git a/tests/format/js/babel-plugins/explicit-resource-management.js b/tests/format/js/babel-plugins/explicit-resource-management.js
deleted file mode 100644
index 1912ca649..000000000
--- a/tests/format/js/babel-plugins/explicit-resource-management.js
+++ /dev/null
@@ -1,12 +0,0 @@
-function * g() {
- using handle = acquireFileHandle(); // block-scoped critical resource
-} // cleanup
-
-{
- using obj = g(); // block-scoped declaration
- const r = obj.next();
-} // calls finally blocks in `g`
-
-{
- await using obj = g();
-}
diff --git a/tests/format/js/babel-plugins/export-default-from.js b/tests/format/js/babel-plugins/export-default-from.js
index ce824ceed..ab6bf4642 100644
--- a/tests/format/js/babel-plugins/export-default-from.js
+++ b/tests/format/js/babel-plugins/export-default-from.js
@@ -1,4 +1,5 @@
-// https://babeljs.io/docs/babel-plugin-proposal-export-default-from
+/*
+`exportDefaultFrom` ([proposal](https://github.com/tc39/ecmascript-export-default-from))
+*/
-
-export v from 'mod';
+export v from "mod"
diff --git a/tests/format/js/babel-plugins/export-namespace-from.js b/tests/format/js/babel-plugins/export-namespace-from.js
deleted file mode 100644
index 6525bdc75..000000000
--- a/tests/format/js/babel-plugins/export-namespace-from.js
+++ /dev/null
@@ -1,3 +0,0 @@
-// https://babeljs.io/docs/babel-plugin-proposal-export-namespace-from
-
-export * as ns from 'mod';
diff --git a/tests/format/js/babel-plugins/flow-comments.js b/tests/format/js/babel-plugins/flow-comments.js
new file mode 100644
index 000000000..b7941cd20
--- /dev/null
+++ b/tests/format/js/babel-plugins/flow-comments.js
@@ -0,0 +1,5 @@
+/*
+`flowComments` ([docs](https://flow.org/en/docs/types/comments/))
+*/
+
+/*:: type Foo = {...}; */
diff --git a/tests/format/js/babel-plugins/flow.js b/tests/format/js/babel-plugins/flow.js
index ae8f62f3d..b1a0e846f 100644
--- a/tests/format/js/babel-plugins/flow.js
+++ b/tests/format/js/babel-plugins/flow.js
@@ -1,3 +1,5 @@
-// https://babeljs.io/docs/babel-preset-flow
+/*
+`flow` ([repo](https://github.com/facebook/flow))
+*/
-function foo(one: any, two: number, three?): string {}
+var a: string = "";
diff --git a/tests/format/js/babel-plugins/format.test.js b/tests/format/js/babel-plugins/format.test.js
index be82247d9..f547bb818 100644
--- a/tests/format/js/babel-plugins/format.test.js
+++ b/tests/format/js/babel-plugins/format.test.js
@@ -3,149 +3,124 @@
runFormatTest(import.meta, ["babel", "babel-ts", "babel-flow"], {
errors: {
+ babel: ["flow.js", "typescript.js"],
+ __babel_estree: ["flow.js", "typescript.js"],
+ "babel-flow": [],
+ "babel-ts": [],
acorn: [
+ "async-do-expressions.js",
+ "decorator-auto-accessors.js",
"decorators.js",
+ "deferred-import-evaluation.js",
"destructuring-private.js",
+ "discard-binding.js",
"do-expressions.js",
"export-default-from.js",
+ // "flow-comments.js",
"flow.js",
"function-bind.js",
+ "function-bind-2.js",
"function-sent.js",
+ "module-blocks.js",
+ "optional-chaining-assign.js",
"partial-application.js",
- "pipeline-operator-fsharp.js",
- "pipeline-operator-minimal.js",
- "pipeline-operator-hack.cjs",
+ "pipeline-operator.js",
+ "source-phase-imports.js",
"throw-expressions.js",
"typescript.js",
"v8intrinsic.js",
- "module-blocks.js",
- "async-do-expressions.js",
- "decorator-auto-accessors.js",
- "source-phase-imports.js",
- "deferred-import-evaluation.js",
- "optional-chaining-assignment.js",
- "discard-binding.js",
],
espree: [
- "decorators.js",
- "destructuring-private.js",
- "do-expressions.js",
- "export-default-from.js",
- "flow.js",
- "function-bind.js",
- "function-sent.js",
- "partial-application.js",
- "pipeline-operator-fsharp.js",
- "pipeline-operator-minimal.js",
- "pipeline-operator-hack.cjs",
- "throw-expressions.js",
- "typescript.js",
- "v8intrinsic.js",
- "module-blocks.js",
"async-do-expressions.js",
"decorator-auto-accessors.js",
- "source-phase-imports.js",
+ "decorators.js",
"deferred-import-evaluation.js",
- "optional-chaining-assignment.js",
- "discard-binding.js",
- ],
- meriyah: [
- "do-expressions.js",
"destructuring-private.js",
+ "discard-binding.js",
+ "do-expressions.js",
"export-default-from.js",
+ // "flow-comments.js",
"flow.js",
"function-bind.js",
+ "function-bind-2.js",
"function-sent.js",
- "module-attributes-dynamic.js",
- "module-attributes-static.js",
+ "module-blocks.js",
+ "optional-chaining-assign.js",
"partial-application.js",
- "pipeline-operator-fsharp.js",
- "pipeline-operator-minimal.js",
- "pipeline-operator-hack.cjs",
+ "pipeline-operator.js",
+ "source-phase-imports.js",
"throw-expressions.js",
"typescript.js",
"v8intrinsic.js",
- "module-blocks.js",
+ ],
+ meriyah: [
"async-do-expressions.js",
- "optional-chaining-assignment.js",
+ // "decorator-auto-accessors.js",
+ // "decorators.js",
+ // "deferred-import-evaluation.js",
+ "destructuring-private.js",
"discard-binding.js",
+ "do-expressions.js",
+ "export-default-from.js",
+ // "flow-comments.js",
+ "flow.js",
+ "function-bind.js",
+ "function-bind-2.js",
+ "function-sent.js",
+ "module-blocks.js",
+ "optional-chaining-assign.js",
+ "partial-application.js",
+ "pipeline-operator.js",
+ // "source-phase-imports.js",
+ "throw-expressions.js",
+ "typescript.js",
+ "v8intrinsic.js",
],
oxc: [
"async-do-expressions.js",
+ // "decorator-auto-accessors.js",
+ // "decorators.js",
+ // "deferred-import-evaluation.js",
"destructuring-private.js",
+ "discard-binding.js",
"do-expressions.js",
"export-default-from.js",
+ // "flow-comments.js",
"flow.js",
"function-bind.js",
+ "function-bind-2.js",
"function-sent.js",
"module-blocks.js",
- "optional-chaining-assignment.js",
+ "optional-chaining-assign.js",
"partial-application.js",
- "pipeline-operator-fsharp.js",
- "pipeline-operator-hack.cjs",
- "pipeline-operator-minimal.js",
+ "pipeline-operator.js",
+ // "source-phase-imports.js",
"throw-expressions.js",
"typescript.js",
"v8intrinsic.js",
- "discard-binding.js",
- ],
- "oxc-ts": [
- "async-do-expressions.js",
- "destructuring-private.js",
- "do-expressions.js",
- "export-default-from.js",
- "flow.js",
- "function-bind.js",
- "function-sent.js",
- "module-blocks.js",
- "optional-chaining-assignment.js",
- "partial-application.js",
- "pipeline-operator-fsharp.js",
- "pipeline-operator-hack.cjs",
- "pipeline-operator-minimal.js",
- "throw-expressions.js",
- "typescript.js",
- "v8intrinsic.js",
- "discard-binding.js",
],
yuku: [
"async-do-expressions.js",
+ // "decorator-auto-accessors.js",
+ // "decorators.js",
+ // "deferred-import-evaluation.js",
"destructuring-private.js",
+ "discard-binding.js",
"do-expressions.js",
"export-default-from.js",
+ // "flow-comments.js",
"flow.js",
"function-bind.js",
+ "function-bind-2.js",
"function-sent.js",
"module-blocks.js",
- "optional-chaining-assignment.js",
+ "optional-chaining-assign.js",
"partial-application.js",
- "pipeline-operator-fsharp.js",
- "pipeline-operator-hack.cjs",
- "pipeline-operator-minimal.js",
+ "pipeline-operator.js",
+ // "source-phase-imports.js",
"throw-expressions.js",
"typescript.js",
"v8intrinsic.js",
- "discard-binding.js",
],
- "yuku-ts": [
- "async-do-expressions.js",
- "destructuring-private.js",
- "do-expressions.js",
- "export-default-from.js",
- "flow.js",
- "function-bind.js",
- "function-sent.js",
- "module-blocks.js",
- "optional-chaining-assignment.js",
- "partial-application.js",
- "pipeline-operator-fsharp.js",
- "pipeline-operator-hack.cjs",
- "pipeline-operator-minimal.js",
- "throw-expressions.js",
- "v8intrinsic.js",
- "discard-binding.js",
- ],
- babel: ["flow.js", "typescript.js"],
- __babel_estree: ["flow.js", "typescript.js"],
},
});
diff --git a/tests/format/js/babel-plugins/function-bind-2.js b/tests/format/js/babel-plugins/function-bind-2.js
new file mode 100644
index 000000000..deca64d3e
--- /dev/null
+++ b/tests/format/js/babel-plugins/function-bind-2.js
@@ -0,0 +1,5 @@
+/*
+`functionBind` ([proposal](https://github.com/zenparsing/es-function-bind))
+*/
+
+::console.log
diff --git a/tests/format/js/babel-plugins/function-bind.js b/tests/format/js/babel-plugins/function-bind.js
index 144e94edb..d8dce65a7 100644
--- a/tests/format/js/babel-plugins/function-bind.js
+++ b/tests/format/js/babel-plugins/function-bind.js
@@ -1,17 +1,5 @@
-// https://babeljs.io/docs/babel-plugin-proposal-function-bind
+/*
+`functionBind` ([proposal](https://github.com/zenparsing/es-function-bind))
+*/
-obj::func
-// is equivalent to:
-func.bind(obj)
-
-::obj.func
-// is equivalent to:
-obj.func.bind(obj)
-
-obj::func(val)
-// is equivalent to:
-func.call(obj, val)
-
-::obj.func(val)
-// is equivalent to:
-obj.func.call(obj, val)
+a::b
diff --git a/tests/format/js/babel-plugins/function-sent.js b/tests/format/js/babel-plugins/function-sent.js
index e2601b0e5..3dd16697f 100644
--- a/tests/format/js/babel-plugins/function-sent.js
+++ b/tests/format/js/babel-plugins/function-sent.js
@@ -1,10 +1,5 @@
-// https://babeljs.io/docs/babel-plugin-proposal-function-sent
+/*
+`functionSent` ([proposal](https://github.com/tc39/proposal-function.sent))
+*/
-function* generator() {
- console.log("Sent", function.sent);
- console.log("Yield", yield);
-}
-
-const iterator = generator();
-iterator.next(1); // Logs "Sent 1"
-iterator.next(2); // Logs "Yield 2"
+function* g() { function.sent }
diff --git a/tests/format/js/babel-plugins/import-assertions-dynamic.js b/tests/format/js/babel-plugins/import-assertions-dynamic.js
deleted file mode 100644
index 2411a524b..000000000
--- a/tests/format/js/babel-plugins/import-assertions-dynamic.js
+++ /dev/null
@@ -1 +0,0 @@
-import("./foo.json", { assert: { type: "json" } });
diff --git a/tests/format/js/babel-plugins/import-attributes-dynamic.js b/tests/format/js/babel-plugins/import-attributes-dynamic.js
deleted file mode 100644
index 717b72d4a..000000000
--- a/tests/format/js/babel-plugins/import-attributes-dynamic.js
+++ /dev/null
@@ -1 +0,0 @@
-import("./foo.json", { with: { type: "json" } });
diff --git a/tests/format/js/babel-plugins/import-attributes-static.js b/tests/format/js/babel-plugins/import-attributes-static.js
deleted file mode 100644
index 7770ae1f0..000000000
--- a/tests/format/js/babel-plugins/import-attributes-static.js
+++ /dev/null
@@ -1 +0,0 @@
-import json from "./foo.json" with { type: "json" };
diff --git a/tests/format/js/babel-plugins/import-meta.js b/tests/format/js/babel-plugins/import-meta.js
deleted file mode 100644
index 0bc02cea0..000000000
--- a/tests/format/js/babel-plugins/import-meta.js
+++ /dev/null
@@ -1,18 +0,0 @@
-// https://babeljs.io/docs/babel-plugin-syntax-import-meta
-
-// Enabled by default https://github.com/babel/babel/pull/11406
-
-// from https://github.com/tc39/proposal-import-meta
-
-(async () => {
- const response = await fetch(new URL("../hamsters.jpg", import.meta.url));
- const blob = await response.blob();
-
- const size = import.meta.scriptElement.dataset.size || 300;
-
- const image = new Image();
- image.src = URL.createObjectURL(blob);
- image.width = image.height = size;
-
- document.body.appendChild(image);
-})();
diff --git a/tests/format/js/babel-plugins/jsx.js b/tests/format/js/babel-plugins/jsx.js
index d2ff9e336..79a97cd6e 100644
--- a/tests/format/js/babel-plugins/jsx.js
+++ b/tests/format/js/babel-plugins/jsx.js
@@ -1,6 +1,5 @@
-// https://babeljs.io/docs/babel-plugin-syntax-jsx
+/*
+`jsx` ([repo](https://facebook.github.io/jsx/))
+*/
-var profile =
-

-
{[user.firstName, user.lastName].join(' ')}
-
;
+{s}
diff --git a/tests/format/js/babel-plugins/logical-assignment-operators.js b/tests/format/js/babel-plugins/logical-assignment-operators.js
deleted file mode 100644
index fba4a46c0..000000000
--- a/tests/format/js/babel-plugins/logical-assignment-operators.js
+++ /dev/null
@@ -1,7 +0,0 @@
-// https://babeljs.io/docs/babel-plugin-proposal-logical-assignment-operators
-
-a ||= b;
-obj.a.b ||= c;
-
-a &&= b;
-obj.a.b &&= c;
diff --git a/tests/format/js/babel-plugins/module-blocks.js b/tests/format/js/babel-plugins/module-blocks.js
index fe2336a23..92e9c4568 100644
--- a/tests/format/js/babel-plugins/module-blocks.js
+++ b/tests/format/js/babel-plugins/module-blocks.js
@@ -1,4 +1,5 @@
-let m = module {
- export let m = 2;
- export let n = 3;
-};
+/*
+`moduleBlocks` ([proposal](https://github.com/tc39/proposal-js-module-blocks))
+*/
+
+let m = module { export let y = 1; };
diff --git a/tests/format/js/babel-plugins/module-string-names.js b/tests/format/js/babel-plugins/module-string-names.js
deleted file mode 100644
index 2bdb75fb7..000000000
--- a/tests/format/js/babel-plugins/module-string-names.js
+++ /dev/null
@@ -1,2 +0,0 @@
-import { "😄" as smile } from "./emojis.js";
-export { smile as "😄" } from "./emojis.js";
diff --git a/tests/format/js/babel-plugins/nullish-coalescing-operator.js b/tests/format/js/babel-plugins/nullish-coalescing-operator.js
deleted file mode 100644
index 2ad3de0ca..000000000
--- a/tests/format/js/babel-plugins/nullish-coalescing-operator.js
+++ /dev/null
@@ -1,3 +0,0 @@
-// https://babeljs.io/docs/babel-plugin-proposal-nullish-coalescing-operator
-
-var foo = object.foo ?? "default";
diff --git a/tests/format/js/babel-plugins/numeric-separator.js b/tests/format/js/babel-plugins/numeric-separator.js
deleted file mode 100644
index 23066a9dc..000000000
--- a/tests/format/js/babel-plugins/numeric-separator.js
+++ /dev/null
@@ -1,36 +0,0 @@
-// https://babeljs.io/docs/babel-plugin-proposal-numeric-separator
-
-let budget = 1_000_000_000_000;
-
-// What is the value of `budget`? It's 1 trillion!
-//
-// Let's confirm:
-console.log(budget === 10 ** 12); // true
-
-let nibbles = 0b1010_0001_1000_0101;
-
-// Is bit 7 on? It sure is!
-// 0b1010_0001_1000_0101
-// ^
-//
-// We can double check:
-console.log(!!(nibbles & (1 << 7))); // true
-
-// Messages are sent as 24 bit values, but should be
-// treated as 3 distinct bytes:
-let message = 0xa0_b0_c0;
-
-// What's the value of the upper most byte? It's A0, or 160.
-// We can confirm that:
-let a = (message >> 16) & 0xff;
-console.log(a.toString(16), a); // a0, 160
-
-// What's the value of the middle byte? It's B0, or 176.
-// Let's just make sure...
-let b = (message >> 8) & 0xff;
-console.log(b.toString(16), b); // b0, 176
-
-// What's the value of the lower most byte? It's C0, or 192.
-// Again, let's prove that:
-let c = message & 0xff;
-console.log(c.toString(16), b); // c0, 192
diff --git a/tests/format/js/babel-plugins/object-rest-spread.js b/tests/format/js/babel-plugins/object-rest-spread.js
deleted file mode 100644
index df90dd669..000000000
--- a/tests/format/js/babel-plugins/object-rest-spread.js
+++ /dev/null
@@ -1,9 +0,0 @@
-// https://babeljs.io/docs/babel-plugin-transform-object-rest-spread
-
-let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };
-console.log(x); // 1
-console.log(y); // 2
-console.log(z); // { a: 3, b: 4 }
-
-let n = { x, y, ...z };
-console.log(n); // { x: 1, y: 2, a: 3, b: 4 }
diff --git a/tests/format/js/babel-plugins/optional-catch-binding.js b/tests/format/js/babel-plugins/optional-catch-binding.js
deleted file mode 100644
index 969b3ebeb..000000000
--- a/tests/format/js/babel-plugins/optional-catch-binding.js
+++ /dev/null
@@ -1,15 +0,0 @@
-// https://babeljs.io/docs/babel-plugin-proposal-optional-catch-binding
-
-try {
- throw 0;
-} catch {
- doSomethingWhichDoesNotCareAboutTheValueThrown();
-}
-
-try {
- throw 0;
-} catch {
- doSomethingWhichDoesNotCareAboutTheValueThrown();
-} finally {
- doSomeCleanup();
-}
diff --git a/tests/format/js/babel-plugins/optional-chaining-assign.js b/tests/format/js/babel-plugins/optional-chaining-assign.js
new file mode 100644
index 000000000..1856c6657
--- /dev/null
+++ b/tests/format/js/babel-plugins/optional-chaining-assign.js
@@ -0,0 +1,5 @@
+/*
+`optionalChainingAssign` ([proposal](https://github.com/tc39/proposal-optional-chaining-assignment))
+*/
+
+x?.prop = 2
diff --git a/tests/format/js/babel-plugins/optional-chaining-assignment.js b/tests/format/js/babel-plugins/optional-chaining-assignment.js
deleted file mode 100644
index d15b0a213..000000000
--- a/tests/format/js/babel-plugins/optional-chaining-assignment.js
+++ /dev/null
@@ -1 +0,0 @@
-maybeAnObj?.prop = theValue;
diff --git a/tests/format/js/babel-plugins/optional-chaining.js b/tests/format/js/babel-plugins/optional-chaining.js
deleted file mode 100644
index 10522a9f2..000000000
--- a/tests/format/js/babel-plugins/optional-chaining.js
+++ /dev/null
@@ -1,62 +0,0 @@
-// https://babeljs.io/docs/babel-plugin-proposal-optional-chaining
-
-const obj = {
- foo: {
- bar: {
- baz: 42,
- },
- },
-};
-
-const baz = obj?.foo?.bar?.baz; // 42
-
-const safe = obj?.qux?.baz; // undefined
-
-// Optional chaining and normal chaining can be intermixed
-obj?.foo.bar?.baz; // Only access `foo` if `obj` exists, and `baz` if
- // `bar` exists
-
-// Example usage with bracket notation:
-obj?.['foo']?.bar?.baz // 42
-
-const obj2 = {
- foo: {
- bar: {
- baz() {
- return 42;
- },
- },
- },
-};
-
-const baz2 = obj?.foo?.bar?.baz(); // 42
-
-const safe3 = obj?.qux?.baz(); // undefined
-const safe4 = obj?.foo.bar.qux?.(); // undefined
-
-const willThrow = obj?.foo.bar.qux(); // Error: not a function
-
-// Top function can be called directly, too.
-function test() {
- return 42;
-}
-test?.(); // 42
-
-exists?.(); // undefined
-
-const obj3 = {
- foo: {
- bar: {
- baz: class {
- },
- },
- },
-};
-
-const obj4 = {
- foo: {
- bar: {}
- },
-};
-
-const ret = delete obj?.foo?.bar?.baz; // true
diff --git a/tests/format/js/babel-plugins/partial-application.js b/tests/format/js/babel-plugins/partial-application.js
index a7b6f59b2..64b9805b0 100644
--- a/tests/format/js/babel-plugins/partial-application.js
+++ b/tests/format/js/babel-plugins/partial-application.js
@@ -1,21 +1,5 @@
-// https://babeljs.io/docs/babel-plugin-proposal-partial-application
+/*
+`partialApplication` ([proposal](https://github.com/babel/proposals/issues/32))
+*/
-function add(x, y) { return x + y; }
-
-const addOne = add(1, ?); // apply from the left
-addOne(2); // 3
-
-const addTen = add(?, 10); // apply from the right
-addTen(2); // 12
-
-let newScore = player.score
- |> add(7, ?)
- |> clamp(0, 100, ?); // shallow stack, the pipe to `clamp` is the same frame as the pipe to `add`.
-
-f(x, ?) // partial application from left
-f(?, x) // partial application from right
-f(?, x, ?) // partial application for any arg
-o.f(x, ?) // partial application from left
-o.f(?, x) // partial application from right
-o.f(?, x, ?) // partial application for any arg
-super.f(?) // partial application allowed for call on |SuperProperty|
+f(?, a)
diff --git a/tests/format/js/babel-plugins/pipeline-operator-fsharp.js b/tests/format/js/babel-plugins/pipeline-operator-fsharp.js
deleted file mode 100644
index feaad1f7b..000000000
--- a/tests/format/js/babel-plugins/pipeline-operator-fsharp.js
+++ /dev/null
@@ -1,34 +0,0 @@
-// https://babeljs.io/docs/babel-plugin-proposal-pipeline-operator
-// https://github.com/valtech-nyc/proposal-fsharp-pipelines
-
-promise
- |> await
- |> x => doubleSay(x, ', ')
- |> capitalize
- |> x => x + '!'
- |> x => new User.Message(x)
- |> x => stream.write(x)
- |> await
- |> console.log;
-
-const result = exclaim(capitalize(doubleSay("hello")));
-result //=> "Hello, hello!"
-
-const result = "hello"
- |> doubleSay
- |> capitalize
- |> exclaim;
-
-result //=> "Hello, hello!"
-
-const person = { score: 25 };
-
-const newScore = person.score
- |> double
- |> n => add(7, n)
- |> n => boundScore(0, 100, n);
-
-newScore //=> 57
-
-// As opposed to:
-let newScore = boundScore(0, 100, add(7, double(person.score)));
diff --git a/tests/format/js/babel-plugins/pipeline-operator-hack.cjs b/tests/format/js/babel-plugins/pipeline-operator-hack.cjs
deleted file mode 100644
index 1d8c19a51..000000000
--- a/tests/format/js/babel-plugins/pipeline-operator-hack.cjs
+++ /dev/null
@@ -1,8 +0,0 @@
-// https://babeljs.io/docs/babel-plugin-proposal-pipeline-operator
-// https://github.com/js-choi/proposal-hack-pipes
-
-return list
- |> take(prefix.length, %)
- |> equals(%, prefix);
-
-// (The % token isn't final; it might instead be @ or ? or #.)
diff --git a/tests/format/js/babel-plugins/pipeline-operator-minimal.js b/tests/format/js/babel-plugins/pipeline-operator-minimal.js
deleted file mode 100644
index a57a2bffb..000000000
--- a/tests/format/js/babel-plugins/pipeline-operator-minimal.js
+++ /dev/null
@@ -1,12 +0,0 @@
-// https://babeljs.io/docs/babel-plugin-proposal-pipeline-operator
-// https://github.com/tc39/proposal-pipeline-operator/
-
-let result = exclaim(capitalize(doubleSay("hello")));
-result //=> "Hello, hello!"
-
-let result = "hello"
- |> doubleSay
- |> capitalize
- |> exclaim;
-
-result //=> "Hello, hello!"
diff --git a/tests/format/js/babel-plugins/pipeline-operator.js b/tests/format/js/babel-plugins/pipeline-operator.js
new file mode 100644
index 000000000..47ce25c0c
--- /dev/null
+++ b/tests/format/js/babel-plugins/pipeline-operator.js
@@ -0,0 +1,5 @@
+/*
+`pipelineOperator` ([proposal](https://github.com/babel/proposals/issues/29))
+*/
+
+a |> b
diff --git a/tests/format/js/babel-plugins/private-fields-in-in.js b/tests/format/js/babel-plugins/private-fields-in-in.js
deleted file mode 100644
index 247ae66cb..000000000
--- a/tests/format/js/babel-plugins/private-fields-in-in.js
+++ /dev/null
@@ -1,55 +0,0 @@
-// https://github.com/tc39/proposal-private-fields-in-in
-
-class C {
- #brand;
-
- static isC(obj) {
- try {
- obj.#brand;
- return true;
- } catch {
- return false;
- }
- }
-}
-
-class C2 {
- #data = null; // populated later
-
- get #getter() {
- if (!this.#data) {
- throw new Error('no data yet!');
- }
- return this.#data;
- }
-
- static isC(obj) {
- try {
- obj.#getter;
- return true;
- } catch {
- return false; // oops! might have gotten here because `#getter` threw :-(
- }
- }
-}
-
-class C3 {
- #brand;
-
- #method() {}
-
- get #getter() {}
-
- static isC(obj) {
- return #brand in obj && #method in obj && #getter in obj;
- }
-}
-
-// Invalid https://github.com/tc39/proposal-private-fields-in-in#try-statement
-// class C {
-// #brand;
-
-// static isC(obj) {
-// return try obj.#brand;
-// }
-// }
diff --git a/tests/format/js/babel-plugins/private-methods.js b/tests/format/js/babel-plugins/private-methods.js
deleted file mode 100644
index fed338759..000000000
--- a/tests/format/js/babel-plugins/private-methods.js
+++ /dev/null
@@ -1,19 +0,0 @@
-// https://babeljs.io/docs/babel-plugin-proposal-private-methods
-
-// Test for `classPrivateProperties` and `classPrivateMethods`
-
-class Counter extends HTMLElement {
- #xValue = 0;
- #render() {}
-
- get #x() { return this.#xValue; }
- set #x(value) {
- this.#xValue = value;
- window.requestAnimationFrame(
- this.#render.bind(this));
- }
-
- #clicked() {
- this.#x++;
- }
-}
diff --git a/tests/format/js/babel-plugins/regex-v-flag.js b/tests/format/js/babel-plugins/regex-v-flag.js
deleted file mode 100644
index 04ee6ccf7..000000000
--- a/tests/format/js/babel-plugins/regex-v-flag.js
+++ /dev/null
@@ -1 +0,0 @@
-/a/v;
diff --git a/tests/format/js/babel-plugins/regexp-modifiers.js b/tests/format/js/babel-plugins/regexp-modifiers.js
deleted file mode 100644
index 21cfd8487..000000000
--- a/tests/format/js/babel-plugins/regexp-modifiers.js
+++ /dev/null
@@ -1 +0,0 @@
-const re = /^(?i:[a-z])[a-z]$/;
diff --git a/tests/format/js/babel-plugins/source-phase-imports.js b/tests/format/js/babel-plugins/source-phase-imports.js
index fe8697e02..38d29ad52 100644
--- a/tests/format/js/babel-plugins/source-phase-imports.js
+++ b/tests/format/js/babel-plugins/source-phase-imports.js
@@ -1,2 +1,5 @@
-import source fooSource from "foo";
-import.source("x");
+/*
+`sourcePhaseImports` ([proposal](https://github.com/tc39/proposal-source-phase-imports))
+*/
+
+import source x from "./x"
diff --git a/tests/format/js/babel-plugins/throw-expressions.js b/tests/format/js/babel-plugins/throw-expressions.js
index 2fb5facde..0ea716b6d 100644
--- a/tests/format/js/babel-plugins/throw-expressions.js
+++ b/tests/format/js/babel-plugins/throw-expressions.js
@@ -1,5 +1,5 @@
-// https://babeljs.io/docs/babel-plugin-proposal-throw-expressions
+/*
+`throwExpressions` ([proposal](https://github.com/babel/proposals/issues/23))
+*/
-function test(param = throw new Error('required!')) {
- const test = param === true || throw new Error('Falsy!');
-}
+() => throw new Error("")
diff --git a/tests/format/js/babel-plugins/typescript.js b/tests/format/js/babel-plugins/typescript.js
index 9b0f9b2ba..9a53550a1 100644
--- a/tests/format/js/babel-plugins/typescript.js
+++ b/tests/format/js/babel-plugins/typescript.js
@@ -1,3 +1,5 @@
-// https://babeljs.io/docs/babel-preset-typescript
+/*
+`typescript` ([repo](https://github.com/Microsoft/TypeScript))
+*/
-const x: number = 0;
+var a: string = "";
diff --git a/tests/format/js/babel-plugins/v8intrinsic.js b/tests/format/js/babel-plugins/v8intrinsic.js
index 600086f28..fe50710fd 100644
--- a/tests/format/js/babel-plugins/v8intrinsic.js
+++ b/tests/format/js/babel-plugins/v8intrinsic.js
@@ -1,25 +1,5 @@
-// https://github.com/babel/babel/pull/10148
+/*
+`v8intrinsic`
+*/
%DebugPrint(foo);
-
-
-// Invalid code https://github.com/JLHwung/babel/blob/c1a3cbfd65e08b7013fd6f8c62add8cb10b4b169/packages/babel-parser/test/fixtures/v8intrinsic/_errors/in-bind-expression/options.json
-// ::%DebugPrint(null)
-
-// Invalid code https://github.com/JLHwung/babel/blob/c1a3cbfd65e08b7013fd6f8c62add8cb10b4b169/packages/babel-parser/test/fixtures/v8intrinsic/_errors/in-member-expression/options.json
-// a.%DebugPrint();
-
-// Invalid code https://github.com/JLHwung/babel/blob/c1a3cbfd65e08b7013fd6f8c62add8cb10b4b169/packages/babel-parser/test/fixtures/v8intrinsic/_errors/not-in-call-expression/options.json
-// const i = %DebugPrint;
-// i(foo);
-
-// https://github.com/JLHwung/babel/blob/c1a3cbfd65e08b7013fd6f8c62add8cb10b4b169/packages/babel-parser/test/fixtures/v8intrinsic/_errors/not-in-call-expression/options.json
-// %DebugPrint?.(null)
-
-new %DebugPrint(null);
-
-function *foo() {
- yield %StringParseInt("42", 10)
-}
-
-foo%bar()
diff --git a/tests/format/js/function-sent/__snapshots__/format.test.js.snap b/tests/format/js/function-sent/__snapshots__/format.test.js.snap
new file mode 100644
index 000000000..da9d16618
--- /dev/null
+++ b/tests/format/js/function-sent/__snapshots__/format.test.js.snap
@@ -0,0 +1,155 @@
+// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
+
+exports[`function-sent.js format 1`] = `
+====================================options=====================================
+parsers: ["babel", "flow", "typescript"]
+ printWidth: 80 (default) |
+=====================================input======================================
+function *adder(total=0) {
+ let increment=1;
+ do {
+ switch (request = function.sent){
+ case undefined: break;
+ case "done": return total;
+ default: increment = Number(request);
+ }
+ yield total += increment;
+ } while (true)
+}
+
+=====================================output=====================================
+function* adder(total = 0) {
+ let increment = 1;
+ do {
+ switch ((request = function.sent)) {
+ case undefined:
+ break;
+ case "done":
+ return total;
+ default:
+ increment = Number(request);
+ }
+ yield (total += increment);
+ } while (true);
+}
+
+================================================================================
+`;
+
+exports[`function-sent.js format[acorn] 1`] = `
+"Unexpected token (4:34)
+ 2 | let increment=1;
+ 3 | do {
+> 4 | switch (request = function.sent){
+ | ^
+ 5 | case undefined: break;
+ 6 | case "done": return total;
+ 7 | default: increment = Number(request);
+Cause: Unexpected token (4:33)"
+`;
+
+exports[`function-sent.js format[espree] 1`] = `
+"Unexpected token . (4:34)
+ 2 | let increment=1;
+ 3 | do {
+> 4 | switch (request = function.sent){
+ | ^
+ 5 | case undefined: break;
+ 6 | case "done": return total;
+ 7 | default: increment = Number(request);
+Cause: Unexpected token ."
+`;
+
+exports[`function-sent.js format[flow] 1`] = `
+"Unexpected token \`.\`, expected an identifier (4:34)
+ 2 | let increment=1;
+ 3 | do {
+> 4 | switch (request = function.sent){
+ | ^
+ 5 | case undefined: break;
+ 6 | case "done": return total;
+ 7 | default: increment = Number(request);
+Cause: Unexpected token \`.\`, expected an identifier (4:33)"
+`;
+
+exports[`function-sent.js format[hermes] 1`] = `
+"'(' expected at start of function parameter list (4:34)
+ 2 | let increment=1;
+ 3 | do {
+> 4 | switch (request = function.sent){
+ | ^
+ 5 | case undefined: break;
+ 6 | case "done": return total;
+ 7 | default: increment = Number(request);
+Cause: '(' expected at start of function parameter list (4:33)
+ switch (request = function.sent){
+ ~~~~~~~~^"
+`;
+
+exports[`function-sent.js format[meriyah] 1`] = `
+"Expected '(' (4:34)
+ 2 | let increment=1;
+ 3 | do {
+> 4 | switch (request = function.sent){
+ | ^
+ 5 | case undefined: break;
+ 6 | case "done": return total;
+ 7 | default: increment = Number(request);
+Cause: [4:33-4:34]: Expected '('"
+`;
+
+exports[`function-sent.js format[oxc] 1`] = `
+"Expected \`(\` but found \`.\` (4:34)
+ 2 | let increment=1;
+ 3 | do {
+> 4 | switch (request = function.sent){
+ | ^
+ 5 | case undefined: break;
+ 6 | case "done": return total;
+ 7 | default: increment = Number(request);"
+`;
+
+exports[`function-sent.js format[oxc-ts] 1`] = `
+"Expected \`(\` but found \`.\` (4:34)
+ 2 | let increment=1;
+ 3 | do {
+> 4 | switch (request = function.sent){
+ | ^
+ 5 | case undefined: break;
+ 6 | case "done": return total;
+ 7 | default: increment = Number(request);"
+`;
+
+exports[`function-sent.js format[typescript] 1`] = `
+"'(' expected. (4:34)
+ 2 | let increment=1;
+ 3 | do {
+> 4 | switch (request = function.sent){
+ | ^
+ 5 | case undefined: break;
+ 6 | case "done": return total;
+ 7 | default: increment = Number(request);
+Cause: '(' expected."
+`;
+
+exports[`function-sent.js format[yuku] 1`] = `
+"Expected '(' to start parameter list, but found '.' (4:34)
+ 2 | let increment=1;
+ 3 | do {
+> 4 | switch (request = function.sent){
+ | ^
+ 5 | case undefined: break;
+ 6 | case "done": return total;
+ 7 | default: increment = Number(request);"
+`;
+
+exports[`function-sent.js format[yuku-ts] 1`] = `
+"Expected '(' to start parameter list, but found '.' (4:34)
+ 2 | let increment=1;
+ 3 | do {
+> 4 | switch (request = function.sent){
+ | ^
+ 5 | case undefined: break;
+ 6 | case "done": return total;
+ 7 | default: increment = Number(request);"
+`;
diff --git a/tests/format/js/function-sent/format.test.js b/tests/format/js/function-sent/format.test.js
new file mode 100644
index 000000000..9c5c59572
--- /dev/null
+++ b/tests/format/js/function-sent/format.test.js
@@ -0,0 +1,14 @@
+runFormatTest(import.meta, ["babel", "flow", "typescript"], {
+ errors: {
+ flow: true,
+ typescript: true,
+ acorn: true,
+ espree: true,
+ meriyah: true,
+ oxc: true,
+ yuku: true,
+ "oxc-ts": true,
+ "yuku-ts": true,
+ hermes: true,
+ },
+});
diff --git a/tests/format/js/function-sent/function-sent.js b/tests/format/js/function-sent/function-sent.js
new file mode 100644
index 000000000..20d85f397
--- /dev/null
+++ b/tests/format/js/function-sent/function-sent.js
@@ -0,0 +1,11 @@
+function *adder(total=0) {
+ let increment=1;
+ do {
+ switch (request = function.sent){
+ case undefined: break;
+ case "done": return total;
+ default: increment = Number(request);
+ }
+ yield total += increment;
+ } while (true)
+}