vite-plus 0.3.1 → 0.3.2

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.
Files changed (50) hide show
  1. package/README.md +1 -1
  2. package/bin/vp +1 -1
  3. package/binding/index.cjs +54 -55
  4. package/binding/index.d.cts +12 -0
  5. package/dist/{agent-C5jMYVfB.js → agent-C59HKB4Y.js} +2 -2
  6. package/dist/bin.js +6 -5
  7. package/dist/config/bin.js +2 -2
  8. package/dist/{constants-0IAVgpox.js → constants-IhOditRA.js} +2 -2
  9. package/dist/create/bin.js +19 -9
  10. package/dist/{define-config-U3_xg7i-.js → define-config-DAaCa0U_.js} +2 -2
  11. package/dist/{define-config-DIE9de46.cjs → define-config-DpAPETDf.cjs} +1 -1
  12. package/dist/define-config.cjs +1 -1
  13. package/dist/define-config.js +1 -1
  14. package/dist/{editor-B5-lvRaU.js → editor-QOIGtmH4.js} +143 -36
  15. package/dist/index.cjs +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/lint-plugins-dev.d.ts +3 -0
  18. package/dist/lint-plugins-dev.js +2 -0
  19. package/dist/lint-plugins.cjs +21 -0
  20. package/dist/lint-plugins.d.ts +3 -0
  21. package/dist/lint-plugins.js +2 -0
  22. package/dist/migration/bin.js +7 -7
  23. package/dist/{oxlint-plugin-config-Drdl67Xp.js → oxlint-plugin-config-BU42tr8y.js} +1 -1
  24. package/dist/oxlint-plugin.js +93 -32
  25. package/dist/pack-bin.js +1 -1
  26. package/dist/{package-BZz2Ij68.js → package-BB-Jh_z3.js} +1 -1
  27. package/dist/{prompts-CtzEgFY-.js → prompts-CujFOJXu.js} +1 -1
  28. package/dist/{resolve-vite-config-Dnmc-lBc.js → resolve-vite-config-6Nox70uP.js} +1 -1
  29. package/dist/{resolve-vite-config-CGks1xR7.js → resolve-vite-config-CHHjsjKJ.js} +2 -2
  30. package/dist/staged/bin.js +1 -1
  31. package/dist/toolchain.js +8 -8
  32. package/dist/toolchain.json +8 -8
  33. package/dist/{tsconfig-CUggNuJR.js → tsconfig-DCtWfQPA.js} +2 -2
  34. package/dist/{tsconfig-VAbm4ZzJ.js → tsconfig-MXktI3SX.js} +1 -1
  35. package/dist/version.js +2 -2
  36. package/dist/versions.js +4 -4
  37. package/docs/config/fmt.md +4 -2
  38. package/docs/config/lint.md +4 -2
  39. package/docs/guide/env.md +29 -5
  40. package/docs/guide/fmt.md +3 -1
  41. package/docs/guide/install.md +1 -0
  42. package/docs/guide/installer-env-vars.md +35 -1
  43. package/docs/guide/lint.md +58 -1
  44. package/docs/guide/migrate-rules.md +38 -0
  45. package/docs/guide/migrate.md +1 -1
  46. package/docs/guide/monorepo.md +2 -0
  47. package/docs/guide/troubleshooting.md +14 -0
  48. package/package.json +23 -14
  49. package/templates/generator/README.md +14 -0
  50. package/templates/generator/bin/index.ts +54 -5
@@ -18,7 +18,9 @@ vp lint --type-aware
18
18
 
19
19
  ## Configuration
20
20
 
21
- Put lint configuration directly in the `lint` block in `vite.config.ts` so all your configuration stays in one place. We do not recommend using `oxlint.config.ts` or `.oxlintrc.json` with Vite+.
21
+ Put lint configuration directly in the `lint` block in the root `vite.config.ts` so all your configuration stays in one place. We do not recommend using `oxlint.config.ts` or `.oxlintrc.json` with Vite+.
22
+
23
+ Vite+ does not currently support nested lint configuration. For now, use [`lint.overrides`](/guide/monorepo#root-config-with-overrides) in the root `vite.config.ts` for file- or package-specific rules. The long-term behavior is open for discussion; [share your use case and expectations](/guide/troubleshooting#nested-lint-or-format-config-is-not-applied) to help shape it.
22
24
 
23
25
  For the upstream rule set, options, and compatibility details, see the [Oxlint docs](https://oxc.rs/docs/guide/usage/linter.html).
24
26
 
@@ -50,3 +52,58 @@ This path is powered by [tsgolint](https://github.com/oxc-project/tsgolint) on t
50
52
  If you are migrating from ESLint and still depend on a few critical JavaScript-based ESLint plugins, Oxlint has [JS plugin support](https://oxc.rs/docs/guide/usage/linter/js-plugins) that can help you keep those plugins running while you complete the migration.
51
53
 
52
54
  JS Plugins also enable [writing your own custom rules](https://oxc.rs/docs/guide/usage/linter/writing-js-plugins.html) for Oxlint.
55
+
56
+ ### Writing Your Own Rules
57
+
58
+ Import the plugin authoring API from `vite-plus/lint/plugins`:
59
+
60
+ ```js [lint/my-plugin.js]
61
+ import { definePlugin, defineRule } from 'vite-plus/lint/plugins';
62
+
63
+ const noFoo = defineRule({
64
+ meta: { messages: { noFoo: 'Do not name things "foo".' } },
65
+ create(context) {
66
+ return {
67
+ Identifier(node) {
68
+ if (node.name === 'foo') {
69
+ context.report({ node, messageId: 'noFoo' });
70
+ }
71
+ },
72
+ };
73
+ },
74
+ });
75
+
76
+ export default definePlugin({
77
+ meta: { name: 'my' },
78
+ rules: { 'no-foo': noFoo },
79
+ });
80
+ ```
81
+
82
+ Register it under `lint.jsPlugins` and enable its rules:
83
+
84
+ ```ts [vite.config.ts]
85
+ import { defineConfig } from 'vite-plus';
86
+
87
+ export default defineConfig({
88
+ lint: {
89
+ jsPlugins: ['./lint/my-plugin.js'],
90
+ rules: {
91
+ 'my/no-foo': 'error',
92
+ },
93
+ },
94
+ });
95
+ ```
96
+
97
+ For rule tests, `RuleTester` is available from `vite-plus/lint/plugins-dev`.
98
+
99
+ Both entrypoints re-export the copy that ships with Vite+. The API therefore
100
+ always matches the bundled Oxlint.
101
+
102
+ Use them instead of adding `@oxlint/plugins` or `oxlint` as a direct
103
+ dependency. A separately pinned copy can drift from the linter that loads your
104
+ plugin. It also does not resolve from a plugin file under pnpm's strict layout,
105
+ unless every package that holds a plugin declares it.
106
+
107
+ `vp migrate` rewrites existing `oxlint` and `@oxlint/plugins` imports for you.
108
+ See [Oxlint JS Plugin Imports](/guide/migrate-rules#oxlint-js-plugin-imports).
109
+ The `vite-plus/prefer-vite-plus-imports` rule reports any that come back.
@@ -250,6 +250,44 @@ surface are written against `vite-plus` by hand.
250
250
  needed.
251
251
  - Existing `vite-plus/test*` imports are left unchanged.
252
252
 
253
+ ### Oxlint JS Plugin Imports
254
+
255
+ Vite+ bundles Oxlint, so the migration removes a standalone `oxlint`
256
+ dependency. Your own Oxlint JS plugins import the authoring API by name. That
257
+ import stops resolving when the dependency goes away. `vp lint` then fails to
258
+ load the plugin.
259
+
260
+ The migration repoints those imports at Vite+:
261
+
262
+ - It rewrites `@oxlint/plugins` to `vite-plus/lint/plugins`.
263
+ - It rewrites `oxlint/plugins-dev` to `vite-plus/lint/plugins-dev`.
264
+ - It rewrites `oxlint` to `vite-plus/lint/plugins` when the import names a
265
+ binding from the authoring API, such as `defineRule`, `definePlugin`, or
266
+ `Context`. Older Oxlint releases exposed that API from the main entry. It now
267
+ lives in `@oxlint/plugins`.
268
+
269
+ An import through Vite+ always matches the version of Oxlint that Vite+
270
+ bundles. You pin no second package. The import also resolves from any package
271
+ that already depends on `vite-plus`.
272
+
273
+ The migration leaves three forms alone:
274
+
275
+ - `oxlint` imports that name only the config surface, such as `defineConfig`,
276
+ `OxlintConfig`, or `OxlintOverride`. These still resolve against the
277
+ standalone package.
278
+ - Default and namespace `oxlint` imports. They name no binding, so the
279
+ migration cannot tell the two surfaces apart.
280
+ - Bare side-effect `oxlint` imports, for the same reason.
281
+
282
+ The migration also skips a package that declares `oxlint` or `@oxlint/plugins`
283
+ in `dependencies` or `peerDependencies`, or `@oxlint/plugins` in
284
+ `optionalDependencies`. These dependencies can supply a published Oxlint plugin.
285
+ Its consumers may not run Vite+.
286
+
287
+ The cleanup retains a development dependency on `@oxlint/plugins` when source,
288
+ package import aliases, or built plugins still reference it. This includes
289
+ ignored output in directories such as `dist`, `build`, and `out`.
290
+
253
291
  ### What Is Never Rewritten
254
292
 
255
293
  - `declare module 'vitest'` and `declare module '@vitest/browser*'`: module
@@ -117,7 +117,7 @@ After the migration:
117
117
 
118
118
  - Confirm `vite` imports were rewritten to `vite-plus` where needed
119
119
  - Confirm `vitest` imports were rewritten to `vite-plus/test` (and `@vitest/browser*` to `vite-plus/test/browser*`) where needed
120
- - Remove old `vite`, `vitest`, and `@vitest/browser*` dependencies only after those rewrites are confirmed `vite-plus` ships them as direct deps
120
+ - On pnpm, keep the `vite`, `vitest` dependency entries configured by `vp migrate` so the workspace aliases and overrides stay effective; with other package managers, you can remove them once those rewrites are confirmed
121
121
  - Move remaining tool-specific config into the appropriate blocks in `vite.config.ts`
122
122
 
123
123
  Command mapping to keep in mind:
@@ -6,6 +6,8 @@ Because `vite.config.ts` is just JavaScript, you can choose to put your entire c
6
6
 
7
7
  ## Root Config With Overrides
8
8
 
9
+ Vite+ does not currently support nested lint or format configuration. Package-level `lint` and `fmt` blocks are not automatically applied. For now, define file- or package-specific settings with overrides in the root `vite.config.ts`. The long-term behavior is open for discussion; [share your use case and expectations](/guide/troubleshooting#nested-lint-or-format-config-is-not-applied) to help shape it.
10
+
9
11
  Use `lint.overrides` for Oxlint rules that only apply to some packages:
10
12
 
11
13
  ```ts [vite.config.ts]
@@ -28,6 +28,20 @@ The Oxlint type checker path powered by `tsgolint` does not support `baseUrl`.
28
28
  fix before enabling type-aware linting. If that fix fails or is declined, Vite+
29
29
  skips `typeAware` and `typeCheck`.
30
30
 
31
+ ## Nested lint or format config is not applied
32
+
33
+ Vite+ does not currently support nested lint or format configuration. When running `vp lint`, `vp fmt`, or `vp check` from the workspace root, do not rely on configs in subdirectories or on `lint` and `fmt` blocks in package-level `vite.config.ts` files to override the root settings.
34
+
35
+ Keep lint and format settings in the root `vite.config.ts`. Use [`lint.overrides`](/guide/monorepo#root-config-with-overrides) and [`fmt.overrides`](/guide/monorepo#format-overrides) for file- or package-specific settings. You can also [import configuration objects](/guide/monorepo#composing-configuration-files) into the root config to keep settings in separate files.
36
+
37
+ For IDE integration, we have `disableNestedConfig` and `fmt.disableNestedConfig` config to disable nested lint and format configs and keep editor behavior aligned with the root Vite+ config. See [IDE Integration](/guide/ide-integration) for setup instructions for your editor.
38
+
39
+ We're holding off on nested config support for now. Some of the factors we're considering are how implicit config discovery affects the predictability of linting and formatting, what context AI agents need to understand the settings that apply, and the potential performance cost of finding and loading multiple configs. At the same time, we recognize that keeping package-specific context close to the code may have benefits. The use cases we've heard so far haven't given us a strong enough reason to commit to those semantics. Waiting leaves room to add support later, and we'd like to hear why your project needs nested configs, especially where root-level overrides fall short.
40
+
41
+ Do you need nested configs? [Share your use case and opinion on GitHub](https://github.com/voidzero-dev/vite-plus/discussions/2669), including your project structure, the reason why you want them and whether root-level overrides meet your needs.
42
+
43
+ We sincerely hope to hear your feedback. This will help us decide whether to improve the current situation in the future.
44
+
31
45
  ## VS Code extension does not read `vite.config.ts`
32
46
 
33
47
  If VS Code has multiple folders open, the shared Oxc language server may pick a different workspace than expected. That can make it look like `vite.config.ts` support is missing.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plus",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "The Unified Toolchain for the Web",
5
5
  "homepage": "https://viteplus.dev/guide",
6
6
  "bugs": {
@@ -69,6 +69,15 @@
69
69
  "types": "./dist/lint.d.ts",
70
70
  "import": "./dist/lint.js"
71
71
  },
72
+ "./lint/plugins": {
73
+ "types": "./dist/lint-plugins.d.ts",
74
+ "import": "./dist/lint-plugins.js",
75
+ "require": "./dist/lint-plugins.cjs"
76
+ },
77
+ "./lint/plugins-dev": {
78
+ "types": "./dist/lint-plugins-dev.d.ts",
79
+ "default": "./dist/lint-plugins-dev.js"
80
+ },
72
81
  "./oxlint-plugin": {
73
82
  "module-sync": "./dist/oxlint-plugin.js",
74
83
  "node": "./dist/oxlint-plugin.js",
@@ -350,7 +359,7 @@
350
359
  }
351
360
  },
352
361
  "dependencies": {
353
- "@oxc-project/types": "=0.148.0",
362
+ "@oxc-project/types": "=0.149.0",
354
363
  "@oxlint/plugins": "=1.79.0",
355
364
  "@vitest/browser": "4.1.11",
356
365
  "@vitest/browser-preview": "4.1.11",
@@ -361,16 +370,16 @@
361
370
  "@vitest/snapshot": "4.1.11",
362
371
  "@vitest/spy": "4.1.11",
363
372
  "@vitest/utils": "4.1.11",
364
- "oxfmt": "=0.66.0",
365
- "oxlint": "=1.81.0",
373
+ "oxfmt": "=0.67.0",
374
+ "oxlint": "=1.82.0",
366
375
  "oxlint-tsgolint": "=7.0.2001",
367
- "vite": "npm:@voidzero-dev/vite-plus-core@0.3.1",
376
+ "vite": "npm:@voidzero-dev/vite-plus-core@0.3.2",
368
377
  "vitest": "4.1.11"
369
378
  },
370
379
  "devDependencies": {
371
380
  "@emnapi/core": "2.0.0-alpha.4",
372
381
  "@emnapi/runtime": "2.0.0-alpha.4",
373
- "@napi-rs/cli": "^3.8.2",
382
+ "@napi-rs/cli": "^3.9.0",
374
383
  "@nkzw/safe-word-list": "^3.1.0",
375
384
  "@types/cross-spawn": "^6.0.6",
376
385
  "@types/semver": "^7.8.0",
@@ -425,14 +434,14 @@
425
434
  "node": "^20.19.0 || ^22.18.0 || >=24.11.0"
426
435
  },
427
436
  "optionalDependencies": {
428
- "@voidzero-dev/vite-plus-darwin-arm64": "0.3.1",
429
- "@voidzero-dev/vite-plus-darwin-x64": "0.3.1",
430
- "@voidzero-dev/vite-plus-linux-arm64-gnu": "0.3.1",
431
- "@voidzero-dev/vite-plus-linux-arm64-musl": "0.3.1",
432
- "@voidzero-dev/vite-plus-linux-x64-gnu": "0.3.1",
433
- "@voidzero-dev/vite-plus-linux-x64-musl": "0.3.1",
434
- "@voidzero-dev/vite-plus-win32-x64-msvc": "0.3.1",
435
- "@voidzero-dev/vite-plus-win32-arm64-msvc": "0.3.1"
437
+ "@voidzero-dev/vite-plus-darwin-arm64": "0.3.2",
438
+ "@voidzero-dev/vite-plus-darwin-x64": "0.3.2",
439
+ "@voidzero-dev/vite-plus-linux-arm64-gnu": "0.3.2",
440
+ "@voidzero-dev/vite-plus-linux-arm64-musl": "0.3.2",
441
+ "@voidzero-dev/vite-plus-linux-x64-gnu": "0.3.2",
442
+ "@voidzero-dev/vite-plus-linux-x64-musl": "0.3.2",
443
+ "@voidzero-dev/vite-plus-win32-x64-msvc": "0.3.2",
444
+ "@voidzero-dev/vite-plus-win32-arm64-msvc": "0.3.2"
436
445
  },
437
446
  "scripts": {
438
447
  "build": "oxnode -C dev ./build.ts",
@@ -11,6 +11,20 @@ From monorepo root:
11
11
  vp create
12
12
  ```
13
13
 
14
+ For automation, provide the directory and every required template option:
15
+
16
+ ```bash
17
+ vp create <generator-name> --no-interactive -- --directory new-package --name new-package
18
+ ```
19
+
20
+ Vite+ sets `VP_CREATE_INTERACTIVE=0` for non-interactive local Bingo generators.
21
+ This starter then validates the arguments and runs Bingo's programmatic API.
22
+ Missing options and existing directories fail before any files are generated.
23
+ Existing generators are copied project files and are not updated by upgrading Vite+.
24
+ To adopt this behavior, update their entrypoint to match this starter.
25
+ Direct invocation uses the interactive CLI unless this variable is set to `0`.
26
+ When adding template options, also add their CLI types in `bin/index.ts`.
27
+
14
28
  ## Development
15
29
 
16
30
  ```bash
@@ -1,10 +1,59 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { runTemplateCLI, type Template } from 'bingo';
3
+ import fs from 'node:fs';
4
+ import { parseArgs } from 'node:util';
5
+
6
+ import { runTemplate, runTemplateCLI, type Template } from 'bingo';
7
+ import { z } from 'zod';
4
8
 
5
9
  import template from '../src/template.ts';
6
10
 
7
- // runTemplateCLI accepts the base `Template` type, which is wider than the
8
- // strongly typed template returned by createTemplate(). Cast through `unknown`
9
- // to bridge the two.
10
- process.exitCode = await runTemplateCLI(template as unknown as Template);
11
+ async function main() {
12
+ if (
13
+ process.env.VP_CREATE_INTERACTIVE !== '0' ||
14
+ process.argv.includes('--help') ||
15
+ process.argv.includes('--version')
16
+ ) {
17
+ // runTemplateCLI accepts a wider type than createTemplate returns.
18
+ return await runTemplateCLI(template as unknown as Template);
19
+ }
20
+
21
+ // Add CLI entries here when adding options to src/template.ts.
22
+ const { values } = parseArgs({
23
+ options: {
24
+ directory: { type: 'string' },
25
+ name: { type: 'string' },
26
+ offline: { type: 'boolean' },
27
+ 'skip-requests': { type: 'boolean' },
28
+ 'skip-files': { type: 'boolean' },
29
+ 'skip-scripts': { type: 'boolean' },
30
+ },
31
+ });
32
+ if (!values.directory?.trim()) {
33
+ throw new Error('Missing --directory. Pass generator options after -- in vp create.');
34
+ }
35
+ const options = z.object(template.options).parse(values);
36
+ if (fs.existsSync(values.directory)) {
37
+ throw new Error(`Directory already exists: ${values.directory}`);
38
+ }
39
+
40
+ await runTemplate(template, {
41
+ directory: values.directory,
42
+ mode: 'setup',
43
+ options,
44
+ offline: values.offline,
45
+ skips: {
46
+ requests: values['skip-requests'],
47
+ files: values['skip-files'],
48
+ scripts: values['skip-scripts'],
49
+ },
50
+ });
51
+ return 0;
52
+ }
53
+
54
+ try {
55
+ process.exitCode = await main();
56
+ } catch (error) {
57
+ console.error(error instanceof Error ? error.message : String(error));
58
+ process.exitCode = 1;
59
+ }