Skip to content

Commit 3bac377

Browse files
committed
fix(migrate): remove ESLint plugins/configs and detect type-aware usage
`vp migrate` left `eslint-plugin-*`, `eslint-config-*`, `typescript-eslint`, and `@typescript-eslint/*` behind in `package.json` after removing `eslint` itself, leaving the user with dead packages that only configure ESLint. Expand `rewriteEslintPackageJson` to drop those plus scoped variants (e.g. `@vue/eslint-config-typescript`). Add a `hasTypeAwareEslintConfig` heuristic that recognizes `recommendedTypeChecked`, `projectService`, and `parserOptions.project` across flat configs, legacy `.eslintrc.*`, and `package.json#eslintConfig`, and record the result on the migration report so downstream messaging can be transparent about preserving type-aware coverage in the resulting Oxlint config. Addresses PR comments r3255784734, r3255786019, r3255859061 from WeakAuras/WeakAuras-Companion#2956.
1 parent ada9d33 commit 3bac377

12 files changed

Lines changed: 461 additions & 76 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default [
2+
{
3+
rules: {
4+
'no-unused-vars': 'error',
5+
},
6+
},
7+
];
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "migration-eslint-plugins-cleanup",
3+
"scripts": {
4+
"dev": "vite",
5+
"build": "vite build",
6+
"lint": "eslint ."
7+
},
8+
"devDependencies": {
9+
"@typescript-eslint/eslint-plugin": "^8.0.0",
10+
"@typescript-eslint/parser": "^8.0.0",
11+
"@vitejs/plugin-vue": "^6.0.0",
12+
"@vue/eslint-config-typescript": "^14.0.0",
13+
"eslint": "^9.0.0",
14+
"eslint-config-airbnb": "^19.0.0",
15+
"eslint-plugin-vue": "^10.0.0",
16+
"typescript-eslint": "^8.0.0",
17+
"vite": "^7.0.0",
18+
"vue": "^3.5.0"
19+
}
20+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
> vp migrate --no-interactive # migration should remove ESLint and its plugins/configs
2+
◇ Migrated . to Vite+
3+
• Node <semver> pnpm <semver>
4+
• 4 config updates applied
5+
• ESLint rules migrated to Oxlint
6+
• TypeScript shim added for framework component files
7+
8+
> cat package.json # check eslint, eslint-plugin-*, eslint-config-*, typescript-eslint and @typescript-eslint/* are removed
9+
{
10+
"name": "migration-eslint-plugins-cleanup",
11+
"scripts": {
12+
"dev": "vp dev",
13+
"build": "vp build",
14+
"lint": "vp lint .",
15+
"prepare": "vp config"
16+
},
17+
"devDependencies": {
18+
"@vitejs/plugin-vue": "^6.0.0",
19+
"vite": "catalog:",
20+
"vue": "^3.5.0",
21+
"vite-plus": "catalog:"
22+
},
23+
"packageManager": "pnpm@<semver>"
24+
}
25+
26+
> test ! -f eslint.config.mjs # check eslint config is removed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"commands": [
3+
"vp migrate --no-interactive # migration should remove ESLint and its plugins/configs",
4+
"cat package.json # check eslint, eslint-plugin-*, eslint-config-*, typescript-eslint and @typescript-eslint/* are removed",
5+
"test ! -f eslint.config.mjs # check eslint config is removed"
6+
]
7+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Flat config exercising the type-aware sniffer without importing
2+
// typescript-eslint at runtime, so `@oxlint/migrate` can load the file
3+
// in the snap-test sandbox where no node_modules are installed.
4+
export default [
5+
{
6+
languageOptions: {
7+
parserOptions: {
8+
projectService: true,
9+
},
10+
},
11+
rules: {
12+
'no-unused-vars': 'error',
13+
},
14+
},
15+
];
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "migration-eslint-type-aware",
3+
"scripts": {
4+
"dev": "vite",
5+
"build": "vite build",
6+
"lint": "eslint ."
7+
},
8+
"devDependencies": {
9+
"@typescript-eslint/eslint-plugin": "^8.0.0",
10+
"@typescript-eslint/parser": "^8.0.0",
11+
"eslint": "^9.0.0",
12+
"typescript": "^5.6.0",
13+
"typescript-eslint": "^8.0.0",
14+
"vite": "^7.0.0"
15+
}
16+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
> vp migrate --no-interactive # migration should preserve type-aware coverage
2+
◇ Migrated . to Vite+
3+
• Node <semver> pnpm <semver>
4+
• 4 config updates applied
5+
• ESLint rules migrated to Oxlint
6+
7+
> cat package.json # check typescript-eslint and @typescript-eslint/* are removed; typescript is preserved
8+
{
9+
"name": "migration-eslint-type-aware",
10+
"scripts": {
11+
"dev": "vp dev",
12+
"build": "vp build",
13+
"lint": "vp lint .",
14+
"prepare": "vp config"
15+
},
16+
"devDependencies": {
17+
"typescript": "^5.6.0",
18+
"vite": "catalog:",
19+
"vite-plus": "catalog:"
20+
},
21+
"packageManager": "pnpm@<semver>"
22+
}
23+
24+
> cat vite.config.ts # check options.typeAware/typeCheck = true is set in the lint block
25+
import { defineConfig } from 'vite-plus';
26+
27+
export default defineConfig({
28+
staged: {
29+
"*": "vp check --fix"
30+
},
31+
fmt: {},
32+
lint: {
33+
"plugins": [
34+
"oxc",
35+
"typescript",
36+
"unicorn",
37+
"react"
38+
],
39+
"categories": {
40+
"correctness": "warn"
41+
},
42+
"env": {
43+
"builtin": true
44+
},
45+
"rules": {
46+
"no-unused-vars": "error",
47+
"vite-plus/prefer-vite-plus-imports": "error"
48+
},
49+
"options": {
50+
"typeAware": true,
51+
"typeCheck": true
52+
},
53+
"jsPlugins": [
54+
{
55+
"name": "vite-plus",
56+
"specifier": "vite-plus/oxlint-plugin"
57+
}
58+
]
59+
},
60+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"commands": [
3+
"vp migrate --no-interactive # migration should preserve type-aware coverage",
4+
"cat package.json # check typescript-eslint and @typescript-eslint/* are removed; typescript is preserved",
5+
"cat vite.config.ts # check options.typeAware/typeCheck = true is set in the lint block"
6+
]
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2022",
4+
"module": "ESNext",
5+
"moduleResolution": "Bundler",
6+
"strict": true,
7+
"skipLibCheck": true
8+
},
9+
"include": ["src/**/*"]
10+
}

0 commit comments

Comments
 (0)