Skip to content

Commit 41ecbad

Browse files
authored
Enable prettier for some blocklisted fixtures with invalid GraphQL (#30425)
The invalid GraphQL in these fixtures somehow causes an unhandled promise rejection error when running `yarn prettier-all`. This fixes that issue by making the GraphQL valid.
1 parent ab7c166 commit 41ecbad

17 files changed

+159
-60
lines changed

.prettierignore

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,6 @@ compiler/**/.next
2222

2323
# contains invalid graphql`...` which results in a promise rejection error from `yarn prettier-all`.
2424
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-kitchensink.js
25-
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/destructuring-mixed-scope-and-local-variables-with-default.js
26-
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/destructuring-mixed-scope-declarations-and-locals.js
27-
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-kitchensink.js
28-
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hook-inside-logical-expression.js
29-
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/optional-call-logical.js
30-
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/readonly-object-method-calls-mutable-lambda.js
31-
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/readonly-object-method-calls.js
32-
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/tagged-template-in-hook.js
33-
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/tagged-template-literal.js
3425

3526
compiler/crates
3627
compiler/apps/playground/public

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/destructuring-mixed-scope-and-local-variables-with-default.expect.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@ function useFragment(_arg1, _arg2) {
1313
}
1414

1515
function Component(props) {
16-
const post = useFragment(graphql`...`, props.post);
16+
const post = useFragment(
17+
graphql`
18+
fragment F on T {
19+
id
20+
}
21+
`,
22+
props.post
23+
);
1724
const allUrls = [];
1825
// `media` and `urls` are exported from the scope that will wrap this code,
1926
// but `comments` is not (it doesn't need to be memoized, bc the callback
@@ -59,7 +66,11 @@ function Component(props) {
5966
const $ = _c(9);
6067
let t0;
6168
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
62-
t0 = graphql`...`;
69+
t0 = graphql`
70+
fragment F on T {
71+
id
72+
}
73+
`;
6374
$[0] = t0;
6475
} else {
6576
t0 = $[0];

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/destructuring-mixed-scope-and-local-variables-with-default.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ function useFragment(_arg1, _arg2) {
99
}
1010

1111
function Component(props) {
12-
const post = useFragment(graphql`...`, props.post);
12+
const post = useFragment(
13+
graphql`
14+
fragment F on T {
15+
id
16+
}
17+
`,
18+
props.post
19+
);
1320
const allUrls = [];
1421
// `media` and `urls` are exported from the scope that will wrap this code,
1522
// but `comments` is not (it doesn't need to be memoized, bc the callback

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/destructuring-mixed-scope-declarations-and-locals.expect.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33

44
```javascript
55
function Component(props) {
6-
const post = useFragment(graphql`...`, props.post);
6+
const post = useFragment(
7+
graphql`
8+
fragment F on T {
9+
id
10+
}
11+
`,
12+
props.post
13+
);
714
const allUrls = [];
815
// `media` and `urls` are exported from the scope that will wrap this code,
916
// but `comments` is not (it doesn't need to be memoized, bc the callback
@@ -31,7 +38,14 @@ function Component(props) {
3138
import { c as _c } from "react/compiler-runtime";
3239
function Component(props) {
3340
const $ = _c(4);
34-
const post = useFragment(graphql`...`, props.post);
41+
const post = useFragment(
42+
graphql`
43+
fragment F on T {
44+
id
45+
}
46+
`,
47+
props.post,
48+
);
3549
let t0;
3650
if ($[0] !== post) {
3751
const allUrls = [];

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/destructuring-mixed-scope-declarations-and-locals.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
function Component(props) {
2-
const post = useFragment(graphql`...`, props.post);
2+
const post = useFragment(
3+
graphql`
4+
fragment F on T {
5+
id
6+
}
7+
`,
8+
props.post
9+
);
310
const allUrls = [];
411
// `media` and `urls` are exported from the scope that will wrap this code,
512
// but `comments` is not (it doesn't need to be memoized, bc the callback

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hook-inside-logical-expression.expect.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33

44
```javascript
55
function Component(props) {
6-
const user = useFragment(graphql`...`, props.user) ?? {};
6+
const user =
7+
useFragment(
8+
graphql`
9+
fragment F on T {
10+
id
11+
}
12+
`,
13+
props.user
14+
) ?? {};
715
return user.name;
816
}
917

@@ -13,7 +21,15 @@ function Component(props) {
1321
1422
```javascript
1523
function Component(props) {
16-
const user = useFragment(graphql`...`, props.user) ?? {};
24+
const user =
25+
useFragment(
26+
graphql`
27+
fragment F on T {
28+
id
29+
}
30+
`,
31+
props.user,
32+
) ?? {};
1733
return user.name;
1834
}
1935

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
function Component(props) {
2-
const user = useFragment(graphql`...`, props.user) ?? {};
2+
const user =
3+
useFragment(
4+
graphql`
5+
fragment F on T {
6+
id
7+
}
8+
`,
9+
props.user
10+
) ?? {};
311
return user.name;
412
}

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/optional-call-logical.expect.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33

44
```javascript
55
function Component(props) {
6-
const item = useFragment(graphql`...`, props.item);
6+
const item = useFragment(
7+
graphql`
8+
fragment F on T {
9+
id
10+
}
11+
`,
12+
props.item
13+
);
714
return item.items?.map(item => renderItem(item)) ?? [];
815
}
916

@@ -15,7 +22,14 @@ function Component(props) {
1522
import { c as _c } from "react/compiler-runtime";
1623
function Component(props) {
1724
const $ = _c(2);
18-
const item = useFragment(graphql`...`, props.item);
25+
const item = useFragment(
26+
graphql`
27+
fragment F on T {
28+
id
29+
}
30+
`,
31+
props.item,
32+
);
1933
let t0;
2034
if ($[0] !== item.items) {
2135
t0 = item.items?.map(_temp) ?? [];
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
function Component(props) {
2-
const item = useFragment(graphql`...`, props.item);
2+
const item = useFragment(
3+
graphql`
4+
fragment F on T {
5+
id
6+
}
7+
`,
8+
props.item
9+
);
310
return item.items?.map(item => renderItem(item)) ?? [];
411
}

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/readonly-object-method-calls-mutable-lambda.expect.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
function Component(props) {
66
const x = makeObject();
77
const user = useFragment(
8-
graphql`fragment Component_user on User { ... }`,
8+
graphql`
9+
fragment Component_user on User {
10+
name
11+
}
12+
`,
913
props.user
1014
);
1115
const posts = user.timeline.posts.edges.nodes.map(node => {
@@ -28,7 +32,11 @@ function Component(props) {
2832
const $ = _c(3);
2933
const x = makeObject();
3034
const user = useFragment(
31-
graphql`fragment Component_user on User { ... }`,
35+
graphql`
36+
fragment Component_user on User {
37+
name
38+
}
39+
`,
3240
props.user,
3341
);
3442
const posts = user.timeline.posts.edges.nodes.map((node) => {

0 commit comments

Comments
 (0)