Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

vite.config.ts

710 lines25.8 KB

1import "vite-plus/test/config";
2import { defineConfig } from "vite-plus";
3import * as NodeURL from "node:url";
4import { remoteCacheUrl } from "./infra/task-cache/src/remoteCache.ts";
5import { cachedTestTasks } from "./scripts/lib/cached-tests.ts";
6import { cliTestFiles } from "./scripts/lib/cli-test-files.ts";
7​
8const TEST_EXCLUDE = [
9 "**/.repos/**",
10 "**/.t3/**",
11 "**/node_modules/**",
12 "**/dist/**",
13 "**/dist-electron/**",
14 "**/.{idea,git,cache,output,temp}/**",
15];
16​
17// Directories whose tests belong to a package's own test config. desktop also
18// owns the kde-snap-shot tests through its `include`.
19const TEST_CONFIG_PACKAGES = [
20 "apps/desktop",
21 "apps/mobile",
22 "apps/server",
23 "apps/web",
24 "packages/client-runtime",
25];
26​
27// `vp test run <file>` from the repo root hands each file to its package's
28// config. Packages that borrow this config (`--config ../../vite.config.ts`) run
29// from their own directory, as CI does, so they keep one plain project.
30const isRepoRootTestRun = process.cwd() === import.meta.dirname;
31​
32// Setting up every package's project costs 5-20 s; a run that names test files
33// only needs the projects that own them.
34const ownedTestProjects = await (async () => {
35 const files = isRepoRootTestRun ? await cliTestFiles() : undefined;
36 if (!files) return undefined;
37 const owner = (file: string) => {
38 if (file.startsWith("native/kde-snap-shot/")) return "apps/desktop";
39 return TEST_CONFIG_PACKAGES.find((dir) => file.startsWith(`${dir}/`)) ?? "root";
40 };
41 return new Set(files.map(owner));
42})();
43const includesTestProject = (project: string) => ownedTestProjects?.has(project) ?? true;
44​
45const RESTRICTED_IMPORT_PATHS = [
46 {
47 name: "react-native",
48 importNames: ["FlatList"],
49 message:
50 "Use LegendList from @legendapp/list/react-native, with renderScrollComponent={NativeScrollView} in a screen. Pass whatever renderItem reads through extraData: rows only re-render when their item or extraData changes.",
51 },
52 {
53 name: "@t3tools/client-runtime",
54 message:
55 "Import from an explicit @t3tools/client-runtime/* subpath. The package has no root export.",
56 },
57 {
58 name: "@pierre/diffs/react",
59 importNames: ["CodeView"],
60 message: "Use StyledDiffCodeView so web diff surfaces share styling and virtualized geometry.",
61 },
62 {
63 name: "react-native-screens",
64 importNames: ["ScrollViewMarker"],
65 message:
66 "Use NativeScrollViewMarker or NativeScrollView (src/native/NativeScrollViewMarker.tsx): they carry the header's scroll-edge blur under the Duo's vertical bar.",
67 },
68 {
69 name: "react-native",
70 importNames: ["RefreshControl"],
71 message:
72 "Use RefreshControl from src/components/ui/RefreshControl: Android bottom sheets own the pull at the top, so it steps aside there.",
73 },
74];
75​
76const RESTRICTED_UI_VARIANT_PATTERNS = [
77 {
78 group: ["**/components/ui/*", "**/ui/*", "./ui/*"],
79 importNames: ["buttonVariants", "toggleVariants", "badgeVariants", "selectTriggerVariants"],
80 message:
81 "Render the components/ui export instead of borrowing its class recipe (render={<Button …/>}, SelectButton, ToggleGroup).",
82 },
83];
84​
85const RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS = {
86 name: "lucide-react",
87 importNames: [
88 "GitMerge",
89 "GitMergeIcon",
90 "GitPullRequest",
91 "GitPullRequestIcon",
92 "GitPullRequestArrow",
93 "GitPullRequestArrowIcon",
94 "GitPullRequestClosed",
95 "GitPullRequestClosedIcon",
96 "GitPullRequestDraft",
97 "GitPullRequestDraftIcon",
98 "GitPullRequestCreate",
99 "GitPullRequestCreateIcon",
100 "GitPullRequestCreateArrow",
101 "GitPullRequestCreateArrowIcon",
102 ],
103 message:
104 "Pick a glyph by meaning from PullRequestGlyph in apps/web/src/components/pullRequest/pullRequestIcons.tsx so every surface draws the same pull request the same way.",
105};
106​
107// Vite+ supports remote configuration before its published types include it.
108const cacheUrl = remoteCacheUrl(import.meta.dirname);
109const taskCacheConfig = {
110 scripts: false,
111 ...(cacheUrl ? { remote: { url: cacheUrl } } : {}),
112};
113​
114export default defineConfig({
115 run: {
116 cache: taskCacheConfig,
117 tasks: {
118 ...cachedTestTasks(process.env.T3_CACHED_TESTS),
119 },
120 },
121 resolve: {
122 alias: {
123 "~": NodeURL.fileURLToPath(new URL("./apps/web/src", import.meta.url)),
124 },
125 },
126 test: {
127 environment: "node",
128 // Fixture subprocesses must not inherit the outer task runner’s cache policy.
129 env: { VP_REMOTE_CACHE: "off", VP_REMOTE_CACHE_URL: "" },
130 exclude: TEST_EXCLUDE,
131 hookTimeout: 60_000,
132 testTimeout: 60_000,
133 allowOnly: !process.env.CI,
134 // Flaky tests are fixed, not retried.
135 retry: 0,
136 fakeTimers: {
137 toFake: [
138 "setTimeout",
139 "clearTimeout",
140 "setInterval",
141 "clearInterval",
142 "setImmediate",
143 "clearImmediate",
144 "Date",
145 "performance",
146 "requestAnimationFrame",
147 "cancelAnimationFrame",
148 "requestIdleCallback",
149 "cancelIdleCallback",
150 ],
151 },
152 setupFiles: [
153 NodeURL.fileURLToPath(
154 new URL("./packages/shared/src/testing/longTempDir.ts", import.meta.url),
155 ),
156 NodeURL.fileURLToPath(
157 new URL("./packages/shared/src/testing/providerEnv.ts", import.meta.url),
158 ),
159 NodeURL.fileURLToPath(new URL("./packages/shared/src/testing/gitEnv.ts", import.meta.url)),
160 ],
161 ...(isRepoRootTestRun
162 ? {
163 projects: [
164 ...TEST_CONFIG_PACKAGES.filter(includesTestProject),
165 ...(includesTestProject("root")
166 ? [
167 {
168 extends: true,
169 test: {
170 name: "root",
171 exclude: [
172 ...TEST_EXCLUDE,
173 ...TEST_CONFIG_PACKAGES.map((dir) => `${dir}/**`),
174 "native/kde-snap-shot/**",
175 ],
176 },
177 },
178 ]
179 : []),
180 ],
181 }
182 : {}),
183 },
184 staged: {
185 // In order, so lint reads the formatted file. CI lint failures cost a full round trip.
186 "*": ["vp fmt --no-error-on-unmatched-pattern", "vp lint --no-error-on-unmatched-pattern"],
187 // knip checks the whole repo, so it takes no file list. Any code or manifest change can leave
188 // a file, export, or dependency unused.
189 "{*.{js,jsx,ts,tsx,mjs,cjs,mts,cts},package.json,knip.jsonc}": () => "vp run knip:check",
190 },
191 fmt: {
192 ignorePatterns: [
193 ".repos/**",
194 "infra/task-cache/vendor/**",
195 // Macroscope requires one glob per line; Markdown formatting corrupts it.
196 ".macroscope/ignore.md",
197 ".alchemy",
198 "dist",
199 "dist-electron",
200 "node_modules",
201 "pnpm-lock.yaml",
202 "*.tsbuildinfo",
203 "**/routeTree.gen.ts",
204 "**/*.graphql.ts",
205 "packages/source-control-github/schema/**",
206 "apps/server/schema/**",
207 "apps/mobile/android/**",
208 "apps/mobile/ios/**",
209 "apps/mobile/uniwind-types.d.ts",
210 // Vendored and generated C.
211 "apps/mobile/modules/t3-highlights/Vendor/**",
212 "apps/mobile/modules/t3-highlights/cpp/generated/**",
213 "apps/mobile/modules/t3-highlights/nitrogen/generated/**",
214 "*.icon/**",
215 ],
216 sortPackageJson: {},
217 overrides: [
218 {
219 files: [".devcontainer/devcontainer.json"],
220 options: {
221 trailingComma: "none",
222 },
223 },
224 ],
225 },
226 lint: {
227 ignorePatterns: [
228 ".repos",
229 ".repos/**",
230 "infra/task-cache/vendor/**",
231 "dist",
232 "dist-electron",
233 "node_modules",
234 "pnpm-lock.yaml",
235 "*.tsbuildinfo",
236 "**/routeTree.gen.ts",
237 "**/*.graphql.ts",
238 "packages/source-control-github/schema/**",
239 "apps/server/schema/**",
240 "apps/mobile/android/**",
241 "apps/mobile/ios/**",
242 "apps/mobile/uniwind-types.d.ts",
243 ],
244 plugins: ["eslint", "oxc", "react", "unicorn", "typescript"],
245 jsPlugins: ["./oxlint-plugin-t3code/index.ts", "@shadcn/lint"],
246 settings: {
247 shadcn: { ui: "~/components/ui" },
248 },
249 categories: {
250 correctness: "warn",
251 suspicious: "warn",
252 perf: "warn",
253 },
254 rules: {
255 "oxc/no-accumulating-spread": "error",
256 "eslint/no-control-regex": "off",
257 "typescript/no-this-alias": "off",
258 "unicorn/prefer-add-event-listener": "off",
259 "unicorn/prefer-string-starts-ends-with": "off",
260 "unicorn/prefer-set-has": "off",
261 "unicorn/prefer-array-find": "off",
262 "unicorn/no-new-array": "off",
263 "unicorn/no-array-reverse": "off",
264 "react/no-object-type-as-default-prop": "off",
265 "react/jsx-no-constructed-context-values": "off",
266 "react/memo-dependencies": "error",
267 "react/purity": "error",
268 "react/refs": "error",
269 "react/exhaustive-effect-dependencies": "error",
270 "react/set-state-in-effect": "error",
271 "react/immutability": "error",
272 "react/no-array-index-key": "error",
273 "react/no-unstable-nested-components": "error",
274 "react/static-components": "error",
275 "react/capitalized-calls": "error",
276 "typescript/no-extraneous-class": "error",
277 "eslint/no-empty-pattern": "error",
278 "eslint/no-new": "error",
279 "unicorn/no-useless-spread": "error",
280 "eslint/no-unused-vars": [
281 "error",
282 { argsIgnorePattern: "^_", varsIgnorePattern: "^_", caughtErrorsIgnorePattern: "^_" },
283 ],
284 "eslint/no-unsafe-optional-chaining": "error",
285 "eslint/no-unneeded-ternary": "error",
286 "unicorn/no-useless-fallback-in-spread": "error",
287 "unicorn/require-module-specifiers": "error",
288 "unicorn/no-array-sort": "off",
289 "unicorn/consistent-function-scoping": "off",
290 "oxc/no-map-spread": "off",
291 "react-in-jsx-scope": "off",
292 "react-hooks/exhaustive-deps": "off",
293 "eslint/no-shadow": "off",
294 "eslint/no-await-in-loop": "off",
295 "eslint/no-underscore-dangle": "off",
296 "typescript/consistent-return": "off",
297 "typescript/no-base-to-string": "off",
298 "typescript/no-duplicate-type-constituents": "off",
299 "typescript/no-floating-promises": "off",
300 "typescript/no-implied-eval": "off",
301 "typescript/no-meaningless-void-operator": "off",
302 "typescript/no-redundant-type-constituents": "off",
303 "typescript/no-unnecessary-boolean-literal-compare": "off",
304 "typescript/no-unnecessary-type-conversion": "off",
305 "typescript/no-unnecessary-type-arguments": "off",
306 "typescript/no-unnecessary-type-assertion": "off",
307 "typescript/no-unnecessary-type-parameters": "off",
308 "typescript/no-unsafe-type-assertion": "off",
309 "typescript/await-thenable": "off",
310 "typescript/require-array-sort-compare": "off",
311 "typescript/restrict-template-expressions": "off",
312 "typescript/unbound-method": "off",
313 "eslint/no-restricted-imports": [
314 "error",
315 { paths: [...RESTRICTED_IMPORT_PATHS, RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS] },
316 ],
317 "t3code/no-global-process-runtime": "error",
318 "t3code/no-inline-schema-compile": "error",
319 "t3code/no-low-value-comments": "error",
320 "t3code/no-manual-effect-runtime-in-tests": "error",
321 "t3code/no-native-title-tooltip": "error",
322 // Test files only (the rule checks the filename).
323 "t3code/no-polling-loop-in-tests": "error",
324 "t3code/no-layout-command-approval-writes": "error",
325 "t3code/no-raw-mcp-registration": "error",
326 "t3code/no-real-time-wait-in-tests": "error",
327 "t3code/no-test-in-loop": "error",
328 "t3code/no-test-timeout-or-unreasoned-skip": "error",
329 "t3code/no-rpc-permission-bypass": ["error", { allowRawClientAccess: true }],
330 "t3code/no-unscoped-has": "error",
331 "t3code/no-wall-clock-in-tests": "error",
332 "t3code/namespace-node-imports": "error",
333 "t3code/prefer-catch-tags": "error",
334 "t3code/prefer-effect-fn": "error",
335 "t3code/require-centered-scroll-gutter": "error",
336 "t3code/require-suppression-reason": "error",
337 },
338 overrides: [
339 {
340 files: [
341 "**/*.{test,spec,testkit}.{ts,tsx}",
342 "**/{test,tests,testkit,testing,fixtures,integration}/**",
343 "packages/provider-testing/**",
344 ],
345 rules: { "t3code/prefer-effect-fn": "off" },
346 },
347 {
348 files: ["apps/web/src/**", "apps/mobile/src/**", "apps/desktop/src/**"],
349 // Users still pick their own project icon from the full Lucide set.
350 excludeFiles: ["apps/web/src/projectIconOptions.ts"],
351 rules: { "t3code/no-sparkles-icon": "error" },
352 },
353 {
354 files: ["apps/web/**/*.test.{ts,tsx}"],
355 rules: { "t3code/require-disposable-render": "error" },
356 },
357 {
358 files: ["apps/web/src/**/*.browser.test.{ts,tsx}"],
359 rules: { "t3code/no-frame-waits-in-browser-tests": "error" },
360 },
361 {
362 files: ["apps/**/src/**", "packages/**/src/**"],
363 rules: { "t3code/no-dom-test-environment": "error" },
364 },
365 {
366 files: ["packages/client-runtime/src/state/**", "apps/{web,mobile,desktop}/src/**"],
367 rules: { "t3code/no-rpc-permission-bypass": ["error", { allowRawClientAccess: false }] },
368 },
369 {
370 files: [
371 "packages/client-runtime/src/state/runtime.ts",
372 "packages/client-runtime/src/state/vcsAction.ts",
373 ],
374 rules: {
375 "t3code/no-rpc-permission-bypass": [
376 "error",
377 { allowGuardInstallation: true, allowRawClientAccess: false },
378 ],
379 },
380 },
381 {
382 files: [
383 "apps/web/src/components/settings/AuthorizedClientsSettings.tsx",
384 "apps/mobile/src/features/updates/app-updates.ts",
385 "apps/web/src/components/device/DevicePhoneViewport.tsx",
386 "apps/web/src/components/device/DeviceDuoViewport.tsx",
387 ],
388 rules: { "t3code/no-rpc-permission-bypass": ["error", { allowRawClientAccess: true }] },
389 },
390 {
391 files: ["packages/client-runtime/src/connection/outdatedHostUpdate.ts"],
392 rules: { "t3code/no-rpc-permission-bypass": "off" },
393 },
394 {
395 files: [
396 "packages/client-runtime/src/rpc/**",
397 "**/*.{test,spec}.{ts,tsx,js,jsx,mts,cts,mjs,cjs}",
398 ],
399 rules: { "t3code/no-rpc-permission-bypass": "off" },
400 },
401 {
402 files: ["packages/shared/src/HostProcess.ts"],
403 rules: { "t3code/no-global-process-runtime": "off" },
404 },
405 {
406 // The `t3` npm launcher is published as plain, dependency-free Node.
407 files: ["scripts/npm-launcher/**"],
408 rules: {
409 "t3code/no-global-process-runtime": "off",
410 "t3code/namespace-node-imports": "off",
411 },
412 },
413 {
414 files: ["apps/server/src/mcp/McpHttpServer.ts"],
415 rules: { "t3code/no-raw-mcp-registration": "off" },
416 },
417 {
418 // The client RPC, the layer that builds it, and the tests that stand in for a person.
419 files: [
420 "apps/server/src/ws.ts",
421 "apps/server/src/server.ts",
422 "apps/server/src/ws.test.ts",
423 "apps/server/src/workspace/TaskFolders.testkit.ts",
424 ],
425 rules: { "t3code/no-layout-command-approval-writes": "off" },
426 },
427 {
428 files: ["apps/web/src/**"],
429 excludeFiles: ["apps/web/src/components/ui/**"],
430 rules: {
431 "eslint/no-restricted-imports": [
432 "error",
433 {
434 paths: [...RESTRICTED_IMPORT_PATHS, RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS],
435 patterns: RESTRICTED_UI_VARIANT_PATTERNS,
436 },
437 ],
438 },
439 },
440 {
441 files: ["apps/web/src/components/pullRequest/pullRequestIcons.tsx"],
442 rules: { "eslint/no-restricted-imports": ["error", { paths: RESTRICTED_IMPORT_PATHS }] },
443 },
444 {
445 // The server and every client load a forge's shared definition, so a UI runtime
446 // imported there would break the server; client-only forge code goes in `src/client/`.
447 files: ["packages/source-control-*/src/shared/**"],
448 rules: {
449 "eslint/no-restricted-imports": [
450 "error",
451 {
452 paths: [...RESTRICTED_IMPORT_PATHS, RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS],
453 patterns: [
454 {
455 group: [
456 "react",
457 "react/*",
458 "react-*",
459 "expo",
460 "expo-*",
461 "lucide-react",
462 "@t3tools/client-runtime",
463 "@t3tools/client-runtime/*",
464 "../client/*",
465 "../server/*",
466 "../../client/*",
467 "../../server/*",
468 "../../../client/*",
469 "../../../server/*",
470 "@t3tools/source-control-*/client/*",
471 "@t3tools/source-control-*/server/*",
472 ],
473 message:
474 "Shared forge definitions load on the server and every client; keep UI and server code out.",
475 },
476 ],
477 },
478 ],
479 },
480 },
481 {
482 files: ["apps/server/src/**", "packages/source-control-*/src/server/**"],
483 rules: {
484 "eslint/no-restricted-imports": [
485 "error",
486 {
487 paths: [...RESTRICTED_IMPORT_PATHS, RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS],
488 patterns: [
489 {
490 group: [
491 "@t3tools/source-control-*/client/*",
492 "../client/*",
493 "../../client/*",
494 "../../../client/*",
495 ],
496 message:
497 "A forge's client entry is UI-only; the server reads its `shared/definition`.",
498 },
499 ],
500 },
501 ],
502 },
503 },
504 {
505 files: ["apps/mobile/src/**"],
506 rules: {
507 "t3code/no-mobile-uniwind-theme-escape-hatches": "error",
508 "t3code/require-registered-list-scroll": "error",
509 },
510 },
511 {
512 files: ["apps/mobile/src/**"],
513 excludeFiles: [
514 "apps/mobile/src/components/ui/AppSymbol.tsx",
515 "apps/mobile/src/components/ui/AppSymbol.android.tsx",
516 "apps/mobile/src/features/pull-requests/pullRequestGlyphs.ts",
517 ],
518 rules: { "t3code/no-mobile-pull-request-glyph-literals": "error" },
519 },
520 {
521 files: ["apps/mobile/src/**"],
522 excludeFiles: ["**/*.test.{ts,tsx}"],
523 rules: { "t3code/no-ambiguous-detail-navigation": "error" },
524 },
525 {
526 // Raw ResizeObserver state commits miss the paint; observeResize flushes derived layout together.
527 files: ["apps/web/src/**"],
528 excludeFiles: [
529 "apps/web/src/lib/observeResize.ts",
530 "**/*.{test,spec}.{ts,tsx,js,jsx,mts,cts,mjs,cjs}",
531 ],
532 rules: { "t3code/no-raw-resize-observer": "error" },
533 },
534 {
535 files: ["apps/web/src/**"],
536 rules: { "shadcn/no-unknown-classes": "error" },
537 },
538 {
539 files: ["apps/web/src/**"],
540 rules: { "t3code/no-outset-state-indicators": "error" },
541 },
542 {
543 files: ["apps/web/src/**"],
544 rules: { "t3code/max-settings-description-length": "error" },
545 },
546 {
547 files: ["apps/*/src/**", "packages/*/src/**"],
548 excludeFiles: [
549 "**/*.{test,spec}.{ts,tsx,js,jsx,mts,cts,mjs,cjs}",
550 "**/testkit/**",
551 "**/_generated/**",
552 // Real user quotes stay verbatim.
553 "apps/marketing/src/lib/tweets.ts",
554 ],
555 rules: { "t3code/no-em-dash-copy": "error" },
556 },
557 {
558 files: ["apps/web/src/**"],
559 rules: { "shadcn/no-raw-colors": "error" },
560 },
561 {
562 // Third-party marks must retain their exact colors.
563 files: ["apps/web/src/components/Icons.tsx", "apps/web/src/components/JetBrainsIcons.tsx"],
564 rules: { "shadcn/no-raw-colors": "off" },
565 },
566 {
567 files: ["apps/web/src/**"],
568 excludeFiles: ["apps/web/src/components/ui/**"],
569 rules: {
570 "shadcn/require-static-classes": "error",
571 "shadcn/no-arbitrary-values": [
572 "error",
573 {
574 allow: [
575 "layout",
576 "transition",
577 "rounded-[inherit]",
578 "gap-[0.33em]",
579 "gap-[0.2em]",
580 "leading-[normal]",
581 "underline-offset-[0.2em]",
582 "rounded-[25%]",
583 "text-[length:80cqh]",
584 "bg-[Highlight]",
585 "fill-[#26251E]",
586 "fill-[#EDECEC]",
587 "fill-[#0F0F0F]",
588 "fill-[#F5F5F5]",
589 "fill-[#d97757]",
590 "text-[#d97757]",
591 ],
592 },
593 ],
594 "shadcn/no-restyle": [
595 "error",
596 {
597 allow: ["layout"],
598 contracts: [
599 {
600 // CollapsibleTrigger has no styled counterpart; other triggers use render={<Button …/>}.
601 pattern: "^CollapsibleTrigger$",
602 allow: ["layout", "color", "typography", "spacing", "shape", "effects", "motion"],
603 },
604 ],
605 },
606 ],
607 },
608 },
609 // Registered always so a disable comment for intentional English counts as used.
610 // `vp run i18n:untranslated` counts what it flags.
611 {
612 files: ["apps/web/src/**", "apps/mobile/src/**", "packages/client-runtime/src/**"],
613 excludeFiles: [
614 "**/*.{test,spec,bench}.{ts,tsx}",
615 "**/{test,testkit,testing,fixtures}/**",
616 "**/*.test-fixtures.ts",
617 "**/{test-fixtures,*TestFixtures}.ts",
618 "apps/mobile/src/features/development/**",
619 "packages/client-runtime/src/rpc/**",
620 ],
621 rules: { "t3code/no-untranslated-copy": "error" },
622 },
623 {
624 // React Compiler owns memoization; upstream rules do not ban redundant useMemo/useCallback.
625 files: ["apps/web/src/**/*.{ts,tsx}"],
626 rules: {
627 "react/exhaustive-effect-dependencies": "error",
628 "react/globals": "error",
629 "react/hooks": "error",
630 "react/immutability": "error",
631 // The compiler memoizes context values; this rule would ask for useMemo.
632 "react/jsx-no-constructed-context-values": "off",
633 "react/memo-dependencies": "error",
634 "react/preserve-manual-memoization": "error",
635 // Render-time clock reads use @t3tools/client-runtime/clock or state seeded with the
636 // time; any other read carries a suppression that says why. oxlint also flags time reads
637 // inside event handlers (oxc#27309); those suppressions cite it.
638 "react/purity": "error",
639 "react/refs": "error",
640 "react/set-state-in-effect": "error",
641 "react/set-state-in-render": "error",
642 "react/static-components": "error",
643 "react/unsupported-syntax": "error",
644 "t3code/no-manual-memo": "error",
645 },
646 },
647 {
648 // ESNext types allow APIs absent from Hermes; restrict shared client code, exempting Node tests.
649 files: [
650 "apps/mobile/src/**",
651 "packages/client-runtime/src/**",
652 "packages/contracts/src/**",
653 "packages/shared/src/**",
654 ],
655 excludeFiles: ["**/*.test.ts", "**/*.test.tsx"],
656 rules: { "t3code/no-hermes-unsupported-apis": "error" },
657 },
658 {
659 // Directives hide bailouts from mobile's compiler-coverage check; retain hooks until its allowlist is empty.
660 files: ["apps/mobile/src/**/*.{ts,tsx}"],
661 rules: { "t3code/no-manual-memo": ["error", { allowMemoHooks: true }] },
662 },
663 {
664 files: ["apps/web/src/**", "apps/mobile/src/**", "packages/*/src/**"],
665 rules: { "t3code/no-unreasoned-state-sync": "error" },
666 },
667 {
668 // React Compiler caches use* functions only if they call a hook.
669 files: ["apps/web/src/**/*.{ts,tsx}", "apps/mobile/src/**/*.{ts,tsx}"],
670 excludeFiles: ["**/*.test.ts", "**/*.test.tsx"],
671 rules: { "t3code/no-hookless-use-function": "error" },
672 },
673 {
674 files: [
675 "apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx",
676 "apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx",
677 "apps/mobile/src/features/files/FileMarkdownPreview.tsx",
678 "apps/mobile/src/features/files/SourceFileSurface.tsx",
679 "apps/mobile/src/features/files/AttachmentFileScreen.tsx",
680 "apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx",
681 "apps/mobile/src/features/files/thread-file-navigator-pane.tsx",
682 "apps/mobile/src/features/layout/nested-stacks.tsx",
683 "apps/mobile/src/features/review/ReviewSheet.tsx",
684 "apps/mobile/src/features/review/useNativeReviewDiffBridge.ts",
685 "apps/mobile/src/features/settings/SettingsEnvironmentsRouteScreen.tsx",
686 "apps/mobile/src/features/threads/ThreadComposer.tsx",
687 "apps/mobile/src/components/ComposerSurface.tsx",
688 "apps/mobile/src/features/threads/ThreadFeed.tsx",
689 "apps/mobile/src/features/threads/ThreadQueueControl.tsx",
690 "apps/mobile/src/features/review/ReviewCommentCard.tsx",
691 "apps/mobile/src/features/threads/thread-list-v2-items.tsx",
692 "apps/mobile/src/components/ui/SecretTextInput.android.tsx",
693 "apps/mobile/src/lib/useMobileNavigationTheme.ts",
694 "apps/mobile/src/native/T3ComposerEditor.ios.tsx",
695 "apps/mobile/src/native/T3ComposerEditor.native.tsx",
696 "apps/mobile/src/native/SelectableMarkdownText.tsx",
697 "apps/mobile/src/native/useEnrichedLinkVariants.ts",
698 ],
699 rules: {
700 "t3code/no-mobile-uniwind-theme-escape-hatches": ["error", { allowUniwindTheme: true }],
701 },
702 },
703 ],
704 options: {
705 reportUnusedDisableDirectives: "error",
706 typeAware: false,
707 typeCheck: false,
708 },
709 },
710});