Repository navigation
Expand file tree
/
Copy pathvite.config.ts
More file actions
579 lines (568 loc) · 24 KB
/
Copy pathvite.config.ts
File metadata and controls
579 lines (568 loc) · 24 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
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
import { existsSync, readdirSync } from "node:fs";
import { resolve } from "node:path";
import { transform } from "esbuild";
import { rules as sonarjsPluginRules } from "eslint-plugin-sonarjs";
import { defineConfig } from "vite-plus";
import { type PackUserConfig } from "vite-plus/pack";
import { webdriverio } from "vite-plus/test/browser-webdriverio";
const rootDirectory = import.meta.dirname;
const sourceDirectory = resolve(rootDirectory, "src");
type PackPlugin = Extract<NonNullable<PackUserConfig["plugins"]>, unknown[]>[number];
/**
* Every SonarJS rule as an error, so a plugin upgrade that adds rules turns them on by default;
* the rules that are off on purpose are listed right after the spread in the lint config.
*/
const sonarjsRules = Object.fromEntries(
Object.keys(sonarjsPluginRules).map((rule) => [`sonarjs/${rule}`, "error"]),
);
/**
* The root build ships a UMD file for `require()`, which tsdown never pairs with a `.d.cts`
* twin (that only happens for the `cjs` format). The bundled declaration has no
* format-specific syntax, so a same-content copy keeps CommonJS consumers off TypeScript's
* "masquerading as ESM" error under `moduleResolution: node16`/`nodenext`.
* @returns {PackPlugin} The pack plugin that emits the `.d.cts` twin.
*/
const emitCjsDtsTwin = (): PackPlugin => ({
name: "brazilian-utils:emit-cjs-dts-twin",
generateBundle(_options, bundle) {
const dts: (typeof bundle)[string] | undefined = bundle["brazilian-utils.d.ts"];
if (dts === undefined) return;
this.emitFile({
type: "asset",
fileName: "brazilian-utils.d.cts",
source: dts.type === "chunk" ? dts.code : dts.source,
});
},
});
/**
* The UMD bundle is consumed as-is from a CDN `<script>` tag, where no consumer bundler will
* ever tree-shake it, so it can take the full `compress` pass (see the `minify` note below for
* why the ESM bundle cannot). rolldown composes the source map returned here with its own.
* @returns {PackPlugin} The pack plugin that minifies the UMD chunk.
*/
const minifyUmdChunk = (): PackPlugin => ({
name: "brazilian-utils:minify-umd",
async renderChunk(code, _chunk, options) {
if (options.format !== "umd") return null;
const result = await transform(code, { minify: true, sourcemap: true, target: "es2020" });
return { code: result.code, map: result.map };
},
});
/**
* Every util directory under `src/` (skipping the `_`-prefixed internal ones) that has a
* same-named entry file (`src/get-cities/get-cities.ts`, `src/is-valid-cpf/is-valid-cpf.ts`,
* etc.) becomes its own subpath build entry below, served through the `"./*"` pattern in
* `package.json`'s `exports`. That lets a consumer `import("@brazilian-utils/brazilian-utils/
* get-cities")` and pull in only that util's code (and, for `getCities`, its ~90 KB embedded
* IBGE dataset) instead of the whole root bundle, with no bespoke entry file to maintain per
* util.
*/
const utilityEntryNames = readdirSync(sourceDirectory, { withFileTypes: true })
.filter((entry) => entry.isDirectory() && !entry.name.startsWith("_"))
.map((entry) => entry.name)
.filter((name) => existsSync(resolve(sourceDirectory, name, `${name}.ts`)))
.toSorted();
const utilityEntries = Object.fromEntries(
utilityEntryNames.map((name) => [name, resolve(sourceDirectory, name, `${name}.ts`)]),
);
/**
* Settings shared by both pack configs below (the root build and the per-util subpath build).
*/
const sharedPack = {
outDir: "dist",
sourcemap: true,
dts: true,
outExtensions: ({ format }: { format: string }): { js: string } => ({
js: format === "es" ? ".js" : ".cjs",
}),
// `compress: false` is intentional: tsdown's default oxc-minify `compress`
// pass restructures/merges top-level statements, which defeats a
// consumer bundler's ability to tree-shake unused exports from this
// entry point (verified: full `compress` shrinks this package's own
// bundle but makes a single-import consumer bundle balloon to ~80% of
// the whole library instead of a small fraction of it). Mangling names
// and stripping whitespace still gets us close to the previous
// (rollup/esbuild-built) bundle size without breaking tree-shaking.
minify: { compress: false, mangle: true, codegen: true },
treeshake: {
moduleSideEffects: false,
propertyReadSideEffects: false,
},
// Both pack configs below declare the same `publint`/`attw` value, so the build engine
// dedupes them and runs a single combined check over the fully assembled `dist/`, once
// every entry (root + every subpath) has finished building, rather than once per config.
publint: true,
attw: true,
} satisfies Partial<PackUserConfig>;
/**
* Why this is two separate `PackUserConfig`s (`pack: [...]`) instead of one multi-entry config
* with ~77 entries (the root plus one per util):
*
* rolldown's default multi-entry code splitting factors any module reachable from 2+ entries out
* into shared, hash-named chunk files. With every util *also* being its own subpath entry, that
* means every util module (root's `index.ts` importing it, plus its own subpath entry importing
* it) clears the "shared by 2+" bar. A combined build turned `dist/brazilian-utils.js` from a
* ~137 KB self-contained bundle into a ~6 KB barrel of `export ... from "./is-valid-cpf-<hash>.js"`
* re-exports pointing at ~76 sibling chunk files. Functionally equivalent (an npm-installed
* consumer still gets everything, since `files` ships the whole `dist/`), but it violates the
* actual requirement here: the root bundle's *content* must stay put.
*
* Two ways to keep multi-entry splitting from touching the root were tried and are dead ends:
* - `codeSplitting: false` is rejected outright for a multi-entry build (error: "multiple
* inputs are not supported when output.codeSplitting is false"; that flag maps to
* `inlineDynamicImports: true`, meaningful only for a single input).
* - An explicit catch-all `codeSplitting.groups` entry (`test: /./`) with `minShareCount` set
* far above the entry count, intended to make every module fail the threshold and fall back
* to being inlined per-entry, has no effect: a module that doesn't clear a group's
* `minShareCount` falls back to the *same default automatic splitting*, not to per-entry
* inlining (confirmed by comparing `dist/` output with and without the group: identical).
*
* So instead, the root is built completely alone, in its own rolldown invocation with no other
* entry in its module graph (byte-for-byte the same single-entry build this package always
* shipped), and the ~76 util subpaths are built together in a second, separate invocation. Within
* that second group, rolldown's default splitting still applies *among the utils themselves*:
* most end up self-contained (single importer within that graph), but a few genuine cross-util
* dependencies (e.g. `getPixKeyInfo` reusing `isValidCpf`'s digit-check, several phone utils sharing
* `formatPhone`'s area-code table) get factored into a small shared chunk, real code reuse that
* would otherwise be duplicated; either way, none of it touches the root. Running
* ~77 entries as ~77 *separate* `PackUserConfig`s (fully self-contained, zero sharing at all) was
* also tried and rejected: with no way to throttle this build engine's per-config concurrency from
* `vite.config.ts` (`--concurrency` is a CLI-only flag, and this project's `build` script is fixed
* to plain `vp pack`), that many concurrent rolldown + dts builds reliably exhausted the heap
* (`FATAL ERROR: Reached heap limit`) before producing any output. Two configs is the balance that
* keeps both memory use and cross-entry sharing in check.
*/
export default defineConfig({
fmt: {
// `reports` holds generated output only (the Stryker mutation reports).
// `CHANGELOG.md` and `jsr.json` are written by release-please (`* ` bullets in the first, every
// array expanded in the second when it bumps the version); formatting them would fail the
// Check workflow on every release PR.
ignorePatterns: [
"dist",
"coverage",
"docs",
"reports",
".stryker-tmp",
".claude",
"CHANGELOG.md",
"jsr.json",
],
singleQuote: false,
sortImports: true,
useTabs: true,
},
lint: {
options: {
typeAware: true,
typeCheck: true,
},
plugins: ["oxc", "typescript", "unicorn", "import", "jsdoc", "promise", "vitest"],
// SonarJS runs as an oxlint JS plugin (bug patterns, cognitive complexity, regex checks
// and test smells that the Rust plugins do not cover). Its type-aware rules are inert
// here because oxlint does not hand ESLint plugins a type checker.
jsPlugins: ["eslint-plugin-sonarjs"],
categories: {
correctness: "error",
suspicious: "error",
perf: "error",
pedantic: "error",
},
ignorePatterns: ["dist", "coverage", "docs", "reports", ".stryker-tmp", ".claude"],
rules: {
"eslint/complexity": ["error", { max: 20 }],
"eslint/max-lines": "off",
"eslint/max-lines-per-function": [
"error",
{ max: 120, skipBlankLines: true, skipComments: true },
],
"eslint/no-console": "error",
"eslint/no-empty": "error",
"import/no-unassigned-import": ["error", { allow: ["**/*.d.ts"] }],
"eslint/max-classes-per-file": "off",
"eslint/no-empty-function": "error",
"eslint/no-param-reassign": "error",
"eslint/no-use-before-define": "error",
"eslint/no-void": "error",
"eslint/require-unicode-regexp": "off",
"typescript/prefer-readonly-parameter-types": "off",
"unicorn/prefer-code-point": "off",
"unicorn/prefer-number-coercion": "off",
"import/no-cycle": "error",
"import/no-default-export": "error",
"import/no-duplicates": "error",
"jsdoc/check-tag-names": "error",
"jsdoc/require-param": "error",
"jsdoc/require-returns": "error",
"typescript/array-type": ["error", { default: "array" }],
"typescript/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }],
"typescript/consistent-type-definitions": ["error", "type"],
"typescript/explicit-function-return-type": "error",
"typescript/explicit-member-accessibility": "error",
"typescript/explicit-module-boundary-types": "error",
"typescript/no-non-null-assertion": "error",
"unicorn/max-nested-calls": "error",
"unicorn/no-array-for-each": "error",
"unicorn/no-array-reverse": "off",
"unicorn/no-array-sort": "off",
"unicorn/no-nested-ternary": "off",
"unicorn/no-zero-fractions": "error",
"unicorn/number-literal-case": "off",
"unicorn/numeric-separators-style": "error",
"unicorn/prefer-export-from": "error",
"unicorn/prefer-spread": "error",
"unicorn/switch-case-braces": "error",
"eslint/max-params": ["error", { max: 4 }],
"eslint/prefer-template": "error",
"eslint/prefer-regex-literals": "error",
"eslint/no-duplicate-imports": "error",
"eslint/operator-assignment": "error",
"eslint/arrow-body-style": "error",
"eslint/no-multi-assign": "error",
"eslint/prefer-spread": "error",
"eslint/no-else-return": "error",
"eslint/no-lonely-if": "error",
"eslint/no-unneeded-ternary": "error",
"eslint/no-useless-return": "error",
"eslint/no-useless-concat": "error",
"eslint/no-useless-computed-key": "error",
"eslint/no-useless-rename": "error",
"eslint/prefer-exponentiation-operator": "error",
"eslint/prefer-numeric-literals": "error",
"eslint/prefer-object-has-own": "error",
"eslint/prefer-promise-reject-errors": "error",
"eslint/require-await": "error",
"eslint/yoda": "error",
"eslint/eqeqeq": "error",
"eslint/no-negated-condition": "error",
"eslint/default-case-last": "error",
"eslint/grouped-accessor-pairs": "error",
"eslint/no-label-var": "error",
"eslint/no-labels": "error",
"eslint/no-sequences": "error",
"eslint/no-throw-literal": "error",
"eslint/radix": "error",
"eslint/symbol-description": "error",
"eslint/no-implicit-coercion": "error",
"typescript/prefer-for-of": "error",
"typescript/method-signature-style": "error",
"typescript/prefer-optional-chain": "error",
"typescript/prefer-nullish-coalescing": "error",
"typescript/prefer-readonly": "error",
"typescript/prefer-string-starts-ends-with": "error",
"typescript/prefer-includes": "error",
"typescript/prefer-regexp-exec": "error",
"typescript/no-unnecessary-type-arguments": "error",
"typescript/no-unnecessary-boolean-literal-compare": "error",
"typescript/switch-exhaustiveness-check": "error",
"typescript/no-inferrable-types": "error",
"typescript/require-array-sort-compare": "error",
"typescript/no-confusing-void-expression": "error",
"typescript/no-meaningless-void-operator": "error",
"typescript/no-redundant-type-constituents": "error",
"typescript/no-useless-empty-export": "error",
"typescript/prefer-reduce-type-parameter": "error",
"typescript/no-empty-object-type": "error",
"unicorn/prefer-negative-index": "error",
"unicorn/consistent-existence-index-check": "error",
"unicorn/prefer-default-parameters": "error",
"unicorn/no-unreadable-array-destructuring": "error",
"unicorn/prefer-string-raw": "error",
"unicorn/consistent-date-clone": "error",
"unicorn/no-await-expression-member": "error",
"unicorn/no-array-reduce": "error",
"unicorn/filename-case": ["error", { case: "kebabCase" }],
"unicorn/catch-error-name": "error",
"unicorn/prefer-array-flat-map": "error",
"unicorn/prefer-array-flat": "error",
"unicorn/prefer-array-some": "error",
"unicorn/prefer-array-find": "error",
"unicorn/prefer-array-index-of": "error",
"unicorn/prefer-includes": "error",
"unicorn/prefer-string-slice": "error",
"unicorn/prefer-string-trim-start-end": "error",
"unicorn/prefer-regexp-test": "error",
"unicorn/prefer-optional-catch-binding": "error",
"unicorn/prefer-set-has": "error",
"unicorn/prefer-set-size": "error",
"unicorn/prefer-logical-operator-over-ternary": "error",
"unicorn/prefer-date-now": "error",
"unicorn/prefer-math-min-max": "error",
"unicorn/prefer-modern-math-apis": "error",
"unicorn/prefer-math-trunc": "error",
"unicorn/prefer-native-coercion-functions": "error",
"unicorn/prefer-number-properties": "error",
"unicorn/prefer-object-from-entries": "error",
"unicorn/prefer-structured-clone": "error",
"unicorn/prefer-type-error": "error",
"unicorn/prefer-global-this": "error",
"unicorn/prefer-node-protocol": "error",
"unicorn/prefer-at": "error",
"unicorn/require-array-join-separator": "error",
"unicorn/require-number-to-fixed-digits-argument": "error",
"unicorn/throw-new-error": "error",
"unicorn/error-message": "error",
"unicorn/no-instanceof-builtins": "error",
"unicorn/no-typeof-undefined": "error",
"unicorn/no-negation-in-equality-check": "error",
"unicorn/no-thenable": "error",
"unicorn/no-unnecessary-await": "error",
"unicorn/no-useless-promise-resolve-reject": "error",
"unicorn/no-useless-spread": "error",
"unicorn/no-useless-fallback-in-spread": "error",
"unicorn/no-useless-length-check": "error",
"unicorn/no-useless-switch-case": "error",
"unicorn/no-lonely-if": "error",
"unicorn/no-negated-condition": "error",
"unicorn/no-object-as-default-parameter": "error",
"unicorn/no-static-only-class": "error",
"unicorn/no-empty-file": "error",
"unicorn/no-hex-escape": "error",
"unicorn/escape-case": "error",
"unicorn/no-new-array": "error",
"unicorn/no-array-method-this-argument": "error",
"unicorn/no-array-callback-reference": "error",
"unicorn/no-length-as-slice-end": "error",
"unicorn/no-magic-array-flat-depth": "error",
"unicorn/no-single-promise-in-promise-methods": "error",
"unicorn/no-await-in-promise-methods": "error",
"unicorn/no-unreadable-iife": "error",
"unicorn/no-anonymous-default-export": "error",
"unicorn/no-abusive-eslint-disable": "error",
"unicorn/explicit-length-check": "error",
"unicorn/consistent-empty-array-spread": "error",
"unicorn/text-encoding-identifier-case": "error",
"unicorn/prefer-import-meta-properties": "error",
"unicorn/prefer-prototype-methods": "error",
"unicorn/prefer-reflect-apply": "error",
"unicorn/no-console-spaces": "error",
"unicorn/no-instanceof-array": "error",
"unicorn/relative-url-style": "error",
"promise/prefer-await-to-then": "error",
"promise/param-names": "error",
"promise/no-return-wrap": "error",
"promise/no-nesting": "error",
"promise/no-promise-in-callback": "error",
"promise/no-callback-in-promise": "error",
"promise/valid-params": "error",
"promise/no-new-statics": "error",
"promise/no-multiple-resolved": "error",
"promise/catch-or-return": "error",
"promise/always-return": "error",
"promise/no-return-in-finally": "error",
"promise/spec-only": "error",
"node/no-exports-assign": "error",
"node/no-new-require": "error",
"jsdoc/require-param-description": "error",
"jsdoc/require-returns-description": "error",
"jsdoc/require-param-name": "error",
"jsdoc/require-property": "error",
"jsdoc/require-property-description": "error",
"jsdoc/require-property-name": "error",
"jsdoc/require-property-type": "error",
"jsdoc/require-yields": "error",
"jsdoc/check-access": "error",
"jsdoc/empty-tags": "error",
"jsdoc/implements-on-classes": "error",
"jsdoc/no-defaults": "error",
"jsdoc/check-property-names": "error",
"vitest/prefer-describe-function-title": "error",
"vitest/prefer-to-be": "error",
"vitest/prefer-to-have-length": "error",
"vitest/prefer-to-be-object": "error",
"vitest/prefer-strict-equal": "error",
"vitest/prefer-equality-matcher": "error",
"vitest/prefer-comparison-matcher": "error",
"vitest/prefer-called-with": "error",
"vitest/prefer-hooks-in-order": "error",
"vitest/prefer-hooks-on-top": "error",
"vitest/prefer-mock-promise-shorthand": "error",
"vitest/no-alias-methods": "error",
"vitest/no-commented-out-tests": "error",
"vitest/no-duplicate-hooks": "error",
"vitest/no-identical-title": "error",
"vitest/no-interpolation-in-snapshots": "error",
"vitest/no-large-snapshots": "error",
"vitest/no-mocks-import": "error",
"vitest/no-restricted-matchers": "error",
"vitest/no-standalone-expect": "error",
"vitest/no-test-prefixes": "error",
"vitest/no-test-return-statement": "error",
"vitest/consistent-test-it": ["error", { fn: "test" }],
"vitest/consistent-vitest-vi": "error",
"vitest/expect-expect": "error",
"vitest/max-nested-describe": "error",
"vitest/require-to-throw-message": "error",
"vitest/require-top-level-describe": "error",
"vitest/valid-describe-callback": "error",
"vitest/valid-expect": "error",
"vitest/valid-expect-in-promise": "error",
"vitest/no-focused-tests": "error",
"import/consistent-type-specifier-style": ["error", "prefer-inline"],
"import/first": "error",
"import/newline-after-import": "error",
"import/no-absolute-path": "error",
"import/no-amd": "error",
"import/no-commonjs": "error",
"import/no-dynamic-require": "error",
"import/no-empty-named-blocks": "error",
"import/no-mutable-exports": "error",
"import/no-named-default": "error",
"import/no-self-import": "error",
"import/no-webpack-loader-syntax": "error",
"import/no-anonymous-default-export": "error",
...sonarjsRules,
// Formatting, naming and layout are vp fmt's job or are enforced by other plugins.
"sonarjs/file-header": "off",
"sonarjs/no-tab": "off",
"sonarjs/arrow-function-convention": "off",
"sonarjs/shorthand-property-grouping": "off",
"sonarjs/concise-regex": "off",
"sonarjs/no-wildcard-import": "off",
"sonarjs/elseif-without-else": "off",
"sonarjs/no-undefined-assignment": "off",
// Already gated by eslint/complexity (20), eslint/max-lines-per-function and jscpd.
"sonarjs/cyclomatic-complexity": "off",
"sonarjs/max-lines": "off",
"sonarjs/max-lines-per-function": "off",
"sonarjs/no-duplicate-string": "off",
"sonarjs/expression-complexity": "off",
"sonarjs/too-many-break-or-continue-in-loop": "off",
"sonarjs/nested-control-flow": "off",
// TypeScript utility types (Record, Pick, ...) are reported as undeclared references.
"sonarjs/no-reference-error": "off",
// The union of the 27 state codes and the generators' Math.random are intentional.
"sonarjs/max-union-size": "off",
"sonarjs/pseudo-random": "off",
// Deprecated aliases kept for backwards compatibility are redundant by design.
"sonarjs/redundant-type-aliases": "off",
// test.todo is a runtime shim feature, not a pending task.
"sonarjs/todo-tag": "off",
"sonarjs/cognitive-complexity": ["error", 25],
"sonarjs/regex-complexity": ["error", { threshold: 25 }],
},
overrides: [
{
files: ["src/_internals/test/**"],
rules: {
// The arbitraries assemble valid documents out of the check-digit internals, so
// this one file reaches for more modules than a util ever should.
"import/max-dependencies": "off",
"sonarjs/no-implicit-dependencies": "off",
"sonarjs/no-nested-functions": "off",
"typescript/consistent-type-definitions": "off",
"vitest/no-disabled-tests": "off",
"vitest/valid-title": "off",
"vitest/warn-todo": "off",
},
},
// The barrel re-exports every deprecated alias, and a deprecated util's own tests (plus
// the `getMunicipalities` property that cross-checks it against `getCities`) have to
// keep calling it for as long as it is still supported.
{
files: [
"src/index.ts",
"src/index.test.ts",
"src/get-cities/get-cities.test.ts",
"src/get-municipalities/get-municipalities.test.ts",
"src/get-municipality/get-municipality.test.ts",
],
rules: {
"typescript/no-deprecated": "off",
},
},
{
files: ["**/*.test.ts", "src/_internals/test/**"],
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-type-assertion": "off",
"typescript/no-unsafe-argument": "off",
"typescript/no-unsafe-assignment": "off",
"typescript/no-unsafe-call": "off",
"typescript/no-unsafe-member-access": "off",
"typescript/no-unsafe-return": "off",
"vitest/no-conditional-in-test": "off",
"unicorn/new-for-builtins": "off",
"eslint/no-new-wrappers": "off",
"sonarjs/no-primitive-wrappers": "off",
"vitest/no-conditional-expect": "off",
"eslint/max-lines-per-function": "off",
"typescript/explicit-function-return-type": "off",
"typescript/explicit-module-boundary-types": "off",
"jsdoc/require-param": "off",
"jsdoc/require-returns": "off",
},
},
{
env: {
node: true,
},
files: ["scripts/**/*.ts", "vite.config.ts"],
rules: {
"eslint/no-console": "off",
// The dataset scripts parse trusted official sources with backtracking regexes.
"sonarjs/super-linear-regex": "off",
"import/no-default-export": "off",
},
},
],
},
test: {
exclude: ["**/node_modules/**", "**/dist/**", "**/.stryker-tmp/**", "**/reports/**"],
benchmark: {
include: ["src/**/*.test.ts"],
exclude: ["**/node_modules/**", "**/dist/**", "**/.stryker-tmp/**", "**/reports/**"],
},
browser: {
provider: webdriverio(),
connectTimeout: 120_000,
instances: [
/**
* Edge ships without a setuid sandbox helper on the ubuntu-latest runner image, so it
* aborts at startup unless the SUID sandbox is disabled. Chrome and Firefox are
* unaffected.
*/
{
browser: "edge",
provider: webdriverio({ capabilities: { "ms:edgeOptions": { args: ["--no-sandbox"] } } }),
},
{ browser: "chrome" },
{ browser: "safari" },
{ browser: "firefox" },
],
},
coverage: {
provider: "v8",
reporter: ["text", "lcov"],
include: ["src/**/*.ts"],
exclude: [
"src/**/*.test.ts",
"src/_internals/test/**",
"src/**/constants.ts",
"src/_internals/constants/**",
"src/index.ts",
],
thresholds: {
statements: 100,
branches: 100,
functions: 100,
lines: 100,
},
},
},
pack: [
{
...sharedPack,
entry: { "brazilian-utils": resolve(rootDirectory, "src/index.ts") },
format: ["es", "umd"],
globalName: "BrazilianUtils",
plugins: [minifyUmdChunk(), emitCjsDtsTwin()],
},
{
...sharedPack,
sourcemap: false,
entry: utilityEntries,
format: ["es", "cjs"],
},
],
});