TypeScript
fix(mobile): screen lists register with their header, enforced by lint (#24710)
Julius Marmingeebd29ca951e1
diff --git a/apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx b/apps/mobile/src/features/archive/ArchivedThreadsScreen.tsxindex 64443efaa83..90f722e5366 100644--- a/apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx+++ b/apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx@@ -1,3 +1,4 @@+import { NativeScrollView } from "../../native/NativeScrollViewMarker";import { Button } from "../../components/ui/Button";import type {EnvironmentProject,@@ -428,6 +429,7 @@ export function ArchivedThreadsScreen(props: {<SettingsScreenContent><GestureDetector gesture={archiveScrollGesture}><LegendList+ renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}className="flex-1"contentContainerStyle={{paddingBottom: 32,diff --git a/apps/mobile/src/features/files/FileTreeBrowser.tsx b/apps/mobile/src/features/files/FileTreeBrowser.tsxindex fc2620dbed6..bc38fde7946 100644--- a/apps/mobile/src/features/files/FileTreeBrowser.tsx+++ b/apps/mobile/src/features/files/FileTreeBrowser.tsx@@ -1,3 +1,4 @@+import { NativeScrollView } from "../../native/NativeScrollViewMarker";import { Button } from "../../components/ui/Button";import { LegendList } from "@legendapp/list/react-native";import type { ProjectEntry } from "@t3tools/contracts";@@ -221,6 +222,7 @@ export function FileTreeBrowser(props: {// Keep the list as direct screen content so UIKit can apply header insets.return (<LegendList+ renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}contentInsetStartAdjustment={headerInset}alwaysBounceVerticalclassName="flex-1"diff --git a/apps/mobile/src/features/pull-requests/PullRequestFiles.tsx b/apps/mobile/src/features/pull-requests/PullRequestFiles.tsxindex de287aa746b..f231479b098 100644--- a/apps/mobile/src/features/pull-requests/PullRequestFiles.tsx+++ b/apps/mobile/src/features/pull-requests/PullRequestFiles.tsx@@ -1,3 +1,4 @@+import { NativeScrollView } from "../../native/NativeScrollViewMarker";import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";import { AnimatedLegendList } from "@legendapp/list/reanimated";import {@@ -440,6 +441,7 @@ export function PullRequestFilesSheet({ route }: StaticScreenProps<PullRequestDi</Toolbar><ScreenContent><AnimatedLegendList+ renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}className="flex-1"data={parsed.kind === "files" ? groupByDirectory(parsed.files, collapsed) : []}keyExtractor={(item) => item.key}diff --git a/apps/mobile/src/features/settings/SettingsOpenSourceLicensesRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsOpenSourceLicensesRouteScreen.tsxindex eba94cdf3bd..e9774d37d4d 100644--- a/apps/mobile/src/features/settings/SettingsOpenSourceLicensesRouteScreen.tsx+++ b/apps/mobile/src/features/settings/SettingsOpenSourceLicensesRouteScreen.tsx@@ -1,3 +1,4 @@+import { NativeScrollView } from "../../native/NativeScrollViewMarker";import { SearchField } from "../../components/ui/SearchField";import { Toolbar } from "../../components/ui/Toolbar";import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";@@ -127,6 +128,7 @@ export function SettingsOpenSourceLicensesRouteScreen() {) : null}<LegendList+ renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}className="flex-1"contentContainerStyle={{paddingBottom: usesNativeMailSearchToolbardiff --git a/apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx b/apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsxindex 3238c5a501a..8a56f3c1606 100644--- a/apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx+++ b/apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx@@ -1,3 +1,4 @@+import { NativeScrollView } from "../../native/NativeScrollViewMarker";import { SearchField } from "../../components/ui/SearchField";import { Button } from "../../components/ui/Button";import { Toolbar } from "../../components/ui/Toolbar";@@ -449,6 +450,7 @@ export function BranchPickerScreen(props: {</ScrollView>) : (<LegendList+ renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}alwaysBounceVertical={false}automaticallyAdjustsScrollIndicatorInsetsautomaticallyAdjustKeyboardInsets={Platform.OS === "ios"}diff --git a/apps/mobile/src/features/threads/ThreadFeed.tsx b/apps/mobile/src/features/threads/ThreadFeed.tsxindex 70aa6f22a61..a292965a975 100644--- a/apps/mobile/src/features/threads/ThreadFeed.tsx+++ b/apps/mobile/src/features/threads/ThreadFeed.tsx@@ -3108,6 +3108,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {<PresentationSource identifier={fileShareSourceIdentifier} style={{ flex: 1 }}><View className="flex-1" onLayout={handleViewportLayout}><View className="flex-1">+ {/* oxlint-disable-next-line t3code/require-registered-list-scroll -- ThreadFeedScrollView is passed through the iOS-only spread below; the prop rejects undefined. */}<KeyboardAwareLegendListref={listRef}// LegendList cannot see adjustedContentInset; remount so initial positioning waits for UIKit attachment.diff --git a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsxindex d56f635a04a..29ba2f4fe24 100644--- a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx+++ b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx@@ -79,6 +79,7 @@ import {type ThreadListV2ListItem,} from "./threadListV2";import { useSelectWorkspaceDetail } from "../workspace/useSelectWorkspaceDetail";+import { NativeScrollView } from "../../native/NativeScrollViewMarker";type SidebarListItem =| ThreadListV2ListItem@@ -725,6 +726,7 @@ function ThreadNavigationSidebarPane(<SwipeableScrollGateProvider enabled={swipeEnabled}><GestureDetector gesture={sidebarScrollGesture}><AnimatedLegendList+ renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}itemLayoutAnimation={THREAD_SIDEBAR_ROW_LAYOUT}data={listItems}drawDistance={500}@@ -793,6 +795,7 @@ function ThreadNavigationSidebarPane() : (<SwipeableScrollGateProvider enabled={swipeEnabled}><GestureDetector gesture={sidebarScrollGesture}>+ {/* oxlint-disable-next-line t3code/require-registered-list-scroll -- Only the non-native workspace layout (Android and the fallback) renders this sidebar, which has no native header to register with. */}<AnimatedLegendListitemLayoutAnimation={THREAD_SIDEBAR_ROW_LAYOUT}data={listItems}diff --git a/apps/mobile/src/features/threads/ThreadPullRequestsSheet.tsx b/apps/mobile/src/features/threads/ThreadPullRequestsSheet.tsxindex a3eac3c42f4..6eb94d3c232 100644--- a/apps/mobile/src/features/threads/ThreadPullRequestsSheet.tsx+++ b/apps/mobile/src/features/threads/ThreadPullRequestsSheet.tsx@@ -50,6 +50,7 @@ export function ThreadPullRequestsSheet(const content = (<View className="flex-1 android:bg-sheet-solid ios:bg-screen">+ {/* oxlint-disable-next-line t3code/require-registered-list-scroll -- Sheet content; sheets sit outside workspace columns and keep their own header handling. */}<LegendListdata={lines}keyExtractor={linkedPullRequestKey}diff --git a/apps/mobile/src/features/threads/ThreadSettingsSheet.tsx b/apps/mobile/src/features/threads/ThreadSettingsSheet.tsxindex 154ecc91f52..030b317f41f 100644--- a/apps/mobile/src/features/threads/ThreadSettingsSheet.tsx+++ b/apps/mobile/src/features/threads/ThreadSettingsSheet.tsx@@ -1009,6 +1009,7 @@ function ThreadSettingsMainContent(props: {};return (+ // oxlint-disable-next-line t3code/require-registered-list-scroll -- Sheet content; sheets sit outside workspace columns and keep their own header handling.<AnimatedLegendListalwaysBounceVerticalautomaticallyAdjustsScrollIndicatorInsetsdiff --git a/apps/mobile/src/features/threads/thread-work-log.tsx b/apps/mobile/src/features/threads/thread-work-log.tsxindex 8e53aacbeaf..80e515aeec4 100644--- a/apps/mobile/src/features/threads/thread-work-log.tsx+++ b/apps/mobile/src/features/threads/thread-work-log.tsx@@ -705,6 +705,7 @@ function ThreadWorkGroupList(props: {return (<View style={{ height, overflow: "hidden" }}>+ {/* oxlint-disable-next-line t3code/require-registered-list-scroll -- Nested in a fixed-height card inside the thread feed, which owns the header's scroll view. */}<AnimatedLegendListref={listRef}data={props.activities}diff --git a/oxlint-plugin-t3code/index.ts b/oxlint-plugin-t3code/index.tsindex 999808515fc..acae1e75258 100644--- a/oxlint-plugin-t3code/index.ts+++ b/oxlint-plugin-t3code/index.ts@@ -15,6 +15,7 @@ import noMobileUniwindThemeEscapeHatches from "./rules/no-mobile-uniwind-theme-eimport noAmbiguousDetailNavigation from "./rules/no-ambiguous-detail-navigation.ts";import noMobilePullRequestGlyphLiterals from "./rules/no-mobile-pull-request-glyph-literals.ts";import noNativeTitleTooltip from "./rules/no-native-title-tooltip.ts";+import requireRegisteredListScroll from "./rules/require-registered-list-scroll.ts";import noOutsetStateIndicators from "./rules/no-outset-state-indicators.ts";import noPollingLoopInTests from "./rules/no-polling-loop-in-tests.ts";import noRawMcpRegistration from "./rules/no-raw-mcp-registration.ts";@@ -51,6 +52,7 @@ export default definePlugin({"no-ambiguous-detail-navigation": noAmbiguousDetailNavigation,"no-mobile-pull-request-glyph-literals": noMobilePullRequestGlyphLiterals,"no-native-title-tooltip": noNativeTitleTooltip,+ "require-registered-list-scroll": requireRegisteredListScroll,"no-outset-state-indicators": noOutsetStateIndicators,"no-polling-loop-in-tests": noPollingLoopInTests,"no-raw-mcp-registration": noRawMcpRegistration,diff --git a/oxlint-plugin-t3code/rules/require-registered-list-scroll.test.ts b/oxlint-plugin-t3code/rules/require-registered-list-scroll.test.tsnew file mode 100644index 00000000000..07b25f041d7--- /dev/null+++ b/oxlint-plugin-t3code/rules/require-registered-list-scroll.test.ts@@ -0,0 +1,32 @@+import { assert, describe } from "@effect/vitest";++import { createOxlintRuleHarness } from "../test/utils.ts";++const rule = createOxlintRuleHarness("t3code/require-registered-list-scroll", {+ filename: "fixture.tsx",+});++describe("t3code/require-registered-list-scroll", () => {+ rule.valid(+ "allows a list that renders through a registered scroll view",+ `const el = <LegendList data={rows} renderScrollComponent={NativeScrollView} />;`,+ );++ rule.valid(+ "allows a keyboard-aware list with its scroll view component",+ `const el = <KeyboardAwareLegendList data={rows} ScrollViewComponent={FeedScrollView} />;`,+ );++ rule.invalid(+ "reports a list given the other list's scroll prop",+ `const el = <LegendList data={rows} ScrollViewComponent={NativeScrollView} />;`,+ );++ rule.invalid(+ "reports a list with the default scroll view",+ `const el = <AnimatedLegendList data={rows} renderItem={renderRow} />;`,+ (output) => {+ assert.match(output, /header-registered scroll view/);+ },+ );+});diff --git a/oxlint-plugin-t3code/rules/require-registered-list-scroll.ts b/oxlint-plugin-t3code/rules/require-registered-list-scroll.tsnew file mode 100644index 00000000000..7645ea77c05--- /dev/null+++ b/oxlint-plugin-t3code/rules/require-registered-list-scroll.ts@@ -0,0 +1,40 @@+import { defineRule } from "@oxlint/plugins";++// LegendList takes a render function; KeyboardAwareLegendList takes the component itself.+const SCROLL_COMPONENT_PROP: Readonly<Record<string, string>> = {+ LegendList: "renderScrollComponent",+ AnimatedLegendList: "renderScrollComponent",+ KeyboardAwareLegendList: "ScrollViewComponent",+};++// A screen's list must scroll in a scroll view registered with its header, or the header loses+// its scroll-edge blur (and, on the iPhone Duo, the blur's reach under the vertical bar).+export default defineRule({+ meta: {+ type: "problem",+ docs: {+ description:+ "Require mobile lists to render through a header-registered scroll view (renderScrollComponent).",+ },+ },+ create(context) {+ return {+ JSXOpeningElement(node) {+ if (node.name.type !== "JSXIdentifier") return;+ const prop = SCROLL_COMPONENT_PROP[node.name.name];+ if (!prop) return;+ const registered = node.attributes.some(+ (attribute) =>+ attribute.type === "JSXAttribute" &&+ attribute.name.type === "JSXIdentifier" &&+ attribute.name.name === prop,+ );+ if (registered) return;+ context.report({+ node,+ message: `Pass ${prop} so the list scrolls in a header-registered scroll view: NativeScrollView on iOS, or a component wrapping NativeScrollViewMarker. A list nested in another scroll surface or sheet can suppress this with a reason.`,+ });+ },+ };+ },+});diff --git a/vite.config.ts b/vite.config.tsindex 164885182ed..63dd5266bf8 100644--- a/vite.config.ts+++ b/vite.config.ts@@ -439,7 +439,10 @@ export default defineConfig({},{files: ["apps/mobile/src/**"],- rules: { "t3code/no-mobile-uniwind-theme-escape-hatches": "error" },+ rules: {+ "t3code/no-mobile-uniwind-theme-escape-hatches": "error",+ "t3code/require-registered-list-scroll": "error",+ },},{files: ["apps/mobile/src/**"],