Skip to content

Commit 49f25bf

Browse files
authored
Update React Compiler to 1.0.0 (#13004)
* update react compiler to 1.0.0 * update test * cleanup
1 parent d85c9b9 commit 49f25bf

15 files changed

+52
-65
lines changed

eslint.config.mjs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ if (!process.features.typescript) {
1515
import path from "node:path";
1616
import { fileURLToPath } from "node:url";
1717

18-
import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
18+
import { fixupPluginRules } from "@eslint/compat";
1919
import { FlatCompat } from "@eslint/eslintrc";
2020
import js from "@eslint/js";
2121
import typescriptEslint from "@typescript-eslint/eslint-plugin";
2222
import tsParser from "@typescript-eslint/parser";
2323
import _import from "eslint-plugin-import";
2424
import * as mdx from "eslint-plugin-mdx";
25-
import reactCompiler from "eslint-plugin-react-compiler";
2625
import globals from "globals";
26+
import reactHooks from "eslint-plugin-react-hooks";
2727

2828
import localRules from "./eslint-local-rules/index.mjs";
2929

@@ -143,19 +143,16 @@ export default [
143143
],
144144
},
145145
},
146-
...fixupConfigRules(compat.extends("plugin:react-hooks/recommended")).map(
147-
(config) => ({
148-
...config,
149-
files: ["**/*.ts", "**/*.tsx"],
150-
ignores: ["**/__tests__/**/*.*", "**/*.d.ts"],
151-
})
152-
),
146+
{
147+
...reactHooks.configs.flat.recommended,
148+
files: ["src/react/**/*.ts", "src/react/**/*.tsx"],
149+
ignores: ["**/__tests__/**/*.*", "**/*.d.ts"],
150+
},
153151
{
154152
files: ["**/*.ts", "**/*.tsx"],
155153
ignores: ["**/__tests__/**/*.*", "**/*.d.ts"],
156154

157155
plugins: {
158-
"react-compiler": reactCompiler,
159156
...tsPlugins,
160157
},
161158

@@ -178,7 +175,6 @@ export default [
178175

179176
// rules for source files, but no tests
180177
rules: {
181-
"react-compiler/react-compiler": "error",
182178
"@typescript-eslint/consistent-type-exports": ["error"],
183179
"@typescript-eslint/no-import-type-side-effects": "error",
184180
"@typescript-eslint/no-restricted-types": [

package-lock.json

Lines changed: 29 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,13 @@
199199
"@typescript-eslint/types": "8.21.0",
200200
"@typescript-eslint/utils": "8.21.0",
201201
"ast-types": "0.16.1",
202-
"babel-plugin-react-compiler": "19.1.0-rc.2",
202+
"babel-plugin-react-compiler": "1.0.0",
203203
"eslint": "9.31.0",
204204
"eslint-import-resolver-typescript": "3.7.0",
205205
"eslint-plugin-import": "2.31.0",
206206
"eslint-plugin-local-rules": "3.0.2",
207207
"eslint-plugin-mdx": "^3.6.2",
208-
"eslint-plugin-react-compiler": "19.1.0-rc.2",
209-
"eslint-plugin-react-hooks": "5.1.0",
208+
"eslint-plugin-react-hooks": "7.0.1",
210209
"eslint-plugin-testing-library": "7.1.1",
211210
"expect": "29.7.0",
212211
"expect-type": "1.1.0",

src/react/hooks/__tests__/bundle.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test("test is running against source or ESM (in CI) build", () => {
1111

1212
test("test is running against uncompiled or compiled (in CI)", () => {
1313
if (isCI) {
14-
expect(reactCompilerVersion).toMatchInlineSnapshot(`"19.1.0-rc.2"`);
14+
expect(reactCompilerVersion).toMatchInlineSnapshot(`"1.0.0"`);
1515
} else {
1616
expect(reactCompilerVersion).toBe("uncompiled");
1717
}

src/react/hooks/internal/useDeepMemo.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ export function useDeepMemo<TValue>(
77
deps: DependencyList
88
) {
99
const ref = React.useRef<{ deps: DependencyList; value: TValue }>(void 0);
10+
// eslint-disable-next-line react-hooks/refs
1011
if (!ref.current || !equal(ref.current.deps, deps)) {
1112
ref.current = { value: memoFn(), deps };
1213
}
14+
// eslint-disable-next-line react-hooks/refs
1315
return ref.current.value;
1416
}

src/react/hooks/useBackgroundQuery.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,6 @@ export function useBackgroundQuery<
427427
"use no memo";
428428
return wrapHook(
429429
"useBackgroundQuery",
430-
// eslint-disable-next-line react-compiler/react-compiler
431430
useBackgroundQuery_,
432431
useApolloClient(typeof options === "object" ? options.client : undefined)
433432
)(query, options ?? ({} as any));

src/react/hooks/useFragment.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ export function useFragment<
182182
"use no memo";
183183
return wrapHook(
184184
"useFragment",
185-
// eslint-disable-next-line react-compiler/react-compiler
186185
useFragment_,
187186
useApolloClient(options.client)
188187
)(options);

src/react/hooks/useLazyQuery.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,11 @@ export function useLazyQuery<
492492
...eagerMethods,
493493
...result,
494494
client,
495+
// eslint-disable-next-line react-hooks/refs
495496
previousData: previousDataRef.current,
496497
variables: observable.variables,
497498
observable,
499+
// eslint-disable-next-line react-hooks/refs
498500
called: !!resultRef.current,
499501
};
500502
}, [client, observableResult, eagerMethods, observable]);

src/react/hooks/useQuery.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,6 @@ export function useQuery<
392392
"use no memo";
393393
return wrapHook(
394394
"useQuery",
395-
// eslint-disable-next-line react-compiler/react-compiler
396395
useQuery_,
397396
useApolloClient(typeof options === "object" ? options.client : undefined)
398397
)(query, options);
@@ -568,7 +567,6 @@ function useResult<TData, TVariables extends OperationVariables>(
568567
return;
569568
}
570569

571-
// eslint-disable-next-line react-compiler/react-compiler
572570
resultData.variables = observable.variables;
573571

574572
if (previous.data && !equal(previous.data, result.data)) {

src/react/hooks/useQueryRefHandlers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ export function useQueryRefHandlers<
8282

8383
return wrapHook(
8484
"useQueryRefHandlers",
85-
// eslint-disable-next-line react-compiler/react-compiler
8685
useQueryRefHandlers_,
8786
clientOrObsQuery
8887
)(queryRef);

0 commit comments

Comments
 (0)