Skip to content

Commit c44d34a

Browse files
authored
chore(repo,ui): Enable the React Compiler lint rules (#10526)
1 parent 50c1e51 commit c44d34a

39 files changed

Lines changed: 679 additions & 201 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/ui': patch
3+
---
4+
5+
Fix custom OAuth provider names and icons incorrectly carrying over from a previously loaded environment.

‎eslint.config.mjs‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -586,12 +586,6 @@ export default tseslint.config([
586586
rules: {
587587
...pluginReactHooks.configs.recommended.rules,
588588
'react-hooks/rules-of-hooks': 'warn',
589-
// Turned off while upgrading eslint-plugin-react-hooks to v7, which added these to the recommended preset.
590-
// They are not meant to stay off; they will be enabled in follow-up changes.
591-
'react-hooks/immutability': 'off',
592-
'react-hooks/preserve-manual-memoization': 'off',
593-
'react-hooks/refs': 'off',
594-
'react-hooks/set-state-in-effect': 'off',
595589
},
596590
},
597591
{
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"src/react/ClerkProvider.tsx": {
3+
"react-hooks/set-state-in-effect": {
4+
"count": 1
5+
}
6+
}
7+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"src/native-components/useAuthViewState.ts": {
3+
"react-hooks/set-state-in-effect": {
4+
"count": 1
5+
}
6+
},
7+
"src/provider/ClerkProvider.tsx": {
8+
"react-hooks/refs": {
9+
"count": 2
10+
}
11+
}
12+
}

‎packages/mosaic/eslint-suppressions.json‎

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
2+
"src/blocks/destructive/destructive.tsx": {
3+
"react-hooks/set-state-in-effect": {
4+
"count": 1
5+
}
6+
},
27
"src/components/dialog/dialog.tsx": {
38
"@typescript-eslint/consistent-type-assertions": {
49
"count": 1
@@ -9,6 +14,11 @@
914
"count": 1
1015
}
1116
},
17+
"src/components/form/use-form.ts": {
18+
"react-hooks/refs": {
19+
"count": 1
20+
}
21+
},
1222
"src/components/icon/icon.tsx": {
1323
"@typescript-eslint/consistent-type-assertions": {
1424
"count": 1
@@ -22,13 +32,31 @@
2232
"src/components/profile/profile.tsx": {
2333
"@typescript-eslint/consistent-type-assertions": {
2434
"count": 1
35+
},
36+
"react-hooks/set-state-in-effect": {
37+
"count": 1
38+
}
39+
},
40+
"src/features/api-keys/api-keys-table.model.ts": {
41+
"react-hooks/refs": {
42+
"count": 1
43+
}
44+
},
45+
"src/features/organization-profile/organization-profile-members-panel/members-table-tab.model.ts": {
46+
"react-hooks/refs": {
47+
"count": 1
2548
}
2649
},
2750
"src/features/reverification/use-reverification-with-state.ts": {
2851
"@typescript-eslint/consistent-type-assertions": {
2952
"count": 1
3053
}
3154
},
55+
"src/features/switcher/switcher.view.tsx": {
56+
"react-hooks/refs": {
57+
"count": 8
58+
}
59+
},
3260
"src/features/user-profile/user-profile-web3-wallets-section/user-profile-solana-wallet.model.ts": {
3361
"boundaries/dependencies": {
3462
"count": 1
@@ -39,6 +67,21 @@
3967
"count": 1
4068
}
4169
},
70+
"src/hooks/use-debounced-async.ts": {
71+
"react-hooks/set-state-in-effect": {
72+
"count": 1
73+
}
74+
},
75+
"src/hooks/use-in-view.ts": {
76+
"react-hooks/refs": {
77+
"count": 1
78+
}
79+
},
80+
"src/hooks/use-spin-delay.ts": {
81+
"react-hooks/set-state-in-effect": {
82+
"count": 1
83+
}
84+
},
4285
"src/localization/context.tsx": {
4386
"@typescript-eslint/consistent-type-assertions": {
4487
"count": 1
@@ -69,12 +112,46 @@
69112
"count": 2
70113
}
71114
},
115+
"src/machine/use-machine.ts": {
116+
"react-hooks/refs": {
117+
"count": 11
118+
}
119+
},
120+
"src/primitives/autocomplete/autocomplete-root.tsx": {
121+
"react-hooks/refs": {
122+
"count": 1
123+
}
124+
},
125+
"src/primitives/combobox/combobox-root.tsx": {
126+
"react-hooks/refs": {
127+
"count": 3
128+
},
129+
"react-hooks/set-state-in-effect": {
130+
"count": 1
131+
}
132+
},
133+
"src/primitives/dialog/dialog-popup.tsx": {
134+
"react-hooks/refs": {
135+
"count": 2
136+
}
137+
},
72138
"src/primitives/dialog/dialog-trigger.tsx": {
73139
"@typescript-eslint/consistent-type-assertions": {
74140
"count": 1
75141
}
76142
},
143+
"src/primitives/drawer/drawer-root.tsx": {
144+
"react-hooks/refs": {
145+
"count": 3
146+
}
147+
},
77148
"src/primitives/drawer/use-drawer-drag.ts": {
149+
"react-hooks/refs": {
150+
"count": 1
151+
},
152+
"react-hooks/set-state-in-effect": {
153+
"count": 1
154+
},
78155
"sonarjs/cognitive-complexity": {
79156
"count": 1
80157
}
@@ -84,6 +161,11 @@
84161
"count": 1
85162
}
86163
},
164+
"src/primitives/file-upload/use-object-url.ts": {
165+
"react-hooks/set-state-in-effect": {
166+
"count": 1
167+
}
168+
},
87169
"src/primitives/hooks/use-data-table.ts": {
88170
"@typescript-eslint/consistent-type-assertions": {
89171
"count": 1
@@ -92,6 +174,14 @@
92174
"src/primitives/hooks/use-focus-target.ts": {
93175
"@typescript-eslint/consistent-type-assertions": {
94176
"count": 2
177+
},
178+
"react-hooks/refs": {
179+
"count": 1
180+
}
181+
},
182+
"src/primitives/menu/menu-root.tsx": {
183+
"react-hooks/refs": {
184+
"count": 1
95185
}
96186
},
97187
"src/primitives/menu/menu-trigger.tsx": {
@@ -104,6 +194,47 @@
104194
"count": 1
105195
}
106196
},
197+
"src/primitives/popover/popover-root.tsx": {
198+
"react-hooks/refs": {
199+
"count": 1
200+
}
201+
},
202+
"src/primitives/portal/portal.tsx": {
203+
"react-hooks/set-state-in-effect": {
204+
"count": 1
205+
}
206+
},
207+
"src/primitives/select/select-root.tsx": {
208+
"react-hooks/refs": {
209+
"count": 4
210+
},
211+
"react-hooks/set-state-in-effect": {
212+
"count": 1
213+
}
214+
},
215+
"src/primitives/tabs/tabs-root.tsx": {
216+
"react-hooks/refs": {
217+
"count": 1
218+
}
219+
},
220+
"src/primitives/toast/toast-provider.tsx": {
221+
"react-hooks/refs": {
222+
"count": 5
223+
},
224+
"react-hooks/set-state-in-effect": {
225+
"count": 1
226+
}
227+
},
228+
"src/primitives/toast/toast-root.tsx": {
229+
"react-hooks/set-state-in-effect": {
230+
"count": 1
231+
}
232+
},
233+
"src/primitives/tooltip/tooltip-root.tsx": {
234+
"react-hooks/refs": {
235+
"count": 1
236+
}
237+
},
107238
"src/primitives/utils/interaction-modality.ts": {
108239
"@typescript-eslint/consistent-type-assertions": {
109240
"count": 1
@@ -121,5 +252,10 @@
121252
"sonarjs/cognitive-complexity": {
122253
"count": 1
123254
}
255+
},
256+
"src/utils/feedback.tsx": {
257+
"react-hooks/refs": {
258+
"count": 2
259+
}
124260
}
125261
}

‎packages/mosaic/src/primitives/combobox/combobox-root.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ function ComboboxInner(props: ComboboxProps) {
7373
),
7474
);
7575

76+
const highlightFirstRef = useRef(false);
77+
7678
const setOpen = useCallback(
7779
(nextOpen: boolean) => {
7880
if (!nextOpen) {
@@ -107,7 +109,6 @@ function ComboboxInner(props: ComboboxProps) {
107109
const popupRef = useRef<HTMLDivElement | null>(null);
108110
const triggerRef = useRef<HTMLButtonElement | null>(null);
109111
const valuesByIndexRef = useRef<Map<number, string>>(new Map());
110-
const highlightFirstRef = useRef(false);
111112
const registerOption = useCallback((index: number) => {
112113
if (index === 0 && highlightFirstRef.current) {
113114
highlightFirstRef.current = false;

‎packages/mosaic/src/primitives/hooks/use-focus-target.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export function useInitialFocus(
3434
floatingContext: FloatingContext,
3535
): ResolvedInitialFocus {
3636
const elementRef = React.useRef<HTMLElement | null>(null);
37+
// eslint-disable-next-line react-hooks/preserve-manual-memoization -- this flags a real bug: openEvent is only updated through floatingContext.onOpenChange, so a controlled open after a controlled close passes initialFocus the previous interaction type
3738
return React.useMemo(() => {
3839
if (!open || initialFocus === undefined || initialFocus === true) {
3940
return 0;

‎packages/mosaic/src/primitives/select/select-root.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function SelectInner(props: SelectProps) {
132132
}
133133
setOpen(next);
134134
},
135-
[setOpen],
135+
[setOpen, setTouchOpen],
136136
);
137137

138138
const {

‎packages/mosaic/src/primitives/table/table-root.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const TableRoot = React.forwardRef<HTMLTableElement, TableRootProps>(func
6464
const [columnCount, registerColumn] = useCounter();
6565
const [rowHeaderColumns, registerRowHeaderColumn] = useRegistry<number>();
6666
const anchorRef = React.useRef<string | null>(null);
67-
const excluded = React.useMemo(() => new WeakSet<Element>(), []);
67+
const [excluded] = React.useState(() => new WeakSet<Element>());
6868

6969
const { tree } = bodyRows;
7070
const selectable = React.useMemo(

‎packages/mosaic/src/primitives/toast/toast-root.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ export const ToastRoot = React.forwardRef<HTMLDivElement, ToastRootProps>(functi
150150
const index = peers.indexOf(toast);
151151
const offsetY = peers.slice(0, Math.max(index, 0)).reduce((sum, t) => sum + (t.limited ? 0 : (t.height ?? 0)), 0);
152152

153-
const behind = frontmost !== undefined && peers.includes(frontmost) && index > peers.indexOf(frontmost);
153+
const frontmostIndex = frontmost === undefined ? -1 : peers.indexOf(frontmost);
154+
const behind = frontmostIndex !== -1 && index > frontmostIndex;
154155

155156
const contextValue = useMemo<ToastRootContextValue>(
156157
() => ({ toast, behind, rootId, titleId, descriptionId, setTitleId, setDescriptionId }),

0 commit comments

Comments
 (0)