Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

feat(lint): enable eslint-plugin-react-compiler (#2260)

Andrey Goderb614647ce9a4
diff --git a/eslint.config.js b/eslint.config.js
index ca7fe28984..3e0f29b3b0 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -3,6 +3,7 @@
import js from "@eslint/js";
import tseslint from "typescript-eslint";
import eslintReact from "@eslint-react/eslint-plugin";
+import reactCompiler from "eslint-plugin-react-compiler";
import xdsPlugin from "./internal/eslint-plugin-xds/index.js";
/* global process */
@@ -71,15 +72,6 @@ export default tseslint.config(
}],
},
},
- // Test files — relax rules for test ergonomics
- {
- files: ["**/*.test.{ts,tsx}", "**/*.perf.test.{ts,tsx}"],
- rules: {
- "no-console": "off",
- "@typescript-eslint/no-non-null-assertion": "off",
- "@typescript-eslint/consistent-type-assertions": "off",
- },
- },
// Copyright header — all source files must have the Meta copyright notice
{
files: ["**/*.{ts,tsx}"],
@@ -113,8 +105,13 @@ export default tseslint.config(
// Children.*/cloneElement are already covered by @xds/no-react-introspection.
{
files: ["packages/core/src/**/*.{ts,tsx}"],
- plugins: eslintReact.configs.recommended.plugins,
+ plugins: {
+ ...eslintReact.configs.recommended.plugins,
+ 'react-compiler': reactCompiler,
+ },
rules: {
+ // React Compiler compatibility
+ 'react-compiler/react-compiler': reactSeverity,
// React fundamentals
'@eslint-react/rules-of-hooks': reactSeverity,
'@eslint-react/purity': reactSeverity,
@@ -174,4 +171,15 @@ export default tseslint.config(
'@eslint-react/web-api-no-leaked-fetch': reactSeverity,
},
},
+ // Test files — relax rules for test ergonomics (must be after React rules
+ // block so it overrides react-compiler/react-compiler)
+ {
+ files: ["**/*.test.{ts,tsx}", "**/*.perf.test.{ts,tsx}"],
+ rules: {
+ "no-console": "off",
+ "@typescript-eslint/no-non-null-assertion": "off",
+ "@typescript-eslint/consistent-type-assertions": "off",
+ "react-compiler/react-compiler": "off",
+ },
+ },
);
diff --git a/package.json b/package.json
index 7c9bedf095..d049d8e30f 100644
--- a/package.json
+++ b/package.json
@@ -42,6 +42,7 @@
"@vitejs/plugin-react": "^4.3.0",
"@vitest/coverage-v8": "^2.1.0",
"eslint": "^10.4.0",
+ "eslint-plugin-react-compiler": "19.1.0-rc.2",
"husky": "^9.1.7",
"jscodeshift": "^17.3.0",
"jsdom": "^27.4.0",
diff --git a/packages/core/src/ButtonGroup/XDSButtonGroup.tsx b/packages/core/src/ButtonGroup/XDSButtonGroup.tsx
index c99c9a9ed7..d9ddcf3510 100644
--- a/packages/core/src/ButtonGroup/XDSButtonGroup.tsx
+++ b/packages/core/src/ButtonGroup/XDSButtonGroup.tsx
@@ -137,6 +137,7 @@ export function XDSButtonGroup({
<XDSSizeProvider value={size}>
<div
ref={(node: HTMLDivElement | null) => {
+ // eslint-disable-next-line react-compiler/react-compiler -- ref callback: assigning hook-returned ref
(listRef as React.MutableRefObject<HTMLElement | null>).current =
node;
if (typeof ref === 'function') {
diff --git a/packages/core/src/Chat/useXDSChatStreamScroll.ts b/packages/core/src/Chat/useXDSChatStreamScroll.ts
index 56029da316..87ff472476 100644
--- a/packages/core/src/Chat/useXDSChatStreamScroll.ts
+++ b/packages/core/src/Chat/useXDSChatStreamScroll.ts
@@ -150,6 +150,7 @@ export function useXDSChatStreamScroll({
const diff = target - el.scrollTop;
if (Math.abs(diff) < 0.5 && Math.abs(velocityRef.current) < 0.1) {
+ // eslint-disable-next-line react-compiler/react-compiler -- imperative DOM: scrollTop assignment
el.scrollTop = target;
animatingRef.current = false;
lastTickRef.current = undefined;
diff --git a/packages/core/src/DropdownMenu/XDSDropdownMenu.tsx b/packages/core/src/DropdownMenu/XDSDropdownMenu.tsx
index e1146cf5fa..e5882809ca 100644
--- a/packages/core/src/DropdownMenu/XDSDropdownMenu.tsx
+++ b/packages/core/src/DropdownMenu/XDSDropdownMenu.tsx
@@ -359,14 +359,15 @@ export function XDSDropdownMenu({
buttonRef as React.MutableRefObject<HTMLButtonElement | null>
).current = el;
popover.triggerRef(el);
- // Forward consumer ref from button config
const consumerRef = button.ref;
if (typeof consumerRef === 'function') {
consumerRef(el);
} else if (consumerRef) {
+ /* eslint-disable react-compiler/react-compiler -- ref callback: forwarding consumer ref object */
(
consumerRef as React.MutableRefObject<HTMLButtonElement | null>
).current = el;
+ /* eslint-enable react-compiler/react-compiler */
}
}}
tooltip={isOpen ? undefined : button.tooltip}
diff --git a/packages/core/src/Overlay/XDSOverlay.tsx b/packages/core/src/Overlay/XDSOverlay.tsx
index cd4a541199..08cb80126d 100644
--- a/packages/core/src/Overlay/XDSOverlay.tsx
+++ b/packages/core/src/Overlay/XDSOverlay.tsx
@@ -117,6 +117,7 @@ export function XDSOverlay({
}
const radius = getComputedStyle(firstChild).borderRadius;
if (radius && radius !== '0px') {
+ // eslint-disable-next-line react-compiler/react-compiler -- imperative DOM: syncing border-radius from child
el.style.borderRadius = radius;
}
}, []);
diff --git a/packages/core/src/Resizable/useXDSResizable.ts b/packages/core/src/Resizable/useXDSResizable.ts
index 695e317801..31e0b94c72 100644
--- a/packages/core/src/Resizable/useXDSResizable.ts
+++ b/packages/core/src/Resizable/useXDSResizable.ts
@@ -375,9 +375,9 @@ export function useXDSResizable(
config: UseXDSResizableSingleConfig | UseXDSResizableMultiConfig,
): ResizableRegion | Record<string, ResizableRegion> {
if ('regions' in config) {
- // eslint-disable-next-line @eslint-react/rules-of-hooks -- branch is determined by call-site type (stable per call site)
+ // eslint-disable-next-line @eslint-react/rules-of-hooks, react-compiler/react-compiler -- branch is determined by call-site type (stable per call site)
return useMultiResizable(config);
}
- // eslint-disable-next-line @eslint-react/rules-of-hooks -- branch is determined by call-site type (stable per call site)
+ // eslint-disable-next-line @eslint-react/rules-of-hooks, react-compiler/react-compiler -- branch is determined by call-site type (stable per call site)
return useSingleResizable(config);
}
diff --git a/packages/core/src/Table/plugins/columnResize/useXDSTableColumnResize.tsx b/packages/core/src/Table/plugins/columnResize/useXDSTableColumnResize.tsx
index b2dfa03bc4..419472d729 100644
--- a/packages/core/src/Table/plugins/columnResize/useXDSTableColumnResize.tsx
+++ b/packages/core/src/Table/plugins/columnResize/useXDSTableColumnResize.tsx
@@ -312,6 +312,7 @@ function ResizeHandle({
(dragging: boolean) => {
const table = tableRef.current;
if (table) {
+ // eslint-disable-next-line react-compiler/react-compiler -- imperative DOM: disable text selection during drag
table.style.userSelect = dragging ? 'none' : '';
}
},
diff --git a/packages/core/src/hooks/useClickableContainer.ts b/packages/core/src/hooks/useClickableContainer.ts
index 672f102191..272ecaca4e 100644
--- a/packages/core/src/hooks/useClickableContainer.ts
+++ b/packages/core/src/hooks/useClickableContainer.ts
@@ -179,6 +179,7 @@ export function useClickableContainer({
// handles navigation (client-side transitions in Next.js, etc.).
interactiveRef.current.click();
} else {
+ // eslint-disable-next-line react-compiler/react-compiler -- browser navigation API
window.location.href = href;
}
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 6417c12a07..60364dedb2 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -54,6 +54,9 @@ importers:
eslint:
specifier: ^10.4.0
version: 10.4.0([email protected])
+ eslint-plugin-react-compiler:
+ specifier: 19.1.0-rc.2
+ version: 19.1.0-rc.2([email protected]([email protected]))
husky:
specifier: ^9.1.7
version: 9.1.7
@@ -1091,6 +1094,13 @@ packages:
engines: {node: '>=6.0.0'}
hasBin: true
+ '@babel/[email protected]':
+ resolution: {integrity: sha512-nutsvktDItsNn4rpGItSNV2sz1XwS+nfU0Rg8aCx3W3NOKVzdMjJRu0O5OkgDp3ZGICSTbgRpxZoWsxoKRvbeA==}
+ engines: {node: '>=6.9.0'}
+ deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-methods instead.
+ peerDependencies:
+ '@babel/core': ^7.0.0-0
+
resolution: {integrity: sha512-D+OrJumc9McXNEBI/JmFnc/0uCM2/Y3PEBG3gfV3QIYkKv5pvnpzFrl1kYCrcHJP8nOeFB/SHi1IHz29pNGuew==}
engines: {node: '>=6.9.0'}
@@ -4250,6 +4260,12 @@ packages:
resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==}
engines: {node: '>=10'}
+ resolution: {integrity: sha512-oKalwDGcD+RX9mf3NEO4zOoUMeLvjSvcbbEOpquzmzqEEM2MQdp7/FY/Hx9NzmUwFzH1W9SKTz5fihfMldpEYw==}
+ engines: {node: ^14.17.0 || ^16.0.0 || >= 18.0.0}
+ peerDependencies:
+ eslint: '>=7'
+
resolution: {integrity: sha512-FHew3Pd39QuwHY0XCiE1mnss8jc7cq0LGwE2QElQ8cpQzOxghkxdb9RxiErjO81SvLoKEEc3c7akqd8qvjEj+w==}
engines: {node: '>=22.0.0'}
@@ -4507,9 +4523,15 @@ packages:
resolution: {integrity: sha512-ej4AhfhfL2Q2zpMmLo7U1Uv9+PyhIZpgQLGT1F9miIGmiCJIoCgSmczFdrc97mWT4kVY72KA+WnnhJ5pghSvSg==}
engines: {node: '>= 0.4'}
+ resolution: {integrity: sha512-0wUoCcLp+5Ev5pDW2OriHC2MJCbwLwuRx+gAqMTOkGKJJiBCLjtrvy4PWUGn6MIVefecRpzoOZ/UV6iGdOr+Cw==}
+
resolution: {integrity: sha512-If1T7lhfXnGlVLbnsmwerNB5cyJm2oIE8TN1UKEq6/OUX1nOGUhjXMpqAwZ1wkkn9Brda0VRyJEWOGT2GgVcAQ==}
+ resolution: {integrity: sha512-6pEjquH3rqaI6cYAXYPcz9MS4rY6R4ngRgrgfDshRptUZIc3lw0MCIJIGDj9++mfySOuPTHB4nrSW99BCvOPIA==}
+
resolution: {integrity: sha512-fWT40jJ/BtlzuyiiQS7lzNIlB5h6flVZoN8Jn8v5l987HL5dK9s+/4+py0FaBmeIEROC2zxt5qMLwXFTPLQ7BA==}
@@ -5945,6 +5967,15 @@ packages:
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
engines: {node: '>=10'}
+ resolution: {integrity: sha512-+hEiRIiPobgyuFlEojnqjJnhFvg4r/i3cqgcm67eehZf/WBaK3g6cD02YU9mtdVxZjv8CzCA9n/Rhrs3yAAvAw==}
+ engines: {node: '>=18.0.0'}
+ peerDependencies:
+ zod: ^3.24.4
+
+ resolution: {integrity: sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==}
+
resolution: {integrity: sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==}
@@ -6107,6 +6138,14 @@ snapshots:
dependencies:
'@babel/types': 7.29.0
+ dependencies:
+ '@babel/core': 7.29.0
+ '@babel/helper-create-class-features-plugin': 7.29.3(@babel/[email protected])
+ '@babel/helper-plugin-utils': 7.28.6
+ transitivePeerDependencies:
+ - supports-color
+
dependencies:
'@babel/core': 7.29.0
@@ -9026,6 +9065,18 @@ snapshots:
+ dependencies:
+ '@babel/core': 7.29.0
+ '@babel/parser': 7.29.3
+ '@babel/plugin-proposal-private-methods': 7.18.6(@babel/[email protected])
+ eslint: 10.4.0([email protected])
+ hermes-parser: 0.25.1
+ zod: 3.25.76
+ zod-validation-error: 3.5.4([email protected])
+ transitivePeerDependencies:
+ - supports-color
+
dependencies:
@@ -9352,8 +9403,14 @@ snapshots:
dependencies:
function-bind: 1.1.2
+
+ dependencies:
+ hermes-estree: 0.25.1
+
dependencies:
hermes-estree: 0.26.0
@@ -10970,4 +11027,10 @@ snapshots:
+ dependencies:
+ zod: 3.25.76
+
+