Repository navigation
Expand file tree
/
Copy pathvite.config.ts
More file actions
364 lines (359 loc) · 12.4 KB
/
Copy pathvite.config.ts
File metadata and controls
364 lines (359 loc) · 12.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
import { basename, dirname, join } from 'node:path'
import { defineConfig } from 'vp'
import { playwright } from 'vp/test/browser-playwright'
const root = import.meta.dirname
/**
* Per-property timeout for the fuzz projects.
*
* `testTimeout` is sized for unit tests. A fuzz property runs `FC_NUM_RUNS`
* cases inside one `test`, so its wall time scales with that budget and with
* how slow the machine is -- a CI runner is several times slower than a
* developer's, which is what made 10k runs time out at 20s there.
*/
const fuzzTimeout = 120_000
/**
* Engines the portable browser projects run against.
*
* A function, not a shared array: Vitest stamps a resolved name onto each
* instance object, so handing the same objects to two projects makes the second
* collide with the first.
*/
const browserInstances = () => [
{ browser: 'chromium' },
{ browser: 'firefox' },
{ browser: 'webkit' },
]
export default defineConfig({
fmt: {
singleQuote: true,
semi: false,
trailingComma: 'all',
printWidth: 80,
ignorePatterns: [
'contracts/**',
'contracts/generated.ts',
'test/kzg/**',
'.agents/uphill/fuzz-fixtures/**',
// `uphill --update` writes it.
'.agents/uphill.baseline.yaml',
'**/tsconfig.json',
'**/tsconfig.*.json',
'**/package.json',
'**/*.md',
],
},
lint: {
plugins: ['eslint', 'typescript', 'unicorn', 'jsdoc'],
jsPlugins: [
{ name: 'vite-plus', specifier: 'vite-plus/oxlint-plugin' },
{ name: 'jsdoc-js', specifier: 'eslint-plugin-jsdoc' },
{ name: 'tsdoc', specifier: 'eslint-plugin-tsdoc' },
],
rules: {
'vite-plus/prefer-vite-plus-imports': 'error',
'no-console': ['error', { allow: ['log'] }],
'jsdoc/check-access': 'error',
'jsdoc/check-property-names': 'error',
'jsdoc/check-tag-names': [
'error',
{
definedTags: ['category', 'entrypointCategory', 'remarks'],
},
],
'jsdoc/empty-tags': 'error',
'jsdoc/implements-on-classes': 'error',
'jsdoc/no-defaults': 'error',
'jsdoc/require-param-name': 'error',
'jsdoc/require-property': 'error',
'jsdoc/require-property-name': 'error',
// Intentional: `& unknown` flattens computed types for inference.
'typescript/no-redundant-type-constituents': 'off',
// Error messages embed raw user input via template literals; the
// resulting `[object Object]` / typeof-string output is acceptable.
'typescript/no-base-to-string': 'off',
'typescript/restrict-template-expressions': 'off',
},
overrides: [
{
files: ['src/**/*.ts'],
rules: {
'jsdoc-js/require-jsdoc': ['error', { publicOnly: true }],
'jsdoc-js/require-description': 'error',
'jsdoc-js/require-example': 'error',
// Disabled: example code inside @example blocks contains `{`/`}`,
// `<->`, indented code fences, and twoslash directives like
// `// @noErrors`, all of which TSDoc parses as syntax errors.
'tsdoc/syntax': 'off',
},
},
{
// Neither internal helpers nor tests are public API, so the
// public-documentation rules do not apply -- and `require-example`'s
// autofix corrupts JSDoc on nested functions, which tests are full of.
files: ['src/**/internal/**/*.ts', 'src/**/_test/**/*.ts'],
rules: {
'jsdoc-js/require-jsdoc': 'off',
'jsdoc-js/require-description': 'off',
'jsdoc-js/require-example': 'off',
},
},
{
files: ['scripts/**', 'test/**'],
rules: {
'no-console': ['error', { allow: ['log', 'warn', 'error'] }],
},
},
],
settings: {
jsdoc: {
ignoreInternal: true,
ignorePrivate: true,
tagNamePreference: {
category: 'category',
entrypointCategory: 'entrypointCategory',
},
},
},
options: {
typeAware: true,
},
ignorePatterns: [
'contracts/**',
'contracts/generated.ts',
'test/kzg/**',
// Uphill's metric scripts log progress to stderr and run their own Vitest.
'.agents/uphill/**',
],
},
// `FC_NUM_RUNS` reaches the fuzz files through `import.meta.env`, so that the
// same properties run under Node and in a browser, where `process` is absent.
envPrefix: ['VITE_', 'FC_'],
test: {
alias: {
ox: join(root, 'src'),
'~test': join(root, 'test/src'),
},
benchmark: {
include: ['src/**/*.bench.ts'],
outputFile: './.bench/report.json',
},
coverage: {
include: ['./src/**'],
provider: 'v8',
reporter: process.env.CI ? ['lcov'] : ['text', 'json', 'html'],
},
passWithNoTests: true,
retry: 3,
resolveSnapshotPath: (path, ext) =>
join(join(dirname(path), '_snap'), `${basename(path)}${ext}`),
hookTimeout: 20_000,
testTimeout: 20_000,
projects: [
{
extends: true,
test: {
// TODO: remove once frame txs in anvil
name: 'tmp_frames',
include: [
'src/core/_test/TxEnvelopeEip8141.test.ts',
'test/frames/**/*.test.ts',
],
globalSetup: [join(root, 'test/frames/setup.global.ts')],
setupFiles: [join(root, 'test/frames/setup.ts')],
hookTimeout: 180_000,
testTimeout: 180_000,
retry: 0,
},
},
{
extends: true,
test: {
name: 'core',
globalSetup: process.env.TYPES
? [join(root, 'test/setup.global.types.ts')]
: [join(root, 'test/setup.global.ts')],
include: [
...(process.env.TYPES
? ['src/**/*.snap-d.ts']
: ['src/**/*.test.ts', 'src/**/*.conformance.ts']),
'!src/tempo/**',
'!src/core/_test/TxEnvelopeEip8141.test.ts',
'!src/**/*.browser.test.ts',
],
setupFiles: process.env.TYPES ? [] : [join(root, 'test/setup.ts')],
},
},
{
extends: true,
test: {
name: 'tempo-unit',
include: [
'src/tempo/**/*.test.ts',
'!src/tempo/e2e.test.ts',
'!src/tempo/configurableAccounts.e2e.test.ts',
],
},
},
{
extends: true,
test: {
name: 'tempo',
include: [
'src/tempo/e2e.test.ts',
'src/tempo/configurableAccounts.e2e.test.ts',
],
setupFiles: [join(root, 'test/tempo/setup.ts')],
globalSetup: [join(root, 'test/tempo/setup.global.ts')],
hookTimeout: 60_000,
},
},
{
extends: true,
test: {
name: 'fuzz',
// Gated behind `FUZZ=true` so the default `pnpm test` run
// doesn't pick up stochastic property tests. Run via
// `pnpm test:fuzz`.
include: process.env.FUZZ ? ['src/**/*.fuzz.ts'] : [],
setupFiles: [
join(root, 'test/setup.ts'),
join(root, 'test/fuzz/setup.ts'),
],
// A property is thousands of cases, not one, so the unit-test
// default does not apply. The job's own timeout is the real guard.
testTimeout: fuzzTimeout,
},
},
{
extends: true,
test: {
// Everything that does not need a virtual authenticator, on every
// engine Playwright can drive. Native codecs differ between them --
// Chromium 145 read `U+C230` as a hex digit where 149 rejects it --
// so an engine ox does not run here is one it is not checked on.
name: 'browser',
// `*.conformance.ts` is deliberately not a `*.test.ts`: the same
// file is collected here and by `core`, so a suite is written once
// and every runtime runs whichever tiers it has.
include: [
'src/**/*.browser.test.ts',
'src/**/*.conformance.ts',
'!src/webauthn/**',
],
deps: {
// Composite engine modules re-export the public API. Discover its
// default implementations before browsers connect.
optimizer: {
client: {
include: [
'@noble/ciphers/aes.js',
'@noble/curves/ed25519.js',
'@noble/curves/secp256k1.js',
'@noble/hashes/blake3.js',
'@noble/hashes/hmac.js',
'@noble/hashes/legacy.js',
'@noble/hashes/pbkdf2.js',
'@noble/hashes/scrypt.js',
'@noble/hashes/sha2.js',
'@noble/hashes/sha3.js',
'@scure/bip32',
'@scure/bip39',
'@scure/bip39/wordlists/czech.js',
'@scure/bip39/wordlists/english.js',
'@scure/bip39/wordlists/french.js',
'@scure/bip39/wordlists/italian.js',
'@scure/bip39/wordlists/japanese.js',
'@scure/bip39/wordlists/korean.js',
'@scure/bip39/wordlists/portuguese.js',
'@scure/bip39/wordlists/simplified-chinese.js',
'@scure/bip39/wordlists/spanish.js',
'@scure/bip39/wordlists/traditional-chinese.js',
],
},
},
},
browser: {
enabled: true,
provider: playwright() as never,
headless: true,
instances: browserInstances(),
screenshotFailures: false,
},
},
},
{
extends: true,
test: {
// WebAuthn needs a virtual authenticator, installed over CDP by
// `test/setup.browser.ts`. CDP is Chromium-only, and that is what
// holds this project to one engine -- keep it to the tests that
// need it, so everything else stays portable.
name: 'browser-webauthn',
include: ['src/webauthn/**/*.browser.test.ts'],
setupFiles: [join(root, 'test/setup.browser.ts')],
browser: {
enabled: true,
provider: playwright() as never,
headless: true,
instances: [{ browser: 'chromium' }],
screenshotFailures: false,
},
},
},
{
extends: true,
test: {
// Browser-compatible properties from the `fuzz` project, put in
// front of native codecs only a browser has. Gated behind
// `FUZZ=true` alongside it.
name: 'fuzz-browser',
deps: {
// Discover every direct fuzz oracle before browsers connect.
// Mid-run dependency optimization reloads the test runtime.
optimizer: {
client: {
include: [
'@fast-check/vitest',
'@noble/ciphers/aes.js',
'@noble/curves/ed25519.js',
'@noble/curves/nist.js',
'@noble/curves/secp256k1.js',
'@noble/hashes/blake3.js',
'@noble/hashes/hmac.js',
'@noble/hashes/legacy.js',
'@noble/hashes/pbkdf2.js',
'@noble/hashes/scrypt.js',
'@noble/hashes/sha2.js',
'@noble/hashes/sha3.js',
'@scure/bip32',
'@scure/bip39',
'@scure/bip39/wordlists/czech.js',
'@scure/bip39/wordlists/english.js',
'@scure/bip39/wordlists/french.js',
'@scure/bip39/wordlists/italian.js',
'@scure/bip39/wordlists/japanese.js',
'@scure/bip39/wordlists/korean.js',
'@scure/bip39/wordlists/portuguese.js',
'@scure/bip39/wordlists/simplified-chinese.js',
'@scure/bip39/wordlists/spanish.js',
'@scure/bip39/wordlists/traditional-chinese.js',
'ethers',
],
},
},
},
include: process.env.FUZZ ? ['src/**/*.fuzz.ts', '!src/node/**'] : [],
setupFiles: [join(root, 'test/fuzz/setup.ts')],
testTimeout: fuzzTimeout,
browser: {
enabled: true,
provider: playwright() as never,
headless: true,
instances: browserInstances(),
screenshotFailures: false,
},
},
},
],
},
})