Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
name = "migration_eslint_monorepo_plugins_in_packages"
vp = "global"
steps = [
{ argv = ["vp", "migrate", "--no-interactive"], comment = "workspace packages get the SAME aggressive cleanup as the root (deps, configs, lint-staged)", continue-on-failure = true },
{ argv = ["vp", "migrate", "--no-interactive"], comment = "migrate ESLint across the workspace", continue-on-failure = true },
{ argv = ["vpt", "print-file", "package.json"], comment = "root: eslint + eslint-config-airbnb removed", continue-on-failure = true },
{ argv = ["vpt", "print-file", "packages/app/package.json"], comment = "workspace: eslint, eslint-plugin-vue, @typescript-eslint/parser removed; @typescript-eslint/utils preserved (reusable AST lib)", continue-on-failure = true },
{ argv = ["vpt", "print-file", "packages/lint-config/package.json"], comment = "workspace: all eslint-plugin-* removed; peerDeps.eslint scrubbed (field deleted when empty)", continue-on-failure = true },
{ argv = ["vpt", "print-file", "packages/lint-config/package.json"], comment = "the shared lint config keeps its plugin dependencies and ESLint peer", continue-on-failure = true },
{ argv = ["vpt", "stat-file", "packages/app/eslint.config.mjs", "--assert-not", "file"], comment = "workspace eslint config is deleted", continue-on-failure = true },
{ argv = ["vpt", "print-file", "packages/app/.lintstagedrc.json"], comment = "workspace lint-staged rewritten (eslint --fix → vp lint --fix)", continue-on-failure = true },
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## `vp migrate --no-interactive`

workspace packages get the SAME aggressive cleanup as the root (deps, configs, lint-staged)
migrate ESLint across the workspace

```
VITE+ - The Unified Toolchain for the Web
Expand Down Expand Up @@ -55,13 +55,21 @@ workspace: eslint, eslint-plugin-vue, @typescript-eslint/parser removed; @typesc

## `vpt print-file packages/lint-config/package.json`

workspace: all eslint-plugin-* removed; peerDeps.eslint scrubbed (field deleted when empty)
the shared lint config keeps its plugin dependencies and ESLint peer

```
{
"name": "@test/lint-config",
"scripts": {
"lint": "vp lint ."
},
"dependencies": {
"@stylistic/eslint-plugin": "^2.0.0",
"eslint-plugin-import": "^2.0.0",
"eslint-plugin-vue": "^10.0.0"
},
"peerDependencies": {
"eslint": ">=9"
}
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
name = "migration_eslint_plugins_cleanup"
vp = "global"
steps = [
{ argv = ["vp", "migrate", "--no-interactive"], comment = "migration should remove ESLint, plugins, configs, scopes, formatters, and peer eslint", continue-on-failure = true },
{ argv = ["vpt", "print-file", "package.json"], comment = "verify the comprehensive ESLint ecosystem cleanup", continue-on-failure = true },
{ argv = ["vp", "migrate", "--no-interactive"], comment = "migrate the ESLint configuration", continue-on-failure = true },
{ argv = ["vpt", "print-file", "package.json"], comment = "remove dev-only ESLint tooling and keep both declarations of the ESLint peer", continue-on-failure = true },
{ argv = ["vpt", "stat-file", "eslint.config.mjs", "--assert-not", "file"], comment = "check eslint config is removed", continue-on-failure = true },
{ argv = ["vpt", "print-file", "vite.config.ts"], comment = "verify the generated vite.config.ts", continue-on-failure = true },
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## `vp migrate --no-interactive`

migration should remove ESLint, plugins, configs, scopes, formatters, and peer eslint
migrate the ESLint configuration

```
VITE+ - The Unified Toolchain for the Web
Expand All @@ -16,7 +16,7 @@ VITE+ - The Unified Toolchain for the Web

## `vpt print-file package.json`

verify the comprehensive ESLint ecosystem cleanup
remove dev-only ESLint tooling and keep both declarations of the ESLint peer

```
{
Expand All @@ -32,9 +32,13 @@ verify the comprehensive ESLint ecosystem cleanup
"@types/node": "^22.0.0",
"@typescript-eslint/utils": "^8.0.0",
"@vitejs/plugin-vue": "^6.0.0",
"eslint": "^9.0.0",
"vite": "catalog:",
"vue": "^3.5.0",
"vite-plus": "catalog:"
},
"peerDependencies": {
"eslint": ">=9"
}
}
```
Expand Down
6 changes: 5 additions & 1 deletion docs/guide/migrate-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ What happens to each toolchain dependency, at a glance:
| `@vitest/*` | Directly installed lockstep packages aligned to the bundled Vitest version (see [Vitest Ecosystem Packages](#vitest-ecosystem-packages)). |
| `@voidzero-dev/vite-plus-test` | Removed everywhere: dependencies, overrides, resolutions, and catalog aliases. Imports are rewritten to the current `vite-plus/test*` surface. |

Vite+ bundles Oxlint, Oxfmt, tsdown, `@vitest/browser`, and `@vitest/browser-preview`, so migration removes their `devDependencies` entries. A package that also lists one of them in `dependencies`, `optionalDependencies`, or `peerDependencies` keeps every declaration of it, including the development copy. Such a package publishes or runs the tool, and its consumers may not use Vite+. A tsdown plugin, for example, keeps `tsdown` as a peer and as the devDependency it tests against. A kept `catalog:` reference becomes the range its catalog entry pointed at, because migration still removes that entry.

The same rule applies to the tools that migration replaces: ESLint and its plugins, Prettier and `prettier-plugin-*`, lint-staged, tsup, tsx, oxnode, and ts-node.

### Version Selection

- `vite-plus` is pinned to the concrete version of the CLI running the migration, never the `latest` dist-tag.
Expand Down Expand Up @@ -239,7 +243,7 @@ The migration leaves three forms alone:
- Default and namespace `oxlint` imports. They name no binding, so the migration cannot tell the two surfaces apart.
- Bare side-effect `oxlint` imports, for the same reason.

The migration also skips a package that declares `oxlint` or `@oxlint/plugins` in `dependencies` or `peerDependencies`, or `@oxlint/plugins` in `optionalDependencies`. These dependencies can supply a published Oxlint plugin. Its consumers may not run Vite+.
The migration also skips a package that declares `oxlint` or `@oxlint/plugins` in `dependencies`, `optionalDependencies`, or `peerDependencies`. These dependencies can supply a published Oxlint plugin. Its consumers may not run Vite+.

The cleanup retains a development dependency on `@oxlint/plugins` when source, package import aliases, or built plugins still reference it. This includes ignored output in directories such as `dist`, `build`, and `out`.

Expand Down
62 changes: 45 additions & 17 deletions packages/cli/src/migration/__tests__/migrator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ describe('rewritePackageJson', () => {
};
rewritePackageJson(pkg, packageManager, isMonorepo);
expect(pkg).toEqual({
dependencies: { foo: '1.0.0' },
dependencies: { foo: '1.0.0', tsdown: '1.0.0' },
devDependencies: { 'vite-plus': vitePlusSpec },
});
},
Expand Down Expand Up @@ -529,9 +529,9 @@ describe('rewritePackageJson', () => {
rewritePackageJson(pkg, PackageManager.pnpm, true);

expect(pkg.peerDependencies.vite).toBe('*');
expect(pkg.peerDependencies).not.toHaveProperty('tsdown');
expect(pkg.peerDependencies).toHaveProperty('tsdown');
expect(pkg.optionalDependencies.vitest).toBe('catalog:test');
expect(pkg.optionalDependencies).not.toHaveProperty('oxlint');
expect(pkg.optionalDependencies).toHaveProperty('oxlint');
expect(pkg).toHaveProperty(['devDependencies', 'vite-plus'], 'catalog:');
});

Expand Down Expand Up @@ -840,7 +840,7 @@ describe('rewriteEslintPackageJson', () => {
rewriteEslintPackageJson(pkgPath);
const pkg = readJson(pkgPath);
expect(pkg.devDependencies).toEqual({ vite: '^7.0.0' });
expect(pkg.dependencies).toEqual({ vue: '^3.5.0' });
expect(pkg.dependencies).toEqual({ 'eslint-plugin-import': '^2.0.0', vue: '^3.5.0' });
});

it('removes scoped ESLint plugin/config packages (e.g. @vue/eslint-config-typescript)', () => {
Expand Down Expand Up @@ -956,22 +956,28 @@ describe('rewriteEslintPackageJson', () => {
expect(pkg.devDependencies).toEqual({ '@types/node': '^22.0.0' });
});

it('scrubs peerDependencies and optionalDependencies', () => {
const pkgPath = writePkg({
peerDependencies: {
eslint: '>=9',
// An ESLint plugin package tests its rules with the ESLint its consumers provide.
it('keeps ESLint packages that the project also declares at runtime', () => {
const pkg = {
peerDependencies: { eslint: '>=9' },
optionalDependencies: { '@typescript-eslint/parser': '^8.0.0' },
devDependencies: {
eslint: '^9.0.0',
'@typescript-eslint/parser': '^8.0.0',
'eslint-plugin-vue': '^10.0.0',
vite: '^7.0.0',
},
optionalDependencies: {
};
const pkgPath = writePkg(pkg);
rewriteEslintPackageJson(pkgPath);
expect(readJson(pkgPath)).toEqual({
...pkg,
devDependencies: {
eslint: '^9.0.0',
'@typescript-eslint/parser': '^8.0.0',
vite: '^7.0.0',
},
devDependencies: { vite: '^7.0.0' },
});
rewriteEslintPackageJson(pkgPath);
const pkg = readJson(pkgPath);
expect(pkg.peerDependencies).toBeUndefined();
expect(pkg.optionalDependencies).toBeUndefined();
expect(pkg.devDependencies).toEqual({ vite: '^7.0.0' });
});

it('deletes the dependency field entirely when our cleanup emptied it', () => {
Expand All @@ -985,7 +991,7 @@ describe('rewriteEslintPackageJson', () => {
rewriteEslintPackageJson(pkgPath);
const pkg = readJson(pkgPath);
expect(pkg.devDependencies).toBeUndefined();
expect(pkg.dependencies).toBeUndefined();
expect(pkg.dependencies).toEqual({ 'eslint-config-airbnb': '^19.0.0' });
});

it('preserves unrelated dependencies (e.g. @vitejs/plugin-vue, vue, vite, @nuxt/kit)', () => {
Expand Down Expand Up @@ -5645,7 +5651,29 @@ describe('rewriteStandaloneProject pnpm workspace yaml', () => {
// catalog entry to its public range before pruning it so the peer cannot
// dangle after migration.
expect(pkg).toHaveProperty(['peerDependencies', 'vitest'], '^4.0.0');
expect(pkg.peerDependencies).not.toHaveProperty('tsdown');
expect(pkg).toHaveProperty(['peerDependencies', 'tsdown'], '^0.1.0');
});

// A tsdown plugin builds and tests against the tsdown its consumers provide.
it('keeps a bundled package that the project also declares as a peer', () => {
const packageJsonPath = path.join(tmpDir, 'package.json');
fs.writeFileSync(
packageJsonPath,
JSON.stringify({
name: 'tsdown-plugin-example',
peerDependencies: { tsdown: '^0.23.0' },
devDependencies: { tsdown: '^0.23.0' },
}),
);
const workspace = makeWorkspaceInfo(tmpDir, PackageManager.pnpm);

rewriteStandaloneProject(tmpDir, workspace, true, true);

const pkg = readJson(packageJsonPath);
expect(pkg.peerDependencies).toEqual({ tsdown: '^0.23.0' });
expect(pkg.devDependencies).toEqual({ tsdown: '^0.23.0', 'vite-plus': 'catalog:' });
checkBootstrapPass(workspace, false);
expect(readJson(packageJsonPath)).toEqual(pkg);
});

it('reuses catalogs.default without creating a duplicate top-level catalog', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,11 +607,11 @@ describe('Oxlint plugin dependency cleanup', () => {
expect(pending()).toBe(false);
});

it('keeps optional oxlint on the existing tool-migration path', () => {
it('keeps optional oxlint as a runtime dependency', () => {
const pkg = { optionalDependencies: { oxlint: '^1.79.0' } };
expect(packageOwnsOxlintApi(pkg)).toBe(false);
expect(packageOwnsOxlintApi(pkg)).toBe(true);
rewritePackageJson(pkg, PackageManager.pnpm);
expect(pkg.optionalDependencies).toEqual({});
expect(pkg.optionalDependencies).toEqual({ oxlint: '^1.79.0' });
});
});

Expand Down
38 changes: 13 additions & 25 deletions packages/cli/src/migration/migrator/eslint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import type { MigrationReport } from '../report.ts';
import {
LINT_STAGED_JSON_CONFIG_FILES,
LINT_STAGED_OTHER_CONFIG_FILES,
removeReplacedDevDependency,
rewritePackageScriptFields,
rewriteScriptMap,
warnMigration,
Expand Down Expand Up @@ -454,33 +455,20 @@ export function rewriteEslintPackageJson(
'lint-staged'?: Record<string, string | Array<string>>;
}>(packageJsonPath, (pkg) => {
let changed = false;
for (const field of [
'devDependencies',
'dependencies',
'peerDependencies',
'optionalDependencies',
] as const) {
const deps = pkg[field];
if (!deps) {
continue;
}
let removedAny = false;
for (const name of Object.keys(deps)) {
if (preserveJsPlugins.has(name)) {
continue;
}
if (isEslintEcosystemDep(name)) {
delete deps[name];
changed = true;
removedAny = true;
}
}
// Drop the field entirely if our cleanup emptied it — avoid
// leaving `"devDependencies": {}` noise in the output.
if (removedAny && Object.keys(deps).length === 0) {
delete pkg[field];
for (const name of Object.keys(pkg.devDependencies ?? {})) {
if (
!preserveJsPlugins.has(name) &&
isEslintEcosystemDep(name) &&
removeReplacedDevDependency(pkg, name)
) {
changed = true;
}
}
// Drop the field entirely if our cleanup emptied it — avoid
// leaving `"devDependencies": {}` noise in the output.
if (changed && Object.keys(pkg.devDependencies ?? {}).length === 0) {
delete pkg.devDependencies;
}
const scriptsChanged = rewritePackageScriptFields(pkg, rewriteEslint);
return changed || scriptsChanged ? pkg : undefined;
});
Expand Down
17 changes: 5 additions & 12 deletions packages/cli/src/migration/migrator/git-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ import {
removeLintStagedFromPackageJson,
} from '../migrator.ts';
import type { MigrationReport } from '../report.ts';
import type { DependencyBag } from './shared.ts';
import { rewriteScriptMap } from './shared.ts';
import {
getCommandStartIndex,
LINT_STAGED_ALL_CONFIG_FILES,
LINT_STAGED_OTHER_CONFIG_FILES,
removeReplacedDevDependency,
SHELL_STATE_COMMANDS,
warnMigration,
} from './shared.ts';
Expand All @@ -38,18 +40,9 @@ const OTHER_HOOK_TOOLS = ['simple-git-hooks', 'lefthook', 'yorkie'] as const;
const SUPPORTED_GIT_HOOK_NAME_SET = new Set<string>(SUPPORTED_GIT_HOOK_NAMES);

function removeReplacedStagedPackage(packageJsonPath: string): void {
editJsonFile<{
devDependencies?: Record<string, string>;
dependencies?: Record<string, string>;
}>(packageJsonPath, (pkg) => {
if (pkg.devDependencies?.['lint-staged']) {
delete pkg.devDependencies['lint-staged'];
}
if (pkg.dependencies?.['lint-staged']) {
delete pkg.dependencies['lint-staged'];
}
return pkg;
});
editJsonFile<DependencyBag>(packageJsonPath, (pkg) =>
removeReplacedDevDependency(pkg, 'lint-staged') ? pkg : undefined,
);
}

export function detectLegacyGitHooksMigrationCandidate(projectPath: string): boolean {
Expand Down
49 changes: 13 additions & 36 deletions packages/cli/src/migration/migrator/package-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import {
resolveProviderPeerSpec,
OPT_IN_BROWSER_PROVIDERS,
OXLINT_PLUGINS_PACKAGE,
OXLINT_PLUGIN_API_PACKAGES,
packageOwnsOxlintApi,
bundledPackagesToRemove,
removeBundledDevDependencies,
VITEST_BROWSER_DEP_NAMES,
VITEST_IS_MANAGED_OVERRIDE,
} from './shared.ts';
Expand Down Expand Up @@ -186,43 +186,20 @@ export function rewritePackageJson(
const hasBrowserDepSignal = VITEST_BROWSER_DEP_NAMES.some((name) =>
dependencyGroups.some(({ dependencies }) => dependencies?.[name] !== undefined),
);
// Published plugins keep their upstream imports and the dependencies that
// supply them, including optional @oxlint/plugins integrations.
const ownsOxlintApi = packageOwnsOxlintApi(pkg);
// Rewritten imports need a direct vite-plus dependency. Defer removal of
// @oxlint/plugins until dropDeadOxlintPluginsDependency checks the final source.
if (pkg.devDependencies?.[OXLINT_PLUGINS_PACKAGE] !== undefined && !ownsOxlintApi) {
// Rewritten imports need a direct vite-plus dependency, but published plugins
// keep their upstream imports. Defer removal of @oxlint/plugins until
// dropDeadOxlintPluginsDependency checks the final source.
if (pkg.devDependencies?.[OXLINT_PLUGINS_PACKAGE] !== undefined && !packageOwnsOxlintApi(pkg)) {
needVitePlus = true;
}
// remove packages that are replaced with vite-plus
for (const name of bundledPackagesToRemove(retainedBrowserPackages)) {
let wasRemoved = false;
for (const { dependencyField, dependencies } of dependencyGroups) {
if (
ownsOxlintApi &&
(dependencyField === 'peerDependencies' || dependencyField === 'dependencies') &&
(OXLINT_PLUGIN_API_PACKAGES as ReadonlyArray<string>).includes(name)
) {
// A `catalog:` reference would dangle once the catalog entry for a
// REMOVE_PACKAGES name is dropped, and the next install fails. Resolve
// it to the concrete range the catalog currently points at.
const current = dependencies?.[name];
if (current?.startsWith('catalog:') && dependencies) {
const resolved = catalogDependencyResolver?.(current, name);
if (resolved) {
dependencies[name] = resolved;
}
}
continue;
}
if (dependencies?.[name]) {
delete dependencies[name];
wasRemoved = true;
}
}
if (wasRemoved) {
needVitePlus = true;
}
if (
removeBundledDevDependencies(
pkg,
bundledPackagesToRemove(retainedBrowserPackages),
catalogDependencyResolver,
)
) {
needVitePlus = true;
}
// Official opt-in providers remain project dependencies. Align their versions
// with bundled Vitest and ensure the framework peer required by each shim.
Expand Down
Loading