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/prefer-effect-fn": "error",
176 "t3code/require-centered-scroll-gutter": "error",
177 "t3code/require-suppression-reason": "error",
178 },
179 overrides: [
180 {
181 files: [
182 "**/*.{test,spec,testkit}.{ts,tsx}",
183 "**/{test,tests,testkit,testing,fixtures,integration}/**",
184 "packages/provider-testing/**",
185 ],
186 rules: { "t3code/prefer-effect-fn": "off" },
187 },
188 {
189 files: ["apps/**/src/**", "packages/**/src/**"],
190 excludeFiles: DOM_TEST_ENVIRONMENT_ALLOWLIST,
191 rules: { "t3code/no-dom-test-environment": "error" },
192 },
193 {
194 files: ["packages/client-runtime/src/state/**", "apps/{web,mobile,desktop}/src/**"],
195 rules: { "t3code/no-rpc-permission-bypass": ["error", { allowRawClientAccess: false }] },
196 },
197 {
198 files: [
199 "packages/client-runtime/src/state/runtime.ts",
200 "packages/client-runtime/src/state/vcsAction.ts",
201 ],
202 rules: {
203 "t3code/no-rpc-permission-bypass": [
204 "error",
205 { allowGuardInstallation: true, allowRawClientAccess: false },
206 ],
207 },
208 },
209 {
210 files: [
211 "apps/web/src/components/settings/ConnectionsSettings.tsx",
212 "apps/mobile/src/features/updates/app-updates.ts",
213 "apps/web/src/components/device/DevicePhoneViewport.tsx",
214 "apps/web/src/components/device/DeviceDuoViewport.tsx",
215 ],
216 rules: { "t3code/no-rpc-permission-bypass": ["error", { allowRawClientAccess: true }] },
217 },
218 {
219 files: ["packages/client-runtime/src/connection/outdatedHostUpdate.ts"],
220 rules: { "t3code/no-rpc-permission-bypass": "off" },
221 },
222 {
223 files: [
224 "packages/client-runtime/src/rpc/**",
225 "**/*.{test,spec}.{ts,tsx,js,jsx,mts,cts,mjs,cjs}",
226 ],
227 rules: { "t3code/no-rpc-permission-bypass": "off" },
228 },
229 {
230 files: ["packages/shared/src/HostProcess.ts"],
231 rules: { "t3code/no-global-process-runtime": "off" },
232 },
233 {
234 // The `t3` npm launcher is published as plain, dependency-free Node.
235 files: ["scripts/npm-launcher/**"],
236 rules: {
237 "t3code/no-global-process-runtime": "off",
238 "t3code/namespace-node-imports": "off",
239 },
240 },
241 {
242 files: ["apps/server/src/mcp/McpHttpServer.ts"],
243 rules: { "t3code/no-raw-mcp-registration": "off" },
244 },
245 {
246 files: ["apps/web/src/**"],
247 excludeFiles: ["apps/web/src/components/ui/**"],
248 rules: {
249 "eslint/no-restricted-imports": [
250 "error",
251 {
252 paths: [...RESTRICTED_IMPORT_PATHS, RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS],
253 patterns: RESTRICTED_UI_VARIANT_PATTERNS,
254 },
255 ],
256 },
257 },
258 {
259 files: ["apps/web/src/components/pullRequest/pullRequestIcons.tsx"],
260 rules: { "eslint/no-restricted-imports": ["error", { paths: RESTRICTED_IMPORT_PATHS }] },
261 },
262 {
263 files: ["apps/mobile/src/**"],
264 rules: { "t3code/no-mobile-uniwind-theme-escape-hatches": "error" },
265 },
266 {
267 files: ["apps/mobile/src/**"],
268 excludeFiles: [
269 "apps/mobile/src/components/ui/AppSymbol.tsx",
270 "apps/mobile/src/components/ui/AppSymbol.ios.tsx",
271 "apps/mobile/src/features/pull-requests/pullRequestGlyphs.ts",
272 ],
273 rules: { "t3code/no-mobile-pull-request-glyph-literals": "error" },
274 },
275 {
276 // React commits state set in a raw ResizeObserver callback after the paint, so derived
277 // layout lands a frame late. observeResize flushes every observed resize in one render.
278 files: ["apps/web/src/**"],
279 excludeFiles: [
280 "apps/web/src/lib/observeResize.ts",
281 "**/*.{test,spec}.{ts,tsx,js,jsx,mts,cts,mjs,cjs}",
282 ],
283 rules: { "t3code/no-raw-resize-observer": "error" },
284 },
285 {
286 files: ["apps/web/src/**"],
287 rules: { "shadcn/no-unknown-classes": "error" },
288 },
289 {
290 files: ["apps/web/src/**"],
291 rules: { "t3code/no-outset-state-indicators": "error" },
292 },
293 {
294 files: ["apps/web/src/**"],
295 rules: { "shadcn/no-raw-colors": "error" },
296 },
297 {
298 // Third-party marks (brand logos, the macOS permission panes, Codex's Computer Use
299 // mark) must keep their exact colors, so the files that hold them are exempt.
300 files: ["apps/web/src/components/Icons.tsx", "apps/web/src/components/JetBrainsIcons.tsx"],
301 rules: { "shadcn/no-raw-colors": "off" },
302 },
303 {
304 files: ["apps/web/src/**"],
305 excludeFiles: ["apps/web/src/components/ui/**"],
306 rules: {
307 "shadcn/require-static-classes": "error",
308 "shadcn/no-arbitrary-values": [
309 "error",
310 {
311 allow: [
312 "layout",
313 "transition",
314 "rounded-[inherit]",
315 "gap-[0.33em]",
316 "px-[0.5em]",
317 "rounded-[0.5em]",
318 "text-[0.86em]",
319 "rounded-[25%]",
320 "text-[length:80cqh]",
321 "bg-[Highlight]",
322 "fill-[#26251E]",
323 "fill-[#EDECEC]",
324 "fill-[#0F0F0F]",
325 "fill-[#F5F5F5]",
326 "fill-[#d97757]",
327 "text-[#d97757]",
328 ],
329 },
330 ],
331 "shadcn/no-restyle": [
332 "error",
333 {
334 allow: ["layout"],
335 contracts: [
336 {
337 // CollapsibleTrigger is a bare button with no styled counterpart
338 // (a disclosure row is not a Button), so its className is the API.
339 // Every other trigger has one: style them with render={<Button …/>}.
340 pattern: "^CollapsibleTrigger$",
341 allow: ["layout", "color", "typography", "spacing", "shape", "effects", "motion"],
342 },
343 ],
344 },
345 ],
346 },
347 },
348 {
349 // Every web file must compile under the React Compiler. Its bailout rules are errors here,
350 // and manual memoization is redundant. No upstream rule bans useMemo/useCallback, hence
351 // t3code/no-manual-memo.
352 files: ["apps/web/src/**/*.{ts,tsx}"],
353 rules: {
354 "react/exhaustive-effect-dependencies": "error",
355 "react/globals": "error",
356 "react/hooks": "error",
357 "react/immutability": "error",
358 // The compiler memoizes context values; this rule would ask for useMemo.
359 "react/jsx-no-constructed-context-values": "off",
360 "react/memo-dependencies": "error",
361 "react/preserve-manual-memoization": "error",
362 "react/purity": "error",
363 "react/refs": "error",
364 "react/set-state-in-effect": "error",
365 "react/set-state-in-render": "error",
366 "react/static-components": "error",
367 "react/unsupported-syntax": "error",
368 "t3code/no-manual-memo": "error",
369 },
370 },
371 {
372 // The sign-in masthead is T3 brand artwork: fixed gradients, not theme surfaces.
373 files: ["apps/web/src/components/auth/AuthSurfaceShell.tsx"],
374 rules: { "shadcn/no-arbitrary-values": "off" },
375 },
376 {
377 // Shared client code must not call APIs missing from Hermes. Our ESNext
378 // TypeScript target accepts them even when they would crash mobile at launch.
379 // Tests run on Node and are exempt.
380 files: [
381 "apps/mobile/src/**",
382 "packages/client-runtime/src/**",
383 "packages/contracts/src/**",
384 "packages/shared/src/**",
385 ],
386 excludeFiles: ["**/*.test.ts", "**/*.test.tsx"],
387 rules: { "t3code/no-hermes-unsupported-apis": "error" },
388 },
389 {
390 // Mobile is ratcheting toward full React Compiler coverage
391 // (apps/mobile/src/reactCompilerCoverage.test.ts). Directives would hide bailouts from it;
392 // the manual memo hooks go once the allowlist there is empty.
393 files: ["apps/mobile/src/**/*.{ts,tsx}"],
394 rules: { "t3code/no-manual-memo": ["error", { allowMemoHooks: true }] },
395 },
396 {
397 // The compiler only compiles a use* function that calls a hook; one that calls none is
398 // silently left as a plain function, so whatever it returns loses its caching.
399 files: ["apps/web/src/**/*.{ts,tsx}", "apps/mobile/src/**/*.{ts,tsx}"],
400 excludeFiles: ["**/*.test.ts", "**/*.test.tsx"],
401 rules: { "t3code/no-hookless-use-function": "error" },
402 },
403 {
404 files: [
405 "apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx",
406 "apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx",
407 "apps/mobile/src/features/files/FileMarkdownPreview.tsx",
408 "apps/mobile/src/features/files/SourceFileSurface.tsx",
409 "apps/mobile/src/features/files/AttachmentFileScreen.tsx",
410 "apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx",
411 "apps/mobile/src/features/files/thread-file-navigator-pane.tsx",
412 "apps/mobile/src/features/home/HomeHeader.tsx",
413 "apps/mobile/src/features/review/ReviewSheet.tsx",
414 "apps/mobile/src/features/review/useNativeReviewDiffBridge.ts",
415 "apps/mobile/src/features/settings/SettingsEnvironmentsRouteScreen.tsx",
416 "apps/mobile/src/features/threads/GitActionProgressOverlay.tsx",
417 "apps/mobile/src/features/threads/NewTaskDraftScreen.tsx",
418 "apps/mobile/src/features/threads/ThreadComposer.tsx",
419 "apps/mobile/src/features/threads/ThreadFeed.tsx",
420 "apps/mobile/src/features/settings/appearance/components/FontSizeSliderRow.tsx",
421 "apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx",
422 "apps/mobile/src/features/threads/ThreadQueueControl.tsx",
423 "apps/mobile/src/features/review/ReviewCommentCard.tsx",
424 "apps/mobile/src/features/threads/ThreadSettingsSheet.tsx",
425 "apps/mobile/src/features/threads/thread-list-items.tsx",
426 "apps/mobile/src/features/threads/thread-list-v2-items.tsx",
427 "apps/mobile/src/lib/useMobileNavigationTheme.ts",
428 "apps/mobile/src/native/T3ComposerEditor.ios.tsx",
429 "apps/mobile/src/native/T3ComposerEditor.native.tsx",
430 "apps/mobile/src/native/SelectableMarkdownText.tsx",
431 ],
432 rules: {
433 "t3code/no-mobile-uniwind-theme-escape-hatches": ["error", { allowUniwindTheme: true }],
434 },
435 },
436 ],
437 options: {
438 reportUnusedDisableDirectives: "error",
439 typeAware: false,
440 typeCheck: false,
441 },
442 },
443});