Fork Horse repository, listed by its owner. Publisher snapshot.
vite.config.ts
Snapshot at 34e3175
1import { defineConfig } from 'vite-plus'
2
3/**
4 * Repo-wide toolchain config, ported from the submodule's own `vite.config.ts` so a contributor
5 * moving between the two repositories meets the same ruleset.
6 *
7 * Lint only. There is deliberately no `run.tasks` block here: Vite+ creates a task for every
8 * package from a workspace-root task definition, including the root package itself, and the root
9 * has no sources for one to act on. Per-package tasks live in each package's own `vite.config.ts`.
10 */
11export default defineConfig({
12 check: {
13 // The tree has never been formatted with oxfmt, so `vp check` would report every file. `vp fmt`
14 // still works if invoked directly.
15 fmt: false,
16 },
17 lint: {
18 categories: {
19 correctness: 'error',
20 suspicious: 'error',
21 },
22 plugins: ['typescript', 'unicorn', 'oxc', 'import'],
23 options: {
24 // Type-aware linting is intentionally off, as upstream. `tsc` is what enforces type safety
25 // here: `pnpm types:scripts` for the deploy tooling and `pnpm build` for the packages.
26 typeAware: false,
27 },
28 env: {
29 es2024: true,
30 },
31 rules: {
32 // False positives: gatekeepers import `.txt` files as bundled text assets, which the import
33 // resolver reports as "no default export".
34 'import/default': 'off',
35
36 // Side-effect imports are used deliberately (the `cloudflare:workers` runtime registration).
37 'import/no-unassigned-import': 'off',
38
39 // Comment-only reference modules are kept intentionally (`src/types.d.ts`).
40 'unicorn/no-empty-file': 'off',
41
42 // Conflicts with the convention of prefixing intentionally-unused bindings with `_`.
43 'no-underscore-dangle': 'off',
44
45 // Do not require churny `_` prefixes on unused callback/interface parameters or catch
46 // bindings, but still flag unused imports and local variables.
47 'no-unused-vars': [
48 'error',
49 {
50 args: 'none',
51 caughtErrors: 'none',
52 varsIgnorePattern: '^_',
53 ignoreRestSiblings: true,
54 },
55 ],
56
57 // Genuine improvements, but churny for an initial rollout. Visible as warnings.
58 'no-shadow': 'warn',
59 'typescript/no-this-alias': 'warn',
60 'typescript/no-extraneous-class': 'warn',
61 'unicorn/consistent-function-scoping': 'warn',
62 },
63 ignorePatterns: [
64 // The submodule lints itself, with its own config, its own plugins (including the local
65 // `gadgets/prefer-jsdoc` rule this file does not load) and its own per-directory overrides.
66 // Linting it from here would report findings nobody in this repository can fix.
67 'cloudflare-os/**',
68 '**/dist/**',
69 '**/generated/**',
70 '**/*.gen.ts',
71 '**/node_modules/**',
72 '**/.wrangler/**',
73 '**/worker-configuration.d.ts',
74 ],
75 overrides: [
76 {
77 // Cloudflare Workers backends: worker/service-worker global scope.
78 files: ['packages/*/src/**/*.ts'],
79 env: {
80 serviceworker: true,
81 es2024: true,
82 },
83 },
84 {
85 files: ['**/*.test.ts', '**/vitest.config.ts', 'packages/*/__tests__/**/*.ts'],
86 plugins: ['typescript', 'unicorn', 'oxc', 'import', 'vitest'],
87 env: {
88 vitest: true,
89 es2024: true,
90 },
91 },
92 {
93 files: ['scripts/**/*.ts'],
94 env: {
95 node: true,
96 es2024: true,
97 },
98 },
99 {
100 // `scripts/` tests run under `node --test`, not vitest, so they must not pick up the vitest
101 // override above (which would supply vitest globals and drop `env: node`). Ordered last so
102 // it wins over that entry.
103 files: ['scripts/**/*.test.ts'],
104 plugins: ['typescript', 'unicorn', 'oxc', 'import'],
105 env: {
106 node: true,
107 es2024: true,
108 },
109 },
110 ],
111 },
112})
113