Open History to see the last commit
1import "vite-plus/test/config";
2import { defineConfig } from "vite-plus";
3import * as NodeURL from "node:url";
4
5/** Import restrictions every file keeps, including the one module exempt from the glyph rule. */
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
19/**
20 * The cva functions behind components/ui exports. They style a foreign element to look
21 * like a Button or Toggle, which bypasses the component's variants; render the component
22 * instead (`render={<Button …/>}`, or `SelectButton` for a picker trigger).
23 */
24const RESTRICTED_UI_VARIANT_PATTERNS = [
25 {
26 group: ["**/components/ui/*", "**/ui/*", "./ui/*"],
27 importNames: ["buttonVariants", "toggleVariants", "badgeVariants", "selectTriggerVariants"],
28 message:
29 "Render the components/ui export instead of borrowing its class recipe (render={<Button …/>}, SelectButton, ToggleGroup).",
30 },
31];
32
33/** Lucide's pull-request glyphs, which only `pullRequestIcons.tsx` may name. */
34const RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS = {
35 name: "lucide-react",
36 importNames: [
37 "GitMerge",
38 "GitMergeIcon",
39 "GitPullRequest",
40 "GitPullRequestIcon",
41 "GitPullRequestArrow",
42 "GitPullRequestArrowIcon",
43 "GitPullRequestClosed",
44 "GitPullRequestClosedIcon",
45 "GitPullRequestDraft",
46 "GitPullRequestDraftIcon",
47 "GitPullRequestCreate",
48 "GitPullRequestCreateIcon",
49 "GitPullRequestCreateArrow",
50 "GitPullRequestCreateArrowIcon",
51 ],
52 message:
53 "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.",
54};
55
56export default defineConfig({
57 resolve: {
58 alias: {
59 "~": NodeURL.fileURLToPath(new URL("./apps/web/src", import.meta.url)),
60 },
61 },
62 test: {
63 environment: "node",
64 exclude: [
65 "**/.repos/**",
66 "**/.t3/**",
67 "**/node_modules/**",
68 "**/dist/**",
69 "**/dist-electron/**",
70 "**/.{idea,git,cache,output,temp}/**",
71 ],
72 hookTimeout: 60_000,
73 testTimeout: 60_000,
74 setupFiles: [
75 NodeURL.fileURLToPath(
76 new URL("./packages/shared/src/testing/longTempDir.ts", import.meta.url),
77 ),
78 ],
79 },
80 staged: {
81 // Formatter only for now — no lint or typecheck on commit.
82 "*": "vp fmt --no-error-on-unmatched-pattern",
83 },
84 fmt: {
85 ignorePatterns: [
86 ".repos/**",
87 // Macroscope's glob-per-line ignore grammar, not Markdown: formatting
88 // it rewrites `*` as `_` and joins lines.
89 ".macroscope/ignore.md",
90 ".alchemy",
91 "dist",
92 "dist-electron",
93 "node_modules",
94 "pnpm-lock.yaml",
95 "*.tsbuildinfo",
96 "**/routeTree.gen.ts",
97 "**/*.graphql.ts",
98 "packages/source-control-github/schema/**",
99 "apps/mobile/android/**",
100 "apps/mobile/ios/**",
101 "apps/mobile/uniwind-types.d.ts",
102 "*.icon/**",
103 ],
104 sortPackageJson: {},
105 overrides: [
106 {
107 files: [".devcontainer/devcontainer.json"],
108 options: {
109 trailingComma: "none",
110 },
111 },
112 ],
113 },
114 lint: {
115 ignorePatterns: [
116 ".repos",
117 ".repos/**",
118 "dist",
119 "dist-electron",
120 "node_modules",
121 "pnpm-lock.yaml",
122 "*.tsbuildinfo",
123 "**/routeTree.gen.ts",
124 "**/*.graphql.ts",
125 "packages/source-control-github/schema/**",
126 "apps/mobile/android/**",
127 "apps/mobile/ios/**",
128 "apps/mobile/uniwind-types.d.ts",
129 ],
130 plugins: ["eslint", "oxc", "react", "unicorn", "typescript"],
131 jsPlugins: ["./oxlint-plugin-t3code/index.ts", "@shadcn/lint"],
132 settings: {
133 shadcn: { ui: "~/components/ui" },
134 },
135 categories: {
136 correctness: "warn",
137 suspicious: "warn",
138 perf: "warn",
139 },
140 rules: {
141 "unicorn/no-array-sort": "off",
142 "unicorn/consistent-function-scoping": "off",
143 "oxc/no-map-spread": "off",
144 "react-in-jsx-scope": "off",
145 "react-hooks/exhaustive-deps": "off",
146 "eslint/no-shadow": "off",
147 "eslint/no-await-in-loop": "off",
148 "eslint/no-underscore-dangle": "off",
149 "typescript/consistent-return": "off",
150 "typescript/no-base-to-string": "off",
151 "typescript/no-duplicate-type-constituents": "off",
152 "typescript/no-floating-promises": "off",
153 "typescript/no-implied-eval": "off",
154 "typescript/no-meaningless-void-operator": "off",
155 "typescript/no-redundant-type-constituents": "off",
156 "typescript/no-unnecessary-boolean-literal-compare": "off",
157 "typescript/no-unnecessary-type-conversion": "off",
158 "typescript/no-unnecessary-type-arguments": "off",
159 "typescript/no-unnecessary-type-assertion": "off",
160 "typescript/no-unnecessary-type-parameters": "off",
161 "typescript/no-unsafe-type-assertion": "off",
162 "typescript/await-thenable": "off",
163 "typescript/require-array-sort-compare": "off",
164 "typescript/restrict-template-expressions": "off",
165 "typescript/unbound-method": "off",
166 "eslint/no-restricted-imports": [
167 "error",
168 { paths: [...RESTRICTED_IMPORT_PATHS, RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS] },
169 ],
170 "t3code/no-global-process-runtime": "error",
171 "t3code/no-inline-schema-compile": "warn",
172 "t3code/no-manual-effect-runtime-in-tests": "error",
173 "t3code/no-native-title-tooltip": "error",
174 "t3code/no-raw-mcp-registration": "error",
175 "t3code/no-test-in-loop": "error",
176 "t3code/no-rpc-permission-bypass": ["error", { allowRawClientAccess: true }],
177 "t3code/no-unscoped-has": "error",
178 "t3code/namespace-node-imports": "error",
179 "t3code/prefer-catch-tags": "error",
180 "t3code/require-centered-scroll-gutter": "error",
181 "t3code/require-suppression-reason": "error",
182 },
183 overrides: [
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 // Only shared command boundaries install the session-backed permission guard.
190 files: [
191 "packages/client-runtime/src/state/runtime.ts",
192 "packages/client-runtime/src/state/vcsAction.ts",
193 ],
194 rules: {
195 "t3code/no-rpc-permission-bypass": [
196 "error",
197 { allowGuardInstallation: true, allowRawClientAccess: false },
198 ],
199 },
200 },
201 {
202 // These clients are session metadata, device streams, and an Expo update adapter.
203 files: [
204 "apps/web/src/components/settings/ConnectionsSettings.tsx",
205 "apps/mobile/src/features/updates/app-updates.ts",
206 "apps/web/src/components/device/DevicePhoneViewport.tsx",
207 "apps/web/src/components/device/DeviceDuoViewport.tsx",
208 ],
209 rules: { "t3code/no-rpc-permission-bypass": ["error", { allowRawClientAccess: true }] },
210 },
211 {
212 // Incompatible hosts cannot open a normal session; their updater uses a dedicated socket.
213 files: ["packages/client-runtime/src/connection/outdatedHostUpdate.ts"],
214 rules: { "t3code/no-rpc-permission-bypass": "off" },
215 },
216 {
217 // RPC implementation and transport test fixtures need the raw client.
218 files: [
219 "packages/client-runtime/src/rpc/**",
220 "**/*.{test,spec}.{ts,tsx,js,jsx,mts,cts,mjs,cjs}",
221 ],
222 rules: { "t3code/no-rpc-permission-bypass": "off" },
223 },
224 {
225 // The one place that reads the host platform to seed the injected references.
226 files: ["packages/shared/src/HostProcess.ts"],
227 rules: { "t3code/no-global-process-runtime": "off" },
228 },
229 {
230 // The registration helpers that only accept handlers built by McpToolAccess.
231 files: ["apps/server/src/mcp/McpHttpServer.ts"],
232 rules: { "t3code/no-raw-mcp-registration": "off" },
233 },
234 {
235 files: ["apps/web/src/**"],
236 excludeFiles: ["apps/web/src/components/ui/**"],
237 rules: {
238 "eslint/no-restricted-imports": [
239 "error",
240 {
241 paths: [...RESTRICTED_IMPORT_PATHS, RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS],
242 patterns: RESTRICTED_UI_VARIANT_PATTERNS,
243 },
244 ],
245 },
246 },
247 {
248 // The one module allowed to name lucide's pull-request glyphs; everything else picks
249 // from its vocabulary. The other import restrictions still apply here.
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 // React commits state set in a raw ResizeObserver callback after the paint, so derived
259 // layout lands a frame late. observeResize flushes every observed resize in one render.
260 files: ["apps/web/src/**"],
261 excludeFiles: [
262 "apps/web/src/lib/observeResize.ts",
263 "**/*.{test,spec}.{ts,tsx,js,jsx,mts,cts,mjs,cjs}",
264 ],
265 rules: { "t3code/no-raw-resize-observer": "error" },
266 },
267 {
268 // Every class in web code must be one Tailwind generates: a typo or a class nothing
269 // declares ships silently unstyled. JS hooks use data attributes, not class names.
270 files: ["apps/web/src/**"],
271 rules: { "shadcn/no-unknown-classes": "error" },
272 },
273 {
274 // State indicators paint inward; decorative rings keep their own geometry.
275 files: ["apps/web/src/**"],
276 rules: { "t3code/no-outset-state-indicators": "error" },
277 },
278 {
279 // Colors come from theme tokens so status tones follow custom themes. components/ui
280 // has no findings and stays covered too.
281 files: ["apps/web/src/**"],
282 rules: { "shadcn/no-raw-colors": "error" },
283 },
284 {
285 // Third-party marks (brand logos, the macOS permission panes, Codex's Computer Use
286 // mark) must keep their exact colors, so the files that hold them are exempt.
287 files: ["apps/web/src/components/Icons.tsx", "apps/web/src/components/JetBrainsIcons.tsx"],
288 rules: { "shadcn/no-raw-colors": "off" },
289 },
290 {
291 // components/ui exports own their look. App code picks a variant or size instead
292 // of restyling with className; layout classes (width, flex, margin, position) stay
293 // allowed because placement belongs to the parent. components/ui is for generic
294 // primitives: a look that belongs to one feature stays in that feature's component.
295 files: ["apps/web/src/**"],
296 excludeFiles: ["apps/web/src/components/ui/**"],
297 rules: {
298 // A className built at runtime on a ui component is one no-restyle cannot read.
299 "shadcn/require-static-classes": "error",
300 // Appearance values come from the theme and Tailwind's scales. Layout stays free
301 // (placement belongs to the parent); the other entries are values no scale can hold.
302 "shadcn/no-arbitrary-values": [
303 "error",
304 {
305 allow: [
306 "layout",
307 // Which properties an element animates is per-element behaviour, like layout,
308 // not a design value; timing curves and durations still come from the theme.
309 "transition",
310 // Overlays that follow their frame's corner, which is set at runtime
311 // (floating preview) or by the element they decorate (composer outline).
312 "rounded-[inherit]",
313 // Inline chips size in em so they scale with the text they sit in
314 // (the composer honours the prompt font-size preference).
315 "gap-[0.33em]",
316 "px-[0.5em]",
317 "rounded-[0.5em]",
318 "text-[0.86em]",
319 // Project icons render from 14px to 48px and keep one proportional corner.
320 "rounded-[25%]",
321 // An emoji project icon fills its container, whatever size the parent gives it.
322 "text-[length:80cqh]",
323 // The platform's own selection colour on a selected composer chip.
324 "bg-[Highlight]",
325 // Brand marks keep their brand colours (Cursor, Grok, Claude).
326 "fill-[#26251E]",
327 "fill-[#EDECEC]",
328 "fill-[#0F0F0F]",
329 "fill-[#F5F5F5]",
330 "fill-[#d97757]",
331 "text-[#d97757]",
332 ],
333 },
334 ],
335 "shadcn/no-restyle": [
336 "error",
337 {
338 allow: ["layout"],
339 contracts: [
340 {
341 // CollapsibleTrigger is a bare button with no styled counterpart
342 // (a disclosure row is not a Button), so its className is the API.
343 // Every other trigger has one: style them with render={<Button …/>}.
344 pattern: "^CollapsibleTrigger$",
345 allow: ["layout", "color", "typography", "spacing", "shape", "effects", "motion"],
346 },
347 ],
348 },
349 ],
350 },
351 },
352 {
353 // The sign-in masthead is T3 brand artwork: fixed gradients, not theme surfaces.
354 files: ["apps/web/src/components/auth/AuthSurfaceShell.tsx"],
355 rules: { "shadcn/no-arbitrary-values": "off" },
356 },
357 {
358 // Shared client code must not call APIs missing from Hermes. Our ESNext
359 // TypeScript target accepts them even when they would crash mobile at launch.
360 // Tests run on Node and are exempt.
361 files: [
362 "apps/mobile/src/**",
363 "packages/client-runtime/src/**",
364 "packages/contracts/src/**",
365 "packages/shared/src/**",
366 ],
367 excludeFiles: ["**/*.test.ts", "**/*.test.tsx"],
368 rules: { "t3code/no-hermes-unsupported-apis": "error" },
369 },
370 {
371 // Reviewed native and third-party interop boundaries that cannot consume a className.
372 files: [
373 "apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx",
374 "apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx",
375 "apps/mobile/src/features/files/FileMarkdownPreview.tsx",
376 "apps/mobile/src/features/files/SourceFileSurface.tsx",
377 "apps/mobile/src/features/files/AttachmentFileScreen.tsx",
378 "apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx",
379 "apps/mobile/src/features/files/thread-file-navigator-pane.tsx",
380 "apps/mobile/src/features/home/HomeHeader.tsx",
381 "apps/mobile/src/features/review/ReviewSheet.tsx",
382 "apps/mobile/src/features/review/useNativeReviewDiffBridge.ts",
383 "apps/mobile/src/features/settings/SettingsEnvironmentsRouteScreen.tsx",
384 "apps/mobile/src/features/threads/GitActionProgressOverlay.tsx",
385 "apps/mobile/src/features/threads/NewTaskDraftScreen.tsx",
386 "apps/mobile/src/features/threads/ThreadComposer.tsx",
387 "apps/mobile/src/features/threads/ThreadFeed.tsx",
388 "apps/mobile/src/features/settings/appearance/components/FontSizeSliderRow.tsx",
389 "apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx",
390 "apps/mobile/src/features/threads/ThreadQueueControl.tsx",
391 "apps/mobile/src/features/threads/ThreadAgentsSheet.tsx",
392 "apps/mobile/src/features/review/ReviewCommentCard.tsx",
393 "apps/mobile/src/features/threads/ThreadSettingsSheet.tsx",
394 "apps/mobile/src/features/threads/git/GitOverviewSheet.tsx",
395 "apps/mobile/src/features/threads/thread-list-items.tsx",
396 "apps/mobile/src/features/threads/thread-list-v2-items.tsx",
397 "apps/mobile/src/lib/useMobileNavigationTheme.ts",
398 "apps/mobile/src/native/T3ComposerEditor.ios.tsx",
399 "apps/mobile/src/native/T3ComposerEditor.native.tsx",
400 "apps/mobile/src/native/SelectableMarkdownText.tsx",
401 ],
402 rules: {
403 "t3code/no-mobile-uniwind-theme-escape-hatches": ["error", { allowUniwindTheme: true }],
404 },
405 },
406 ],
407 options: {
408 reportUnusedDisableDirectives: "error",
409 // Revisit once Oxlint's tsgolint path can integrate with @effect/tsgo diagnostics.
410 typeAware: false,
411 typeCheck: false,
412 },
413 },
414});