Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

vite.config.ts

252 lines10.1 KB

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/** Lucide's pull-request glyphs, which only `pullRequestIcons.tsx` may name. */
20const RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS = {
21 name: "lucide-react",
22 importNames: [
23 "GitMerge",
24 "GitMergeIcon",
25 "GitPullRequest",
26 "GitPullRequestIcon",
27 "GitPullRequestArrow",
28 "GitPullRequestArrowIcon",
29 "GitPullRequestClosed",
30 "GitPullRequestClosedIcon",
31 "GitPullRequestDraft",
32 "GitPullRequestDraftIcon",
33 "GitPullRequestCreate",
34 "GitPullRequestCreateIcon",
35 "GitPullRequestCreateArrow",
36 "GitPullRequestCreateArrowIcon",
37 ],
38 message:
39 "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.",
40};
41​
42export default defineConfig({
43 resolve: {
44 alias: {
45 "~": NodeURL.fileURLToPath(new URL("./apps/web/src", import.meta.url)),
46 },
47 },
48 test: {
49 environment: "node",
50 exclude: [
51 "**/.repos/**",
52 "**/.t3/**",
53 "**/node_modules/**",
54 "**/dist/**",
55 "**/dist-electron/**",
56 "**/.{idea,git,cache,output,temp}/**",
57 ],
58 hookTimeout: 60_000,
59 testTimeout: 60_000,
60 setupFiles: [
61 NodeURL.fileURLToPath(
62 new URL("./packages/shared/src/testing/longTempDir.ts", import.meta.url),
63 ),
64 ],
65 },
66 staged: {
67 // Formatter only for now — no lint or typecheck on commit.
68 "*": "vp fmt --no-error-on-unmatched-pattern",
69 },
70 fmt: {
71 ignorePatterns: [
72 ".repos/**",
73 // Macroscope's glob-per-line ignore grammar, not Markdown: formatting
74 // it rewrites `*` as `_` and joins lines.
75 ".macroscope/ignore.md",
76 ".alchemy",
77 "dist",
78 "dist-electron",
79 "node_modules",
80 "pnpm-lock.yaml",
81 "*.tsbuildinfo",
82 "**/routeTree.gen.ts",
83 "apps/mobile/android/**",
84 "apps/mobile/ios/**",
85 "apps/mobile/uniwind-types.d.ts",
86 "*.icon/**",
87 ],
88 sortPackageJson: {},
89 overrides: [
90 {
91 files: [".devcontainer/devcontainer.json"],
92 options: {
93 trailingComma: "none",
94 },
95 },
96 ],
97 },
98 lint: {
99 ignorePatterns: [
100 ".repos",
101 ".repos/**",
102 "dist",
103 "dist-electron",
104 "node_modules",
105 "pnpm-lock.yaml",
106 "*.tsbuildinfo",
107 "**/routeTree.gen.ts",
108 "apps/mobile/android/**",
109 "apps/mobile/ios/**",
110 "apps/mobile/uniwind-types.d.ts",
111 ],
112 plugins: ["eslint", "oxc", "react", "unicorn", "typescript"],
113 jsPlugins: ["./oxlint-plugin-t3code/index.ts"],
114 categories: {
115 correctness: "warn",
116 suspicious: "warn",
117 perf: "warn",
118 },
119 rules: {
120 "unicorn/no-array-sort": "off",
121 "unicorn/consistent-function-scoping": "off",
122 "oxc/no-map-spread": "off",
123 "react-in-jsx-scope": "off",
124 "react-hooks/exhaustive-deps": "off",
125 "eslint/no-shadow": "off",
126 "eslint/no-await-in-loop": "off",
127 "eslint/no-underscore-dangle": "off",
128 "typescript/consistent-return": "off",
129 "typescript/no-base-to-string": "off",
130 "typescript/no-duplicate-type-constituents": "off",
131 "typescript/no-floating-promises": "off",
132 "typescript/no-implied-eval": "off",
133 "typescript/no-meaningless-void-operator": "off",
134 "typescript/no-redundant-type-constituents": "off",
135 "typescript/no-unnecessary-boolean-literal-compare": "off",
136 "typescript/no-unnecessary-type-conversion": "off",
137 "typescript/no-unnecessary-type-arguments": "off",
138 "typescript/no-unnecessary-type-assertion": "off",
139 "typescript/no-unnecessary-type-parameters": "off",
140 "typescript/no-unsafe-type-assertion": "off",
141 "typescript/await-thenable": "off",
142 "typescript/require-array-sort-compare": "off",
143 "typescript/restrict-template-expressions": "off",
144 "typescript/unbound-method": "off",
145 "eslint/no-restricted-imports": [
146 "error",
147 { paths: [...RESTRICTED_IMPORT_PATHS, RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS] },
148 ],
149 "t3code/no-global-process-runtime": "error",
150 "t3code/no-inline-schema-compile": "warn",
151 "t3code/no-manual-effect-runtime-in-tests": "error",
152 "t3code/no-native-title-tooltip": "error",
153 "t3code/namespace-node-imports": "error",
154 },
155 overrides: [
156 {
157 // The one place that reads the host platform to seed the injected references.
158 files: ["packages/shared/src/hostProcess.ts"],
159 rules: { "t3code/no-global-process-runtime": "off" },
160 },
161 {
162 // The one module allowed to name lucide's pull-request glyphs; everything else picks
163 // from its vocabulary. The other import restrictions still apply here.
164 files: ["apps/web/src/components/pullRequest/pullRequestIcons.tsx"],
165 rules: { "eslint/no-restricted-imports": ["error", { paths: RESTRICTED_IMPORT_PATHS }] },
166 },
167 {
168 files: ["apps/mobile/src/**"],
169 rules: { "t3code/no-mobile-uniwind-theme-escape-hatches": "error" },
170 },
171 {
172 // Shared client code must not call APIs missing from Hermes. Our ESNext
173 // TypeScript target accepts them even when they would crash mobile at launch.
174 // Tests run on Node and are exempt.
175 files: [
176 "apps/mobile/src/**",
177 "packages/client-runtime/src/**",
178 "packages/contracts/src/**",
179 "packages/shared/src/**",
180 ],
181 excludeFiles: ["**/*.test.ts", "**/*.test.tsx"],
182 rules: { "t3code/no-hermes-unsupported-apis": "error" },
183 },
184 {
185 // Reviewed native and third-party interop boundaries that cannot consume a className.
186 files: [
187 "apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx",
188 "apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx",
189 "apps/mobile/src/features/files/FileMarkdownPreview.tsx",
190 "apps/mobile/src/features/files/SourceFileSurface.tsx",
191 "apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx",
192 "apps/mobile/src/features/files/AttachmentFileScreen.tsx",
193 "apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx",
194 "apps/mobile/src/features/files/thread-file-navigator-pane.tsx",
195 "apps/mobile/src/features/home/HomeHeader.tsx",
196 "apps/mobile/src/features/review/ReviewSheet.tsx",
197 "apps/mobile/src/features/review/useNativeReviewDiffBridge.ts",
198 "apps/mobile/src/features/settings/SettingsEnvironmentsRouteScreen.tsx",
199 "apps/mobile/src/features/settings/appearance/components/AppearancePreviews.tsx",
200 "apps/mobile/src/features/threads/GitActionProgressOverlay.tsx",
201 "apps/mobile/src/features/threads/NewTaskDraftScreen.tsx",
202 "apps/mobile/src/features/threads/ThreadComposer.tsx",
203 "apps/mobile/src/features/threads/ThreadFeed.tsx",
204 "apps/mobile/src/features/settings/appearance/components/FontSizeSliderRow.tsx",
205 "apps/mobile/src/features/threads/NewTaskContextPickerScreens.tsx",
206 "apps/mobile/src/features/threads/ThreadQueueControl.tsx",
207 "apps/mobile/src/features/threads/ThreadAgentsSheet.tsx",
208 "apps/mobile/src/features/review/ReviewCommentCard.tsx",
209 "apps/mobile/src/features/threads/ThreadSettingsSheet.tsx",
210 "apps/mobile/src/features/threads/git/GitOverviewSheet.tsx",
211 "apps/mobile/src/features/threads/thread-list-items.tsx",
212 "apps/mobile/src/features/threads/thread-list-v2-items.tsx",
213 "apps/mobile/src/lib/useMobileNavigationTheme.ts",
214 "apps/mobile/src/native/T3ComposerEditor.ios.tsx",
215 "apps/mobile/src/native/T3ComposerEditor.native.tsx",
216 "apps/mobile/src/native/SelectableMarkdownText.android.tsx",
217 ],
218 rules: {
219 "t3code/no-mobile-uniwind-theme-escape-hatches": ["error", { allowUniwindTheme: true }],
220 },
221 },
222 // Legacy manual Effect runners tracked as debt: no net-new occurrences.
223 // Lower a ceiling when you migrate a file, and delete its entry at zero.
224 ...Object.entries({
225 "apps/server/src/orchestration/Layers/CheckpointReactor.test.ts": 42,
226 "apps/server/src/orchestration/Layers/OrchestrationEngine.test.ts": 5,
227 "apps/server/src/orchestration/Layers/OrchestrationReactor.test.ts": 4,
228 "apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts": 66,
229 "apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.ts": 29,
230 "apps/server/src/orchestration/Layers/ThreadDeletionReactor.test.ts": 2,
231 "apps/server/src/orchestration/commandInvariants.test.ts": 5,
232 "apps/server/src/orchestration/projector.test.ts": 20,
233 "apps/server/src/provider/Layers/CodexAdapter.test.ts": 1,
234 "apps/server/src/provider/Layers/CodexSessionRuntime.test.ts": 5,
235 "apps/server/src/provider/Layers/CursorAdapter.test.ts": 1,
236 "apps/server/src/provider/Layers/CursorProvider.test.ts": 1,
237 "apps/server/src/provider/Layers/ProviderService.test.ts": 2,
238 "apps/server/src/provider/Layers/ProviderSessionReaper.test.ts": 12,
239 "apps/server/src/provider/acp/CursorAcpSupport.test.ts": 1,
240 }).map(([file, maxOccurrences]) => {
241 const rule: ["error", { maxOccurrences: number }] = ["error", { maxOccurrences }];
242 return { files: [file], rules: { "t3code/no-manual-effect-runtime-in-tests": rule } };
243 }),
244 ],
245 options: {
246 reportUnusedDisableDirectives: "error",
247 // Revisit once Oxlint's tsgolint path can integrate with @effect/tsgo diagnostics.
248 typeAware: false,
249 typeCheck: false,
250 },
251 },
252});