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 "apps/mobile/android/**",
98 "apps/mobile/ios/**",
99 "apps/mobile/uniwind-types.d.ts",
100 "*.icon/**",
101 ],
102 sortPackageJson: {},
103 overrides: [
104 {
105 files: [".devcontainer/devcontainer.json"],
106 options: {
107 trailingComma: "none",
108 },
109 },
110 ],
111 },
112 lint: {
113 ignorePatterns: [
114 ".repos",
115 ".repos/**",
116 "dist",
117 "dist-electron",
118 "node_modules",
119 "pnpm-lock.yaml",
120 "*.tsbuildinfo",
121 "**/routeTree.gen.ts",
122 "apps/mobile/android/**",
123 "apps/mobile/ios/**",
124 "apps/mobile/uniwind-types.d.ts",
125 ],
126 plugins: ["eslint", "oxc", "react", "unicorn", "typescript"],
127 jsPlugins: ["./oxlint-plugin-t3code/index.ts", "@shadcn/lint"],
128 settings: {
129 shadcn: { ui: "~/components/ui" },
130 },
131 categories: {
132 correctness: "warn",
133 suspicious: "warn",
134 perf: "warn",
135 },
136 rules: {
137 "unicorn/no-array-sort": "off",
138 "unicorn/consistent-function-scoping": "off",
139 "oxc/no-map-spread": "off",
140 "react-in-jsx-scope": "off",
141 "react-hooks/exhaustive-deps": "off",
142 "eslint/no-shadow": "off",
143 "eslint/no-await-in-loop": "off",
144 "eslint/no-underscore-dangle": "off",
145 "typescript/consistent-return": "off",
146 "typescript/no-base-to-string": "off",
147 "typescript/no-duplicate-type-constituents": "off",
148 "typescript/no-floating-promises": "off",
149 "typescript/no-implied-eval": "off",
150 "typescript/no-meaningless-void-operator": "off",
151 "typescript/no-redundant-type-constituents": "off",
152 "typescript/no-unnecessary-boolean-literal-compare": "off",
153 "typescript/no-unnecessary-type-conversion": "off",
154 "typescript/no-unnecessary-type-arguments": "off",
155 "typescript/no-unnecessary-type-assertion": "off",
156 "typescript/no-unnecessary-type-parameters": "off",
157 "typescript/no-unsafe-type-assertion": "off",
158 "typescript/await-thenable": "off",
159 "typescript/require-array-sort-compare": "off",
160 "typescript/restrict-template-expressions": "off",
161 "typescript/unbound-method": "off",
162 "eslint/no-restricted-imports": [
163 "error",
164 { paths: [...RESTRICTED_IMPORT_PATHS, RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS] },
165 ],
166 "t3code/no-global-process-runtime": "error",
167 "t3code/no-inline-schema-compile": "warn",
168 "t3code/no-manual-effect-runtime-in-tests": "error",
169 "t3code/no-native-title-tooltip": "error",
170 "t3code/no-raw-mcp-registration": "error",
171 "t3code/no-test-in-loop": "error",
172 "t3code/no-rpc-permission-bypass": ["error", { allowRawClientAccess: true }],
173 "t3code/no-unscoped-has": "error",
174 "t3code/namespace-node-imports": "error",
175 "t3code/prefer-catch-tags": "error",
176 "t3code/require-suppression-reason": "error",
177 },
178 overrides: [
179 {
180 files: ["packages/client-runtime/src/state/**", "apps/{web,mobile,desktop}/src/**"],
181 rules: { "t3code/no-rpc-permission-bypass": ["error", { allowRawClientAccess: false }] },
182 },
183 {
184 // Only shared command boundaries install the session-backed permission guard.
185 files: [
186 "packages/client-runtime/src/state/runtime.ts",
187 "packages/client-runtime/src/state/vcsAction.ts",
188 ],
189 rules: {
190 "t3code/no-rpc-permission-bypass": [
191 "error",
192 { allowGuardInstallation: true, allowRawClientAccess: false },
193 ],
194 },
195 },
196 {
197 // These clients are session metadata, device streams, and an Expo update adapter.
198 files: [
199 "apps/web/src/components/settings/ConnectionsSettings.tsx",
200 "apps/mobile/src/features/updates/app-updates.ts",
201 "apps/web/src/components/device/DevicePhoneViewport.tsx",
202 "apps/web/src/components/device/DeviceDuoViewport.tsx",
203 ],
204 rules: { "t3code/no-rpc-permission-bypass": ["error", { allowRawClientAccess: true }] },
205 },
206 {
207 // Incompatible hosts cannot open a normal session; their updater uses a dedicated socket.
208 files: ["packages/client-runtime/src/connection/outdatedHostUpdate.ts"],
209 rules: { "t3code/no-rpc-permission-bypass": "off" },
210 },
211 {
212 // RPC implementation and transport test fixtures need the raw client.
213 files: [
214 "packages/client-runtime/src/rpc/**",
215 "**/*.{test,spec}.{ts,tsx,js,jsx,mts,cts,mjs,cjs}",
216 ],
217 rules: { "t3code/no-rpc-permission-bypass": "off" },
218 },
219 {
220 // The one place that reads the host platform to seed the injected references.
221 files: ["packages/shared/src/hostProcess.ts"],
222 rules: { "t3code/no-global-process-runtime": "off" },
223 },
224 {
225 // The registration helpers that only accept handlers built by McpToolAccess.
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 // The one module allowed to name lucide's pull-request glyphs; everything else picks
244 // from its vocabulary. The other import restrictions still apply here.
245 files: ["apps/web/src/components/pullRequest/pullRequestIcons.tsx"],
246 rules: { "eslint/no-restricted-imports": ["error", { paths: RESTRICTED_IMPORT_PATHS }] },
247 },
248 {
249 files: ["apps/mobile/src/**"],
250 rules: { "t3code/no-mobile-uniwind-theme-escape-hatches": "error" },
251 },
252 {
253 // Every class in web code must be one Tailwind generates: a typo or a class nothing
254 // declares ships silently unstyled. JS hooks use data attributes, not class names.
255 files: ["apps/web/src/**"],
256 rules: { "shadcn/no-unknown-classes": "error" },
257 },
258 {
259 // Colors come from theme tokens so status tones follow custom themes. components/ui
260 // has no findings and stays covered too.
261 files: ["apps/web/src/**"],
262 rules: { "shadcn/no-raw-colors": "error" },
263 },
264 {
265 // Third-party marks (brand logos, the macOS permission panes, Codex's Computer Use
266 // mark) must keep their exact colors, so the files that hold them are exempt.
267 files: ["apps/web/src/components/Icons.tsx", "apps/web/src/components/JetBrainsIcons.tsx"],
268 rules: { "shadcn/no-raw-colors": "off" },
269 },
270 {
271 // components/ui exports own their look. App code picks a variant or size instead
272 // of restyling with className; layout classes (width, flex, margin, position) stay
273 // allowed because placement belongs to the parent. components/ui is for generic
274 // primitives: a look that belongs to one feature stays in that feature's component.
275 files: ["apps/web/src/**"],
276 excludeFiles: ["apps/web/src/components/ui/**"],
277 rules: {
278 // A className built at runtime on a ui component is one no-restyle cannot read.
279 "shadcn/require-static-classes": "error",
280 // Appearance values come from the theme and Tailwind's scales. Layout stays free
281 // (placement belongs to the parent); the other entries are values no scale can hold.
282 "shadcn/no-arbitrary-values": [
283 "error",
284 {
285 allow: [
286 "layout",
287 // Which properties an element animates is per-element behaviour, like layout,
288 // not a design value; timing curves and durations still come from the theme.
289 "transition",
290 // Overlays that follow their frame's corner, which is set at runtime
291 // (floating preview) or by the element they decorate (composer outline).
292 "rounded-[inherit]",
293 // Inline chips size in em so they scale with the text they sit in
294 // (the composer honours the prompt font-size preference).
295 "gap-[0.33em]",
296 "px-[0.5em]",
297 "rounded-[0.5em]",
298 "text-[0.86em]",
299 // Project icons render from 14px to 48px and keep one proportional corner.
300 "rounded-[25%]",
301 // An emoji project icon fills its container, whatever size the parent gives it.
302 "text-[length:80cqh]",
303 // The platform's own selection colour on a selected composer chip.
304 "bg-[Highlight]",
305 // Brand marks keep their brand colours (Cursor, Grok, Claude).
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 // The sign-in masthead is T3 brand artwork: fixed gradients, not theme surfaces.
334 files: ["apps/web/src/components/auth/AuthSurfaceShell.tsx"],
335 rules: { "shadcn/no-arbitrary-values": "off" },
336 },
337 {
338 // Shared client code must not call APIs missing from Hermes. Our ESNext
339 // TypeScript target accepts them even when they would crash mobile at launch.
340 // Tests run on Node and are exempt.
341 files: [
342 "apps/mobile/src/**",
343 "packages/client-runtime/src/**",
344 "packages/contracts/src/**",
345 "packages/shared/src/**",
346 ],
347 excludeFiles: ["**/*.test.ts", "**/*.test.tsx"],
348 rules: { "t3code/no-hermes-unsupported-apis": "error" },
349 },
350 {
351 // Reviewed native and third-party interop boundaries that cannot consume a className.
352 files: [
353 "apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx",
354 "apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx",
355 "apps/mobile/src/features/files/FileMarkdownPreview.tsx",
356 "apps/mobile/src/features/files/SourceFileSurface.tsx",
357 "apps/mobile/src/features/files/AttachmentFileScreen.tsx",
358 "apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx",
359 "apps/mobile/src/features/files/thread-file-navigator-pane.tsx",
360 "apps/mobile/src/features/home/HomeHeader.tsx",
361 "apps/mobile/src/features/review/ReviewSheet.tsx",
362 "apps/mobile/src/features/review/useNativeReviewDiffBridge.ts",
363 "apps/mobile/src/features/settings/SettingsEnvironmentsRouteScreen.tsx",
364 "apps/mobile/src/features/threads/GitActionProgressOverlay.tsx",
365 "apps/mobile/src/features/threads/NewTaskDraftScreen.tsx",
366 "apps/mobile/src/features/threads/ThreadComposer.tsx",
367 "apps/mobile/src/features/threads/ThreadFeed.tsx",
368 "apps/mobile/src/features/settings/appearance/components/FontSizeSliderRow.tsx",
369 "apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx",
370 "apps/mobile/src/features/threads/ThreadQueueControl.tsx",
371 "apps/mobile/src/features/threads/ThreadAgentsSheet.tsx",
372 "apps/mobile/src/features/review/ReviewCommentCard.tsx",
373 "apps/mobile/src/features/threads/ThreadSettingsSheet.tsx",
374 "apps/mobile/src/features/threads/git/GitOverviewSheet.tsx",
375 "apps/mobile/src/features/threads/thread-list-items.tsx",
376 "apps/mobile/src/features/threads/thread-list-v2-items.tsx",
377 "apps/mobile/src/lib/useMobileNavigationTheme.ts",
378 "apps/mobile/src/native/T3ComposerEditor.ios.tsx",
379 "apps/mobile/src/native/T3ComposerEditor.native.tsx",
380 "apps/mobile/src/native/SelectableMarkdownText.android.tsx",
381 ],
382 rules: {
383 "t3code/no-mobile-uniwind-theme-escape-hatches": ["error", { allowUniwindTheme: true }],
384 },
385 },
386 ],
387 options: {
388 reportUnusedDisableDirectives: "error",
389 // Revisit once Oxlint's tsgolint path can integrate with @effect/tsgo diagnostics.
390 typeAware: false,
391 typeCheck: false,
392 },
393 },
394});