Update flow-parser (#18929)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: fisker <lionkay@gmail.com>
This commit is contained in:
renovate[bot]andfisker authored and GitHub committed 2026-03-22 10:53:42 +08:00
1 parent 79c0929b3b
commit 9d6833e74a
31 files changed
+194 -578

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
#### Support literal initializers and multiple declarations in `DeclareVariable` (#18929 by @fisker)
<!-- prettier-ignore -->
```flow
// Input
declare const x: string, y: number;
declare const s = 'foo';
// Prettier stable
SyntaxError: Unexpected token `,`, expected the token `;` (1:24)
// Prettier main
declare const x: string, y: number;
declare const s = "foo";
```
+2 -2
View File
@@ -73,11 +73,11 @@
"fast-json-stable-stringify": "2.1.0",
"file-entry-cache": "11.1.2",
"find-cache-directory": "6.0.0",
"flow-parser": "0.301.0",
"flow-parser": "0.306.0",
"get-east-asian-width": "1.4.0",
"get-stdin": "9.0.0",
"graphql": "16.13.1",
"hermes-parser": "0.33.3",
"hermes-parser": "0.34.0",
"html-element-attributes": "3.5.0",
"html-ua-styles": "0.3.1",
"ignore": "7.0.5",
+6
View File
@@ -56,6 +56,7 @@ import { printTypeParameter, printTypeParameters } from "./type-parameters.js";
import { printTypePredicate } from "./type-predicate.js";
import { printTypeQuery } from "./type-query.js";
import { printUnionType } from "./union-type.js";
import { printVariableDeclaration } from "./variable-declaration.js";
function printFlow(path, options, print, args) {
const { node } = path;
@@ -99,6 +100,11 @@ function printFlow(path, options, print, args) {
case "DeclareNamespace":
return ["declare namespace ", print("id"), " ", print("body")];
case "DeclareVariable":
if (Array.isArray(node.declarations)) {
return printVariableDeclaration(path, options, print);
}
// TODO: Remove this part when hermes update AST
return [
printDeclareToken(path),
// TODO: Only use `node.kind` when babel update AST
@@ -25,6 +25,8 @@ const additionalVisitorKeys = {
// Flow
// `SatisfiesExpression` is a private feature https://github.com/facebook/hermes/issues/1808#issuecomment-3392476828
SatisfiesExpression: ["expression", "typeAnnotation"],
DeclareVariable: ["declarations"],
};
const excludeVisitorKeys = {
@@ -32,9 +34,6 @@ const excludeVisitorKeys = {
// https://github.com/facebook/hermes/commit/55a5f881361ef15fd4f7b558166d80e7b9086550
DeclareOpaqueType: ["impltype"],
// Legacy properties
ImportDeclaration: ["assertions"],
// Flow node from Babel
TupleTypeAnnotation: ["types"],
};
@@ -96,6 +96,10 @@ const disabledTests = new Map(
// Different result
"flow/hook/comments-before-arrow.js",
// Bug
"js/decorators/",
"js/explicit-resource-management/",
],
flow: [
// Parsing to different ASTs
@@ -22,3 +22,49 @@ declare export const c: string;
================================================================================
`;
exports[`initializer.js format 1`] = `
====================================options=====================================
parsers: ["flow"]
printWidth: 80 (default) |
=====================================input======================================
declare const s = 'foo';
=====================================output=====================================
declare const s = "foo";
================================================================================
`;
exports[`initializer.js format[hermes] 1`] = `
"expected type annotation on declared var (1:14)
> 1 | declare const s = 'foo';
| ^
2 |
Cause: expected type annotation on declared var (1:14)
declare const s = 'foo';
^"
`;
exports[`multiple.js format 1`] = `
====================================options=====================================
parsers: ["flow"]
printWidth: 80 (default) |
=====================================input======================================
declare const x: string, y: number;
=====================================output=====================================
declare const x: string, y: number;
================================================================================
`;
exports[`multiple.js format[hermes] 1`] = `
"';' expected (1:23)
> 1 | declare const x: string, y: number;
| ^
2 |
Cause: ';' expected (1:23)
declare const x: string, y: number;
^"
`;
@@ -1 +1,3 @@
runFormatTest(import.meta, ["flow"]);
runFormatTest(import.meta, ["flow"], {
errors: { hermes: ["multiple.js", "initializer.js"] },
});
@@ -0,0 +1 @@
declare const s = 'foo';
@@ -0,0 +1 @@
declare const x: string, y: number;
@@ -32,16 +32,3 @@ class Foo {
================================================================================
`;
exports[`test.js format[hermes] 1`] = `
"unrecognized character '@' (3:0)
1 | /* @flow */
2 |
> 3 | @decorator4
4 | class Foo {
5 | @decorator1
6 | method1() {}
Cause: unrecognized character '@' (3:0)
@decorator4
^"
`;
@@ -1,5 +1 @@
runFormatTest(import.meta, ["flow"], {
errors: {
hermes: ["test.js"],
},
});
runFormatTest(import.meta, ["flow"]);
@@ -32,16 +32,3 @@ class Foo {
================================================================================
`;
exports[`test.js format[hermes] 1`] = `
"unrecognized character '@' (3:0)
1 | /* @flow */
2 |
> 3 | @decorator4
4 | class Foo {
5 | @decorator1
6 | method1() {}
Cause: unrecognized character '@' (3:0)
@decorator4
^"
`;
@@ -1 +1 @@
runFormatTest(import.meta, ["flow"], { errors: { hermes: ["test.js"] } });
runFormatTest(import.meta, ["flow"]);
@@ -77,17 +77,6 @@ exports[`classes.js format[flow] 1`] = `
10 |"
`;
exports[`classes.js format[hermes] 1`] = `
"unrecognized character '@' (1:0)
> 1 | @deco class Foo {}
2 |
3 | @deco export class Bar {}
4 |
Cause: unrecognized character '@' (1:0)
@deco class Foo {}
^"
`;
exports[`comments.js format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
@@ -192,19 +181,6 @@ exports[`comments.js format[espree] 1`] = `
Cause: Unexpected character '@'"
`;
exports[`comments.js format[hermes] 1`] = `
"unrecognized character '@' (3:0)
1 | var x = 100
2 |
> 3 | @Hello({
4 | a: 'a', // Comment is in the wrong place
5 | // test
6 | b: '2'
Cause: unrecognized character '@' (3:0)
@Hello({
^"
`;
exports[`member-expression.js format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
@@ -372,20 +348,6 @@ exports[`member-expression.js format[espree] 1`] = `
Cause: Unexpected character '@'"
`;
exports[`member-expression.js format[hermes] 1`] = `
"unrecognized character '@' (3:4)
1 | [
2 | class {
> 3 | @(decorator)
| ^
4 | method() {}
5 | },
6 | class {
Cause: unrecognized character '@' (3:4)
@(decorator)
^"
`;
exports[`methods.js format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
@@ -441,20 +403,6 @@ exports[`methods.js format[espree] 1`] = `
Cause: Unexpected character '@'"
`;
exports[`methods.js format[hermes] 1`] = `
"unrecognized character '@' (3:2)
1 |
2 | class Yo {
> 3 | @foo("hello")
| ^
4 | async plop() {}
5 |
6 | @anotherDecoratorWithALongName("and a very long string as a first argument")
Cause: unrecognized character '@' (3:2)
@foo("hello")
^"
`;
exports[`mixed.js format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
@@ -504,19 +452,6 @@ exports[`mixed.js format[espree] 1`] = `
Cause: Unexpected character '@'"
`;
exports[`mixed.js format[hermes] 1`] = `
"unrecognized character '@' (3:0)
1 | // https://github.com/prettier/prettier/issues/6747
2 |
> 3 | @foo
4 | export default class MyComponent {
5 | @task
6 | *foo() {
Cause: unrecognized character '@' (3:0)
@foo
^"
`;
exports[`mobx.js format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
@@ -632,19 +567,6 @@ exports[`mobx.js format[espree] 1`] = `
Cause: Unexpected character '@'"
`;
exports[`mobx.js format[hermes] 1`] = `
"unrecognized character '@' (3:0)
1 | import {observable} from "mobx";
2 |
> 3 | @observer class OrderLine {
4 | @observable price = 0;
5 | @observable amount = 1;
6 |
Cause: unrecognized character '@' (3:0)
@observer class OrderLine {
^"
`;
exports[`multiline.js format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
@@ -705,19 +627,6 @@ exports[`multiline.js format[espree] 1`] = `
Cause: Unexpected character '@'"
`;
exports[`multiline.js format[hermes] 1`] = `
"unrecognized character '@' (2:2)
1 | class Foo {
> 2 | @deco([
| ^
3 | foo,
4 | bar
5 | ]) prop = value;
Cause: unrecognized character '@' (2:2)
@deco([
^"
`;
exports[`multiple.js format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
@@ -788,19 +697,6 @@ exports[`multiple.js format[espree] 1`] = `
Cause: Unexpected character '@'"
`;
exports[`multiple.js format[hermes] 1`] = `
"unrecognized character '@' (2:2)
1 | const dog = class {
> 2 | @readonly
| ^
3 | @nonenumerable
4 | @doubledValue
5 | legs = 4;
Cause: unrecognized character '@' (2:2)
@readonly
^"
`;
exports[`parens.js format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
@@ -842,19 +738,6 @@ exports[`parens.js format[espree] 1`] = `
Cause: Unexpected character '@'"
`;
exports[`parens.js format[hermes] 1`] = `
"unrecognized character '@' (2:2)
1 | class X {
> 2 | @(computed().volatile())
| ^
3 | x
4 | }
5 |
Cause: unrecognized character '@' (2:2)
@(computed().volatile())
^"
`;
exports[`redux.js format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
@@ -895,14 +778,3 @@ exports[`redux.js format[espree] 1`] = `
4 | @connect(state => ({ todos: state.todos }))
Cause: Unexpected character '@'"
`;
exports[`redux.js format[hermes] 1`] = `
"unrecognized character '@' (1:0)
> 1 | @connect(mapStateToProps, mapDispatchToProps)
2 | export class MyApp extends React.Component {}
3 |
4 | @connect(state => ({ todos: state.todos }))
Cause: unrecognized character '@' (1:0)
@connect(mapStateToProps, mapDispatchToProps)
^"
`;
@@ -48,17 +48,6 @@ exports[`arguments.js - {"semi":false} format[flow] 1`] = `
3 |"
`;
exports[`arguments.js - {"semi":false} format[hermes] 1`] = `
"unrecognized character '@' (1:12)
> 1 | console.log(@deco class Foo {})
| ^
2 | console.log(@deco class {})
3 |
Cause: unrecognized character '@' (1:12)
console.log(@deco class Foo {})
^"
`;
exports[`arguments.js format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
@@ -106,17 +95,6 @@ exports[`arguments.js format[flow] 1`] = `
3 |"
`;
exports[`arguments.js format[hermes] 1`] = `
"unrecognized character '@' (1:12)
> 1 | console.log(@deco class Foo {})
| ^
2 | console.log(@deco class {})
3 |
Cause: unrecognized character '@' (1:12)
console.log(@deco class Foo {})
^"
`;
exports[`class-expression.js - {"semi":false} format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
@@ -203,18 +181,6 @@ exports[`class-expression.js - {"semi":false} format[flow] 1`] = `
4 | (@deco class Foo {});"
`;
exports[`class-expression.js - {"semi":false} format[hermes] 1`] = `
"unrecognized character '@' (1:12)
> 1 | const a1 = (@deco class Foo {});
| ^
2 | const a2 = (@deco class {});
3 |
4 | (@deco class Foo {});
Cause: unrecognized character '@' (1:12)
const a1 = (@deco class Foo {});
^"
`;
exports[`class-expression.js format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
@@ -300,18 +266,6 @@ exports[`class-expression.js format[flow] 1`] = `
4 | (@deco class Foo {});"
`;
exports[`class-expression.js format[hermes] 1`] = `
"unrecognized character '@' (1:12)
> 1 | const a1 = (@deco class Foo {});
| ^
2 | const a2 = (@deco class {});
3 |
4 | (@deco class Foo {});
Cause: unrecognized character '@' (1:12)
const a1 = (@deco class Foo {});
^"
`;
exports[`member-expression.js - {"semi":false} format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
@@ -360,17 +314,6 @@ exports[`member-expression.js - {"semi":false} format[flow] 1`] = `
3 |"
`;
exports[`member-expression.js - {"semi":false} format[hermes] 1`] = `
"unrecognized character '@' (1:1)
> 1 | (@deco class Foo {}).name;
| ^
2 | (@deco class {}).name;
3 |
Cause: unrecognized character '@' (1:1)
(@deco class Foo {}).name;
^"
`;
exports[`member-expression.js format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
@@ -418,17 +361,6 @@ exports[`member-expression.js format[flow] 1`] = `
3 |"
`;
exports[`member-expression.js format[hermes] 1`] = `
"unrecognized character '@' (1:1)
> 1 | (@deco class Foo {}).name;
| ^
2 | (@deco class {}).name;
3 |
Cause: unrecognized character '@' (1:1)
(@deco class Foo {}).name;
^"
`;
exports[`super-class.js - {"semi":false} format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
@@ -437,7 +369,7 @@ semi: false
=====================================input======================================
class Foo extends (@deco class Foo {}){}
class Foo extends (@deco class {}){}
class Fo2 extends (@deco class {}){}
=====================================output=====================================
class Foo extends (
@@ -445,7 +377,7 @@ class Foo extends (
class Foo {}
) {}
class Foo extends (
class Fo2 extends (
@deco
class {}
) {}
@@ -458,7 +390,7 @@ exports[`super-class.js - {"semi":false} format[acorn] 1`] = `
> 1 | class Foo extends (@deco class Foo {}){}
| ^
2 |
3 | class Foo extends (@deco class {}){}
3 | class Fo2 extends (@deco class {}){}
4 |
Cause: Unexpected character '@' (1:19)"
`;
@@ -468,7 +400,7 @@ exports[`super-class.js - {"semi":false} format[espree] 1`] = `
> 1 | class Foo extends (@deco class Foo {}){}
| ^
2 |
3 | class Foo extends (@deco class {}){}
3 | class Fo2 extends (@deco class {}){}
4 |
Cause: Unexpected character '@'"
`;
@@ -478,22 +410,10 @@ exports[`super-class.js - {"semi":false} format[flow] 1`] = `
> 1 | class Foo extends (@deco class Foo {}){}
| ^
2 |
3 | class Foo extends (@deco class {}){}
3 | class Fo2 extends (@deco class {}){}
4 |"
`;
exports[`super-class.js - {"semi":false} format[hermes] 1`] = `
"unrecognized character '@' (1:19)
> 1 | class Foo extends (@deco class Foo {}){}
| ^
2 |
3 | class Foo extends (@deco class {}){}
4 |
Cause: unrecognized character '@' (1:19)
class Foo extends (@deco class Foo {}){}
^"
`;
exports[`super-class.js format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
@@ -501,7 +421,7 @@ parsers: ["babel", "flow", "typescript"]
=====================================input======================================
class Foo extends (@deco class Foo {}){}
class Foo extends (@deco class {}){}
class Fo2 extends (@deco class {}){}
=====================================output=====================================
class Foo extends (
@@ -509,7 +429,7 @@ class Foo extends (
class Foo {}
) {}
class Foo extends (
class Fo2 extends (
@deco
class {}
) {}
@@ -522,7 +442,7 @@ exports[`super-class.js format[acorn] 1`] = `
> 1 | class Foo extends (@deco class Foo {}){}
| ^
2 |
3 | class Foo extends (@deco class {}){}
3 | class Fo2 extends (@deco class {}){}
4 |
Cause: Unexpected character '@' (1:19)"
`;
@@ -532,7 +452,7 @@ exports[`super-class.js format[espree] 1`] = `
> 1 | class Foo extends (@deco class Foo {}){}
| ^
2 |
3 | class Foo extends (@deco class {}){}
3 | class Fo2 extends (@deco class {}){}
4 |
Cause: Unexpected character '@'"
`;
@@ -542,18 +462,6 @@ exports[`super-class.js format[flow] 1`] = `
> 1 | class Foo extends (@deco class Foo {}){}
| ^
2 |
3 | class Foo extends (@deco class {}){}
3 | class Fo2 extends (@deco class {}){}
4 |"
`;
exports[`super-class.js format[hermes] 1`] = `
"unrecognized character '@' (1:19)
> 1 | class Foo extends (@deco class Foo {}){}
| ^
2 |
3 | class Foo extends (@deco class {}){}
4 |
Cause: unrecognized character '@' (1:19)
class Foo extends (@deco class Foo {}){}
^"
`;
@@ -1,6 +1,5 @@
const errors = {
flow: true,
hermes: true,
acorn: true,
espree: true,
};
@@ -1,3 +1,3 @@
class Foo extends (@deco class Foo {}){}
class Foo extends (@deco class {}){}
class Fo2 extends (@deco class {}){}
@@ -634,15 +634,15 @@ exports[`discard-binding-for-await-using-binding.js format[flow] 1`] = `
`;
exports[`discard-binding-for-await-using-binding.js format[hermes] 1`] = `
"';' or 'in' expected inside 'for' (2:18)
"invalid expression (2:27)
1 | async () => {
> 2 | for(await using void of []);
| ^
| ^
3 | }
4 |
Cause: ';' or 'in' expected inside 'for' (2:18)
Cause: invalid expression (2:27)
for(await using void of []);
~~~~~~~~~~~~~~~~^"
^"
`;
exports[`discard-binding-for-await-using-binding.js format[meriyah] 1`] = `
@@ -882,15 +882,11 @@ exports[`discard-binding-for-using-binding.js format[flow] 1`] = `
`;
exports[`discard-binding-for-using-binding.js format[hermes] 1`] = `
"';' or 'in' expected inside 'for' (2:12)
"Failed to parse source (0:0)
1 | {
> 2 | for(using void of []);
| ^
2 | for(using void of []);
3 | }
4 |
Cause: ';' or 'in' expected inside 'for' (2:12)
for(using void of []);
~~~~~~~~~~^"
Cause: Failed to parse source"
`;
exports[`discard-binding-for-using-binding.js format[meriyah] 1`] = `
@@ -1472,16 +1468,16 @@ exports[`using.js format[flow] 1`] = `
`;
exports[`using.js format[hermes] 1`] = `
"';' expected (2:8)
"'identifier' expected in declaration (2:8)
1 | {
> 2 | using void = f();
| ^
3 | }
4 | async (void) => {
5 | await using void = f();
Cause: ';' expected (2:8)
Cause: 'identifier' expected in declaration (2:8)
using void = f();
^"
~~~~~~^"
`;
exports[`using.js format[meriyah] 1`] = `
@@ -1645,7 +1641,7 @@ exports[`using-variable-declarator.js format[flow] 1`] = `
`;
exports[`using-variable-declarator.js format[hermes] 1`] = `
"';' expected (3:8)
"'identifier' expected in declaration (3:8)
1 | {
2 | // using 1 declarator
> 3 | using void = f();
@@ -1653,9 +1649,9 @@ exports[`using-variable-declarator.js format[hermes] 1`] = `
4 | }
5 | {
6 | // using 2 declarators
Cause: ';' expected (3:8)
Cause: 'identifier' expected in declaration (3:8)
using void = f();
^"
~~~~~~^"
`;
exports[`using-variable-declarator.js format[meriyah] 1`] = `
@@ -20,16 +20,6 @@ exports[`for-await-using-of-comments.js format[flow] 1`] = `
2 |"
`;
exports[`for-await-using-of-comments.js format[hermes] 1`] = `
"'(' expected after 'for' (1:18)
> 1 | /*1*/ for /* 2 */ await /*3*/ ( /*4*/ using /*5*/ fo /*6*/ of /*7*/ of /*8*/) /*9*/;
| ^
2 |
Cause: '(' expected after 'for' (1:18)
/*1*/ for /* 2 */ await /*3*/ ( /*4*/ using /*5*/ fo /*6*/ of /*7*/ of /*8*/) /*9*/;
~~~~~~~~~~~~^"
`;
exports[`for-await-using-of-comments.js format[meriyah] 1`] = `
"for await (... of ...) is only valid in async functions and async generators (1:51)
> 1 | /*1*/ for /* 2 */ await /*3*/ ( /*4*/ using /*5*/ fo /*6*/ of /*7*/ of /*8*/) /*9*/;
@@ -96,19 +86,6 @@ exports[`invalid-duplicate-using-bindings.js format[flow] 1`] = `
5 | using g = foo();"
`;
exports[`invalid-duplicate-using-bindings.js format[hermes] 1`] = `
"';' expected (2:8)
1 | {
> 2 | using f = foo(), f = foo();
| ^
3 | }
4 | {
5 | using g = foo();
Cause: ';' expected (2:8)
using f = foo(), f = foo();
^"
`;
exports[`invalid-duplicate-using-bindings.js format[meriyah] 1`] = `
"Unexpected token: 'identifier' (2:9)
1 | {
@@ -140,16 +117,6 @@ exports[`invalid-script-top-level-using-binding.js format[flow] 1`] = `
2 |"
`;
exports[`invalid-script-top-level-using-binding.js format[hermes] 1`] = `
"';' expected (1:6)
> 1 | using x = bar();
| ^
2 |
Cause: ';' expected (1:6)
using x = bar();
^"
`;
exports[`invalid-script-top-level-using-binding.js format[meriyah] 1`] = `
"Unexpected token: 'identifier' (1:7)
> 1 | using x = bar();
@@ -194,19 +161,6 @@ exports[`using-declarations.js format[flow] 1`] = `
5 | for(using /* 1 */ a = foo(), /* 2 */ b = foo();;);"
`;
exports[`using-declarations.js format[hermes] 1`] = `
"';' expected (2:16)
1 | {
> 2 | using /* 1 */ a = foo(), /* 2 */ b = foo()
| ^
3 | }
4 |
5 | for(using /* 1 */ a = foo(), /* 2 */ b = foo();;);
Cause: ';' expected (2:16)
using /* 1 */ a = foo(), /* 2 */ b = foo()
^"
`;
exports[`using-declarations.js format[meriyah] 1`] = `
"Unexpected token: 'identifier' (2:17)
1 | {
@@ -316,18 +270,6 @@ exports[`valid-await-using-binding-basic.js format[flow] 1`] = `
4 |"
`;
exports[`valid-await-using-binding-basic.js format[hermes] 1`] = `
"';' expected (2:14)
1 | async function f() {
> 2 | await using basic = getReader();
| ^
3 | }
4 |
Cause: ';' expected (2:14)
await using basic = getReader();
^"
`;
exports[`valid-await-using-binding-basic.js format[meriyah] 1`] = `
"Unexpected token: 'identifier' (2:15)
1 | async function f() {
@@ -364,18 +306,6 @@ exports[`valid-await-using-binding-escaped.js format[flow] 1`] = `
4 |"
`;
exports[`valid-await-using-binding-escaped.js format[hermes] 1`] = `
"';' expected (2:14)
1 | async function f() {
> 2 | await using \\u0061b = c;
| ^
3 | }
4 |
Cause: ';' expected (2:14)
await using \\u0061b = c;
^"
`;
exports[`valid-await-using-binding-escaped.js format[meriyah] 1`] = `
"Unexpected token: 'identifier' (2:15)
1 | async function f() {
@@ -412,17 +342,6 @@ exports[`valid-await-using-binding-non-bmp.js format[flow] 1`] = `
4 |"
`;
exports[`valid-await-using-binding-non-bmp.js format[hermes] 1`] = `
"';' expected (2:14)
1 | async function f() {
> 2 | await using 𠮷 = foo();
| ^
3 | }
4 |
Cause: ';' expected (2:14)
await using 𠮷 = foo();"
`;
exports[`valid-await-using-binding-non-bmp.js format[meriyah] 1`] = `
"Unexpected token: 'identifier' (2:15)
1 | async function f() {
@@ -462,19 +381,6 @@ exports[`valid-await-using-binding-using.js format[flow] 1`] = `
5 |"
`;
exports[`valid-await-using-binding-using.js format[hermes] 1`] = `
"';' expected (2:14)
1 | async function f() {
> 2 | await using using = of;
| ^
3 | for (await using using of of);
4 | }
5 |
Cause: ';' expected (2:14)
await using using = of;
^"
`;
exports[`valid-await-using-binding-using.js format[meriyah] 1`] = `
"Unexpected token: 'identifier' (2:15)
1 | async function f() {
@@ -539,20 +445,6 @@ exports[`valid-await-using-comments.js format[flow] 1`] = `
6 | /*0*/for/*1*/(/*2*/await/*3*/using/*4*/b/*5*/=/*6*/x/*7*/;/*8*/;/*9*/)/*10*/;"
`;
exports[`valid-await-using-comments.js format[hermes] 1`] = `
"';' expected (3:27)
1 | async function f() {
2 | {
> 3 | /*0*/await/*1*/using/*2*/b/*3*/=/*4*/f()/*5*/;
| ^
4 | }
5 | {
6 | /*0*/for/*1*/(/*2*/await/*3*/using/*4*/b/*5*/=/*6*/x/*7*/;/*8*/;/*9*/)/*10*/;
Cause: ';' expected (3:27)
/*0*/await/*1*/using/*2*/b/*3*/=/*4*/f()/*5*/;
^"
`;
exports[`valid-await-using-comments.js format[meriyah] 1`] = `
"Unexpected token: 'identifier' (3:28)
1 | async function f() {
@@ -646,19 +538,6 @@ exports[`valid-for-using-binding-of-of.js format[flow] 1`] = `
5 |"
`;
exports[`valid-for-using-binding-of-of.js format[hermes] 1`] = `
"')' expected after 'for(... in/of ...' (2:25)
1 | async function f() {
> 2 | for (await using of of of);
| ^
3 | for await (await using of of of);
4 | }
5 |
Cause: ')' expected after 'for(... in/of ...' (2:25)
for (await using of of of);
~~~~~~~~~~~~~~~~~~~^"
`;
exports[`valid-for-using-binding-of-of.js format[meriyah] 1`] = `
"Invalid left-hand side in for-of (2:20)
1 | async function f() {
@@ -696,18 +575,6 @@ exports[`valid-for-using-declaration.js format[flow] 1`] = `
4 |"
`;
exports[`valid-for-using-declaration.js format[hermes] 1`] = `
"';' or 'in' expected inside 'for' (2:19)
1 | async function f() {
> 2 | for (await using basic = reader();;);
| ^
3 | }
4 |
Cause: ';' or 'in' expected inside 'for' (2:19)
for (await using basic = reader();;);
~~~~~~~~~~~~~~~~~^"
`;
exports[`valid-for-using-declaration.js format[meriyah] 1`] = `
"Expected ';' (2:20)
1 | async function f() {
@@ -764,18 +631,6 @@ exports[`valid-module-block-top-level-await-using-binding.js format[flow] 1`] =
4 |"
`;
exports[`valid-module-block-top-level-await-using-binding.js format[hermes] 1`] = `
"';' expected (1:17)
> 1 | const m = module {
| ^
2 | await using foo = bar();
3 | }
4 |
Cause: ';' expected (1:17)
const m = module {
^"
`;
exports[`valid-module-block-top-level-await-using-binding.js format[meriyah] 1`] = `
"Unexpected token: '{' (1:18)
> 1 | const m = module {
@@ -860,18 +715,6 @@ exports[`valid-module-block-top-level-using-binding.js format[flow] 1`] = `
4 |"
`;
exports[`valid-module-block-top-level-using-binding.js format[hermes] 1`] = `
"';' expected (1:7)
> 1 | module {
| ^
2 | using foo = bar();
3 | }
4 |
Cause: ';' expected (1:7)
module {
^"
`;
exports[`valid-module-block-top-level-using-binding.js format[meriyah] 1`] = `
"Unexpected token: '{' (1:8)
> 1 | module {
@@ -960,16 +803,6 @@ exports[`valid-using-as-identifier-for-await-of.js format[flow] 1`] = `
2 |"
`;
exports[`valid-using-as-identifier-for-await-of.js format[hermes] 1`] = `
"'(' expected after 'for' (1:4)
> 1 | for await (using of of);
| ^
2 |
Cause: '(' expected after 'for' (1:4)
for await (using of of);
~~~~^"
`;
exports[`valid-using-as-identifier-for-in.js format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
@@ -1062,18 +895,6 @@ exports[`valid-using-binding-basic.js format[flow] 1`] = `
4 |"
`;
exports[`valid-using-binding-basic.js format[hermes] 1`] = `
"';' expected (2:8)
1 | {
> 2 | using basic = getReader();
| ^
3 | }
4 |
Cause: ';' expected (2:8)
using basic = getReader();
^"
`;
exports[`valid-using-binding-basic.js format[meriyah] 1`] = `
"Unexpected token: 'identifier' (2:9)
1 | {
@@ -1106,16 +927,6 @@ exports[`valid-using-binding-escaped.js format[flow] 1`] = `
2 |"
`;
exports[`valid-using-binding-escaped.js format[hermes] 1`] = `
"';' expected (1:8)
> 1 | { using \\u0061b = c; }
| ^
2 |
Cause: ';' expected (1:8)
{ using \\u0061b = c; }
^"
`;
exports[`valid-using-binding-escaped.js format[meriyah] 1`] = `
"Unexpected token: 'identifier' (1:9)
> 1 | { using \\u0061b = c; }
@@ -1146,15 +957,6 @@ exports[`valid-using-binding-non-bmp.js format[flow] 1`] = `
2 |"
`;
exports[`valid-using-binding-non-bmp.js format[hermes] 1`] = `
"';' expected (1:8)
> 1 | { using 𠮷 = foo(); }
| ^
2 |
Cause: ';' expected (1:8)
{ using 𠮷 = foo(); }"
`;
exports[`valid-using-binding-non-bmp.js format[meriyah] 1`] = `
"Unexpected token: 'identifier' (1:9)
> 1 | { using 𠮷 = foo(); }
@@ -1192,19 +994,6 @@ exports[`valid-using-binding-using.js format[flow] 1`] = `
5 |"
`;
exports[`valid-using-binding-using.js format[hermes] 1`] = `
"';' expected (2:8)
1 | {
> 2 | using using = of;
| ^
3 | for (using using of of);
4 | }
5 |
Cause: ';' expected (2:8)
using using = of;
^"
`;
exports[`valid-using-binding-using.js format[meriyah] 1`] = `
"Unexpected token: 'identifier' (2:9)
1 | {
@@ -27,26 +27,23 @@ runFormatTest(import.meta, ["babel", "flow", "typescript"], {
hermes: [
"for-await-using-of-comments.js",
"invalid-duplicate-using-bindings.js",
"invalid-script-top-level-using-binding.js",
"using-declarations.js",
// "valid-for-await-using-binding-escaped-of-of.js",
// "valid-for-using-binding-escaped-of-of.js",
"valid-module-block-top-level-using-binding.js",
"valid-using-as-identifier-for-await-of.js",
"valid-using-binding-basic.js",
"valid-using-binding-escaped.js",
"valid-using-binding-non-bmp.js",
"valid-using-binding-using.js",
"valid-await-using-binding-basic.js",
"valid-await-using-binding-escaped.js",
"valid-await-using-binding-non-bmp.js",
"valid-await-using-binding-using.js",
"valid-await-using-comments.js",
"valid-for-lhs-await-as-identifier.js",
"valid-for-using-binding-of-of.js",
"valid-for-using-declaration.js",
"valid-module-block-top-level-await-using-binding.js",
"valid-using-as-identifier-in.js",
"valid-using-as-identifier-for-in.js",
"valid-await-expr-using-instanceof.js",
"valid-await-expr-using-in.js",
],
typescript: [
// TypeScript does not support module expr
@@ -37,17 +37,6 @@ exports[`decorator.js format[espree] 1`] = `
Cause: Unexpected character '@'"
`;
exports[`decorator.js format[hermes] 1`] = `
"unrecognized character '@' (2:0)
1 | // prettier-ignore
> 2 | @decorator
3 | class A {}
4 |
Cause: unrecognized character '@' (2:0)
@decorator
^"
`;
exports[`ignore.js format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
-1
View File
@@ -2,6 +2,5 @@ runFormatTest(import.meta, ["babel", "flow", "typescript"], {
errors: {
acorn: ["decorator.js"],
espree: ["decorator.js"],
hermes: ["decorator.js"],
},
});
@@ -92,20 +92,6 @@ exports[`class-expression-decorator.js - {"semi":false} format[flow] 1`] = `
6 |"
`;
exports[`class-expression-decorator.js - {"semi":false} format[hermes] 1`] = `
"unrecognized character '@' (3:2)
1 | (
2 | // prettier-ignore
> 3 | @decorator
| ^
4 | class {}
5 | );
6 |
Cause: unrecognized character '@' (3:2)
@decorator
^"
`;
exports[`class-expression-decorator.js format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
@@ -162,20 +148,6 @@ exports[`class-expression-decorator.js format[flow] 1`] = `
6 |"
`;
exports[`class-expression-decorator.js format[hermes] 1`] = `
"unrecognized character '@' (3:2)
1 | (
2 | // prettier-ignore
> 3 | @decorator
| ^
4 | class {}
5 | );
6 |
Cause: unrecognized character '@' (3:2)
@decorator
^"
`;
exports[`directive.js - {"semi":false} format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
@@ -2,7 +2,6 @@ const errors = {
acorn: ["class-expression-decorator.js"],
espree: ["class-expression-decorator.js"],
flow: ["class-expression-decorator.js"],
hermes: ["class-expression-decorator.js"],
};
runFormatTest(import.meta, ["babel", "flow", "typescript"], { errors });
@@ -95,17 +95,15 @@ Cause: Missing semicolon. (1:20)"
`;
exports[`keyword-detect.js format[hermes] 1`] = `
"';' expected (4:52)
"';' expected (1:32)
> 1 | import "./test.json" /* with */ assert /* with */ { type: "json" }
| ^
2 | import {default as b} from "./test.json" /* with */ assert /* with */ { type: "json" }
3 |
> 4 | export {default as e} from "./test.json" /* with */ assert /* with */ { type: "json" }
| ^
5 |
6 | export * from "./test.json" /* with */ assert /* with */ { type: "json" }
7 |
Cause: ';' expected (4:52)
export {default as e} from "./test.json" /* with */ assert /* with */ { type: "json" }
^"
4 | export {default as e} from "./test.json" /* with */ assert /* with */ { type: "json" }
Cause: ';' expected (1:32)
import "./test.json" /* with */ assert /* with */ { type: "json" }
^"
`;
exports[`multi-types.js format 1`] = `
@@ -129,6 +127,16 @@ exports[`multi-types.js format[babel-ts] 1`] = `
Cause: Unexpected token (1:57)"
`;
exports[`multi-types.js format[hermes] 1`] = `
"';' expected (1:30)
> 1 | import json from "./foo.json" assert { type: "json", type: "bar" };
| ^
2 |
Cause: ';' expected (1:30)
import json from "./foo.json" assert { type: "json", type: "bar" };
^"
`;
exports[`non-type.js format 1`] = `
====================================options=====================================
parsers: ["oxc", "typescript", "hermes"]
@@ -150,6 +158,16 @@ exports[`non-type.js format[babel-ts] 1`] = `
Cause: Missing semicolon. (1:26)"
`;
exports[`non-type.js format[hermes] 1`] = `
"';' expected (1:27)
> 1 | import foo from "foo.json" assert { lazy: "true" };
| ^
2 |
Cause: ';' expected (1:27)
import foo from "foo.json" assert { lazy: "true" };
^"
`;
exports[`not-import-assertions.js format 1`] = `
====================================options=====================================
parsers: ["oxc", "typescript", "hermes"]
@@ -225,6 +243,16 @@ exports[`static-import.js format[babel-ts] 1`] = `
Cause: Missing semicolon. (1:29)"
`;
exports[`static-import.js format[hermes] 1`] = `
"';' expected (1:30)
> 1 | import json from "./foo.json" assert { type: "json" };
| ^
2 |
Cause: ';' expected (1:30)
import json from "./foo.json" assert { type: "json" };
^"
`;
exports[`without-from.js format 1`] = `
====================================options=====================================
parsers: ["oxc", "typescript", "hermes"]
@@ -245,3 +273,13 @@ exports[`without-from.js format[babel-ts] 1`] = `
2 |
Cause: Missing semicolon. (1:12)"
`;
exports[`without-from.js format[hermes] 1`] = `
"';' expected (1:13)
> 1 | import "foo" assert { type: "json" }
| ^
2 |
Cause: ';' expected (1:13)
import "foo" assert { type: "json" }
^"
`;
@@ -96,3 +96,13 @@ exports[`static-import.js - {"bracketSpacing":false} format[babel-ts] 1`] = `
2 |
Cause: Missing semicolon. (1:29)"
`;
exports[`static-import.js - {"bracketSpacing":false} format[hermes] 1`] = `
"';' expected (1:30)
> 1 | import json from "./foo.json" assert { type: "json" };
| ^
2 |
Cause: ';' expected (1:30)
import json from "./foo.json" assert { type: "json" };
^"
`;
@@ -2,6 +2,6 @@ runFormatTest(import.meta, ["oxc", "typescript", "hermes"], {
bracketSpacing: false,
errors: {
"babel-ts": ["static-import.js", "re-export.js", "empty.js"],
hermes: ["empty.js", "re-export.js"],
hermes: ["static-import.js", "empty.js", "re-export.js"],
},
});
@@ -9,6 +9,14 @@ runFormatTest(import.meta, ["oxc", "typescript", "hermes"], {
"non-type.js",
"keyword-detect.js",
],
hermes: ["keyword-detect.js", "empty.js", "re-export.js"],
hermes: [
"empty.js",
"multi-types.js",
"static-import.js",
"re-export.js",
"without-from.js",
"non-type.js",
"keyword-detect.js",
],
},
});
@@ -95,12 +95,7 @@ const foo1: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
================================================================================
`;
exports[`template-literal-types.ts format[flow] 1`] = `
"Flow does not support template literal types. (1:84)
> 1 | const foo1: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<\`Hello, \${keyof World}\`> = a;
| ^
2 |"
`;
exports[`template-literal-types.ts format[flow] 1`] = `"Missing visitor keys for 'TemplateLiteralTypeAnnotation'."`;
exports[`template-literal-types.ts format[hermes] 1`] = `
"unexpected token in type annotation (1:83)
@@ -246,6 +246,7 @@ exports[`visitor keys estree 1`] = `
"typeParameters",
],
"DeclareVariable": [
"declarations",
"id",
],
"DeclaredPredicate": [
+15 -15
View File
@@ -5256,10 +5256,10 @@ __metadata:
languageName: node
linkType: hard
"flow-parser@npm:0.301.0":
version: 0.301.0
resolution: "flow-parser@npm:0.301.0"
checksum: 10/940f41d3b6649a86bb02c4f58c59e07b4fc57f6fafc0ee69fb5da31456a9d734ae3cc20cab59a486308a97dff3309bb9be3faaaedaac4f8cf5176050b6a0eafe
"flow-parser@npm:0.306.0":
version: 0.306.0
resolution: "flow-parser@npm:0.306.0"
checksum: 10/50a4477fa2fe745bdc5de40d889912e647a04556d418024e534809b4ed611205f81c0d954bc25239a421a642cf7703d0205e8dc245b081987f1577fa55f61fb0
languageName: node
linkType: hard
@@ -5609,19 +5609,19 @@ __metadata:
languageName: node
linkType: hard
"hermes-estree@npm:0.33.3":
version: 0.33.3
resolution: "hermes-estree@npm:0.33.3"
checksum: 10/dfaac7eb91e282cf04f26c8f557fcadbfb78f630062c7abc1e75b9765918103ebee1359dffbe6c5e42a52c7cee0b14420affda984d534f76ba3d7e8d9ba98215
"hermes-estree@npm:0.34.0":
version: 0.34.0
resolution: "hermes-estree@npm:0.34.0"
checksum: 10/f03d62c404023526fee2a64ef9a0605ef194a3174ba3de60f459de70ac89cb268282acabf54d334be2c9c59d10d9edb74fc1ce90f6036a272ea098695719f9d9
languageName: node
linkType: hard
"hermes-parser@npm:0.33.3":
version: 0.33.3
resolution: "hermes-parser@npm:0.33.3"
"hermes-parser@npm:0.34.0":
version: 0.34.0
resolution: "hermes-parser@npm:0.34.0"
dependencies:
hermes-estree: "npm:0.33.3"
checksum: 10/709dac7283a9eab706f3fff5c6f09deee5197a1a38751da66fdf499a307120ba3ef14ce734715430a838145531973a8c0b69874bf5bc615cca10059ee87f5ff3
hermes-estree: "npm:0.34.0"
checksum: 10/5f3d7e66452c63f7c53b201ad0c6fef47243dfa092f27438e56c06ae252c382c0757ca3ab8e038026baad930d6f72a49bb9453372e5e6c539bc3ff848ac57ec2
languageName: node
linkType: hard
@@ -8667,14 +8667,14 @@ __metadata:
fast-json-stable-stringify: "npm:2.1.0"
file-entry-cache: "npm:11.1.2"
find-cache-directory: "npm:6.0.0"
flow-parser: "npm:0.301.0"
flow-parser: "npm:0.306.0"
get-east-asian-width: "npm:1.4.0"
get-port: "npm:7.1.0"
get-stdin: "npm:9.0.0"
gfm-test-suite: "npm:0.0.2"
globals: "npm:17.4.0"
graphql: "npm:16.13.1"
hermes-parser: "npm:0.33.3"
hermes-parser: "npm:0.34.0"
html-element-attributes: "npm:3.5.0"
html-ua-styles: "npm:0.3.1"
ignore: "npm:7.0.5"