@kasoa/vite-plus-config 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,30 +1,26 @@
1
1
  # @kasoa/vite-plus-config
2
2
 
3
- Kasoa's shared Vite+ presets for formatting, linting, and type checking.
3
+ Strict Vite+ presets for formatting, linting, type checking, testing, packaging, and staged checks. Requires Node.js 24.11 or newer, Vite+ 0.2.8 or newer, and TypeScript 7.
4
4
 
5
5
  ## Installation
6
6
 
7
- Install Vite+ and the shared config:
8
-
9
7
  ```bash
10
8
  pnpm add -D @kasoa/vite-plus-config vite-plus typescript@^7
11
9
  ```
12
10
 
13
- **Note**: Requires Node.js >=24 and TypeScript-first projects. Use the stable `typescript` package; Vite+'s native type-checking path does not require `@typescript/native-preview` or a separate `tsgo` command.
14
-
15
- ## Usage
11
+ ## Presets
16
12
 
17
- Create a local `vite.config.ts` and call the shared preset factory that matches the project.
13
+ | Export | Use |
14
+ | -------------------- | ----------------------------------------------- |
15
+ | `base` | TypeScript applications and custom compositions |
16
+ | `react` | Browser React applications |
17
+ | `react-native` | React Native and Expo applications |
18
+ | `node` | Node.js applications and tools |
19
+ | `library` | ESM libraries built with `vp pack` |
20
+ | `monorepo` | Workspace roots using Vite+ tasks |
21
+ | `cloudflare-workers` | Node preset plus workerd-based Vitest wiring |
18
22
 
19
- ### Base Config
20
-
21
- ```ts
22
- import { createConfig } from "@kasoa/vite-plus-config/base";
23
-
24
- export default createConfig();
25
- ```
26
-
27
- ### React Projects
23
+ Create `vite.config.ts` with the matching factory:
28
24
 
29
25
  ```ts
30
26
  import { createConfig } from "@kasoa/vite-plus-config/react";
@@ -32,121 +28,78 @@ import { createConfig } from "@kasoa/vite-plus-config/react";
32
28
  export default createConfig();
33
29
  ```
34
30
 
35
- The React preset enables Oxlint's native `react/react-compiler` diagnostics as errors. This experimental aggregate lint rule does not enable React Compiler transforms; override it to `off` if a project needs to opt out.
36
-
37
- ### Node Projects
31
+ ### React Native and Expo
38
32
 
39
33
  ```ts
40
- import { createConfig } from "@kasoa/vite-plus-config/node";
34
+ import { createConfig } from "@kasoa/vite-plus-config/react-native";
41
35
 
42
36
  export default createConfig();
43
37
  ```
44
38
 
45
- ### Libraries
46
-
47
- ```ts
48
- import { createConfig } from "@kasoa/vite-plus-config/library";
49
-
50
- export default createConfig();
51
- ```
39
+ The native preset rejects DOM globals, permits Expo's statically replaced `process.env` and React Native's `__DEV__`, excludes DOM accessibility rules, and ignores `.expo` output. It does not ignore `android` or `ios`, which may be project-owned source.
52
40
 
53
- ### Monorepo Root
41
+ ### Cloudflare Workers tests
54
42
 
55
- ```ts
56
- import { createConfig } from "@kasoa/vite-plus-config/monorepo";
43
+ Install the optional peers:
57
44
 
58
- export default createConfig();
45
+ ```bash
46
+ pnpm add -D @cloudflare/vitest-pool-workers wrangler
59
47
  ```
60
48
 
61
- ## Customizing a Preset
62
-
63
- Pass overrides directly to the preset factory. Nested config is merged so consumers can stay strict by default and still tweak what they need.
64
-
65
49
  ```ts
66
- import { createConfig } from "@kasoa/vite-plus-config/react";
50
+ import { createConfig } from "@kasoa/vite-plus-config/cloudflare-workers";
67
51
 
