@devries-cameron20 / t3code-1 / commits / 92224ddfa2
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

chore(lint): reject use* functions that call no hooks (#21260)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 18, 2026 at 13:12 UTC 92224ddfa282761eb618662aaba57a0476beba0c
34 files changed +190 -68
apps/mobile/src/features/files/FileMarkdownPreview.tsx
+3 -3
@@ -5,7 +5,7 @@ import { useCallback, useMemo, useState } from "react";
5 import { RefreshControl, ScrollView, View } from "react-native";
6
7 import { tryOpenExternalUrl } from "../../lib/openExternalUrl";
8 -import { useFontFamily } from "../../lib/useFontFamily";
8 +import { FONT_FAMILIES } from "../../lib/fontFamilies";
9 import { resolveNativeMarkdownTypography } from "../../lib/appearancePreferences";
10 import { useUniwindTheme } from "../../lib/useUniwindTheme";
11 import {
@@ -45,8 +45,8 @@ export function useMarkdownPreviewStyles(): MarkdownPreviewStyles {
45 const codeBackground = theme["--color-md-code-bg"];
46 const codeText = theme["--color-md-code-text"];
47 const horizontalRule = theme["--color-md-hr"];
48 - const regularFontFamily = useFontFamily("regular");
49 - const boldFontFamily = useFontFamily("bold");
48 + const regularFontFamily = FONT_FAMILIES.regular;
49 + const boldFontFamily = FONT_FAMILIES.bold;
50
51 return useMemo(() => {
52 return {
apps/mobile/src/features/review/useReviewHeaderPresentation.android.ts
+1
@@ -1,5 +1,6 @@
1 import type { useReviewHeaderPresentation as useIosReviewHeaderPresentation } from "./useReviewHeaderPresentation";
2
3 +// oxlint-disable-next-line t3code/no-hookless-use-function -- Android stub of a hook; the iOS file calls hooks.
4 export function useReviewHeaderPresentation(
5 props: Parameters<typeof useIosReviewHeaderPresentation>[0],
6 ): ReturnType<typeof useIosReviewHeaderPresentation> {
apps/mobile/src/features/threads/NewTaskDraftScreen.tsx
+2 -2
@@ -28,7 +28,7 @@ import {
28 import Animated from "react-native-reanimated";
29 import { useSafeAreaInsets } from "react-native-safe-area-context";
30 import { useUniwindTheme } from "../../lib/useUniwindTheme";
31 -import { useFontFamily } from "../../lib/useFontFamily";
31 +import { FONT_FAMILIES } from "../../lib/fontFamilies";
32 import {
33 AuthOrchestrationOperateScope,
34 PROVIDER_SEND_TURN_MAX_ATTACHMENTS,
@@ -641,7 +641,7 @@ export function NewTaskDraftScreen(props: {
641
642 const theme = useUniwindTheme();
643 const foregroundColor = theme["--color-foreground"];
644 - const regularFontFamily = useFontFamily("regular");
644 + const regularFontFamily = FONT_FAMILIES.regular;
645 const bodyText = useScaledTextRole("body");
646
647 const lastInitialProjectRefRef = useRef(props.initialProjectRef);
apps/mobile/src/features/threads/ThreadFeed.tsx
+3 -3
@@ -112,7 +112,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
112 import Animated, { FadeIn, FadeInUp, type SharedValue } from "react-native-reanimated";
113 import { useUniwindTheme } from "../../lib/useUniwindTheme";
114 import { IOS_NAV_BAR_HEIGHT } from "../../lib/layoutMetrics";
115 -import { useFontFamily } from "../../lib/useFontFamily";
115 +import { FONT_FAMILIES } from "../../lib/fontFamilies";
116 import { scopedThreadKey } from "../../lib/scopedEntities";
117 import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";
118 import { tryOpenExternalUrl } from "../../lib/openExternalUrl";
@@ -861,8 +861,8 @@ function useMarkdownStyles(): MarkdownStyleSets {
861 const markdownUserFenceBg = theme["--color-md-user-fence-bg"];
862 const inlineSkillForeground = theme["--color-inline-skill-foreground"];
863 const userBubbleSkillForeground = theme["--color-user-bubble-skill-foreground"];
864 - const regularFontFamily = useFontFamily("regular");
865 - const boldFontFamily = useFontFamily("bold");
864 + const regularFontFamily = FONT_FAMILIES.regular;
865 + const boldFontFamily = FONT_FAMILIES.bold;
866
867 return useMemo(() => {
868 return {
apps/mobile/src/features/threads/ThreadGitControls.android.tsx
+3
@@ -9,10 +9,12 @@ export type { ThreadGitMenuProps } from "./ThreadGitControls";
9 type ThreadGitControlsProps = Parameters<typeof IosThreadGitControls>[0];
10 const EMPTY_HEADER_ITEMS: ReturnType<typeof useIosThreadGitRightHeaderItems> = [];
11
12 +// oxlint-disable-next-line t3code/no-hookless-use-function -- Android stub of a hook; the iOS file calls hooks.
13 export function useThreadGitRightHeaderItems(_props: ThreadGitControlsProps) {
14 return EMPTY_HEADER_ITEMS;
15 }
16
17 +// oxlint-disable-next-line t3code/no-hookless-use-function -- Android stub of a hook; the iOS file calls hooks.
18 export function useThreadGitCenterHeaderItems(_props: ThreadGitControlsProps) {
19 return EMPTY_HEADER_ITEMS;
20 }
@@ -25,6 +27,7 @@ export function ThreadGitMenu(_props: Parameters<typeof IosThreadGitMenu>[0]) {
27 return null;
28 }
29
30 +// oxlint-disable-next-line t3code/no-hookless-use-function -- Android stub of a hook; the iOS file calls hooks.
31 export function useThreadGitMenuDefinition(_props: Parameters<typeof IosThreadGitMenu>[0]) {
32 return null;
33 }
apps/mobile/src/features/threads/useThreadHeaderOptions.android.ts
+1
@@ -1,5 +1,6 @@
1 import type { useThreadHeaderOptions as useIosThreadHeaderOptions } from "./useThreadHeaderOptions";
2
3 +// oxlint-disable-next-line t3code/no-hookless-use-function -- Android stub of a hook; the iOS file calls hooks.
4 export function useThreadHeaderOptions(
5 props: Parameters<typeof useIosThreadHeaderOptions>[0],
6 ): ReturnType<typeof useIosThreadHeaderOptions> {
apps/mobile/src/lib/fontFamilies.ts new
+5
@@ -0,0 +1,5 @@
1 +export const FONT_FAMILIES = {
2 + regular: "DMSans-Regular",
3 + medium: "DMSans-Medium",
4 + bold: "DMSans-Bold",
5 +} as const;
apps/mobile/src/lib/useFontFamily.ts deleted
-9
@@ -1,9 +0,0 @@
1 -const FONT_FAMILIES = {
2 - regular: "DMSans-Regular",
3 - medium: "DMSans-Medium",
4 - bold: "DMSans-Bold",
5 -} as const;
6 -
7 -export function useFontFamily(weight: keyof typeof FONT_FAMILIES): string {
8 - return FONT_FAMILIES[weight];
9 -}
apps/mobile/src/native/NativeWorkspaceColumns.tsx
+2
@@ -1,10 +1,12 @@
1 import { Platform } from "react-native";
2 export const NATIVE_WORKSPACE_COLUMNS_SUPPORTED = Platform.OS === "ios" && Platform.isPad;
3
4 +// oxlint-disable-next-line t3code/no-hookless-use-function -- Non-iOS stub of a hook; the .ios.tsx file calls hooks.
5 export function useNativeWorkspaceColumnsReady() {
6 return true;
7 }
8
9 +// oxlint-disable-next-line t3code/no-hookless-use-function -- Non-iOS stub of a hook; the .ios.tsx file calls hooks.
10 export function useNativeWorkspaceColumnsSupported() {
11 return NATIVE_WORKSPACE_COLUMNS_SUPPORTED;
12 }
apps/mobile/src/native/T3ComposerEditor.ios.tsx
+2 -2
@@ -20,7 +20,7 @@ import { composerChipSizeSuffix, contextChipPresentation } from "../lib/composer
20 import { resolveMarkdownFileIcon } from "../lib/markdownLinks";
21 import { useUniwindTheme } from "../lib/useUniwindTheme";
22 import { createNativeComposerTheme } from "../lib/nativeComposerTheme";
23 -import { useFontFamily } from "../lib/useFontFamily";
23 +import { FONT_FAMILIES } from "../lib/fontFamilies";
24 import { useScaledTextRole } from "../features/settings/appearance/useScaledTextRole";
25 import {
26 acknowledgeComposerNativeEvent,
@@ -139,7 +139,7 @@ export function ComposerEditor({
139 const confirmedTokensRef = useRef(collectComposerInlineTokens(props.value));
140 const bodyText = useScaledTextRole("body");
141 const theme = useUniwindTheme();
142 - const fontFamily = useFontFamily("regular");
142 + const fontFamily = FONT_FAMILIES.regular;
143
144 useImperativeHandle(
145 ref,
apps/mobile/src/native/T3ComposerEditor.native.tsx
+2 -2
@@ -21,7 +21,7 @@ import { composerChipSizeSuffix, contextChipPresentation } from "../lib/composer
21 import { resolveMarkdownFileIcon } from "../lib/markdownLinks";
22 import { MOBILE_TYPOGRAPHY } from "../lib/typography";
23 import { useNativePaste } from "../lib/useNativePaste";
24 -import { useFontFamily } from "../lib/useFontFamily";
24 +import { FONT_FAMILIES } from "../lib/fontFamilies";
25 import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
26 import { useUniwindTheme } from "../lib/useUniwindTheme";
27 import { createNativeComposerTheme } from "../lib/nativeComposerTheme";
@@ -257,7 +257,7 @@ export function ComposerEditor({
257 selection: Platform.OS === "android" || systemColorsActive ? theme["--color-focus"] : null,
258 });
259 const resolvedTextStyle = StyleSheet.flatten(textStyle) ?? {};
260 - const regularFontFamily = useFontFamily("regular");
260 + const regularFontFamily = FONT_FAMILIES.regular;
261 return (
262 <TextInputWrapper onPaste={handlePaste} style={[{ minHeight: 0 }, style]}>
263 <NativeView
apps/mobile/src/native/T3ComposerEditor.tsx
+2 -2
@@ -2,7 +2,7 @@ import { TextInputWrapper } from "expo-paste-input";
2 import { useImperativeHandle, useRef } from "react";
3 import { TextInput, type TextInputInstance } from "react-native";
4
5 -import { useFontFamily } from "../lib/useFontFamily";
5 +import { FONT_FAMILIES } from "../lib/fontFamilies";
6 import { useScaledTextRole } from "../features/settings/appearance/useScaledTextRole";
7 import { useNativePaste } from "../lib/useNativePaste";
8 import type { ComposerEditorProps } from "./T3ComposerEditor.types";
@@ -23,7 +23,7 @@ export function ComposerEditor({
23 }: ComposerEditorProps) {
24 const inputRef = useRef<TextInputInstance>(null);
25 const bodyText = useScaledTextRole("body");
26 - const fontFamily = useFontFamily("regular");
26 + const fontFamily = FONT_FAMILIES.regular;
27 const handlePaste = useNativePaste((uris) => onPasteImages?.(uris));
28
29 useImperativeHandle(
apps/web/src/components/ChatView.tsx
+3 -3
@@ -3329,7 +3329,7 @@ export default function ChatView(props: ChatViewProps) {
3329 });
3330 };
3331 const scheduleComposerFocusStable = useStableCallback(scheduleComposerFocus);
3332 - const useArtifactTemplate = (template: CodexArtifactTemplate) => {
3332 + const insertArtifactTemplate = (template: CodexArtifactTemplate) => {
3333 const composer = composerRef.current;
3334 if (!composer) return;
3335
@@ -3345,7 +3345,7 @@ export default function ChatView(props: ChatViewProps) {
3345 }
3346 scheduleComposerFocus();
3347 };
3348 - const useArtifactTemplateStable = useStableCallback(useArtifactTemplate);
3348 + const insertArtifactTemplateStable = useStableCallback(insertArtifactTemplate);
3349 const sendAppMessage = async (text: string) => {
3350 if (!isServerThread || activeThreadId === null) {
3351 throw new Error("Messages from apps need a started thread.");
@@ -8018,7 +8018,7 @@ export default function ChatView(props: ChatViewProps) {
8018 }
8019 {...(!paintOnlyDisplayedTimeline
8020 ? {
8021 - onUseArtifactTemplate: useArtifactTemplateStable,
8021 + onUseArtifactTemplate: insertArtifactTemplateStable,
8022 onSendAppMessage: sendAppMessageStable,
8023 }
8024 : {})}
apps/web/src/components/DiffPanel.tsx
+1 -2
@@ -46,7 +46,7 @@ import { PREFERRED_HIGHLIGHTER } from "../lib/syntaxHighlighting";
46 import { areAllDiffFilesCollapsed, toggleAllDiffFiles } from "../lib/diffCollapse";
47 import { useWorkspaceMutationRefresh } from "../hooks/useWorkspaceMutationRefresh";
48 import { useProject, useThreadCheckpointSummaries, useQuietThreadShell } from "../state/entities";
49 -import { useClientSettings, useUpdateClientSettings } from "../hooks/useSettings";
49 +import { useClientSettings, updateClientSettings } from "../hooks/useSettings";
50 import { formatShortTimestamp } from "../timestampFormat";
51 import { DiffFilePathCopyButton } from "./DiffFilePathCopyButton";
52 import { DiffPanelLoadingState, DiffPanelShell, type DiffPanelMode } from "./DiffPanelShell";
@@ -204,7 +204,6 @@ export default function DiffPanel({
204 wordWrap: settings.wordWrap,
205 }));
206 const diffLayout = settings.diffLayout;
207 - const updateClientSettings = useUpdateClientSettings();
207 const [wordWrap, setWordWrap] = useState(settings.wordWrap);
208 const [diffIgnoreWhitespace, setDiffIgnoreWhitespace] = useState(settings.diffIgnoreWhitespace);
209 const [fileTreeOpen, setFileTreeOpen] = useLocalStorage(
apps/web/src/components/LegacySidebar.tsx
+5 -10
@@ -205,7 +205,7 @@ import { SidebarChromeFooter, SidebarChromeHeader } from "./sidebar/SidebarChrom
205 import { useCopyToClipboard } from "~/hooks/useCopyToClipboard";
206 import { useIsMobile } from "~/hooks/useMediaQuery";
207 import { CommandDialogTrigger } from "./ui/command";
208 -import { useClientSettings, useUpdateClientSettings } from "~/hooks/useSettings";
208 +import { useClientSettings, updateClientSettings } from "~/hooks/useSettings";
209 import { primaryServerKeybindingsAtom } from "../state/server";
210 import {
211 derivePhysicalProjectKey,
@@ -1277,7 +1277,6 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
1277 const updateThreadMetadata = useOrchestrationCommand(threadEnvironment.updateMetadata, {
1278 reportFailure: false,
1279 });
1280 - const updateSettings = useUpdateClientSettings();
1280 const router = useRouter();
1281 const queuePendingFileDrop = useSidebarPendingFileDropStore((s) => s.queuePendingFileDrop);
1282 const clearPendingFileDrop = useSidebarPendingFileDropStore((s) => s.clearPendingFileDrop);
@@ -2124,7 +2123,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
2123 } else {
2124 nextOverrides[overrideKey] = projectGroupingSelection;
2125 }
2127 - updateSettings({
2126 + updateClientSettings({
2127 sidebarProjectGroupingOverrides: nextOverrides,
2128 });
2129 closeProjectGroupingDialog();
@@ -2769,7 +2768,6 @@ interface SidebarProjectsContentProps {
2768 projectSortOrder: SidebarProjectSortOrder;
2769 threadSortOrder: SidebarThreadSortOrder;
2770 threadPreviewCount: SidebarThreadPreviewCount;
2772 - updateSettings: ReturnType<typeof useUpdateClientSettings>;
2771 openAddProject: () => void;
2772 isManualProjectSorting: boolean;
2773 projectDnDSensors: ReturnType<typeof useSensors>;
@@ -2813,7 +2811,6 @@ const SidebarProjectsContent = memo(function SidebarProjectsContent(
2811 projectSortOrder,
2812 threadSortOrder,
2813 threadPreviewCount,
2816 - updateSettings,
2814 openAddProject,
2815 isManualProjectSorting,
2816 projectDnDSensors,
@@ -2845,13 +2842,13 @@ const SidebarProjectsContent = memo(function SidebarProjectsContent(
2842 } = props;
2843
2844 const handleProjectSortOrderChange = (sortOrder: SidebarProjectSortOrder) => {
2848 - updateSettings({ sidebarProjectSortOrder: sortOrder });
2845 + updateClientSettings({ sidebarProjectSortOrder: sortOrder });
2846 };
2847 const handleThreadSortOrderChange = (sortOrder: SidebarThreadSortOrder) => {
2851 - updateSettings({ sidebarThreadSortOrder: sortOrder });
2848 + updateClientSettings({ sidebarThreadSortOrder: sortOrder });
2849 };
2850 const handleThreadPreviewCountChange = (count: SidebarThreadPreviewCount) => {
2854 - updateSettings({ sidebarThreadPreviewCount: count });
2851 + updateClientSettings({ sidebarThreadPreviewCount: count });
2852 };
2853
2854 return (
@@ -3246,7 +3243,6 @@ export default function LegacySidebar() {
3243 const sidebarThreadSortOrder = useClientSettings((s) => s.sidebarThreadSortOrder);
3244 const sidebarProjectSortOrder = useClientSettings((s) => s.sidebarProjectSortOrder);
3245 const sidebarThreadPreviewCount = useClientSettings((s) => s.sidebarThreadPreviewCount);
3249 - const updateSettings = useUpdateClientSettings();
3246 const handleNewThread = useNewThreadHandler();
3247 const { archiveThread, deleteThread, markThreadUnread } = useThreadActions();
3248 const { isMobile, setOpenMobile } = useSidebar();
@@ -3629,7 +3625,6 @@ export default function LegacySidebar() {
3625 projectSortOrder={sidebarProjectSortOrder}
3626 threadSortOrder={sidebarThreadSortOrder}
3627 threadPreviewCount={sidebarThreadPreviewCount}
3632 - updateSettings={updateSettings}
3628 openAddProject={openAddProjectCommandPalette}
3629 isManualProjectSorting={isManualProjectSorting}
3630 projectDnDSensors={projectDnDSensors}
apps/web/src/components/files/AttachmentFilePreview.tsx
+1 -2
@@ -16,7 +16,7 @@ import { MorphIcon } from "~/components/MorphIcon";
16 import { ScrollArea } from "~/components/ui/scroll-area";
17 import { toastManager } from "~/components/ui/toast";
18 import { useCopyToClipboard } from "~/hooks/useCopyToClipboard";
19 -import { useClientSettings, useUpdateClientSettings } from "~/hooks/useSettings";
19 +import { useClientSettings, updateClientSettings } from "~/hooks/useSettings";
20 import { cn } from "~/lib/utils";
21
22 import { AudioPreview } from "./AudioPreview";
@@ -159,7 +159,6 @@ export function AttachmentFilePreview(props: {
159 }, [url, needsText, revision, props.sizeBytes, props.file, refresh]);
160 const failure = error ?? (needsText ? contentError : null);
161 const wordWrap = useClientSettings((settings) => settings.wordWrap);
162 - const updateClientSettings = useUpdateClientSettings();
162 const showsRawText =
163 failure === null &&
164 needsText &&
apps/web/src/components/files/FilePreviewPanel.tsx
+1 -2
@@ -49,7 +49,7 @@ import { MediaVideoPlayer } from "~/components/media/MediaVideoPlayer";
49 import { MediaActions, type MediaActionSource } from "~/components/media/MediaActions";
50 import { MorphIcon } from "~/components/MorphIcon";
51 import { useRemoteOpenState } from "~/remoteOpen";
52 -import { useClientSettings, useUpdateClientSettings } from "~/hooks/useSettings";
52 +import { useClientSettings, updateClientSettings } from "~/hooks/useSettings";
53 import { useTheme } from "~/hooks/useTheme";
54 import { getLocalStorageItem, setLocalStorageItem, useLocalStorage } from "~/hooks/useLocalStorage";
55 import { useWorkspaceMutationRefresh } from "~/hooks/useWorkspaceMutationRefresh";
@@ -1084,7 +1084,6 @@ export default function FilePreviewPanel({
1084 : null;
1085 const canToggleRendered =
1086 previewPath !== null && attachment === undefined && renderedMode !== null;
1087 - const updateClientSettings = useUpdateClientSettings();
1087 const showsRawText =
1088 previewPath !== null &&
1089 file.data !== null &&
apps/web/src/components/onboarding/FirstRunGate.tsx
+2 -3
@@ -10,7 +10,7 @@ import {
10 useClientSettingsHydrationStatus,
11 } from "../../hooks/useSettings";
12 import { isLocalEnvironmentDisabled } from "../../localEnvironment";
13 -import { useCompleteOnboarding } from "../../onboarding/firstRun";
13 +import { completeOnboarding } from "../../onboarding/firstRun";
14 import {
15 isFirstRunWorkspaceProvenanceAuthoritative,
16 isFreshFirstRunWorkspace,
@@ -82,7 +82,6 @@ export function FirstRunGate({
82 const pathname = useLocation({ select: (location) => location.pathname });
83 const hydrationStatus = useClientSettingsHydrationStatus();
84 const hydrated = hydrationStatus === "ready";
85 - const completeOnboarding = useCompleteOnboarding();
85 const onboardingCompletedAt = useClientSettings((settings) => settings.onboardingCompletedAt);
86 const bootstrapped = useAllEnvironmentShellsBootstrapped();
87 const { environments, isReady: environmentCatalogReady } = useEnvironments();
@@ -160,7 +159,7 @@ export function FirstRunGate({
159 if (persistCompletion && onboardingCompletedAt === null) {
160 void completeOnboarding().catch(() => undefined);
161 }
163 - }, [completeOnboarding, decision, hydrated, onboardingCompletedAt, persistCompletion]);
162 + }, [decision, hydrated, onboardingCompletedAt, persistCompletion]);
163
164 useEffect(() => {
165 if (!enabled || decision !== "pending" || !hydrated) return;
apps/web/src/components/onboarding/WelcomeWizard.browser.test.tsx
+1 -1
@@ -27,7 +27,7 @@ vi.mock("../../state/use-atom-command", () => ({
27 ? mocks.createProject
28 : mocks.refresh,
29 }));
30 -vi.mock("../../onboarding/firstRun", () => ({ useCompleteOnboarding: () => mocks.complete }));
30 +vi.mock("../../onboarding/firstRun", () => ({ completeOnboarding: mocks.complete }));
31 vi.mock("../../state/entities", () => ({
32 useProjects: () => mocks.projects,
33 readProjects: () => mocks.projects,
apps/web/src/components/onboarding/WelcomeWizard.import.browser.test.tsx
+1 -1
@@ -57,7 +57,7 @@ vi.mock(import("../../cloud/publicConfig"), async (original) => ({
57 }));
58 vi.mock(import("../../onboarding/firstRun"), async (original) => ({
59 ...(await original()),
60 - useCompleteOnboarding: () => state.completeOnboarding,
60 + completeOnboarding: state.completeOnboarding,
61 }));
62 vi.mock(import("../../state/environments"), async (original) => {
63 const environment = (environmentId: string) => ({
apps/web/src/components/onboarding/WelcomeWizard.terminal.browser.test.tsx
+1 -1
@@ -114,7 +114,7 @@ vi.mock(import("../../onboarding/useProjectScans"), async (original) => ({
114 }));
115 vi.mock(import("../../onboarding/firstRun"), async (original) => ({
116 ...(await original()),
117 - useCompleteOnboarding: () => state.complete,
117 + completeOnboarding: state.complete,
118 }));
119 vi.mock(import("../../cloud/publicConfig"), async (original) => ({
120 ...(await original()),
apps/web/src/components/onboarding/WelcomeWizard.tsx
+1 -2
@@ -39,7 +39,7 @@ import { useLocalStorage } from "../../hooks/useLocalStorage";
39 import { hasCloudPublicConfig } from "../../cloud/publicConfig";
40 import { PRIVACY_POLICY_URL } from "../../legalLinks";
41 import { useT3ConnectAuthPrompt } from "../clerk/useT3ConnectAuthPrompt";
42 -import { useCompleteOnboarding } from "../../onboarding/firstRun";
42 +import { completeOnboarding } from "../../onboarding/firstRun";
43 import {
44 groupOnboardingProjects,
45 partitionOnboardingProjects,
@@ -116,7 +116,6 @@ export function WelcomeWizard({
116 readonly resumeEnvironmentId?: EnvironmentId | undefined;
117 readonly onDone: (projectRef?: ScopedProjectRef) => void | Promise<void>;
118 }) {
119 - const completeOnboarding = useCompleteOnboarding();
119 const [step, setStep] = useState<WizardStep>(resumeEnvironmentId ? "agents" : "connection");
120 const { environments } = useEnvironments();
121 const [selection, setSelection] = useState<ReadonlySet<EnvironmentId> | null>(null);
apps/web/src/components/pullRequest/PullRequestCodeTab.tsx
+1 -2
@@ -37,7 +37,7 @@ import {
37 } from "react";
38
39 import { useLocalStorage } from "~/hooks/useLocalStorage";
40 -import { useClientSettings, useUpdateClientSettings } from "~/hooks/useSettings";
40 +import { useClientSettings, updateClientSettings } from "~/hooks/useSettings";
41 import { useTheme } from "~/hooks/useTheme";
42 import { areAllDiffFilesCollapsed } from "~/lib/diffCollapse";
43 import { pullRequestFindingKey, type PullRequestFinding } from "./pullRequestDetail.logic";
@@ -281,7 +281,6 @@ function PullRequestCodeTab({
281 const effectiveFoldOverride =
282 foldOverride ?? (settings.diffFilesCollapsed ? "folded" : "expanded");
283 const diffLayout = settings.diffLayout;
284 - const updateClientSettings = useUpdateClientSettings();
284 const [wordWrap, setWordWrap] = useState(settings.wordWrap);
285 const [ignoreWhitespace, setIgnoreWhitespace] = useState(settings.diffIgnoreWhitespace);
286 const [fileTreeOpen, setFileTreeOpen] = useLocalStorage(
apps/web/src/components/settings/LoadBalancingSettings.tsx
+3 -4
@@ -3,7 +3,7 @@ import { resolveEnvironmentMachineKind } from "@t3tools/contracts";
3 import {
4 useClientSettings,
5 useClientSettingsHydrated,
6 - useUpdateClientSettings,
6 + updateClientSettings,
7 } from "~/hooks/useSettings";
8 import type { EnvironmentPresentation } from "~/state/environments";
9 import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select";
@@ -54,7 +54,6 @@ export function LoadBalancingSettings({
54 loadBalancingWeights: current.loadBalancingWeights,
55 }));
56 const settingsHydrated = useClientSettingsHydrated();
57 - const updateSettings = useUpdateClientSettings();
57
58 if (environments.length < 2) return null;
59
@@ -73,7 +72,7 @@ export function LoadBalancingSettings({
72 aria-label="Automatically balance load"
73 checked={settings.loadBalancingEnabled}
74 disabled={!settingsHydrated}
76 - onCheckedChange={(loadBalancingEnabled) => updateSettings({ loadBalancingEnabled })}
75 + onCheckedChange={(loadBalancingEnabled) => updateClientSettings({ loadBalancingEnabled })}
76 />
77 }
78 >
@@ -96,7 +95,7 @@ export function LoadBalancingSettings({
95 disabled={!settingsHydrated || !settings.loadBalancingEnabled}
96 onValueChange={(value) => {
97 if (value === null) return;
99 - updateSettings({
98 + updateClientSettings({
99 loadBalancingWeights: {
100 ...settings.loadBalancingWeights,
101 [environment.environmentId]: value,
apps/web/src/components/settings/SnapShotSettings.browser.test.tsx
+1 -1
@@ -54,7 +54,7 @@ vi.mock(import("../../hooks/useSettings"), async (original) => {
54 ...(await original()),
55 useClientSettings: (() =>
56 useSyncExternalStore(subscribe, () => settingsStore.current)) as never,
57 - useUpdateClientSettings: () => settingsStore.update as never,
57 + updateClientSettings: settingsStore.update as never,
58 };
59 });
60
apps/web/src/components/settings/SnapShotSettings.tsx
+2 -3
@@ -13,7 +13,7 @@ import * as Cause from "effect/Cause";
13 import { useEffect, useRef, useState } from "react";
14
15 import { useStableCallback } from "../../hooks/useStableCallback";
16 -import { useClientSettings, useUpdateClientSettings } from "../../hooks/useSettings";
16 +import { useClientSettings, updateClientSettings } from "../../hooks/useSettings";
17 import { getDesktopSnapShotBridge } from "../../lib/desktopSnapShot";
18 import {
19 readSnapShotSetupResume,
@@ -86,7 +86,6 @@ export function SnapShotSettings() {
86 snapShotShortcut: current.snapShotShortcut,
87 snapShotSound: current.snapShotSound,
88 }));
89 - const updateSettings = useUpdateClientSettings();
89 const keybindings = useAtomValue(primaryServerKeybindingsAtom);
90 const bridge = getDesktopSnapShotBridge();
91 const [state, setState] = useState<DesktopSnapShotState | null>(null);
@@ -226,7 +225,7 @@ export function SnapShotSettings() {
225 const save = async (patch: ClientSettingsPatch) => {
226 setSetupError(null);
227 try {
229 - await updateSettings(patch);
228 + await updateClientSettings(patch);
229 return await refreshState();
230 } catch (error) {
231 setSetupError(captureSettingsError("Couldn't save capture settings", error));
apps/web/src/hooks/useSettings.ts
+2 -2
@@ -728,8 +728,8 @@ export function useUpdatePrimarySettings() {
728 return useUpdateSettingsTarget(usePrimaryEnvironment()?.environmentId ?? null);
729 }
730
731 -export function useUpdateClientSettings() {
732 - return (patch: ClientSettingsPatch) => persistClientSettingsPatch(patch);
731 +export function updateClientSettings(patch: ClientSettingsPatch): Promise<void> {
732 + return persistClientSettingsPatch(patch);
733 }
734
735 export function __resetClientSettingsPersistenceForTests(): void {
apps/web/src/onboarding/firstRun.ts
+1 -5
@@ -1,11 +1,7 @@
1 import { ensureClientSettingsHydrated, persistClientSettingsUpdate } from "../hooks/useSettings";
2
3 -async function completeOnboarding(): Promise<void> {
3 +export async function completeOnboarding(): Promise<void> {
4 await ensureClientSettingsHydrated();
5 const onboardingCompletedAt = new Date().toISOString();
6 await persistClientSettingsUpdate((current) => ({ ...current, onboardingCompletedAt }));
7 }
8 -
9 -export function useCompleteOnboarding(): () => Promise<void> {
10 - return completeOnboarding;
11 -}
docs/internals/mobile-development.md
+3
@@ -79,3 +79,6 @@ manual `useMemo`/`useCallback`/`memo` in the same change. Most mobile bailouts a
79 `catch` or with `finally`, and refs read during render; see [Web UI](web-ui.md#react-compiler)
80 for the usual rewrites. Mobile runs `t3code/no-manual-memo` with `allowMemoHooks`, so memo
81 directives are errors but the hooks stay legal until `KNOWN_BAILOUTS` is empty.
82 +`t3code/no-hookless-use-function` rejects a `use*` function that calls no hook, since the compiler
83 +leaves it uncached. A platform stub of a real hook, such as an `.android.ts` file, keeps the hook
84 +name and suppresses the rule with a reason.
docs/internals/web-ui.md
+2 -1
@@ -68,7 +68,8 @@ scope when a value reaches plain function calls on both sides of a hook call. A
68 helper forces one, but hides the ordering problem. Fix the order instead: plain uses of a value go
69 before the hook, or the helper is inlined. A `use*` helper that calls no hook is compiled as a
70 plain function and caches nothing, so a derived-value helper reads its source hook itself instead
71 -of taking the value as an argument. Lint misses some bailouts, notably `try` with `finally` and
71 +of taking the value as an argument. `t3code/no-hookless-use-function` rejects a `use*` function
72 +that calls no hook. Lint misses some bailouts, notably `try` with `finally` and
73 `throw` inside `try`, so [`reactCompilerCoverage.test.ts`](../../apps/web/src/reactCompilerCoverage.test.ts)
74 compiles every file and fails on any skip. Async handlers rarely need `try`: an
75 atom command settles into a result, so cleanup can follow the `await`. `useStableCallback` still
oxlint-plugin-t3code/index.ts
+2
@@ -3,6 +3,7 @@ import { definePlugin } from "@oxlint/plugins";
3 import namespaceNodeImports from "./rules/namespace-node-imports.ts";
4 import noGlobalProcessRuntime from "./rules/no-global-process-runtime.ts";
5 import noHermesUnsupportedApis from "./rules/no-hermes-unsupported-apis.ts";
6 +import noHooklessUseFunction from "./rules/no-hookless-use-function.ts";
7 import noInlineSchemaCompile from "./rules/no-inline-schema-compile.ts";
8 import noLowValueComments from "./rules/no-low-value-comments.ts";
9 import noManualMemo from "./rules/no-manual-memo.ts";
@@ -28,6 +29,7 @@ export default definePlugin({
29 "namespace-node-imports": namespaceNodeImports,
30 "no-global-process-runtime": noGlobalProcessRuntime,
31 "no-hermes-unsupported-apis": noHermesUnsupportedApis,
32 + "no-hookless-use-function": noHooklessUseFunction,
33 "no-inline-schema-compile": noInlineSchemaCompile,
34 "no-low-value-comments": noLowValueComments,
35 "no-manual-effect-runtime-in-tests": noManualEffectRuntimeInTests,
oxlint-plugin-t3code/rules/no-hookless-use-function.test.ts new
+48
@@ -0,0 +1,48 @@
1 +import { describe } from "@effect/vitest";
2 +
3 +import { createOxlintRuleHarness } from "../test/utils.ts";
4 +
5 +const rule = createOxlintRuleHarness("t3code/no-hookless-use-function", {
6 + filename: "fixture.tsx",
7 +});
8 +
9 +describe("t3code/no-hookless-use-function", () => {
10 + rule.valid(
11 + "allows a hook that calls useState",
12 + `function useCount() { const [count] = useState(0); return count; }`,
13 + );
14 +
15 + rule.valid(
16 + "allows a hook that only calls use()",
17 + `const useTheme = () => { return use(ThemeContext); };`,
18 + );
19 +
20 + rule.valid(
21 + "allows a hook that calls a member hook",
22 + `const useStore = () => React.useContext(StoreContext);`,
23 + );
24 +
25 + rule.valid("allows a plain function", `function formatLabel(value) { return String(value); }`);
26 +
27 + rule.valid("allows names that only start with use", `function user() { return null; }`);
28 +
29 + rule.invalid(
30 + "reports a hook-less function declaration",
31 + `function useFontFamily(weight) { return FONT_FAMILIES[weight]; }`,
32 + );
33 +
34 + rule.invalid(
35 + "reports a hook-less arrow returning a closure",
36 + `const useUpdateSettings = () => (patch) => persist(patch);`,
37 + );
38 +
39 + rule.invalid(
40 + "reports a hook-less function expression",
41 + `const useCompleteOnboarding = function () { return completeOnboarding; };`,
42 + );
43 +
44 + rule.invalid(
45 + "reports a hook call that only happens inside a nested callback",
46 + `function useHandler() { return () => useState(0); }`,
47 + );
48 +});
oxlint-plugin-t3code/rules/no-hookless-use-function.ts new
+75
@@ -0,0 +1,75 @@
1 +import { defineRule, type ESTree } from "@oxlint/plugins";
2 +
3 +const HOOK_NAME = /^use[A-Z]/;
4 +// Bare `use` is React 19's `use(promise | context)`, which is a hook call too.
5 +const HOOK_CALLEE = /^use([A-Z]|$)/;
6 +
7 +type FunctionNode = ESTree.Function | ESTree.ArrowFunctionExpression;
8 +
9 +function isFunctionNode(node: ESTree.Node): node is FunctionNode {
10 + return (
11 + node.type === "FunctionDeclaration" ||
12 + node.type === "FunctionExpression" ||
13 + node.type === "ArrowFunctionExpression"
14 + );
15 +}
16 +
17 +function isHookCallee(callee: ESTree.Node): boolean {
18 + if (callee.type === "Identifier") return HOOK_CALLEE.test(callee.name);
19 + if (callee.type === "MemberExpression" && !callee.computed) {
20 + return callee.property.type === "Identifier" && HOOK_CALLEE.test(callee.property.name);
21 + }
22 + return false;
23 +}
24 +
25 +// A hook call inside a nested callback runs when the callback runs, not during render,
26 +// so it does not make the outer function a hook.
27 +function callsHook(node: unknown, root: unknown): boolean {
28 + if (typeof node !== "object" || node === null) return false;
29 + if (Array.isArray(node)) return node.some((child) => callsHook(child, root));
30 + if (!("type" in node) || typeof node.type !== "string") return false;
31 + const typed = node as ESTree.Node;
32 + if (typed !== root && isFunctionNode(typed)) return false;
33 + if (typed.type === "CallExpression" && isHookCallee(typed.callee)) return true;
34 + for (const [key, value] of Object.entries(typed)) {
35 + if (key === "parent") continue;
36 + if (callsHook(value, root)) return true;
37 + }
38 + return false;
39 +}
40 +
41 +export default defineRule({
42 + meta: {
43 + type: "problem",
44 + docs: {
45 + description:
46 + "Disallow use* functions that call no hooks; the React Compiler only compiles functions that do. Mirrors eslint-react's no-unnecessary-use-prefix, which oxlint does not ship.",
47 + },
48 + schema: [],
49 + },
50 + create(context) {
51 + const check = (name: string, fn: FunctionNode, reportNode: ESTree.Node) => {
52 + if (!HOOK_NAME.test(name)) return;
53 + if (callsHook(fn.body, fn)) return;
54 + context.report({
55 + node: reportNode,
56 + message: `"${name}" calls no hooks, so the React Compiler skips it and whatever it returns is rebuilt on every render. Rename it to a plain function, or read the hook it depends on inside it.`,
57 + });
58 + };
59 + return {
60 + FunctionDeclaration(node) {
61 + if (node.id) check(node.id.name, node, node.id);
62 + },
63 + VariableDeclarator(node) {
64 + if (node.id.type !== "Identifier" || node.init == null) return;
65 + if (
66 + node.init.type !== "ArrowFunctionExpression" &&
67 + node.init.type !== "FunctionExpression"
68 + ) {
69 + return;
70 + }
71 + check(node.id.name, node.init, node.id);
72 + },
73 + };
74 + },
75 +});
vite.config.ts
+7
@@ -377,6 +377,13 @@ export default defineConfig({
377 files: ["apps/mobile/src/**/*.{ts,tsx}"],
378 rules: { "t3code/no-manual-memo": ["error", { allowMemoHooks: true }] },
379 },
380 + {
381 + // The compiler only compiles a use* function that calls a hook; one that calls none is
382 + // silently left as a plain function, so whatever it returns loses its caching.
383 + files: ["apps/web/src/**/*.{ts,tsx}", "apps/mobile/src/**/*.{ts,tsx}"],
384 + excludeFiles: ["**/*.test.ts", "**/*.test.tsx"],
385 + rules: { "t3code/no-hookless-use-function": "error" },
386 + },
387 {
388 files: [
389 "apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx",