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