Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] enable prettier for flow fixtures #30426

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
## Input

```javascript
// @flow @compilationMode(infer)
// @flow @compilationMode(infer)
export default component Foo(bar: number) {
return <Bar bar={bar} />;
}

function shouldNotCompile() {}

```

## Code
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow @compilationMode(infer)
// @flow @compilationMode(infer)
export default component Foo(bar: number) {
return <Bar bar={bar} />;
}

function shouldNotCompile() {}
function shouldNotCompile() {}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{y: []}],
};

```

## Code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ function Component(props) {
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{y: []}],
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
```javascript
// @flow @gating
component Foo(ref: React.RefSetter<Controls>) {
return <Bar ref={ref}/>;
return <Bar ref={ref} />;
}

```


Expand All @@ -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 |
```


Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @flow @gating
component Foo(ref: React.RefSetter<Controls>) {
return <Bar ref={ref}/>;
}
return <Bar ref={ref} />;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

```javascript
// @flow @gating
import { memo } from "react";
import {memo} from 'react';

type Props = React.ElementConfig<typeof Component>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @flow @gating
import { memo } from "react";
import {memo} from 'react';

type Props = React.ElementConfig<typeof Component>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Input

```javascript
// @flow @compilationMode(infer)
// @flow @compilationMode(infer)
export default hook useFoo(bar: number) {
return [bar];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @flow @compilationMode(infer)
// @flow @compilationMode(infer)
export default hook useFoo(bar: number) {
return [bar];
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{}],
isComponent: false,
}
};

```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{}],
isComponent: false,
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,33 @@

```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} />)}</>
}></Foo>
)
: null;
// 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} />
))}
</>
}></Foo>
) : null;
}

function Foo({value}) {
return <div>{value}</div>;
return <div>{value}</div>;
}

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{items: [{id: 1, name: 'One!'}]}],
fn: Component,
params: [{items: [{id: 1, name: 'One!'}]}],
};

```

## Code
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
// @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} />)}</>
}></Foo>
)
: null;
// 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} />
))}
</>
}></Foo>
) : null;
}

function Foo({value}) {
return <div>{value}</div>;
return <div>{value}</div>;
}

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{items: [{id: 1, name: 'One!'}]}],
};
fn: Component,
params: [{items: [{id: 1, name: 'One!'}]}],
};
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ function TypeAliasUsedAsAnnotation() {
const fun = (f: Foo) => {
console.log(f);
};
fun("hello, world");
fun('hello, world');
}

export const FIXTURE_ENTRYPOINT = {
fn: TypeAliasUsedAsAnnotation,
params: [],
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
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: [],
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{name: 'Mofei'}],
};

```

## Code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ function Component(props) {
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{name: 'Mofei'}],
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

```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;
}

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ id: 42 }],
params: [{id: 42}],
};

```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// @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;
}

export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{ id: 42 }],
params: [{id: 42}],
};
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Loading
Loading