Skip to content

Commit 07d8f8e

Browse files
committed
[BE] enable prettier for flow fixtures
Since switching to `hermes-parser`, we can parse all flow syntax and no longer need to exclude these fixtures from prettier.
1 parent 7048484 commit 07d8f8e

15 files changed

+46
-45
lines changed

.prettierignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ packages/react-devtools-timeline/static
1818
# react compiler
1919
compiler/**/dist
2020
compiler/**/__tests__/fixtures/**/*.expect.md
21-
compiler/**/__tests__/fixtures/**/*.flow.js
2221
compiler/**/.next
2322

2423
# contains invalid graphql`...` which results in a promise rejection error from `yarn prettier-all`.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// @flow @compilationMode(infer)
1+
// @flow @compilationMode(infer)
22
export default component Foo(bar: number) {
33
return <Bar bar={bar} />;
44
}
55

6-
function shouldNotCompile() {}
6+
function shouldNotCompile() {}

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/destructuring-with-typecast-as-default-value.flow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ function Component(props) {
77
export const FIXTURE_ENTRYPOINT = {
88
fn: Component,
99
params: [{y: []}],
10-
};
10+
};
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// @flow @gating
22
component Foo(ref: React.RefSetter<Controls>) {
3-
return <Bar ref={ref}/>;
4-
}
3+
return <Bar ref={ref} />;
4+
}

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/gating-with-hoisted-type-reference.flow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow @gating
2-
import { memo } from "react";
2+
import {memo} from 'react';
33

44
type Props = React.ElementConfig<typeof Component>;
55

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// @flow @compilationMode(infer)
1+
// @flow @compilationMode(infer)
22
export default hook useFoo(bar: number) {
33
return [bar];
44
}

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-types-through-type-cast.flow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ export const FIXTURE_ENTRYPOINT = {
1414
fn: Component,
1515
params: [{}],
1616
isComponent: false,
17-
}
17+
};
Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
// @flow
2-
import { Stringify } from "shared-runtime";
2+
import {Stringify} from 'shared-runtime';
33

44
function Component({items}) {
5-
// Per the spec, <Foo value=<>{...}</> /> is valid.
6-
// But many tools don't allow fragments as jsx attribute values,
7-
// so we ensure not to emit them wrapped in an expression container
8-
return items.length > 0
9-
? (
10-
<Foo value={
11-
<>{items.map(item => <Stringify key={item.id} item={item} />)}</>
12-
}></Foo>
13-
)
14-
: null;
5+
// Per the spec, <Foo value=<>{...}</> /> is valid.
6+
// But many tools don't allow fragments as jsx attribute values,
7+
// so we ensure not to emit them wrapped in an expression container
8+
return items.length > 0 ? (
9+
<Foo
10+
value={
11+
<>
12+
{items.map(item => (
13+
<Stringify key={item.id} item={item} />
14+
))}
15+
</>
16+
}></Foo>
17+
) : null;
1518
}
1619

1720
function Foo({value}) {
18-
return <div>{value}</div>;
21+
return <div>{value}</div>;
1922
}
2023

2124
export const FIXTURE_ENTRYPOINT = {
22-
fn: Component,
23-
params: [{items: [{id: 1, name: 'One!'}]}],
24-
};
25+
fn: Component,
26+
params: [{items: [{id: 1, name: 'One!'}]}],
27+
};

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/type-alias-used-as-annotation_.flow.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ function TypeAliasUsedAsAnnotation() {
55
const fun = (f: Foo) => {
66
console.log(f);
77
};
8-
fun("hello, world");
8+
fun('hello, world');
99
}
1010

1111
export const FIXTURE_ENTRYPOINT = {
1212
fn: TypeAliasUsedAsAnnotation,
1313
params: [],
14-
};
14+
};

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/type-alias-used-as-variable-annotation_.flow.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
type Bar = string;
33
function TypeAliasUsedAsAnnotation() {
44
type Foo = Bar;
5-
const fun = (f) => {
5+
const fun = f => {
66
let g: Foo = f;
77
console.log(g);
88
};
9-
fun("hello, world");
9+
fun('hello, world');
1010
}
1111

12-
1312
export const FIXTURE_ENTRYPOINT = {
1413
fn: TypeAliasUsedAsAnnotation,
1514
params: [],
16-
};
15+
};

0 commit comments

Comments
 (0)