Open History to see the last commit
1import "vite-plus/test/config";
2import { defineConfig } from "vite-plus";
3import * as NodeURL from "node:url";
4
5const DOM_TEST_ENVIRONMENT_ALLOWLIST: Array<string> = [];
6
7const RESTRICTED_IMPORT_PATHS = [
8 {
9 name: "@t3tools/client-runtime",
10 message:
11 "Import from an explicit @t3tools/client-runtime/* subpath. The package has no root export.",
12 },
13 {
14 name: "@pierre/diffs/react",
15 importNames: ["CodeView"],
16 message: "Use StyledDiffCodeView so web diff surfaces share styling and virtualized geometry.",
17 },
18];
19
20const RESTRICTED_UI_VARIANT_PATTERNS = [
21 {
22 group: ["**/components/ui/*", "**/ui/*", "./ui/*"],
23 importNames: ["buttonVariants", "toggleVariants", "badgeVariants", "selectTriggerVariants"],
24 message:
25 "Render the components/ui export instead of borrowing its class recipe (render={<Button …/>}, SelectButton, ToggleGroup).",
26 },
27];
28
29const RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS = {
30 name: "lucide-react",
31 importNames: [
32 "GitMerge",
33 "GitMergeIcon",
34 "GitPullRequest",
35 "GitPullRequestIcon",
36 "GitPullRequestArrow",
37 "GitPullRequestArrowIcon",
38 "GitPullRequestClosed",
39 "GitPullRequestClosedIcon",
40 "GitPullRequestDraft",
41 "GitPullRequestDraftIcon",
42 "GitPullRequestCreate",
43 "GitPullRequestCreateIcon",
44 "GitPullRequestCreateArrow",
45 "GitPullRequestCreateArrowIcon",
46 ],
47 message:
48 "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.",
49};
50
51export default defineConfig({
52 resolve: {
53 alias: {
54 "~": NodeURL.fileURLToPath(new URL("./apps/web/src", import.meta.url)),
55 },
56 },
57 test: {
58 environment: "node",
59 exclude: [
60 "**/.repos/**",
61 "**/.t3/**",
62 "**/node_modules/**",
63 "**/dist/**",
64 "**/dist-electron/**",
65 "**/.{idea,git,cache,output,temp}/**",
66 ],
67 hookTimeout: 60_000,
68 testTimeout: 60_000,
69 setupFiles: [
70 NodeURL.fileURLToPath(
71 new URL("./packages/shared/src/testing/longTempDir.ts", import.meta.url),
72 ),
73 ],
74 },
75 staged: {
76 "*": "vp fmt --no-error-on-unmatched-pattern",
77 },
78 fmt: {
79 ignorePatterns: [
80 ".repos/**",
81 // Macroscope's glob-per-line ignore grammar, not Markdown: formatting
82 // it rewrites `*` as `_` and joins lines.
83 ".macroscope/ignore.md",
84 ".alchemy",
85 "dist",
86 "dist-electron",
87 "node_modules",
88 "pnpm-lock.yaml",
89 "*.tsbuildinfo",
90 "**/routeTree.gen.ts",
91 "**/*.graphql.ts",
92 "packages/source-control-github/schema/**",
93 "apps/server/schema/**",
94 "apps/mobile/android/**",
95 "apps/mobile/ios/**",
96 "apps/mobile/uniwind-types.d.ts",
97 "*.icon/**",
98 ],
99 sortPackageJson: {},
100 overrides: [
101 {
102 files: [".devcontainer/devcontainer.json"],
103 options: {
104 trailingComma: "none",
105 },
106 },
107 ],
108 },
109 lint: {
110 ignorePatterns: [
111 ".repos",
112 ".repos/**",
113 "dist",
114 "dist-electron",
115 "node_modules",
116 "pnpm-lock.yaml",
117 "*.tsbuildinfo",
118 "**/routeTree.gen.ts",
119 "**/*.graphql.ts",
120 "packages/source-control-github/schema/**",
121 "apps/server/schema/**",
122 "apps/mobile/android/**",
123 "apps/mobile/ios/**",
124 "apps/mobile/uniwind-types.d.ts",
125 ],
126 plugins: ["eslint", "oxc", "react", "unicorn", "typescript"],
127 jsPlugins: ["./oxlint-plugin-t3code/index.ts", "@shadcn/lint"],
128 settings: {
129 shadcn: { ui: "~/components/ui" },
130 },
131 categories: {
132 correctness: "warn",
133 suspicious: "warn",
134 perf: "warn",
135 },
136 rules: {
137 "unicorn/no-array-sort": "off",
138 "unicorn/consistent-function-scoping": "off",
139 "oxc/no-map-spread": "off",
140 "react-in-jsx-scope": "off",
141 "react-hooks/exhaustive-deps": "off",
142 "eslint/no-shadow": "off",
143 "eslint/no-await-in-loop": "off",
144 "eslint/no-underscore-dangle": "off",
145 "typescript/consistent-return": "off",
146 "typescript/no-base-to-string": "off",
147 "typescript/no-duplicate-type-constituents": "off",
148 "typescript/no-floating-promises": "off",
149 "typescript/no-implied-eval": "off",
150 "typescript/no-meaningless-void-operator": "off",
151 "typescript/no-redundant-type-constituents": "off",
152 "typescript/no-unnecessary-boolean-literal-compare": "off",
153 "typescript/no-unnecessary-type-conversion": "off",
154 "typescript/no-unnecessary-type-arguments": "off",
155 "typescript/no-unnecessary-type-assertion": "off",
156 "typescript/no-unnecessary-type-parameters": "off",
157 "typescript/no-unsafe-type-assertion": "off",
158 "typescript/await-thenable": "off",
159 "typescript/require-array-sort-compare": "off",
160 "typescript/restrict-template-expressions": "off",
161 "typescript/unbound-method": "off",
162 "eslint/no-restricted-imports": [
163 "error",
164 { paths: [...RESTRICTED_IMPORT_PATHS, RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS] },
165 ],
166 "t3code/no-global-process-runtime": "error",
167 "t3code/no-inline-schema-compile": "warn",
168 "t3code/no-low-value-comments": "error",
169 "t3code/no-manual-effect-runtime-in-tests": "error",
170 "t3code/no-native-title-tooltip": "error",
171 "t3code/no-raw-mcp-registration": "error",
172 "t3code/no-test-in-loop": "error",
173 "t3code/no-rpc-permission-bypass": ["error", { allowRawClientAccess: true }],
174 "t3code/no-unscoped-has": "error",
175 "t3code/namespace-node-imports": "error",
176 "t3code/prefer-catch-tags": "error",
177 "t3code/prefer-effect-fn": "error",
178 "t3code/require-centered-scroll-gutter": "error",
179 "t3code/require-suppression-reason": "error",
180 },
181 overrides: [
182 {
183 files: [
184 "**/*.{test,spec,testkit}.{ts,tsx}",
185 "**/{test,tests,testkit,testing,fixtures,integration}/**",
186 "packages/provider-testing/**",
187 ],
188 rules: { "t3code/prefer-effect-fn": "off" },
189 },
190 {
191 files: ["apps/**/src/**", "packages/**/src/**"],
192 excludeFiles: DOM_TEST_ENVIRONMENT_ALLOWLIST,
193 rules: { "t3code/no-dom-test-environment": "error" },
194 },
195 {
196 files: ["packages/client-runtime/src/state/**", "apps/{web,mobile,desktop}/src/**"],
197 rules: { "t3code/no-rpc-permission-bypass": ["error", { allowRawClientAccess: false }] },
198 },
199 {
200 files: [
201 "packages/client-runtime/src/state/runtime.ts",
202 "packages/client-runtime/src/state/vcsAction.ts",
203 ],
204 rules: {
205 "t3code/no-rpc-permission-bypass": [
206 "error",
207 { allowGuardInstallation: true, allowRawClientAccess: false },
208 ],
209 },
210 },
211 {
212 files: [
213 "apps/web/src/components/settings/ConnectionsSettings.tsx",
214 "apps/mobile/src/features/updates/app-updates.ts",
215 "apps/web/src/components/device/DevicePhoneViewport.tsx",
216 "apps/web/src/components/device/DeviceDuoViewport.tsx",
217 ],
218 rules: { "t3code/no-rpc-permission-bypass": ["error", { allowRawClientAccess: true }] },
219 },
220 {
221 files: ["packages/client-runtime/src/connection/outdatedHostUpdate.ts"],
222 rules: { "t3code/no-rpc-permission-bypass": "off" },
223 },
224 {
225 files: [
226 "packages/client-runtime/src/rpc/**",
227 "**/*.{test,spec}.{ts,tsx,js,jsx,mts,cts,mjs,cjs}",
228 ],
229 rules: { "t3code/no-rpc-permission-bypass": "off" },
230 },
231 {
232 files: ["packages/shared/src/HostProcess.ts"],
233 rules: { "t3code/no-global-process-runtime": "off" },
234 },
235 {
236 // The `t3` npm launcher is published as plain, dependency-free Node.
237 files: ["scripts/npm-launcher/**"],
238 rules: {
239 "t3code/no-global-process-runtime": "off",
240 "t3code/namespace-node-imports": "off",
241 },
242 },
243 {
244 files: ["apps/server/src/mcp/McpHttpServer.ts"],
245 rules: { "t3code/no-raw-mcp-registration": "off" },
246 },
247 {
248 files: ["apps/web/src/**"],
249 excludeFiles: ["apps/web/src/components/ui/**"],
250 rules: {
251 "eslint/no-restricted-imports": [
252 "error",
253 {
254 paths: [...RESTRICTED_IMPORT_PATHS, RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS],
255 patterns: RESTRICTED_UI_VARIANT_PATTERNS,
256 },
257 ],
258 },
259 },
260 {
261 files: ["apps/web/src/components/pullRequest/pullRequestIcons.tsx"],
262 rules: { "eslint/no-restricted-imports": ["error", { paths: RESTRICTED_IMPORT_PATHS }] },
263 },
264 {
265 files: ["apps/mobile/src/**"],
266 rules: { "t3code/no-mobile-uniwind-theme-escape-hatches": "error" },
267 },
268 {
269 files: ["apps/mobile/src/**"],
270 excludeFiles: [
271 "apps/mobile/src/components/ui/AppSymbol.tsx",
272 "apps/mobile/src/components/ui/AppSymbol.ios.tsx",
273 "apps/mobile/src/features/pull-requests/pullRequestGlyphs.ts",
274 ],
275 rules: { "t3code/no-mobile-pull-request-glyph-literals": "error" },
276 },
277 {
278 // React commits state set in a raw ResizeObserver callback after the paint, so derived
279 // layout lands a frame late. observeResize flushes every observed resize in one render.
280 files: ["apps/web/src/**"],
281 excludeFiles: [
282 "apps/web/src/lib/observeResize.ts",
283 "**/*.{test,spec}.{ts,tsx,js,jsx,mts,cts,mjs,cjs}",
284 ],
285 rules: { "t3code/no-raw-resize-observer": "error" },
286 },
287 {
288 files: ["apps/web/src/**"],
289 rules: { "shadcn/no-unknown-classes": "error" },
290 },
291 {
292 files: ["apps/web/src/**"],
293 rules: { "t3code/no-outset-state-indicators": "error" },
294 },
295 {
296 files: ["apps/web/src/**"],
297 rules: { "shadcn/no-raw-colors": "error" },
298 },
299 {
300 // Third-party marks (brand logos, the macOS permission panes, Codex's Computer Use
301 // mark) must keep their exact colors, so the files that hold them are exempt.
302 files: ["apps/web/src/components/Icons.tsx", "apps/web/src/components/JetBrainsIcons.tsx"],
303 rules: { "shadcn/no-raw-colors": "off" },
304 },
305 {
306 files: ["apps/web/src/**"],
307 excludeFiles: ["apps/web/src/components/ui/**"],
308 rules: {
309 "shadcn/require-static-classes": "error",
310 "shadcn/no-arbitrary-values": [
311 "error",
312 {
313 allow: [
314 "layout",
315 "transition",
316 "rounded-[inherit]",
317 "gap-[0.33em]",
318 "px-[0.5em]",
319 "rounded-[0.5em]",
320 "text-[0.86em]",
321 "rounded-[25%]",
322 "text-[length:80cqh]",
323 "bg-[Highlight]",
324 "fill-[#26251E]",
325 "fill-[#EDECEC]",
326 "fill-[#0F0F0F]",
327 "fill-[#F5F5F5]",
328 "fill-[#d97757]",
329 "text-[#d97757]",
330 ],
331 },
332 ],
333 "shadcn/no-restyle": [
334 "error",
335 {
336 allow: ["layout"],
337 contracts: [
338 {
339 // CollapsibleTrigger is a bare button with no styled counterpart
340 // (a disclosure row is not a Button), so its className is the API.
341 // Every other trigger has one: style them with render={<Button …/>}.
342 pattern: "^CollapsibleTrigger$",
343 allow: ["layout", "color", "typography", "spacing", "shape", "effects", "motion"],
344 },
345 ],
346 },
347 ],
348 },
349 },
350 {
351 // Every web file must compile under the React Compiler. Its bailout rules are errors here,
352 // and manual memoization is redundant. No upstream rule bans useMemo/useCallback, hence
353 // t3code/no-manual-memo.
354 files: ["apps/web/src/**/*.{ts,tsx}"],
355 rules: {
356 "react/exhaustive-effect-dependencies": "error",
357 "react/globals": "error",
358 "react/hooks": "error",
359 "react/immutability": "error",
360 // The compiler memoizes context values; this rule would ask for useMemo.
361 "react/jsx-no-constructed-context-values": "off",
362 "react/memo-dependencies": "error",
363 "react/preserve-manual-memoization": "error",
364 "react/purity": "error",
365 "react/refs": "error",
366 "react/set-state-in-effect": "error",
367 "react/set-state-in-render": "error",
368 "react/static-components": "error",
369 "react/unsupported-syntax": "error",
370 "t3code/no-manual-memo": "error",
371 },
372 },
373 {
374 // The sign-in masthead is T3 brand artwork: fixed gradients, not theme surfaces.
375 files: ["apps/web/src/components/auth/AuthSurfaceShell.tsx"],
376 rules: { "shadcn/no-arbitrary-values": "off" },
377 },
378 {
379 // Shared client code must not call APIs missing from Hermes. Our ESNext
380 // TypeScript target accepts them even when they would crash mobile at launch.
381 // Tests run on Node and are exempt.
382 files: [
383 "apps/mobile/src/**",
384 "packages/client-runtime/src/**",
385 "packages/contracts/src/**",
386 "packages/shared/src/**",
387 ],
388 excludeFiles: ["**/*.test.ts", "**/*.test.tsx"],
389 rules: { "t3code/no-hermes-unsupported-apis": "error" },
390 },
391 {
392 // Mobile is ratcheting toward full React Compiler coverage
393 // (apps/mobile/src/reactCompilerCoverage.test.ts). Directives would hide bailouts from it;
394 // the manual memo hooks go once the allowlist there is empty.
395 files: ["apps/mobile/src/**/*.{ts,tsx}"],
396 rules: { "t3code/no-manual-memo": ["error", { allowMemoHooks: true }] },
397 },
398 {
399 // The compiler only compiles a use* function that calls a hook; one that calls none is
400 // silently left as a plain function, so whatever it returns loses its caching.
401 files: ["apps/web/src/**/*.{ts,tsx}", "apps/mobile/src/**/*.{ts,tsx}"],
402 excludeFiles: ["**/*.test.ts", "**/*.test.tsx"],
403 rules: { "t3code/no-hookless-use-function": "error" },
404 },
405 {
406 files: [
407 "apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx",
408 "apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx",
409 "apps/mobile/src/features/files/FileMarkdownPreview.tsx",
410 "apps/mobile/src/features/files/SourceFileSurface.tsx",
411 "apps/mobile/src/features/files/AttachmentFileScreen.tsx",
412 "apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx",
413 "apps/mobile/src/features/files/thread-file-navigator-pane.tsx",
414 "apps/mobile/src/features/home/HomeHeader.tsx",
415 "apps/mobile/src/features/review/ReviewSheet.tsx",
416 "apps/mobile/src/features/review/useNativeReviewDiffBridge.ts",
417 "apps/mobile/src/features/settings/SettingsEnvironmentsRouteScreen.tsx",
418 "apps/mobile/src/features/threads/GitActionProgressOverlay.tsx",
419 "apps/mobile/src/features/threads/NewTaskDraftScreen.tsx",
420 "apps/mobile/src/features/threads/ThreadComposer.tsx",
421 "apps/mobile/src/features/threads/ThreadFeed.tsx",
422 "apps/mobile/src/features/settings/appearance/components/FontSizeSliderRow.tsx",
423 "apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx",
424 "apps/mobile/src/features/threads/ThreadQueueControl.tsx",
425 "apps/mobile/src/features/review/ReviewCommentCard.tsx",
426 "apps/mobile/src/features/threads/ThreadSettingsSheet.tsx",
427 "apps/mobile/src/features/threads/thread-list-items.tsx",
428 "apps/mobile/src/features/threads/thread-list-v2-items.tsx",
429 "apps/mobile/src/lib/useMobileNavigationTheme.ts",
430 "apps/mobile/src/native/T3ComposerEditor.ios.tsx",
431 "apps/mobile/src/native/T3ComposerEditor.native.tsx",
432 "apps/mobile/src/native/SelectableMarkdownText.tsx",
433 ],
434 rules: {
435 "t3code/no-mobile-uniwind-theme-escape-hatches": ["error", { allowUniwindTheme: true }],
436 },
437 },
438 ],
439 options: {
440 reportUnusedDisableDirectives: "error",
441 typeAware: false,
442 typeCheck: false,
443 },
444 },
445});