[BE] enable prettier for flow fixtures (#30426)

Since switching to `hermes-parser`, we can parse all flow syntax and no
longer need to exclude these fixtures from prettier.
This commit is contained in:
Jan Kassens 2024-07-24 10:59:40 -04:00 committed by GitHub
parent e902c45caf
commit ab2135c708
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
31 changed files with 98 additions and 93 deletions

View File

@ -18,7 +18,6 @@ packages/react-devtools-timeline/static
# react compiler
compiler/**/dist
compiler/**/__tests__/fixtures/**/*.expect.md
compiler/**/__tests__/fixtures/**/*.flow.js
compiler/**/.next
# contains invalid graphql`...` which results in a promise rejection error from `yarn prettier-all`.

View File

@ -8,6 +8,7 @@ export default component Foo(bar: number) {
}
function shouldNotCompile() {}
```
## Code

View File

@ -12,6 +12,7 @@ export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{y: []}],
};
```
## Code

View File

@ -4,8 +4,9 @@
```javascript
// @flow @gating
component Foo(ref: React.RefSetter<Controls>) {
return <Bar ref={ref}/>;
return <Bar ref={ref} />;
}
```
@ -15,8 +16,9 @@ component Foo(ref: React.RefSetter<Controls>) {
1 | // @flow @gating
> 2 | component Foo(ref: React.RefSetter<Controls>) {
| ^^^ Invariant: Encountered a function used before its declaration, which breaks Forget's gating codegen due to hoisting. Rewrite the reference to Foo_withRef to not rely on hoisting to fix this issue (2:2)
3 | return <Bar ref={ref}/>;
3 | return <Bar ref={ref} />;
4 | }
5 |
```

View File

@ -1,4 +1,4 @@
// @flow @gating
component Foo(ref: React.RefSetter<Controls>) {
return <Bar ref={ref}/>;
return <Bar ref={ref} />;
}

View File

@ -3,7 +3,7 @@
```javascript
// @flow @gating
import { memo } from "react";
import {memo} from 'react';
type Props = React.ElementConfig<typeof Component>;

View File

@ -1,5 +1,5 @@
// @flow @gating
import { memo } from "react";
import {memo} from 'react';
type Props = React.ElementConfig<typeof Component>;

View File

@ -18,7 +18,7 @@ export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{}],
isComponent: false,
}
};
```

View File

@ -14,4 +14,4 @@ export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{}],
isComponent: false,
}
};

View File

@ -3,19 +3,22 @@
```javascript
// @flow
import { Stringify } from "shared-runtime";
import {Stringify} from 'shared-runtime';
function Component({items}) {
// Per the spec, <Foo value=<>{...}</> /> is valid.
// But many tools don't allow fragments as jsx attribute values,
// so we ensure not to emit them wrapped in an expression container
return items.length > 0
? (
<Foo value={
<>{items.map(item => <Stringify key={item.id} item={item} />)}</>
return items.length > 0 ? (
<Foo
value={
<>
{items.map(item => (
<Stringify key={item.id} item={item} />
))}
</>
}></Foo>
)
: null;
) : null;
}
function Foo({value}) {
@ -26,6 +29,7 @@ export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{items: [{id: 1, name: 'One!'}]}],
};
```
## Code

View File

@ -1,17 +1,20 @@
// @flow
import { Stringify } from "shared-runtime";
import {Stringify} from 'shared-runtime';
function Component({items}) {
// Per the spec, <Foo value=<>{...}</> /> is valid.
// But many tools don't allow fragments as jsx attribute values,
// so we ensure not to emit them wrapped in an expression container
return items.length > 0
? (
<Foo value={
<>{items.map(item => <Stringify key={item.id} item={item} />)}</>
return items.length > 0 ? (
<Foo
value={
<>
{items.map(item => (
<Stringify key={item.id} item={item} />
))}
</>
}></Foo>
)
: null;
) : null;
}
function Foo({value}) {

View File

@ -3,12 +3,9 @@
```javascript
// @flow @validatePreserveExistingMemoizationGuarantees
import { identity } from "shared-runtime";
import {identity} from 'shared-runtime';
component Component(
disableLocalRef,
ref,
) {
component Component(disableLocalRef, ref) {
const localRef = useFooRef();
const mergedRef = useMemo(() => {
return disableLocalRef ? ref : identity(ref, localRef);

View File

@ -1,10 +1,7 @@
// @flow @validatePreserveExistingMemoizationGuarantees
import { identity } from "shared-runtime";
import {identity} from 'shared-runtime';
component Component(
disableLocalRef,
ref,
) {
component Component(disableLocalRef, ref) {
const localRef = useFooRef();
const mergedRef = useMemo(() => {
return disableLocalRef ? ref : identity(ref, localRef);

View File

@ -9,13 +9,14 @@ function TypeAliasUsedAsAnnotation() {
const fun = (f: Foo) => {
console.log(f);
};
fun("hello, world");
fun('hello, world');
}
export const FIXTURE_ENTRYPOINT = {
fn: TypeAliasUsedAsAnnotation,
params: [],
};
```
## Code

View File

@ -5,7 +5,7 @@ function TypeAliasUsedAsAnnotation() {
const fun = (f: Foo) => {
console.log(f);
};
fun("hello, world");
fun('hello, world');
}
export const FIXTURE_ENTRYPOINT = {

View File

@ -6,18 +6,18 @@
type Bar = string;
function TypeAliasUsedAsAnnotation() {
type Foo = Bar;
const fun = (f) => {
const fun = f => {
let g: Foo = f;
console.log(g);
};
fun("hello, world");
fun('hello, world');
}
export const FIXTURE_ENTRYPOINT = {
fn: TypeAliasUsedAsAnnotation,
params: [],
};
```
## Code

View File

@ -2,14 +2,13 @@
type Bar = string;
function TypeAliasUsedAsAnnotation() {
type Foo = Bar;
const fun = (f) => {
const fun = f => {
let g: Foo = f;
console.log(g);
};
fun("hello, world");
fun('hello, world');
}
export const FIXTURE_ENTRYPOINT = {
fn: TypeAliasUsedAsAnnotation,
params: [],

View File

@ -13,6 +13,7 @@ export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{name: 'Mofei'}],
};
```
## Code

View File

@ -3,9 +3,9 @@
```javascript
// @flow @enableUseTypeAnnotations
import { identity, makeArray } from "shared-runtime";
import {identity, makeArray} from 'shared-runtime';
function Component(props: { id: number }) {
function Component(props: {id: number}) {
const x = (makeArray(props.id): Array<number>);
const y = x.at(0);
return y;
@ -13,7 +13,7 @@ function Component(props: { id: number }) {
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ id: 42 }],
params: [{id: 42}],
};
```

View File

@ -1,7 +1,7 @@
// @flow @enableUseTypeAnnotations
import { identity, makeArray } from "shared-runtime";
import {identity, makeArray} from 'shared-runtime';
function Component(props: { id: number }) {
function Component(props: {id: number}) {
const x = (makeArray(props.id): Array<number>);
const y = x.at(0);
return y;
@ -9,5 +9,5 @@ function Component(props: { id: number }) {
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ id: 42 }],
params: [{id: 42}],
};

View File

@ -3,7 +3,7 @@
```javascript
// @flow @enableUseTypeAnnotations
import { identity } from "shared-runtime";
import {identity} from 'shared-runtime';
function Component(props: {id: number}) {
const x = identity(props.id);

View File

@ -1,5 +1,5 @@
// @flow @enableUseTypeAnnotations
import { identity } from "shared-runtime";
import {identity} from 'shared-runtime';
function Component(props: {id: number}) {
const x = identity(props.id);

View File

@ -3,9 +3,9 @@
```javascript
// @flow @enableUseTypeAnnotations
import { identity } from "shared-runtime";
import {identity} from 'shared-runtime';
function Component(props: { id: number }) {
function Component(props: {id: number}) {
const x: Array<number> = makeArray(props.id);
const y = x.at(0);
return y;
@ -17,7 +17,7 @@ function makeArray<T>(x: T): Array<T> {
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ id: 42 }],
params: [{id: 42}],
};
```

View File

@ -1,7 +1,7 @@
// @flow @enableUseTypeAnnotations
import { identity } from "shared-runtime";
import {identity} from 'shared-runtime';
function Component(props: { id: number }) {
function Component(props: {id: number}) {
const x: Array<number> = makeArray(props.id);
const y = x.at(0);
return y;
@ -13,5 +13,5 @@ function makeArray<T>(x: T): Array<T> {
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ id: 42 }],
params: [{id: 42}],
};

View File

@ -13,8 +13,8 @@ function Component(props) {
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: ["TodoAdd"],
isComponent: "TodoAdd",
params: ['TodoAdd'],
isComponent: 'TodoAdd',
};
```

View File

@ -9,6 +9,6 @@ function Component(props) {
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: ["TodoAdd"],
isComponent: "TodoAdd",
params: ['TodoAdd'],
isComponent: 'TodoAdd',
};