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/mobile/android/**",
94 "apps/mobile/ios/**",
95 "apps/mobile/uniwind-types.d.ts",
96 "*.icon/**",
97 ],
98 sortPackageJson: {},
99 overrides: [
100 {
101 files: [".devcontainer/devcontainer.json"],
102 options: {
103 trailingComma: "none",
104 },
105 },
106 ],
107 },
108 lint: {
109 ignorePatterns: [
110 ".repos",
111 ".repos/**",
112 "dist",
113 "dist-electron",
114 "node_modules",
115 "pnpm-lock.yaml",
116 "*.tsbuildinfo",
117 "**/routeTree.gen.ts",
118 "**/*.graphql.ts",
119 "packages/source-control-github/schema/**",
120 "apps/mobile/android/**",
121 "apps/mobile/ios/**",
122 "apps/mobile/uniwind-types.d.ts",
123 ],
124 plugins: ["eslint", "oxc", "react", "unicorn", "typescript"],
125 jsPlugins: ["./oxlint-plugin-t3code/index.ts", "@shadcn/lint"],
126 settings: {
127 shadcn: { ui: "~/components/ui" },
128 },
129 categories: {
130 correctness: "warn",
131 suspicious: "warn",
132 perf: "warn",
133 },
134 rules: {
135 "unicorn/no-array-sort": "off",
136 "unicorn/consistent-function-scoping": "off",
137 "oxc/no-map-spread": "off",
138 "react-in-jsx-scope": "off",
139 "react-hooks/exhaustive-deps": "off",
140 "eslint/no-shadow": "off",
141 "eslint/no-await-in-loop": "off",
142 "eslint/no-underscore-dangle": "off",
143 "typescript/consistent-return": "off",
144 "typescript/no-base-to-string": "off",
145 "typescript/no-duplicate-type-constituents": "off",
146 "typescript/no-floating-promises": "off",
147 "typescript/no-implied-eval": "off",
148 "typescript/no-meaningless-void-operator": "off",
149 "typescript/no-redundant-type-constituents": "off",
150 "typescript/no-unnecessary-boolean-literal-compare": "off",
151 "typescript/no-unnecessary-type-conversion": "off",
152 "typescript/no-unnecessary-type-arguments": "off",
153 "typescript/no-unnecessary-type-assertion": "off",
154 "typescript/no-unnecessary-type-parameters": "off",
155 "typescript/no-unsafe-type-assertion": "off",
156 "typescript/await-thenable": "off",
157 "typescript/require-array-sort-compare": "off",
158 "typescript/restrict-template-expressions": "off",
159 "typescript/unbound-method": "off",
160 "eslint/no-restricted-imports": [
161 "error",
162 { paths: [...RESTRICTED_IMPORT_PATHS, RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS] },
163 ],
164 "t3code/no-global-process-runtime": "error",
165 "t3code/no-inline-schema-compile": "warn",
166 "t3code/no-low-value-comments": "error",
167 "t3code/no-manual-effect-runtime-in-tests": "error",
168 "t3code/no-native-title-tooltip": "error",
169 "t3code/no-raw-mcp-registration": "error",
170 "t3code/no-test-in-loop": "error",
171 "t3code/no-rpc-permission-bypass": ["error", { allowRawClientAccess: true }],
172 "t3code/no-unscoped-has": "error",
173 "t3code/namespace-node-imports": "error",
174 "t3code/prefer-catch-tags": "error",
175 "t3code/require-centered-scroll-gutter": "error",
176 "t3code/require-suppression-reason": "error",
177 },
178 overrides: [
179 {
180 files: ["apps/**/src/**", "packages/**/src/**"],
181 excludeFiles: DOM_TEST_ENVIRONMENT_ALLOWLIST,
182 rules: { "t3code/no-dom-test-environment": "error" },
183 },
184 {
185 files: ["packages/client-runtime/src/state/**", "apps/{web,mobile,desktop}/src/**"],
186 rules: { "t3code/no-rpc-permission-bypass": ["error", { allowRawClientAccess: false }] },
187 },
188 {
189 files: [
190 "packages/client-runtime/src/state/runtime.ts",
191 "packages/client-runtime/src/state/vcsAction.ts",
192 ],
193 rules: {
194 "t3code/no-rpc-permission-bypass": [
195 "error",
196 { allowGuardInstallation: true, allowRawClientAccess: false },
197 ],
198 },
199 },
200 {
201 files: [
202 "apps/web/src/components/settings/ConnectionsSettings.tsx",
203 "apps/mobile/src/features/updates/app-updates.ts",
204 "apps/web/src/components/device/DevicePhoneViewport.tsx",
205 "apps/web/src/components/device/DeviceDuoViewport.tsx",
206 ],
207 rules: { "t3code/no-rpc-permission-bypass": ["error", { allowRawClientAccess: true }] },
208 },
209 {
210 files: ["packages/client-runtime/src/connection/outdatedHostUpdate.ts"],
211 rules: { "t3code/no-rpc-permission-bypass": "off" },
212 },
213 {
214 files: [
215 "packages/client-runtime/src/rpc/**",
216 "**/*.{test,spec}.{ts,tsx,js,jsx,mts,cts,mjs,cjs}",
217 ],
218 rules: { "t3code/no-rpc-permission-bypass": "off" },
219 },
220 {
221 files: ["packages/shared/src/HostProcess.ts"],
222 rules: { "t3code/no-global-process-runtime": "off" },
223 },
224 {
225 // The `t3` npm launcher is published as plain, dependency-free Node.
226 files: ["scripts/npm-launcher/**"],
227 rules: {
228 "t3code/no-global-process-runtime": "off",
229 "t3code/namespace-node-imports": "off",
230 },
231 },
232 {
233 files: ["apps/server/src/mcp/McpHttpServer.ts"],
234 rules: { "t3code/no-raw-mcp-registration": "off" },
235 },
236 {
237 files: ["apps/web/src/**"],
238 excludeFiles: ["apps/web/src/components/ui/**"],
239 rules: {
240 "eslint/no-restricted-imports": [
241 "error",
242 {
243 paths: [...RESTRICTED_IMPORT_PATHS, RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS],
244 patterns: RESTRICTED_UI_VARIANT_PATTERNS,
245 },
246 ],
247 },
248 },
249 {
250 files: ["apps/web/src/components/pullRequest/pullRequestIcons.tsx"],
251 rules: { "eslint/no-restricted-imports": ["error", { paths: RESTRICTED_IMPORT_PATHS }] },
252 },
253 {
254 files: ["apps/mobile/src/**"],
255 rules: { "t3code/no-mobile-uniwind-theme-escape-hatches": "error" },
256 },
257 {
258 files: ["apps/mobile/src/**"],
259 excludeFiles: [
260 "apps/mobile/src/components/ui/AppSymbol.tsx",
261 "apps/mobile/src/components/ui/AppSymbol.ios.tsx",
262 "apps/mobile/src/features/pull-requests/pullRequestGlyphs.ts",
263 ],
264 rules: { "t3code/no-mobile-pull-request-glyph-literals": "error" },
265 },
266 {
267 // React commits state set in a raw ResizeObserver callback after the paint, so derived
268 // layout lands a frame late. observeResize flushes every observed resize in one render.
269 files: ["apps/web/src/**"],
270 excludeFiles: [
271 "apps/web/src/lib/observeResize.ts",
272 "**/*.{test,spec}.{ts,tsx,js,jsx,mts,cts,mjs,cjs}",
273 ],
274 rules: { "t3code/no-raw-resize-observer": "error" },
275 },
276 {
277 files: ["apps/web/src/**"],
278 rules: { "shadcn/no-unknown-classes": "error" },
279 },
280 {
281 files: ["apps/web/src/**"],
282 rules: { "t3code/no-outset-state-indicators": "error" },
283 },
284 {
285 files: ["apps/web/src/**"],
286 rules: { "shadcn/no-raw-colors": "error" },
287 },
288 {
289 // Third-party marks (brand logos, the macOS permission panes, Codex's Computer Use
290 // mark) must keep their exact colors, so the files that hold them are exempt.
291 files: ["apps/web/src/components/Icons.tsx", "apps/web/src/components/JetBrainsIcons.tsx"],
292 rules: { "shadcn/no-raw-colors": "off" },
293 },
294 {
295 files: ["apps/web/src/**"],
296 excludeFiles: ["apps/web/src/components/ui/**"],
297 rules: {
298 "shadcn/require-static-classes": "error",
299 "shadcn/no-arbitrary-values": [
300 "error",
301 {
302 allow: [
303 "layout",
304 "transition",
305 "rounded-[inherit]",
306 "gap-[0.33em]",
307 "px-[0.5em]",
308 "rounded-[0.5em]",
309 "text-[0.86em]",
310 "rounded-[25%]",
311 "text-[length:80cqh]",
312 "bg-[Highlight]",
313 "fill-[#26251E]",
314 "fill-[#EDECEC]",
315 "fill-[#0F0F0F]",
316 "fill-[#F5F5F5]",
317 "fill-[#d97757]",
318 "text-[#d97757]",
319 ],
320 },
321 ],
322 "shadcn/no-restyle": [
323 "error",
324 {
325 allow: ["layout"],
326 contracts: [
327 {
328 // CollapsibleTrigger is a bare button with no styled counterpart
329 // (a disclosure row is not a Button), so its className is the API.
330 // Every other trigger has one: style them with render={<Button …/>}.
331 pattern: "^CollapsibleTrigger$",
332 allow: ["layout", "color", "typography", "spacing", "shape", "effects", "motion"],
333 },
334 ],
335 },
336 ],
337 },
338 },
339 {
340 // Every web file must compile under the React Compiler. Its bailout rules are errors here,
341 // and manual memoization is redundant. No upstream rule bans useMemo/useCallback, hence
342 // t3code/no-manual-memo.
343 files: ["apps/web/src/**/*.{ts,tsx}"],
344 rules: {
345 "react/exhaustive-effect-dependencies": "error",
346 "react/globals": "error",
347 "react/hooks": "error",
348 "react/immutability": "error",
349 // The compiler memoizes context values; this rule would ask for useMemo.
350 "react/jsx-no-constructed-context-values": "off",
351 "react/memo-dependencies": "error",
352 "react/preserve-manual-memoization": "error",
353 "react/purity": "error",
354 "react/refs": "error",
355 "react/set-state-in-effect": "error",
356 "react/set-state-in-render": "error",
357 "react/static-components": "error",
358 "react/unsupported-syntax": "error",
359 "t3code/no-manual-memo": "error",
360 },
361 },
362 {
363 // The sign-in masthead is T3 brand artwork: fixed gradients, not theme surfaces.
364 files: ["apps/web/src/components/auth/AuthSurfaceShell.tsx"],
365 rules: { "shadcn/no-arbitrary-values": "off" },
366 },
367 {
368 // Shared client code must not call APIs missing from Hermes. Our ESNext
369 // TypeScript target accepts them even when they would crash mobile at launch.
370 // Tests run on Node and are exempt.
371 files: [
372 "apps/mobile/src/**",
373 "packages/client-runtime/src/**",
374 "packages/contracts/src/**",
375 "packages/shared/src/**",
376 ],
377 excludeFiles: ["**/*.test.ts", "**/*.test.tsx"],
378 rules: { "t3code/no-hermes-unsupported-apis": "error" },
379 },
380 {
381 // Mobile is ratcheting toward full React Compiler coverage
382 // (apps/mobile/src/reactCompilerCoverage.test.ts). Directives would hide bailouts from it;
383 // the manual memo hooks go once the allowlist there is empty.
384 files: ["apps/mobile/src/**/*.{ts,tsx}"],
385 rules: { "t3code/no-manual-memo": ["error", { allowMemoHooks: true }] },
386 },
387 {
388 // The compiler only compiles a use* function that calls a hook; one that calls none is
389 // silently left as a plain function, so whatever it returns loses its caching.
390 files: ["apps/web/src/**/*.{ts,tsx}", "apps/mobile/src/**/*.{ts,tsx}"],
391 excludeFiles: ["**/*.test.ts", "**/*.test.tsx"],
392 rules: { "t3code/no-hookless-use-function": "error" },
393 },
394 {
395 files: [
396 "apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx",
397 "apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx",
398 "apps/mobile/src/features/files/FileMarkdownPreview.tsx",
399 "apps/mobile/src/features/files/SourceFileSurface.tsx",
400 "apps/mobile/src/features/files/AttachmentFileScreen.tsx",
401 "apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx",
402 "apps/mobile/src/features/files/thread-file-navigator-pane.tsx",
403 "apps/mobile/src/features/home/HomeHeader.tsx",
404 "apps/mobile/src/features/review/ReviewSheet.tsx",
405 "apps/mobile/src/features/review/useNativeReviewDiffBridge.ts",
406 "apps/mobile/src/features/settings/SettingsEnvironmentsRouteScreen.tsx",
407 "apps/mobile/src/features/threads/GitActionProgressOverlay.tsx",
408 "apps/mobile/src/features/threads/NewTaskDraftScreen.tsx",
409 "apps/mobile/src/features/threads/ThreadComposer.tsx",
410 "apps/mobile/src/features/threads/ThreadFeed.tsx",
411 "apps/mobile/src/features/settings/appearance/components/FontSizeSliderRow.tsx",
412 "apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx",
413 "apps/mobile/src/features/threads/ThreadQueueControl.tsx",
414 "apps/mobile/src/features/review/ReviewCommentCard.tsx",
415 "apps/mobile/src/features/threads/ThreadSettingsSheet.tsx",
416 "apps/mobile/src/features/threads/thread-list-items.tsx",
417 "apps/mobile/src/features/threads/thread-list-v2-items.tsx",
418 "apps/mobile/src/lib/useMobileNavigationTheme.ts",
419 "apps/mobile/src/native/T3ComposerEditor.ios.tsx",
420 "apps/mobile/src/native/T3ComposerEditor.native.tsx",
421 "apps/mobile/src/native/SelectableMarkdownText.tsx",
422 ],
423 rules: {
424 "t3code/no-mobile-uniwind-theme-escape-hatches": ["error", { allowUniwindTheme: true }],
425 },
426 },
427 ],
428 options: {
429 reportUnusedDisableDirectives: "error",
430 typeAware: false,
431 typeCheck: false,
432 },
433 },
434});