68
52
  export default createConfig({
69
- lint: {
70
- rules: {
71
- "no-console": "warn",
53
+ miniflare: {
54
+ bindings: {
55
+ CORS_ALLOWED_ORIGINS: "",
72
56
  },
73
57
  },
74
58
  test: {
75
- coverage: {
76
- reporter: ["text", "html"],
59
+ provide: {
60
+ d1Migrations: [],
77
61
  },
78
62
  },
79
63
  });
80
64
  ```
81
65
 
82
- ## Cloudflare Workers Tests
66
+ Wrangler owns Worker development, builds, type generation, and deployment. Vite+ owns static checks and workerd tests. Consumers retain ownership of bindings, migrations, setup files, coverage, and `test.provide` values.
83
67
 
84
- The `cloudflare-workers` preset combines the Node.js preset with `cloudflareTest()` and reads `wrangler.jsonc` from the project root by default. Vite+ provides Vitest; import test APIs from `vite-plus/test`.
68
+ ## Overrides
85
69
 
86
- ```bash
87
- pnpm add -D @cloudflare/vitest-pool-workers wrangler
88
- ```
70
+ Pass project-specific overrides to the factory. Lint rule tuples are replaced atomically; other arrays follow Vite's merge behavior.
89
71
 
90
72
  ```ts
91
- import { createConfig } from "@kasoa/vite-plus-config/cloudflare-workers";
73
+ import { createConfig } from "@kasoa/vite-plus-config/react";
92
74
 
93
75
  export default createConfig({
94
- miniflare: {
95
- bindings: {
96
- CORS_ALLOWED_ORIGINS: "",
76
+ lint: {
77
+ rules: {
78
+ complexity: "off",
79
+ "max-params": ["warn", { max: 5 }],
97
80
  },
98
81
  },
99
82
  test: {
100
- provide: {
101
- d1Migrations: [],
83
+ coverage: {
84
+ reporter: ["text", "html"],
102
85
  },
103
86
  },
104
87
  });
105
88
  ```
106
89
 
107
- Use Wrangler for backend Worker development, builds, type generation, remote development, and deployment. Use Vite+ for checks and Worker tests:
108
-
109
- ```json
110
- {
111
- "scripts": {
112
- "dev": "wrangler dev",
113
- "build": "wrangler deploy --dry-run",
114
- "check": "vp check",
115
- "test": "vp test"
116
- }
117
- }
118
- ```
90
+ The React presets report React Compiler violations, but linting does not install or enable compiler transforms. Configure the compiler separately in applications that use it.
119
91
 
120
- Keep project-specific migrations, bindings, coverage, setup files, and `test.provide` values in the consuming project. Vite-owned frontend and full-stack applications should configure `@cloudflare/vite-plugin` with their project-specific plugins.
92
+ ## Commands
121
93
 
122
- ## Recommended Workflow
123
-
124
- ```json
125
- {
126
- "scripts": {
127
- "check": "vp check",
128
- "check:fix": "vp check --fix"
129
- }
130
- }
94
+ ```bash
95
+ vp check
96
+ vp check --fix
97
+ vp test
131
98
  ```
132
99
 
133
- `vp check` formats, lints, and type-checks the project. Use `vp check --fix` for automatic fixes, path arguments for focused checks, and the full command for final verification.
134
-
135
- Use `vp config` to generate commit hooks from the shared `staged` rules. Keep one `vite.config.ts` unless the project needs separate configurations.
136
-
137
- ## Configurations
138
-
139
- - **`base`**: Strict TypeScript-first format, lint, type-aware/type-check defaults, dependency/build ignores, test include, and staged-file defaults.
140
- - **`react`**: `base` plus browser globals, React lint rules, and Tailwind-aware formatting. React Native or Expo projects that want to reject DOM globals can override `lint.env.browser` to `false`.
141
- - **`node`**: `base` plus Node-oriented lint rules.
142
- - **`library`**: `base` plus ESM-only packaging defaults for `vp pack`.
143
- - **`monorepo`**: `base` plus root-only `run` defaults for workspace caching.
144
- - **`cloudflare-workers`**: `node` plus Cloudflare Worker test wiring.
145
-
146
- ## Author
100
+ Use path arguments for focused iteration and run the complete command before committing. Import Vitest APIs from `vite-plus/test`.
147
101
 
148
- Emmanuel Chucks
149
- https://github.com/emmanuelchucks
102
+ `vp config` generates commit hooks from the preset's staged-check configuration.
150
103
 
151
104
  ## License
152
105