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 "**/node_modules/**",
67 "**/dist/**",
68 "**/dist-electron/**",
69 "**/.{idea,git,cache,output,temp}/**",
70 ],
71 hookTimeout: 60_000,
72 testTimeout: 60_000,
73 setupFiles: [
74 NodeURL.fileURLToPath(
75 new URL("./packages/shared/src/testing/longTempDir.ts", import.meta.url),
76 ),
77 ],
78 },
79 staged: {
80 // Formatter only for now — no lint or typecheck on commit.
81 "*": "vp fmt --no-error-on-unmatched-pattern",
82 },
83 fmt: {
84 ignorePatterns: [
85 ".repos/**",
86 // Macroscope's glob-per-line ignore grammar, not Markdown: formatting
87 // it rewrites `*` as `_` and joins lines.
88 ".macroscope/ignore.md",
89 ".alchemy",
90 "dist",
91 "dist-electron",
92 "node_modules",
93 "pnpm-lock.yaml",
94 "*.tsbuildinfo",
95 "**/routeTree.gen.ts",
96 "apps/mobile/android/**",
97 "apps/mobile/ios/**",
98 "apps/mobile/uniwind-types.d.ts",
99 "*.icon/**",
100 ],
101 sortPackageJson: {},
102 overrides: [
103 {
104 files: [".devcontainer/devcontainer.json"],
105 options: {
106 trailingComma: "none",
107 },
108 },
109 ],
110 },
111 lint: {
112 ignorePatterns: [
113 ".repos",
114 ".repos/**",
115 "dist",
116 "dist-electron",
117 "node_modules",
118 "pnpm-lock.yaml",
119 "*.tsbuildinfo",
120 "**/routeTree.gen.ts",
121 "apps/mobile/android/**",
122 "apps/mobile/ios/**",
123 "apps/mobile/uniwind-types.d.ts",
124 ],
125 plugins: ["eslint", "oxc", "react", "unicorn", "typescript"],
126 jsPlugins: ["./oxlint-plugin-t3code/index.ts", "@shadcn/lint"],
127 settings: {
128 shadcn: { ui: "~/components/ui" },
129 },
130 categories: {
131 correctness: "warn",
132 suspicious: "warn",
133 perf: "warn",
134 },
135 rules: {
136 "unicorn/no-array-sort": "off",
137 "unicorn/consistent-function-scoping": "off",
138 "oxc/no-map-spread": "off",
139 "react-in-jsx-scope": "off",
140 "react-hooks/exhaustive-deps": "off",
141 "eslint/no-shadow": "off",
142 "eslint/no-await-in-loop": "off",
143 "eslint/no-underscore-dangle": "off",
144 "typescript/consistent-return": "off",
145 "typescript/no-base-to-string": "off",
146 "typescript/no-duplicate-type-constituents": "off",
147 "typescript/no-floating-promises": "off",
148 "typescript/no-implied-eval": "off",
149 "typescript/no-meaningless-void-operator": "off",
150 "typescript/no-redundant-type-constituents": "off",
151 "typescript/no-unnecessary-boolean-literal-compare": "off",
152 "typescript/no-unnecessary-type-conversion": "off",
153 "typescript/no-unnecessary-type-arguments": "off",
154 "typescript/no-unnecessary-type-assertion": "off",
155 "typescript/no-unnecessary-type-parameters": "off",
156 "typescript/no-unsafe-type-assertion": "off",
157 "typescript/await-thenable": "off",
158 "typescript/require-array-sort-compare": "off",
159 "typescript/restrict-template-expressions": "off",
160 "typescript/unbound-method": "off",
161 "eslint/no-restricted-imports": [
162 "error",
163 { paths: [...RESTRICTED_IMPORT_PATHS, RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS] },
164 ],
165 "t3code/no-global-process-runtime": "error",
166 "t3code/no-inline-schema-compile": "warn",
167 "t3code/no-manual-effect-runtime-in-tests": "error",
168 "t3code/no-native-title-tooltip": "error",
169 "t3code/namespace-node-imports": "error",
170 },
171 overrides: [
172 {
173 // The one place that reads the host platform to seed the injected references.
174 files: ["packages/shared/src/hostProcess.ts"],
175 rules: { "t3code/no-global-process-runtime": "off" },
176 },
177 {
178 files: ["apps/web/src/**"],
179 excludeFiles: ["apps/web/src/components/ui/**"],
180 rules: {
181 "eslint/no-restricted-imports": [
182 "error",
183 {
184 paths: [...RESTRICTED_IMPORT_PATHS, RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS],
185 patterns: RESTRICTED_UI_VARIANT_PATTERNS,
186 },
187 ],
188 },
189 },
190 {
191 // The one module allowed to name lucide's pull-request glyphs; everything else picks
192 // from its vocabulary. The other import restrictions still apply here.
193 files: ["apps/web/src/components/pullRequest/pullRequestIcons.tsx"],
194 rules: { "eslint/no-restricted-imports": ["error", { paths: RESTRICTED_IMPORT_PATHS }] },
195 },
196 {
197 files: ["apps/mobile/src/**"],
198 rules: { "t3code/no-mobile-uniwind-theme-escape-hatches": "error" },
199 },
200 {
201 // Every class in web code must be one Tailwind generates: a typo or a class nothing
202 // declares ships silently unstyled. JS hooks use data attributes, not class names.
203 files: ["apps/web/src/**"],
204 rules: { "shadcn/no-unknown-classes": "error" },
205 },
206 {
207 // Colors come from theme tokens so status tones follow custom themes. components/ui
208 // has no findings and stays covered too.
209 files: ["apps/web/src/**"],
210 rules: { "shadcn/no-raw-colors": "error" },
211 },
212 {
213 // Third-party marks (brand logos, the macOS permission panes, Codex's Computer Use
214 // mark) must keep their exact colors, so the files that hold them are exempt.
215 files: ["apps/web/src/components/Icons.tsx", "apps/web/src/components/JetBrainsIcons.tsx"],
216 rules: { "shadcn/no-raw-colors": "off" },
217 },
218 {
219 // components/ui exports own their look. App code picks a variant or size instead
220 // of restyling with className; layout classes (width, flex, margin, position) stay
221 // allowed because placement belongs to the parent. components/ui is for generic
222 // primitives: a look that belongs to one feature stays in that feature's component.
223 files: ["apps/web/src/**"],
224 excludeFiles: ["apps/web/src/components/ui/**"],
225 rules: {
226 // A className built at runtime on a ui component is one no-restyle cannot read.
227 "shadcn/require-static-classes": "error",
228 // Appearance values come from the theme and Tailwind's scales. Layout stays free
229 // (placement belongs to the parent); the other entries are values no scale can hold.
230 "shadcn/no-arbitrary-values": [
231 "error",
232 {
233 allow: [
234 "layout",
235 // Which properties an element animates is per-element behaviour, like layout,
236 // not a design value; timing curves and durations still come from the theme.
237 "transition",
238 // Overlays that follow their frame's corner, which is set at runtime
239 // (floating preview) or by the element they decorate (composer outline).
240 "rounded-[inherit]",
241 // Inline chips size in em so they scale with the text they sit in
242 // (the composer honours the prompt font-size preference).
243 "gap-[0.33em]",
244 "px-[0.5em]",
245 "rounded-[0.5em]",
246 "text-[0.86em]",
247 // Project icons render from 14px to 48px and keep one proportional corner.
248 "rounded-[25%]",
249 // An emoji project icon fills its container, whatever size the parent gives it.
250 "text-[length:80cqh]",
251 // The platform's own selection colour on a selected composer chip.
252 "bg-[Highlight]",
253 // Brand marks keep their brand colours (Cursor, Grok, Claude).
254 "fill-[#26251E]",
255 "fill-[#EDECEC]",
256 "fill-[#0F0F0F]",
257 "fill-[#F5F5F5]",
258 "fill-[#d97757]",
259 "text-[#d97757]",
260 ],
261 },
262 ],
263 "shadcn/no-restyle": [
264 "error",
265 {
266 allow: ["layout"],
267 contracts: [
268 {
269 // CollapsibleTrigger is a bare button with no styled counterpart
270 // (a disclosure row is not a Button), so its className is the API.
271 // Every other trigger has one: style them with render={<Button …/>}.
272 pattern: "^CollapsibleTrigger$",
273 allow: ["layout", "color", "typography", "spacing", "shape", "effects", "motion"],
274 },
275 ],
276 },
277 ],
278 },
279 },
280 {
281 // The sign-in masthead is T3 brand artwork: fixed gradients, not theme surfaces.
282 files: ["apps/web/src/components/auth/AuthSurfaceShell.tsx"],
283 rules: { "shadcn/no-arbitrary-values": "off" },
284 },
285 {
286 // Shared client code must not call APIs missing from Hermes. Our ESNext
287 // TypeScript target accepts them even when they would crash mobile at launch.
288 // Tests run on Node and are exempt.
289 files: [
290 "apps/mobile/src/**",
291 "packages/client-runtime/src/**",
292 "packages/contracts/src/**",
293 "packages/shared/src/**",
294 ],
295 excludeFiles: ["**/*.test.ts", "**/*.test.tsx"],
296 rules: { "t3code/no-hermes-unsupported-apis": "error" },
297 },
298 {
299 // Reviewed native and third-party interop boundaries that cannot consume a className.
300 files: [
301 "apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx",
302 "apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx",
303 "apps/mobile/src/features/files/FileMarkdownPreview.tsx",
304 "apps/mobile/src/features/files/SourceFileSurface.tsx",
305 "apps/mobile/src/features/files/AttachmentFileScreen.tsx",
306 "apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx",
307 "apps/mobile/src/features/files/thread-file-navigator-pane.tsx",
308 "apps/mobile/src/features/home/HomeHeader.tsx",
309 "apps/mobile/src/features/review/ReviewSheet.tsx",
310 "apps/mobile/src/features/review/useNativeReviewDiffBridge.ts",
311 "apps/mobile/src/features/settings/SettingsEnvironmentsRouteScreen.tsx",
312 "apps/mobile/src/features/threads/GitActionProgressOverlay.tsx",
313 "apps/mobile/src/features/threads/NewTaskDraftScreen.tsx",
314 "apps/mobile/src/features/threads/ThreadComposer.tsx",
315 "apps/mobile/src/features/threads/ThreadFeed.tsx",
316 "apps/mobile/src/features/review/ReviewCommentCard.tsx",
317 "apps/mobile/src/features/threads/ThreadSettingsSheet.tsx",
318 "apps/mobile/src/features/threads/git/GitOverviewSheet.tsx",
319 "apps/mobile/src/features/threads/thread-list-items.tsx",
320 "apps/mobile/src/features/threads/thread-list-v2-items.tsx",
321 "apps/mobile/src/lib/useMobileNavigationTheme.ts",
322 "apps/mobile/src/native/T3ComposerEditor.ios.tsx",
323 "apps/mobile/src/native/T3ComposerEditor.native.tsx",
324 "apps/mobile/src/native/SelectableMarkdownText.android.tsx",
325 ],
326 rules: {
327 "t3code/no-mobile-uniwind-theme-escape-hatches": ["error", { allowUniwindTheme: true }],
328 },
329 },
330 // Legacy manual Effect runners tracked as debt: no net-new occurrences.
331 // Lower a ceiling when you migrate a file, and delete its entry at zero.
332 ...Object.entries({
333 "apps/server/src/orchestration/Layers/CheckpointReactor.test.ts": 42,
334 "apps/server/src/orchestration/Layers/OrchestrationEngine.test.ts": 5,
335 "apps/server/src/orchestration/Layers/OrchestrationReactor.test.ts": 4,
336 "apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts": 66,
337 "apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.ts": 29,
338 "apps/server/src/orchestration/Layers/ThreadDeletionReactor.test.ts": 2,
339 "apps/server/src/orchestration/commandInvariants.test.ts": 5,
340 "apps/server/src/orchestration/projector.test.ts": 20,
341 "apps/server/src/provider/Layers/CodexAdapter.test.ts": 1,
342 "apps/server/src/provider/Layers/CodexSessionRuntime.test.ts": 5,
343 "apps/server/src/provider/Layers/CursorAdapter.test.ts": 1,
344 "apps/server/src/provider/Layers/CursorProvider.test.ts": 1,
345 "apps/server/src/provider/Layers/ProviderService.test.ts": 2,
346 "apps/server/src/provider/Layers/ProviderSessionReaper.test.ts": 12,
347 "apps/server/src/provider/acp/CursorAcpSupport.test.ts": 1,
348 }).map(([file, maxOccurrences]) => {
349 const rule: ["error", { maxOccurrences: number }] = ["error", { maxOccurrences }];
350 return { files: [file], rules: { "t3code/no-manual-effect-runtime-in-tests": rule } };
351 }),
352 ],
353 options: {
354 reportUnusedDisableDirectives: "error",
355 // Revisit once Oxlint's tsgolint path can integrate with @effect/tsgo diagnostics.
356 typeAware: false,
357 typeCheck: false,
358 },
359 },
360});