@kasoa/vite-plus-config 0.5.1 → 0.6.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 +51 -113
- package/dist/{compose-XJvIUwAG.d.mts → compose-DcbEF5Mv.d.mts} +1 -3
- package/dist/compose-DcbEF5Mv.d.mts.map +1 -0
- package/dist/{constants-D3UBePrC.mjs → constants-BYglvKjm.mjs} +2 -3
- package/dist/{constants-D3UBePrC.mjs.map → constants-BYglvKjm.mjs.map} +1 -1
- package/dist/src/cloudflare-workers/index.d.mts +2 -3
- package/dist/src/cloudflare-workers/index.d.mts.map +1 -1
- package/dist/src/cloudflare-workers/index.mjs +2 -3
- package/dist/src/index.d.mts +2 -9
- package/dist/src/index.d.mts.map +1 -1
- package/dist/src/index.mjs +38 -43
- package/dist/src/index.mjs.map +1 -1
- package/dist/src/lint/plugin/index.d.mts +4 -0
- package/dist/src/lint/plugin/index.d.mts.map +1 -0
- package/dist/src/lint/plugin/index.mjs +315 -0
- package/dist/src/lint/plugin/index.mjs.map +1 -0
- package/package.json +10 -6
- package/dist/compose-XJvIUwAG.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
# @kasoa/vite-plus-config
|
|
2
2
|
|
|
3
|
-
Strict, composable Vite+ configuration fragments. Requires Node.js 24.11
|
|
4
|
-
|
|
5
|
-
The preset is intentionally strict. Fix violations by default. When a runtime, protocol, generated file, framework, or external signature requires an exception, keep it narrow and explain why it is necessary.
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
3
|
+
Strict, composable Vite+ configuration fragments. Requires Node.js 24.11+, Vite+ 1.4+ and TypeScript 7.
|
|
8
4
|
|
|
9
5
|
```bash
|
|
10
6
|
pnpm add -D @kasoa/vite-plus-config vite-plus typescript@^7
|
|
11
7
|
```
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
Each `*Config` export is a plain Vite+ config fragment, and each `*Lint` export is a plain Oxlint profile for `lint.overrides`. `composeConfig()` merges fragments left to right with Vite's `mergeConfig()` (arrays concatenate); call it once, in the final config.
|
|
14
10
|
|
|
15
11
|
## Node
|
|
16
12
|
|
|
@@ -46,7 +42,9 @@ export default composeConfig(
|
|
|
46
42
|
);
|
|
47
43
|
```
|
|
48
44
|
|
|
49
|
-
|
|
45
|
+
Tests run in Node here. For DOM-emulated tests, compose `browserTestLintConfig` instead and set the matching Vitest environment.
|
|
46
|
+
|
|
47
|
+
The React fragments report React Compiler violations; they don't install or enable the compiler.
|
|
50
48
|
|
|
51
49
|
## React Native and Expo
|
|
52
50
|
|
|
@@ -69,41 +67,18 @@ export default composeConfig(
|
|
|
69
67
|
);
|
|
70
68
|
```
|
|
71
69
|
|
|
72
|
-
|
|
70
|
+
- `*.native.test.*` and `*.native.spec.*` files are Jest tests; other test files are Vitest tests, which may use `vi.mock` because Node can't load native modules.
|
|
71
|
+
- The runtime rules follow Hermes, so APIs it lacks (`toSorted()`, `Temporal`, some `Intl` formatters) are errors.
|
|
72
|
+
- Mapping data inside a `ScrollView` is an error unless the data is a module-level constant. To allow constants imported from your own modules, name them: `"kasoa/no-mapped-scrollview": ["error", { constantModules: ["/contracts$"] }]`.
|
|
73
73
|
|
|
74
|
-
##
|
|
74
|
+
## Workspaces
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
```ts
|
|
79
|
-
import {
|
|
80
|
-
baseToolingConfig,
|
|
81
|
-
composeConfig,
|
|
82
|
-
libraryPackConfig,
|
|
83
|
-
nodeRuntimeConfig,
|
|
84
|
-
nodeTestLintConfig,
|
|
85
|
-
} from "@kasoa/vite-plus-config";
|
|
86
|
-
|
|
87
|
-
export default composeConfig(
|
|
88
|
-
baseToolingConfig,
|
|
89
|
-
nodeRuntimeConfig,
|
|
90
|
-
nodeTestLintConfig,
|
|
91
|
-
libraryPackConfig,
|
|
92
|
-
{
|
|
93
|
-
pack: {
|
|
94
|
-
entry: {
|
|
95
|
-
"src/index": "./src/index.ts",
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
);
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
Use `workspaceRunConfig` at a workspace root. Vite+ applies the root lint configuration to workspace-wide checks, so model package runtimes with the exported lint profiles in root `lint.overrides`:
|
|
76
|
+
Vite+ applies the root lint config to the whole workspace, so give each package its runtime with a profile in a root override:
|
|
103
77
|
|
|
104
78
|
```ts
|
|
105
79
|
import {
|
|
106
80
|
RUNTIME_OVERRIDE_EXCLUDE_FILES,
|
|
81
|
+
TEST_FILES,
|
|
107
82
|
baseToolingConfig,
|
|
108
83
|
cloudflareWorkerGeneratedConfig,
|
|
109
84
|
cloudflareWorkerLint,
|
|
@@ -111,7 +86,7 @@ import {
|
|
|
111
86
|
nodeTestLintConfig,
|
|
112
87
|
reactNativeGeneratedConfig,
|
|
113
88
|
reactNativeLint,
|
|
114
|
-
|
|
89
|
+
reactNativeTestLint,
|
|
115
90
|
workspaceRunConfig,
|
|
116
91
|
} from "@kasoa/vite-plus-config";
|
|
117
92
|
|
|
@@ -130,14 +105,13 @@ export default composeConfig(
|
|
|
130
105
|
...reactNativeLint,
|
|
131
106
|
},
|
|
132
107
|
{
|
|
133
|
-
files:
|
|
134
|
-
|
|
135
|
-
...cloudflareWorkerLint,
|
|
108
|
+
files: TEST_FILES.map((pattern) => `apps/mobile/${pattern}`),
|
|
109
|
+
...reactNativeTestLint,
|
|
136
110
|
},
|
|
137
111
|
{
|
|
138
|
-
files: ["
|
|
112
|
+
files: ["apps/server/**"],
|
|
139
113
|
excludeFiles: [...RUNTIME_OVERRIDE_EXCLUDE_FILES],
|
|
140
|
-
...
|
|
114
|
+
...cloudflareWorkerLint,
|
|
141
115
|
},
|
|
142
116
|
],
|
|
143
117
|
},
|
|
@@ -145,50 +119,40 @@ export default composeConfig(
|
|
|
145
119
|
);
|
|
146
120
|
```
|
|
147
121
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
122
|
+
- `RUNTIME_OVERRIDE_EXCLUDE_FILES` keeps tests and config files out of a runtime override, so they keep their own rules. Config and CommonJS files always get the Node profile.
|
|
123
|
+
- `reactNativeLint` and `reactWebLint` cover a whole app; the narrower `reactCoreLint`, `reactDomLint` and `reactNativeRuntimeLint` are there when one part of a package needs only some of it.
|
|
124
|
+
- The same override pattern works in a single package with mixed runtimes, for example `{ files: ["scripts/**"], ...nodeLint }` in a Worker.
|
|
151
125
|
|
|
152
|
-
|
|
126
|
+
## Libraries
|
|
153
127
|
|
|
154
128
|
```ts
|
|
155
129
|
import {
|
|
156
130
|
baseToolingConfig,
|
|
157
|
-
cloudflareWorkerGeneratedConfig,
|
|
158
|
-
cloudflareWorkerRuntimeConfig,
|
|
159
131
|
composeConfig,
|
|
160
|
-
|
|
132
|
+
libraryPackConfig,
|
|
133
|
+
nodeRuntimeConfig,
|
|
134
|
+
nodeTestLintConfig,
|
|
161
135
|
} from "@kasoa/vite-plus-config";
|
|
162
136
|
|
|
163
137
|
export default composeConfig(
|
|
164
138
|
baseToolingConfig,
|
|
165
|
-
|
|
166
|
-
|
|
139
|
+
nodeRuntimeConfig,
|
|
140
|
+
nodeTestLintConfig,
|
|
141
|
+
libraryPackConfig,
|
|
167
142
|
{
|
|
168
|
-
|
|
169
|
-
overrides: [
|
|
170
|
-
{
|
|
171
|
-
files: ["scripts/**", "evals/**"],
|
|
172
|
-
...nodeLint,
|
|
173
|
-
},
|
|
174
|
-
],
|
|
175
|
-
},
|
|
143
|
+
pack: { entry: { "src/index": "./src/index.ts" } },
|
|
176
144
|
},
|
|
177
145
|
);
|
|
178
146
|
```
|
|
179
147
|
|
|
180
|
-
|
|
148
|
+
For several pack entries, spread `libraryPackDefaults` into each one instead of composing `libraryPackConfig`.
|
|
181
149
|
|
|
182
150
|
## Cloudflare Workers tests
|
|
183
151
|
|
|
184
|
-
Install the optional peer:
|
|
185
|
-
|
|
186
152
|
```bash
|
|
187
|
-
pnpm add -D @cloudflare/vitest-plugin@^1
|
|
153
|
+
pnpm add -D @cloudflare/vitest-plugin@^1.4
|
|
188
154
|
```
|
|
189
155
|
|
|
190
|
-
`@cloudflare/vitest-plugin` 1.x supports Vitest 4 only, so Workers tests need Vite+ 0.3 until Cloudflare adds Vitest 5 support. The rest of this package also works with Vite+ 1.x.
|
|
191
|
-
|
|
192
156
|
```ts
|
|
193
157
|
import {
|
|
194
158
|
baseToolingConfig,
|
|
@@ -204,46 +168,37 @@ export default composeConfig(
|
|
|
204
168
|
cloudflareWorkerRuntimeConfig,
|
|
205
169
|
cloudflareWorkerGeneratedConfig,
|
|
206
170
|
cloudflareWorkerTestLintConfig,
|
|
207
|
-
createCloudflareTestConfig(
|
|
208
|
-
miniflare: {
|
|
209
|
-
bindings: {
|
|
210
|
-
CORS_ALLOWED_ORIGINS: "",
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
}),
|
|
214
|
-
{
|
|
215
|
-
test: {
|
|
216
|
-
provide: {
|
|
217
|
-
d1Migrations: [],
|
|
218
|
-
},
|
|
219
|
-
},
|
|
220
|
-
},
|
|
171
|
+
createCloudflareTestConfig(),
|
|
221
172
|
);
|
|
222
173
|
```
|
|
223
174
|
|
|
224
|
-
`createCloudflareTestConfig` reads `cloudflare.config.ts` when
|
|
175
|
+
- `createCloudflareTestConfig()` takes the plugin's options. It reads `cloudflare.config.ts` when there is one (the `cf` CLI) and `wrangler.jsonc` otherwise; set `wrangler.configPath` to choose.
|
|
176
|
+
- With `cloudflare.config.ts`, the plugin renames the Worker under test, so a Durable Object binding that points back at the same Worker fails to start. Bind the class directly: `createCloudflareTestConfig({ miniflare: { durableObjects: { MY_OBJECT: "MyObject" } } })`.
|
|
225
177
|
|
|
226
|
-
|
|
178
|
+
## Kasoa rules
|
|
227
179
|
|
|
228
|
-
|
|
180
|
+
`baseToolingConfig` loads Kasoa's own Oxlint plugin. Its rules, configured like any other rule:
|
|
229
181
|
|
|
230
|
-
|
|
182
|
+
| Rule | Where | What it requires |
|
|
183
|
+
| ---------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
184
|
+
| `kasoa/disable-reason` | everywhere | every `oxlint-disable` or `eslint-disable` gives a reason after `--`, and a block `disable` has a matching `enable` |
|
|
185
|
+
| `kasoa/no-shadowed-globals` | everywhere | no binding named after a language global such as `Symbol` or `Map`; browser and Node globals like `name` stay free |
|
|
186
|
+
| `kasoa/effects-in-hooks` | React | `useEffect`, `useLayoutEffect` and `useInsertionEffect` only inside functions named `use…` |
|
|
187
|
+
| `kasoa/legend-list-only` | React Native | lists of data use Legend List, not `FlatList`, `SectionList` or `VirtualizedList` |
|
|
188
|
+
| `kasoa/no-mapped-scrollview` | React Native | no mapping data to elements inside a `ScrollView` |
|
|
189
|
+
| `kasoa/no-dynamic-import` | React Native, outside tests | static imports only |
|
|
231
190
|
|
|
232
|
-
|
|
233
|
-
import { baseToolingConfig, composeConfig, nodeRuntimeConfig } from "@kasoa/vite-plus-config";
|
|
191
|
+
## Changing a rule
|
|
234
192
|
|
|
193
|
+
A rule in a later fragment replaces the preset's setting for that rule:
|
|
194
|
+
|
|
195
|
+
```ts
|
|
235
196
|
export default composeConfig(baseToolingConfig, nodeRuntimeConfig, {
|
|
236
|
-
lint: {
|
|
237
|
-
rules: {
|
|
238
|
-
"max-params": ["error", { max: 4 }],
|
|
239
|
-
},
|
|
240
|
-
},
|
|
197
|
+
lint: { rules: { "max-params": ["error", { max: 4 }] } },
|
|
241
198
|
});
|
|
242
199
|
```
|
|
243
200
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
To change a scoped test rule, construct that test fragment directly instead of composing the default one:
|
|
201
|
+
To change a rule only in tests, build the test override yourself instead of composing the test fragment:
|
|
247
202
|
|
|
248
203
|
```ts
|
|
249
204
|
import type { ConfigFragment } from "@kasoa/vite-plus-config";
|
|
@@ -255,33 +210,16 @@ const testLintConfig = {
|
|
|
255
210
|
{
|
|
256
211
|
files: [...TEST_FILES],
|
|
257
212
|
...nodeTestLint,
|
|
258
|
-
rules: {
|
|
259
|
-
...nodeTestLint.rules,
|
|
260
|
-
"vitest/padding-around-test-blocks": "off",
|
|
261
|
-
},
|
|
213
|
+
rules: { ...nodeTestLint.rules, "vitest/padding-around-test-blocks": "off" },
|
|
262
214
|
},
|
|
263
215
|
],
|
|
264
216
|
},
|
|
265
217
|
} satisfies ConfigFragment;
|
|
266
218
|
```
|
|
267
219
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
## Project commands and hooks
|
|
271
|
-
|
|
272
|
-
Run these commands in the consuming project:
|
|
273
|
-
|
|
274
|
-
```bash
|
|
275
|
-
vp check
|
|
276
|
-
vp check --fix
|
|
277
|
-
vp test
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
Import Vitest APIs from `vite-plus/test`. The base fragment routes code through `vp check --fix` and supported non-code files through `vp fmt --write` when `vp staged` runs. Commit a project-owned `.vite-hooks/pre-commit` containing `vp staged`, then run `vp config --no-agent` to install or refresh Vite+'s generated dispatcher.
|
|
281
|
-
|
|
282
|
-
## Contributing
|
|
220
|
+
## Commit hooks
|
|
283
221
|
|
|
284
|
-
|
|
222
|
+
`baseToolingConfig` sets up `vp staged` to run `vp check --fix` on code and `vp fmt --write` on other files. Commit a `.vite-hooks/pre-commit` containing `vp staged`, then run `vp config --no-agent` to install the hook. Import Vitest APIs from `vite-plus/test`.
|
|
285
223
|
|
|
286
224
|
## License
|
|
287
225
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { UserConfig } from "vite-plus";
|
|
2
|
-
//#region src/compose.d.ts
|
|
3
2
|
interface NamedPlugin {
|
|
4
3
|
readonly name: string;
|
|
5
4
|
}
|
|
@@ -9,6 +8,5 @@ type ConfigFragment = Omit<UserConfig, "plugins"> & {
|
|
|
9
8
|
readonly plugins?: readonly PluginInput[];
|
|
10
9
|
};
|
|
11
10
|
declare function composeConfig(...fragments: readonly ConfigFragment[]): UserConfig;
|
|
12
|
-
//#endregion
|
|
13
11
|
export { PluginInput as n, composeConfig as r, ConfigFragment as t };
|
|
14
|
-
//# sourceMappingURL=compose-
|
|
12
|
+
//# sourceMappingURL=compose-DcbEF5Mv.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose-DcbEF5Mv.d.mts","names":[],"sources":["../src/compose.ts"],"mappings":";UAGU;WACC;;KAGN,cAAc;KAEP,cAAc,cAAc,QAAQ,wBAAwB;KAE5D,iBAAiB,KAAK;WACvB,mBAAmB;;iBAQd,iBAAiB,oBAAoB,mBAAmB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/constants.ts
|
|
2
2
|
const CODE_FILES = ["**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts}"];
|
|
3
3
|
const COMMONJS_FILES = ["**/*.{cjs,cts}"];
|
|
4
4
|
const CONFIG_FILES = ["**/*.config.{js,jsx,ts,tsx,mjs,cjs,mts,cts}"];
|
|
@@ -34,7 +34,6 @@ const DEFAULT_STAGED_FORMAT_GLOB = "*.{css,html,json,jsonc,less,md,mdx,scss,yaml
|
|
|
34
34
|
const DEFAULT_STAGED_FORMAT_COMMAND = "vp fmt --write --no-error-on-unmatched-pattern";
|
|
35
35
|
const DEFAULT_WRANGLER_CONFIG_PATH = "./wrangler.jsonc";
|
|
36
36
|
const CLOUDFLARE_CONFIG_PATH = "./cloudflare.config.ts";
|
|
37
|
-
//#endregion
|
|
38
37
|
export { VITEST_SETUP_FILES as _, CONFIG_FILES as a, DEFAULT_STAGED_CHECK_GLOB as c, DEFAULT_WRANGLER_CONFIG_PATH as d, REACT_NATIVE_IGNORE_PATTERNS as f, TEST_FILES as g, RUNTIME_OVERRIDE_EXCLUDE_FILES as h, COMMONJS_FILES as i, DEFAULT_STAGED_FORMAT_COMMAND as l, REACT_NATIVE_JEST_TEST_FILES as m, CLOUDFLARE_WORKER_IGNORE_PATTERNS as n, DEFAULT_IGNORE_PATTERNS as o, REACT_NATIVE_JEST_SETUP_FILES as p, CODE_FILES as r, DEFAULT_STAGED_CHECK_COMMAND as s, CLOUDFLARE_CONFIG_PATH as t, DEFAULT_STAGED_FORMAT_GLOB as u };
|
|
39
38
|
|
|
40
|
-
//# sourceMappingURL=constants-
|
|
39
|
+
//# sourceMappingURL=constants-BYglvKjm.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants-
|
|
1
|
+
{"version":3,"file":"constants-BYglvKjm.mjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["export const CODE_FILES = [\"**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts}\"] as const;\nexport const COMMONJS_FILES = [\"**/*.{cjs,cts}\"] as const;\nexport const CONFIG_FILES = [\"**/*.config.{js,jsx,ts,tsx,mjs,cjs,mts,cts}\"] as const;\nexport const TEST_FILES = [\n \"**/test/**\",\n \"**/tests/**\",\n \"**/__tests__/**\",\n \"**/*.{test,spec}.{js,jsx,ts,tsx,mjs,cjs,mts,cts}\",\n] as const;\nexport const VITEST_SETUP_FILES = [\n \"**/{vitest.setup,setup.vitest}.{js,jsx,ts,tsx,mjs,cjs,mts,cts}\",\n] as const;\nexport const REACT_NATIVE_JEST_TEST_FILES = [\n \"**/*.native.{test,spec}.{js,jsx,ts,tsx,mjs,cjs,mts,cts}\",\n] as const;\nexport const REACT_NATIVE_JEST_SETUP_FILES = [\n \"**/{jest.setup,setup.jest}.{js,jsx,ts,tsx,mjs,cjs,mts,cts}\",\n] as const;\nexport const RUNTIME_OVERRIDE_EXCLUDE_FILES: readonly string[] = [\n ...COMMONJS_FILES,\n ...CONFIG_FILES,\n ...TEST_FILES,\n] as const;\n\nexport const DEFAULT_IGNORE_PATTERNS = [\n \"node_modules/**\",\n \"dist/**\",\n \"dist-ssr/**\",\n \"**/.wrangler/**\",\n \"**/.cloudflare/**\",\n \"**/migrations/**\",\n \"**/drizzle/migrations.js\",\n \"**/drizzle/meta/*.json\",\n] as const;\nexport const CLOUDFLARE_WORKER_IGNORE_PATTERNS = [\"**/worker-configuration.d.ts\"] as const;\nexport const REACT_NATIVE_IGNORE_PATTERNS = [\"**/.expo/**\"] as const;\n\nexport const DEFAULT_STAGED_CHECK_GLOB = \"*.{js,jsx,ts,tsx,mjs,cjs,mts,cts,svelte,vue}\";\nexport const DEFAULT_STAGED_CHECK_COMMAND = \"vp check --fix\";\nexport const DEFAULT_STAGED_FORMAT_GLOB = \"*.{css,html,json,jsonc,less,md,mdx,scss,yaml,yml}\";\nexport const DEFAULT_STAGED_FORMAT_COMMAND = \"vp fmt --write --no-error-on-unmatched-pattern\";\nexport const DEFAULT_WRANGLER_CONFIG_PATH = \"./wrangler.jsonc\";\nexport const CLOUDFLARE_CONFIG_PATH = \"./cloudflare.config.ts\";\n"],"mappings":";AAAA,MAAa,aAAa,CAAC,sCAAsC;AACjE,MAAa,iBAAiB,CAAC,gBAAgB;AAC/C,MAAa,eAAe,CAAC,6CAA6C;AAC1E,MAAa,aAAa;CACxB;CACA;CACA;CACA;AACF;AACA,MAAa,qBAAqB,CAChC,gEACF;AACA,MAAa,+BAA+B,CAC1C,yDACF;AACA,MAAa,gCAAgC,CAC3C,4DACF;AACA,MAAa,iCAAoD;CAC/D,GAAG;CACH,GAAG;CACH,GAAG;AACL;AAEA,MAAa,0BAA0B;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AACA,MAAa,oCAAoC,CAAC,8BAA8B;AAChF,MAAa,+BAA+B,CAAC,aAAa;AAE1D,MAAa,4BAA4B;AACzC,MAAa,+BAA+B;AAC5C,MAAa,6BAA6B;AAC1C,MAAa,gCAAgC;AAC7C,MAAa,+BAA+B;AAC5C,MAAa,yBAAyB"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { t as ConfigFragment } from "../../compose-
|
|
1
|
+
import { t as ConfigFragment } from "../../compose-DcbEF5Mv.mjs";
|
|
2
2
|
import { cloudflareTest } from "@cloudflare/vitest-plugin";
|
|
3
|
-
//#region src/cloudflare-workers/index.d.ts
|
|
4
3
|
type CloudflareTestOptions = Exclude<NonNullable<Parameters<typeof cloudflareTest>[0]>, (...args: readonly never[]) => unknown>;
|
|
5
4
|
export interface CloudflareTestConfigOptions extends Omit<CloudflareTestOptions, "wrangler"> {
|
|
6
5
|
readonly wrangler?: CloudflareTestOptions["wrangler"];
|
|
7
6
|
}
|
|
8
7
|
export declare function createCloudflareTestConfig(options?: CloudflareTestConfigOptions): ConfigFragment;
|
|
9
|
-
|
|
8
|
+
export {};
|
|
10
9
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/cloudflare-workers/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/cloudflare-workers/index.ts"],"mappings":";;KAQK,wBAAwB,QAC3B,YAAY,kBAAkB,yBAC1B;iBAGW,oCAAoC,KAAK;WAC/C,WAAW;;wBAUN,2BACd,UAAS,8BACR"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { d as DEFAULT_WRANGLER_CONFIG_PATH, t as CLOUDFLARE_CONFIG_PATH } from "../../constants-
|
|
1
|
+
import { d as DEFAULT_WRANGLER_CONFIG_PATH, t as CLOUDFLARE_CONFIG_PATH } from "../../constants-BYglvKjm.mjs";
|
|
2
2
|
import { lazyPlugins } from "vite-plus";
|
|
3
3
|
import { cloudflareTest } from "@cloudflare/vitest-plugin";
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
|
-
|
|
5
|
+
// src/cloudflare-workers/index.ts
|
|
6
6
|
function createLazyPluginInputs(factory) {
|
|
7
7
|
return lazyPlugins(factory);
|
|
8
8
|
}
|
|
@@ -19,7 +19,6 @@ function createCloudflareTestConfig(options = {}) {
|
|
|
19
19
|
}
|
|
20
20
|
})]) };
|
|
21
21
|
}
|
|
22
|
-
//#endregion
|
|
23
22
|
export { createCloudflareTestConfig };
|
|
24
23
|
|
|
25
24
|
//# sourceMappingURL=index.mjs.map
|
package/dist/src/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { n as PluginInput, r as composeConfig, t as ConfigFragment } from "../compose-
|
|
1
|
+
import { n as PluginInput, r as composeConfig, t as ConfigFragment } from "../compose-DcbEF5Mv.mjs";
|
|
2
2
|
import { UserConfig } from "vite-plus";
|
|
3
|
-
//#region src/constants.d.ts
|
|
4
3
|
export declare const CODE_FILES: readonly ["**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts}"];
|
|
5
4
|
export declare const COMMONJS_FILES: readonly ["**/*.{cjs,cts}"];
|
|
6
5
|
export declare const CONFIG_FILES: readonly ["**/*.config.{js,jsx,ts,tsx,mjs,cjs,mts,cts}"];
|
|
@@ -9,8 +8,6 @@ export declare const VITEST_SETUP_FILES: readonly ["**/{vitest.setup,setup.vites
|
|
|
9
8
|
export declare const REACT_NATIVE_JEST_TEST_FILES: readonly ["**/*.native.{test,spec}.{js,jsx,ts,tsx,mjs,cjs,mts,cts}"];
|
|
10
9
|
export declare const REACT_NATIVE_JEST_SETUP_FILES: readonly ["**/{jest.setup,setup.jest}.{js,jsx,ts,tsx,mjs,cjs,mts,cts}"];
|
|
11
10
|
export declare const RUNTIME_OVERRIDE_EXCLUDE_FILES: readonly string[];
|
|
12
|
-
//#endregion
|
|
13
|
-
//#region src/fragments.d.ts
|
|
14
11
|
type PackConfig = Exclude<UserConfig["pack"], readonly unknown[] | undefined>;
|
|
15
12
|
export declare const baseToolingConfig: ConfigFragment;
|
|
16
13
|
export declare const nodeRuntimeConfig: ConfigFragment;
|
|
@@ -28,13 +25,9 @@ export declare const reactNativeTestLintConfig: ConfigFragment;
|
|
|
28
25
|
export declare const libraryPackDefaults: PackConfig;
|
|
29
26
|
export declare const libraryPackConfig: ConfigFragment;
|
|
30
27
|
export declare const workspaceRunConfig: ConfigFragment;
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/lint/types.d.ts
|
|
33
28
|
type LintConfig = NonNullable<UserConfig["lint"]>;
|
|
34
29
|
type LintOverride = NonNullable<LintConfig["overrides"]>[number];
|
|
35
30
|
type LintProfile = Omit<LintOverride, "excludeFiles" | "files">;
|
|
36
|
-
//#endregion
|
|
37
|
-
//#region src/lint/profiles.d.ts
|
|
38
31
|
export declare const nodeLint: LintProfile;
|
|
39
32
|
export declare const browserLint: LintProfile;
|
|
40
33
|
export declare const reactCoreLint: LintProfile;
|
|
@@ -45,8 +38,8 @@ export declare const reactNativeLint: LintProfile;
|
|
|
45
38
|
export declare const reactNativeJestTestLint: LintProfile;
|
|
46
39
|
export declare const cloudflareWorkerLint: LintProfile;
|
|
47
40
|
export declare const nodeTestLint: LintProfile;
|
|
41
|
+
export declare const reactNativeTestLint: LintProfile;
|
|
48
42
|
export declare const browserTestLint: LintProfile;
|
|
49
43
|
export declare const cloudflareWorkerTestLint: LintProfile;
|
|
50
|
-
//#endregion
|
|
51
44
|
export { type ConfigFragment, type PluginInput, composeConfig };
|
|
52
45
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/src/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/constants.ts","../../src/fragments.ts","../../src/lint/types.ts","../../src/lint/profiles.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/constants.ts","../../src/fragments.ts","../../src/lint/types.ts","../../src/lint/profiles.ts"],"mappings":";;qBAAa;qBACA;qBACA;qBACA;qBAMA;qBAGA;qBAGA;qBAGA;KCYR,aAAa,QAAQ;qBAEb,mBAAmB;qBASnB,mBAAmB;qBAInB,sBAAsB;qBAItB,iBAAiB;qBAKjB,gBAAgB;qBAIhB,0BAA0B;qBAI1B,4BAA4B;qBAK5B,+BAA+B;qBAI/B,iCAAiC;qBAKjC,oBAAoB;qBAIpB,uBAAuB;qBAIvB,gCAAgC;qBAIhC,2BAA2B;qBAI3B,qBAAqB;qBAcrB,mBAAmB;qBAInB,oBAAoB;KC5GrB,aAAa,YAAY;KACzB,eAAe,YAAY;KAC3B,cAAc,KAAK;qBC0ElB,UAAU;qBAOV,aAAa;qBAOb,eAAe;qBAKf,cAAc;qBAiDd,wBAAwB;qBAOxB,cAAc;qBAWd,iBAAiB;qBAUjB,yBAAyB;qBAWzB,sBAAsB;qBAMtB,cAAc;qBAWd,qBAAqB;qBAQrB,iBAAiB;qBASjB,0BAA0B"}
|
package/dist/src/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { _ as VITEST_SETUP_FILES, a as CONFIG_FILES, c as DEFAULT_STAGED_CHECK_GLOB, f as REACT_NATIVE_IGNORE_PATTERNS, g as TEST_FILES, h as RUNTIME_OVERRIDE_EXCLUDE_FILES, i as COMMONJS_FILES, l as DEFAULT_STAGED_FORMAT_COMMAND, m as REACT_NATIVE_JEST_TEST_FILES, n as CLOUDFLARE_WORKER_IGNORE_PATTERNS, o as DEFAULT_IGNORE_PATTERNS, p as REACT_NATIVE_JEST_SETUP_FILES, r as CODE_FILES, s as DEFAULT_STAGED_CHECK_COMMAND, u as DEFAULT_STAGED_FORMAT_GLOB } from "../constants-
|
|
1
|
+
import { _ as VITEST_SETUP_FILES, a as CONFIG_FILES, c as DEFAULT_STAGED_CHECK_GLOB, f as REACT_NATIVE_IGNORE_PATTERNS, g as TEST_FILES, h as RUNTIME_OVERRIDE_EXCLUDE_FILES, i as COMMONJS_FILES, l as DEFAULT_STAGED_FORMAT_COMMAND, m as REACT_NATIVE_JEST_TEST_FILES, n as CLOUDFLARE_WORKER_IGNORE_PATTERNS, o as DEFAULT_IGNORE_PATTERNS, p as REACT_NATIVE_JEST_SETUP_FILES, r as CODE_FILES, s as DEFAULT_STAGED_CHECK_COMMAND, u as DEFAULT_STAGED_FORMAT_GLOB } from "../constants-BYglvKjm.mjs";
|
|
2
2
|
import { defineConfig, mergeConfig } from "vite-plus";
|
|
3
|
-
|
|
3
|
+
import { URL, fileURLToPath } from "node:url";
|
|
4
|
+
// src/compose.ts
|
|
4
5
|
function toUserConfig(config) {
|
|
5
6
|
return config;
|
|
6
7
|
}
|
|
@@ -9,8 +10,7 @@ function composeConfig(...fragments) {
|
|
|
9
10
|
for (const fragment of fragments) config = mergeConfig(config, toUserConfig(fragment));
|
|
10
11
|
return defineConfig(config);
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
-
//#region src/format.ts
|
|
13
|
+
// src/format.ts
|
|
14
14
|
const baseFormatConfig = {
|
|
15
15
|
ignorePatterns: [...DEFAULT_IGNORE_PATTERNS],
|
|
16
16
|
sortImports: {
|
|
@@ -38,8 +38,9 @@ const baseFormatConfig = {
|
|
|
38
38
|
const reactFormatConfig = { sortTailwindcss: { functions: ["tv"] } };
|
|
39
39
|
const reactNativeFormatConfig = { ignorePatterns: [...REACT_NATIVE_IGNORE_PATTERNS] };
|
|
40
40
|
const cloudflareWorkerFormatConfig = { ignorePatterns: [...CLOUDFLARE_WORKER_IGNORE_PATTERNS] };
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
// src/lint/plugin-file.ts
|
|
42
|
+
const kasoaPluginFile = fileURLToPath(import.meta.url.endsWith(".ts") ? new URL("plugin/index.ts", import.meta.url) : import.meta.resolve("@kasoa/vite-plus-config/oxlint-plugin"));
|
|
43
|
+
// src/lint/rules/browser.ts
|
|
43
44
|
const browserRules = {
|
|
44
45
|
"no-alert": "error",
|
|
45
46
|
"unicorn/prefer-classlist-toggle": "error",
|
|
@@ -50,8 +51,7 @@ const browserRules = {
|
|
|
50
51
|
"unicorn/prefer-keyboard-event-key": "error",
|
|
51
52
|
"unicorn/prefer-modern-dom-apis": "error"
|
|
52
53
|
};
|
|
53
|
-
|
|
54
|
-
//#region src/lint/rules/jest.ts
|
|
54
|
+
// src/lint/rules/jest.ts
|
|
55
55
|
const jestRules = {
|
|
56
56
|
"max-nested-callbacks": ["error", { max: 4 }],
|
|
57
57
|
"jest/consistent-test-it": ["error", {
|
|
@@ -91,8 +91,7 @@ const jestRules = {
|
|
|
91
91
|
"jest/prefer-to-have-length": "error",
|
|
92
92
|
"jest/prefer-todo": "error"
|
|
93
93
|
};
|
|
94
|
-
|
|
95
|
-
//#region src/lint/rules/node.ts
|
|
94
|
+
// src/lint/rules/node.ts
|
|
96
95
|
const nodeRules = {
|
|
97
96
|
"node/exports-style": "error",
|
|
98
97
|
"node/global-require": "error",
|
|
@@ -100,9 +99,9 @@ const nodeRules = {
|
|
|
100
99
|
"node/no-mixed-requires": "error",
|
|
101
100
|
"unicorn/prefer-node-protocol": "error"
|
|
102
101
|
};
|
|
103
|
-
|
|
104
|
-
//#region src/lint/rules/react-core.ts
|
|
102
|
+
// src/lint/rules/react-core.ts
|
|
105
103
|
const reactCoreRules = {
|
|
104
|
+
"kasoa/effects-in-hooks": "error",
|
|
106
105
|
"react/display-name": "error",
|
|
107
106
|
"react/function-component-definition": ["error", {
|
|
108
107
|
namedComponents: "function-declaration",
|
|
@@ -150,8 +149,7 @@ const reactCoreRules = {
|
|
|
150
149
|
"react/no-unsafe": "error",
|
|
151
150
|
"react/style-prop-object": "off"
|
|
152
151
|
};
|
|
153
|
-
|
|
154
|
-
//#region src/lint/rules/react-dom.ts
|
|
152
|
+
// src/lint/rules/react-dom.ts
|
|
155
153
|
const reactDomRules = {
|
|
156
154
|
"react/checked-requires-onchange-or-readonly": "error",
|
|
157
155
|
"react/jsx-no-target-blank": "error",
|
|
@@ -162,8 +160,7 @@ const reactDomRules = {
|
|
|
162
160
|
"react/no-unknown-property": "error",
|
|
163
161
|
"react/void-dom-elements-no-children": "error"
|
|
164
162
|
};
|
|
165
|
-
|
|
166
|
-
//#region src/lint/rules/universal.ts
|
|
163
|
+
// src/lint/rules/universal.ts
|
|
167
164
|
const universalRestrictedProperties = [{
|
|
168
165
|
object: "Reflect",
|
|
169
166
|
property: "get"
|
|
@@ -172,6 +169,8 @@ const universalRestrictedProperties = [{
|
|
|
172
169
|
property: "apply"
|
|
173
170
|
}];
|
|
174
171
|
const universalRules = {
|
|
172
|
+
"kasoa/disable-reason": "error",
|
|
173
|
+
"kasoa/no-shadowed-globals": "error",
|
|
175
174
|
"accessor-pairs": "error",
|
|
176
175
|
"array-callback-return": "error",
|
|
177
176
|
"arrow-body-style": "error",
|
|
@@ -424,9 +423,11 @@ const universalRules = {
|
|
|
424
423
|
"typescript/use-unknown-in-catch-callback-variable": "error",
|
|
425
424
|
"unicorn/no-abusive-eslint-disable": "error"
|
|
426
425
|
};
|
|
427
|
-
|
|
428
|
-
//#region src/lint/rules/react-native.ts
|
|
426
|
+
// src/lint/rules/react-native.ts
|
|
429
427
|
const reactNativeRules = {
|
|
428
|
+
"kasoa/legend-list-only": "error",
|
|
429
|
+
"kasoa/no-dynamic-import": "error",
|
|
430
|
+
"kasoa/no-mapped-scrollview": "error",
|
|
430
431
|
"no-restricted-properties": [
|
|
431
432
|
"error",
|
|
432
433
|
...universalRestrictedProperties,
|
|
@@ -487,9 +488,9 @@ const reactNativeRules = {
|
|
|
487
488
|
"unicorn/no-array-reverse": "error",
|
|
488
489
|
"unicorn/no-array-sort": ["error", { allowAfterSpread: true }]
|
|
489
490
|
};
|
|
490
|
-
|
|
491
|
-
//#region src/lint/rules/vitest.ts
|
|
491
|
+
// src/lint/rules/vitest.ts
|
|
492
492
|
const vitestRules = {
|
|
493
|
+
"kasoa/no-dynamic-import": "off",
|
|
493
494
|
"max-nested-callbacks": ["error", { max: 4 }],
|
|
494
495
|
"vitest/consistent-each-for": "error",
|
|
495
496
|
"vitest/consistent-test-it": ["error", {
|
|
@@ -538,8 +539,7 @@ const vitestRules = {
|
|
|
538
539
|
"vitest/prefer-to-have-length": "error",
|
|
539
540
|
"vitest/prefer-todo": "error"
|
|
540
541
|
};
|
|
541
|
-
|
|
542
|
-
//#region src/lint/profiles.ts
|
|
542
|
+
// src/lint/profiles.ts
|
|
543
543
|
const BASE_LINT_PLUGINS = [
|
|
544
544
|
"typescript",
|
|
545
545
|
"unicorn",
|
|
@@ -729,6 +729,13 @@ const nodeTestLint = {
|
|
|
729
729
|
...vitestRules
|
|
730
730
|
}
|
|
731
731
|
};
|
|
732
|
+
const reactNativeTestLint = {
|
|
733
|
+
...nodeTestLint,
|
|
734
|
+
rules: {
|
|
735
|
+
...nodeTestLint.rules,
|
|
736
|
+
"vitest/no-restricted-vi-methods": "off"
|
|
737
|
+
}
|
|
738
|
+
};
|
|
732
739
|
const browserTestLint = {
|
|
733
740
|
...browserLint,
|
|
734
741
|
plugins: [...BASE_LINT_PLUGINS, "vitest"],
|
|
@@ -742,10 +749,13 @@ const cloudflareWorkerTestLint = {
|
|
|
742
749
|
plugins: [...BASE_LINT_PLUGINS, "vitest"],
|
|
743
750
|
rules: vitestRules
|
|
744
751
|
};
|
|
745
|
-
|
|
746
|
-
//#region src/lint/configs.ts
|
|
752
|
+
// src/lint/configs.ts
|
|
747
753
|
const baseLintConfig = {
|
|
748
754
|
plugins: [...BASE_LINT_PLUGINS],
|
|
755
|
+
jsPlugins: [{
|
|
756
|
+
name: "kasoa",
|
|
757
|
+
specifier: kasoaPluginFile
|
|
758
|
+
}],
|
|
749
759
|
ignorePatterns: [...DEFAULT_IGNORE_PATTERNS],
|
|
750
760
|
env: neutralEnvironment,
|
|
751
761
|
globals: neutralLint.globals,
|
|
@@ -830,22 +840,9 @@ const cloudflareWorkerTestLintConfig$1 = { overrides: [{
|
|
|
830
840
|
}] };
|
|
831
841
|
const reactNativeTestLintConfig$1 = { overrides: [
|
|
832
842
|
{
|
|
833
|
-
files: [...TEST_FILES],
|
|
834
|
-
excludeFiles: [
|
|
835
|
-
...VITEST_SETUP_FILES,
|
|
836
|
-
...REACT_NATIVE_JEST_TEST_FILES,
|
|
837
|
-
...REACT_NATIVE_JEST_SETUP_FILES
|
|
838
|
-
],
|
|
839
|
-
...nodeTestLint
|
|
840
|
-
},
|
|
841
|
-
{
|
|
842
|
-
files: [...VITEST_SETUP_FILES],
|
|
843
|
+
files: [...TEST_FILES, ...VITEST_SETUP_FILES],
|
|
843
844
|
excludeFiles: [...REACT_NATIVE_JEST_TEST_FILES, ...REACT_NATIVE_JEST_SETUP_FILES],
|
|
844
|
-
...
|
|
845
|
-
rules: {
|
|
846
|
-
...nodeTestLint.rules,
|
|
847
|
-
"vitest/no-restricted-vi-methods": "off"
|
|
848
|
-
}
|
|
845
|
+
...reactNativeTestLint
|
|
849
846
|
},
|
|
850
847
|
{
|
|
851
848
|
files: [...REACT_NATIVE_JEST_TEST_FILES],
|
|
@@ -862,8 +859,7 @@ const reactNativeTestLintConfig$1 = { overrides: [
|
|
|
862
859
|
}
|
|
863
860
|
}
|
|
864
861
|
] };
|
|
865
|
-
|
|
866
|
-
//#region src/fragments.ts
|
|
862
|
+
// src/fragments.ts
|
|
867
863
|
const baseToolingConfig = {
|
|
868
864
|
fmt: baseFormatConfig,
|
|
869
865
|
lint: baseLintConfig,
|
|
@@ -912,7 +908,6 @@ const workspaceRunConfig = { run: {
|
|
|
912
908
|
},
|
|
913
909
|
enablePrePostScripts: true
|
|
914
910
|
} };
|
|
915
|
-
|
|
916
|
-
export { CODE_FILES, COMMONJS_FILES, CONFIG_FILES, REACT_NATIVE_JEST_SETUP_FILES, REACT_NATIVE_JEST_TEST_FILES, RUNTIME_OVERRIDE_EXCLUDE_FILES, TEST_FILES, VITEST_SETUP_FILES, baseToolingConfig, browserLint, browserRuntimeConfig, browserTestLint, browserTestLintConfig, cloudflareWorkerGeneratedConfig, cloudflareWorkerLint, cloudflareWorkerRuntimeConfig, cloudflareWorkerTestLint, cloudflareWorkerTestLintConfig, composeConfig, libraryPackConfig, libraryPackDefaults, nodeLint, nodeRuntimeConfig, nodeTestLint, nodeTestLintConfig, reactCoreConfig, reactCoreLint, reactDomConfig, reactDomLint, reactNativeGeneratedConfig, reactNativeJestTestLint, reactNativeLint, reactNativeRuntimeConfig, reactNativeRuntimeLint, reactNativeTestLintConfig, reactWebLint, workspaceRunConfig };
|
|
911
|
+
export { CODE_FILES, COMMONJS_FILES, CONFIG_FILES, REACT_NATIVE_JEST_SETUP_FILES, REACT_NATIVE_JEST_TEST_FILES, RUNTIME_OVERRIDE_EXCLUDE_FILES, TEST_FILES, VITEST_SETUP_FILES, baseToolingConfig, browserLint, browserRuntimeConfig, browserTestLint, browserTestLintConfig, cloudflareWorkerGeneratedConfig, cloudflareWorkerLint, cloudflareWorkerRuntimeConfig, cloudflareWorkerTestLint, cloudflareWorkerTestLintConfig, composeConfig, libraryPackConfig, libraryPackDefaults, nodeLint, nodeRuntimeConfig, nodeTestLint, nodeTestLintConfig, reactCoreConfig, reactCoreLint, reactDomConfig, reactDomLint, reactNativeGeneratedConfig, reactNativeJestTestLint, reactNativeLint, reactNativeRuntimeConfig, reactNativeRuntimeLint, reactNativeTestLint, reactNativeTestLintConfig, reactWebLint, workspaceRunConfig };
|
|
917
912
|
|
|
918
913
|
//# sourceMappingURL=index.mjs.map
|