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