The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 15:45 UTC
chore(lint): enforce react/purity (#25038)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 25, 2026 at 21:12 UTC
1de64942be496d0f4b64416e9b125eebe2126cd7
10 files changed
+29
-8
apps/mobile/src/features/threads/ThreadArrangementSheet.tsx
+1
@@ -348,6 +348,7 @@ export function ThreadArrangementSheet(props: { onClose: () => void }) {
348
};
349
setPreview({ ...drag.current });
350
update(0);
351
+ // oxlint-disable-next-line react/purity -- runs in an event handler (oxc#27309)
352
let last = performance.now();
353
const tick = () => {
354
const current = drag.current;
apps/mobile/src/features/threads/thread-list-v2-items.tsx
+2
@@ -709,6 +709,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
709
const canUnsettle = variant === "slim";
710
// Keep time in state; cached render-time reads freeze the gate and trigger 50ms expiry loops.
711
const [snoozeGateClock, setSnoozeGateClock] = useState(() => ({ thread, now: Date.now() }));
712
+ // oxlint-disable-next-line react/purity -- Reseeds the snooze gate clock only in the render-phase adjustment that runs when the thread changes.
713
if (snoozeGateClock.thread !== thread) setSnoozeGateClock({ thread, now: Date.now() });
714
const snoozeGateNow = new Date(snoozeGateClock.now).toISOString();
715
const snoozeGateExpiryMs = props.snoozeSupported
@@ -730,6 +731,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
731
snoozed: snoozedRow,
732
});
733
const snoozePresets = useMemo(
734
+ // oxlint-disable-next-line react/purity -- The memo recomputes on the snoozePresetMinute tick, so preset times refresh every minute.
735
() => (swipeActions.secondary === "snooze" ? resolveSnoozePresets(new Date()) : ([] as const)),
736
// oxlint-disable-next-line react/memo-dependencies -- The minute tick refreshes relative snooze times while the row remains mounted.
737
[props.snoozePresetMinute, swipeActions.secondary],
apps/web/src/components/CommandPalette.tsx
+1
@@ -2060,6 +2060,7 @@ function OpenCommandPaletteDialog(props: {
2060
input: {
2061
projectId,
2062
title: inferProjectTitleFromPath(destinationPath),
2063
+ // oxlint-disable-next-line react/purity -- runs in an event handler (oxc#27309)
2064
createdAt: new Date().toISOString(),
2065
remoteUrl: addProjectCloneFlow.remoteUrl,
2066
destinationPath,
apps/web/src/components/CommandPaletteThreadItems.tsx
+1
@@ -164,6 +164,7 @@ export function useCommandPaletteThreadItems(input: {
164
const isOpen =
165
activeThread?.environmentId === thread.environmentId && activeThread.id === thread.id;
166
if (threadSearchQuery.trim().length > 0 && !threadSearchQuery.startsWith(">") && !isOpen) {
167
+ // oxlint-disable-next-line react/purity -- runs in an event handler (oxc#27309)
168
claimThreadOpen(thread.environmentId, thread.id, Date.now());
169
}
170
if (
apps/web/src/components/CustomSnoozeDialog.tsx
+11
-1
@@ -10,6 +10,7 @@ import { Button } from "./ui/button";
10
import { CalendarIcon } from "lucide-react";
11
import { Calendar } from "./ui/calendar";
12
import { weekStartsOn } from "../timestampFormat";
13
+import { useNowMinute } from "../hooks/useNowMinute";
14
import { Popover, PopoverTrigger, PopoverPopup } from "./ui/popover";
15
import { Input } from "./ui/input";
16
import { Label } from "./ui/label";
@@ -47,6 +48,12 @@ function finish(choice: SnoozeChoice | null) {
48
request?.resolve(choice);
49
}
50
51
+function startOfLocalDay(ms: number) {
52
+ const day = new Date(ms);
53
+ day.setHours(0, 0, 0, 0);
54
+ return day;
55
+}
56
+
57
export function CustomSnoozeDialogHost() {
58
const request = useRequest((state) => state.request);
59
useEffect(() => () => finish(null), []);
@@ -56,6 +63,9 @@ export function CustomSnoozeDialogHost() {
63
function CustomSnoozeDialog() {
64
const id = useId();
65
const [initial] = useState(() => new Date(Date.now() + 3_600_000));
66
+ const nowMinute = useNowMinute();
67
+ // Follows the clock so a dialog left open past midnight stops offering yesterday.
68
+ const today = startOfLocalDay(Date.parse(`${nowMinute}Z`));
69
const [mode, setMode] = useState<CustomSnoozeInput["mode"]>("date");
70
const [date, setDate] = useState(initial);
71
const [calendarOpen, setCalendarOpen] = useState(false);
@@ -137,7 +147,7 @@ function CustomSnoozeDialog() {
147
selected={date}
148
defaultMonth={date}
149
{...(weekStartsOn === undefined ? {} : { weekStartsOn })}
140
- disabled={{ before: new Date(new Date().setHours(0, 0, 0, 0)) }}
150
+ disabled={{ before: today }}
151
onSelect={(selected) => {
152
setDate(selected);
153
setCalendarOpen(false);
apps/web/src/components/Sidebar.tsx
+1
@@ -1174,6 +1174,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
1174
return thread ? threadSearchSubject(thread, null) : undefined;
1175
},
1176
foldSearchQuery(threadSearchQuery),
1177
+ // oxlint-disable-next-line react/purity -- Recency ranking samples the clock when the search matches change; the compiler recomputes it only then.
1178
Date.now(),
1179
// A list filter, as on mobile: a pick would move rows unexplained.
1180
{ picks: false },
apps/web/src/components/chat/useThreadLifecycle.tsx
+1
@@ -179,6 +179,7 @@ export function useThreadLifecycle(input: ThreadLifecycleInput) {
179
now: new Date().toISOString(),
180
}));
181
if (snoozeClockState.shell !== activeThreadShell) {
182
+ // oxlint-disable-next-line react/purity -- Reseeds the snooze clock only in the render-phase adjustment that runs when the shell changes.
183
setSnoozeClockState({ shell: activeThreadShell, now: new Date().toISOString() });
184
}
185
const snoozeClock = snoozeClockState.now;
apps/web/src/components/sidebar/SidebarThreadRow.tsx
+2
@@ -370,6 +370,7 @@ function SnoozeMenuButton(props: {
370
timestampFormat: TimestampFormat;
371
}) {
372
const { open, onOpenChange, onSnooze, timestampFormat } = props;
373
+ // oxlint-disable-next-line react/purity -- Presets are resolved only while the menu is open, so each opening reads a fresh time.
374
const presets = open ? resolveSnoozePresets(new Date(), timestampFormat) : [];
375
return (
376
<Menu open={open} onOpenChange={onOpenChange}>
@@ -857,6 +858,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
858
now: new Date().toISOString(),
859
}));
860
if (snoozeGateClock.thread !== thread) {
861
+ // oxlint-disable-next-line react/purity -- Reseeds the snooze gate clock only in the render-phase adjustment that runs when the thread changes.
862
setSnoozeGateClock({ thread, now: new Date().toISOString() });
863
}
864
const snoozeGateNow = snoozeGateClock.now;
apps/web/src/hooks/useThreadActions.ts
+4
-3
@@ -723,9 +723,9 @@ export function useThreadActions() {
723
);
724
}
725
const resolved = resolveThreadTarget(target);
726
- const wokeAt = resolved
727
- ? threadWokeAt(resolved.thread, { now: new Date().toISOString() })
728
- : null;
726
+ // oxlint-disable-next-line react/purity -- runs in an event handler (oxc#27309)
727
+ const nowIso = new Date().toISOString();
728
+ const wokeAt = resolved ? threadWokeAt(resolved.thread, { now: nowIso }) : null;
729
const undoPlan = ThreadUndo.planThreadUndo("settle", resolved?.thread);
730
// An older unpin/snooze Undo would re-pin or re-snooze, and the server
731
// treats either as a promotion that un-settles; settling supersedes them.
@@ -836,6 +836,7 @@ export function useThreadActions() {
836
);
837
}
838
const resolved = resolveThreadTarget(target);
839
+ // oxlint-disable-next-line react/purity -- runs in an event handler (oxc#27309)
840
if (resolved && !canSnooze(resolved.thread, { now: new Date().toISOString() })) {
841
return AsyncResult.failure(
842
Cause.fail(
vite.config.ts
+5
-4
@@ -227,6 +227,7 @@ export default defineConfig({
227
"react/no-object-type-as-default-prop": "off",
228
"react/jsx-no-constructed-context-values": "off",
229
"react/memo-dependencies": "error",
230
+ "react/purity": "error",
231
"react/immutability": "error",
232
"react/no-array-index-key": "error",
233
"react/no-unstable-nested-components": "error",
@@ -580,10 +581,10 @@ export default defineConfig({
581
"react/jsx-no-constructed-context-values": "off",
582
"react/memo-dependencies": "error",
583
"react/preserve-manual-memoization": "error",
583
- // oxlint 1.88 treats `new Date()` as impure (oxc#26894) and also flags it inside event
584
- // handlers (oxc#27309). The compiler we ship (oxc-transform-react) still compiles
585
- // those files, and reactCompilerCoverage.test.ts fails on real bailouts.
586
- "react/purity": "warn",
584
+ // Render-time clock reads use @t3tools/client-runtime/clock or state seeded with the
585
+ // time; any other read carries a suppression that says why. oxlint also flags time reads
586
+ // inside event handlers (oxc#27309); those suppressions cite it.
587
+ "react/purity": "error",
588
"react/refs": "error",
589
"react/set-state-in-effect": "error",
590
"react/set-state-in-render": "error",