From 866ca8df0a9177324352f5147cd26f75cdccf5b3 Mon Sep 17 00:00:00 2001 From: Vida Xie Date: Fri, 21 Nov 2025 01:02:19 +0800 Subject: [PATCH 1/6] refactor: migrate to pnpm workspace --- .gitignore | 5 ---- docs/.gitignore | 5 ++++ .../build-system/{build.mts => build.ts} | 6 ++--- .../build-system/shim/{empty.mjs => empty.js} | 0 .../src/{process-shim.mjs => process-shim.js} | 0 docs/.vitepress/{config.mts => config.ts} | 14 +++++------ docs/.vitepress/theme/index.ts | 24 +++++++------------ .../{vite-plugin.mts => vite-plugin.ts} | 1 + docs/package.json | 8 +++++++ docs/tsconfig.json | 14 +++++++++++ package.json | 5 ++-- pnpm-workspace.yaml | 2 ++ tsconfig.base.json | 18 ++++++++++++++ tsconfig.json | 19 ++------------- 14 files changed, 71 insertions(+), 50 deletions(-) create mode 100644 docs/.gitignore rename docs/.vitepress/build-system/{build.mts => build.ts} (91%) rename docs/.vitepress/build-system/shim/{empty.mjs => empty.js} (100%) rename docs/.vitepress/build-system/src/{process-shim.mjs => process-shim.js} (100%) rename docs/.vitepress/{config.mts => config.ts} (97%) rename docs/.vitepress/{vite-plugin.mts => vite-plugin.ts} (99%) create mode 100644 docs/package.json create mode 100644 docs/tsconfig.json create mode 100644 pnpm-workspace.yaml create mode 100644 tsconfig.base.json diff --git a/.gitignore b/.gitignore index d6fadf92c..91a1985d4 100644 --- a/.gitignore +++ b/.gitignore @@ -7,10 +7,5 @@ /test.* yarn.lock yarn-error.log -/docs/.vitepress/dist -/docs/.vitepress/build-system/shim/vue-eslint-parser.mjs -/docs/.vitepress/build-system/shim/@typescript-eslint/parser.mjs -/docs/.vitepress/.temp -/docs/.vitepress/cache typings/eslint/lib/rules eslint-typegen.d.ts diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 000000000..24cd7295c --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,5 @@ +.vitepress/dist +.vitepress/build-system/shim/@typescript-eslint +.vitepress/build-system/shim/vue-eslint-parser.js +.vitepress/.temp +.vitepress/cache diff --git a/docs/.vitepress/build-system/build.mts b/docs/.vitepress/build-system/build.ts similarity index 91% rename from docs/.vitepress/build-system/build.mts rename to docs/.vitepress/build-system/build.ts index edda69143..81aebea87 100644 --- a/docs/.vitepress/build-system/build.mts +++ b/docs/.vitepress/build-system/build.ts @@ -13,7 +13,7 @@ build( dirname, '../../../node_modules/@typescript-eslint/parser/dist/index.js' ), - path.join(dirname, './shim/@typescript-eslint/parser.mjs'), + path.join(dirname, './shim/@typescript-eslint/parser.js'), [ 'util', 'node:util', @@ -29,7 +29,7 @@ build( build( path.join(dirname, '../../../node_modules/vue-eslint-parser/index.js'), - path.join(dirname, './shim/vue-eslint-parser.mjs'), + path.join(dirname, './shim/vue-eslint-parser.js'), [ 'path', 'debug', @@ -59,7 +59,7 @@ function bundle(entryPoint: string, externals: string[]) { bundle: true, external: externals, write: false, - inject: [path.join(dirname, './src/process-shim.mjs')] + inject: [path.join(dirname, './src/process-shim.js')] }) return `${result.outputFiles[0].text}` diff --git a/docs/.vitepress/build-system/shim/empty.mjs b/docs/.vitepress/build-system/shim/empty.js similarity index 100% rename from docs/.vitepress/build-system/shim/empty.mjs rename to docs/.vitepress/build-system/shim/empty.js diff --git a/docs/.vitepress/build-system/src/process-shim.mjs b/docs/.vitepress/build-system/src/process-shim.js similarity index 100% rename from docs/.vitepress/build-system/src/process-shim.mjs rename to docs/.vitepress/build-system/src/process-shim.js diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.ts similarity index 97% rename from docs/.vitepress/config.mts rename to docs/.vitepress/config.ts index 7d198d588..9e580b2c2 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.ts @@ -2,11 +2,11 @@ import type { DefaultTheme } from 'vitepress' import { defineConfig } from 'vitepress' import path from 'pathe' import { fileURLToPath } from 'url' -import { viteCommonjs, vitePluginRequireResolve } from './vite-plugin.mjs' +import { viteCommonjs, vitePluginRequireResolve } from './vite-plugin' import eslint4b, { requireESLintUseAtYourOwnRisk4b } from 'vite-plugin-eslint4b' // Pre-build cjs packages that cannot be bundled well. -import './build-system/build.mjs' +import './build-system/build' const dirname = path.dirname(fileURLToPath(import.meta.url)) @@ -153,17 +153,17 @@ export default async () => { alias: { 'vue-eslint-parser': path.join( dirname, - './build-system/shim/vue-eslint-parser.mjs' + './build-system/shim/vue-eslint-parser.js' ), '@typescript-eslint/parser': path.join( dirname, - './build-system/shim/@typescript-eslint/parser.mjs' + './build-system/shim/@typescript-eslint/parser.js' ), tslib: path.join(dirname, '../../node_modules/tslib/tslib.es6.js'), - globby: path.join(dirname, './build-system/shim/empty.mjs'), - 'fast-glob': path.join(dirname, './build-system/shim/empty.mjs'), - module: path.join(dirname, './build-system/shim/empty.mjs') + globby: path.join(dirname, './build-system/shim/empty.js'), + 'fast-glob': path.join(dirname, './build-system/shim/empty.js'), + module: path.join(dirname, './build-system/shim/empty.js') } }, define: { diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts index 757e63cab..07dadbf16 100644 --- a/docs/.vitepress/theme/index.ts +++ b/docs/.vitepress/theme/index.ts @@ -1,25 +1,17 @@ -// @ts-expect-error -- Browser -if (typeof window !== 'undefined') { - if (typeof require === 'undefined') { - // @ts-expect-error -- Browser - ;(window as any).require = () => { - const e = new Error('require is not defined') - ;(e as any).code = 'MODULE_NOT_FOUND' - throw e - } - } -} -// @ts-expect-error -- Cannot change `module` option import type { Theme } from 'vitepress' -// @ts-expect-error -- Cannot change `module` option import DefaultTheme from 'vitepress/theme' -// @ts-expect-error -- ignore import Layout from './Layout.vue' -// @ts-expect-error -- ignore import ESLintCodeBlock from './components/eslint-code-block.vue' -// @ts-expect-error -- ignore import RulesTable from './components/rules-table.vue' +if (typeof window !== 'undefined' && typeof require === 'undefined') { + ;(window as any).require = () => { + const e = new Error('require is not defined') + ;(e as any).code = 'MODULE_NOT_FOUND' + throw e + } +} + const theme: Theme = { ...DefaultTheme, Layout, diff --git a/docs/.vitepress/vite-plugin.mts b/docs/.vitepress/vite-plugin.ts similarity index 99% rename from docs/.vitepress/vite-plugin.mts rename to docs/.vitepress/vite-plugin.ts index cd6811cb6..da8ab71bf 100644 --- a/docs/.vitepress/vite-plugin.mts +++ b/docs/.vitepress/vite-plugin.ts @@ -2,6 +2,7 @@ import type { UserConfig } from 'vitepress' import path from 'pathe' import { fileURLToPath } from 'url' import esbuild from 'esbuild' + type Plugin = Extract< NonNullable['plugins']>[number], { name: string } diff --git a/docs/package.json b/docs/package.json new file mode 100644 index 000000000..453f20afb --- /dev/null +++ b/docs/package.json @@ -0,0 +1,8 @@ +{ + "private": true, + "type": "module", + "scripts": { + "dev": "vitepress", + "build": "vitepress build" + } +} diff --git a/docs/tsconfig.json b/docs/tsconfig.json new file mode 100644 index 000000000..5c998cd6f --- /dev/null +++ b/docs/tsconfig.json @@ -0,0 +1,14 @@ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "module": "esnext", + "target": "esnext", + "moduleResolution": "bundler", + "lib": ["ESNext", "DOM"], + }, + "include": [ + ".vitepress/**/*.js", + ".vitepress/**/*.ts", + ".vitepress/**/*.vue" + ] +} diff --git a/package.json b/package.json index 78a103cdf..b05f47719 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "Official ESLint plugin for Vue.js", "main": "lib/index.js", "types": "lib/index.d.ts", + "packageManager": "pnpm@10.23.0", "scripts": { "new": "node tools/new-rule.js", "start": "npm run test:base -- --watch --growl", @@ -22,9 +23,9 @@ "update": "node ./tools/update.js", "update-resources": "node ./tools/update-resources.js", "typegen": "node ./tools/generate-typegen.mjs", - "docs:watch": "vitepress dev docs", + "docs:watch": "pnpm -C docs run dev", "predocs:build": "npm run update", - "docs:build": "vitepress build docs", + "docs:build": "pnpm -C docs run build", "generate:version": "env-cmd -e version npm run update && npm run lint:fix", "changeset:version": "changeset version && npm run generate:version && git add --all", "changeset:publish": "npm run typegen && changeset publish" diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 000000000..28756faef --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - docs diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 000000000..3f5ddd0ad --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "allowJs": true, + "checkJs": true, + "noEmit": true, + "strict": true, + "noImplicitAny": true, + "noImplicitThis": true, + "alwaysStrict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "esModuleInterop": true, + "resolveJsonModule": true, + "skipLibCheck": true + } +} diff --git a/tsconfig.json b/tsconfig.json index b488a6b93..fd4134ad7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,32 +1,17 @@ { + "extends": "./tsconfig.base.json", "compilerOptions": { "target": "ES2019", "module": "node16", "moduleResolution": "Node16", "lib": ["es2020"], - "allowJs": true, - "checkJs": true, - "noEmit": true, - "strict": true, - "noImplicitAny": true, - "noImplicitThis": true, - "alwaysStrict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "esModuleInterop": true, - "resolveJsonModule": true, "baseUrl": ".", "paths": { "*": ["typings/*"] - }, - "skipLibCheck": true + } }, "include": [ "lib/**/*", "typings/eslint-plugin-vue/global.d.ts", - "docs/.vitepress/**/*.ts", - "docs/.vitepress/**/*.mts" ] } From 61720882eb42baeabc483da64c8a6ff4d2cdae5d Mon Sep 17 00:00:00 2001 From: Vida Xie Date: Sat, 22 Nov 2025 13:31:36 +0800 Subject: [PATCH 2/6] ci: update --- .github/workflows/CI.yml | 54 +++++++++++++------ .github/workflows/Release.yml | 9 ++-- .../workflows/check-for-resources-update.yml | 7 ++- 3 files changed, 49 insertions(+), 21 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 69cac752d..98852561f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -19,12 +19,16 @@ jobs: steps: - name: Checkout uses: actions/checkout@v5 + - name: Install pnpm + uses: pnpm/action-setup@v4 - name: Install Node.js uses: actions/setup-node@v6 + with: + cache: pnpm - name: Install Packages - run: npm install --legacy-peer-deps + run: pnpm install --legacy-peer-deps - name: Lint - run: npm run lint + run: pnpm run lint test: name: Test @@ -35,14 +39,17 @@ jobs: steps: - name: Checkout uses: actions/checkout@v5 + - name: Install pnpm + uses: pnpm/action-setup@v4 - name: Install Node.js v${{ matrix.node }} uses: actions/setup-node@v6 with: node-version: ${{ matrix.node }} + cache: pnpm - name: Install Packages - run: npm install + run: pnpm install - name: Test - run: npm test + run: pnpm test test-with-eslint-v8: name: Test with ESLint v8 @@ -50,16 +57,19 @@ jobs: steps: - name: Checkout uses: actions/checkout@v5 + - name: Install pnpm + uses: pnpm/action-setup@v4 - name: Install Node.js v18 uses: actions/setup-node@v6 with: node-version: 18 + cache: pnpm - name: Install Packages - run: npm install + run: pnpm install - name: Install ESLint v8 - run: npm install --save-dev eslint@8 --force + run: pnpm install --save-dev eslint@8 --force - name: Test - run: npm test + run: pnpm test test-without-eslint-stylistic: name: Test without ESLint Stylistic @@ -67,14 +77,18 @@ jobs: steps: - name: Checkout uses: actions/checkout@v5 + - name: Install pnpm + uses: pnpm/action-setup@v4 - name: Install Node.js uses: actions/setup-node@v6 + with: + cache: pnpm - name: Install Packages - run: npm install + run: pnpm install - name: Uninstall @stylistic/eslint-plugin - run: npm uninstall @stylistic/eslint-plugin + run: pnpm uninstall @stylistic/eslint-plugin - name: Test - run: npm test + run: pnpm test test-with-old-eslint-stylistic: name: Test with old ESLint Stylistic @@ -85,14 +99,18 @@ jobs: steps: - name: Checkout uses: actions/checkout@v5 + - name: Install pnpm + uses: pnpm/action-setup@v4 - name: Install Node.js uses: actions/setup-node@v6 + with: + cache: pnpm - name: Install Packages - run: npm install + run: pnpm install - name: Install @stylistic/eslint-plugin v${{ matrix.stylistic }} - run: npm install -D @stylistic/eslint-plugin@${{ matrix.stylistic }} --force + run: pnpm install -D @stylistic/eslint-plugin@${{ matrix.stylistic }} --force - name: Test - run: npm test + run: pnpm test test-with-typescript-eslint-v7: name: Test with typescript-eslint v7 @@ -100,11 +118,15 @@ jobs: steps: - name: Checkout uses: actions/checkout@v5 + - name: Install pnpm + uses: pnpm/action-setup@v4 - name: Install Node.js uses: actions/setup-node@v6 + with: + cache: pnpm - name: Install Packages - run: npm install + run: pnpm install - name: Install @typescript-eslint/parser v7 - run: npm install -D @typescript-eslint/parser@7 --force + run: pnpm install -D @typescript-eslint/parser@7 --force - name: Test - run: npm test + run: pnpm test diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index feb5a19e5..9b4430324 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -20,18 +20,21 @@ jobs: steps: - name: Checkout Repo uses: actions/checkout@v5 + - name: Install pnpm + uses: pnpm/action-setup@v4 - name: Setup Node.js uses: actions/setup-node@v6 with: node-version: 24 + cache: pnpm - name: Install Dependencies - run: npm install + run: pnpm install - name: Create Release Pull Request or Publish to npm id: changesets uses: changesets/action@v1 with: - version: npm run changeset:version - publish: npm run changeset:publish + version: pnpm run changeset:version + publish: pnpm run changeset:publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/check-for-resources-update.yml b/.github/workflows/check-for-resources-update.yml index 362ca48cc..1b7985138 100644 --- a/.github/workflows/check-for-resources-update.yml +++ b/.github/workflows/check-for-resources-update.yml @@ -15,14 +15,17 @@ jobs: steps: - name: Checkout uses: actions/checkout@v5 + - name: Install pnpm + uses: pnpm/action-setup@v4 - name: Install Node.js uses: actions/setup-node@v6 with: node-version: 18 + cache: pnpm - name: Install Packages - run: npm install + run: pnpm install - name: Update - run: npm run update-resources + run: pnpm run update-resources - uses: peter-evans/create-pull-request@v7 with: commit-message: Updates resources From 7222647a0a5dcf537c7ea9dcb848e5802f5812cf Mon Sep 17 00:00:00 2001 From: Vida Xie Date: Sat, 22 Nov 2025 13:34:09 +0800 Subject: [PATCH 3/6] chore: remove `cache: pnpm` --- .github/workflows/CI.yml | 10 ---------- .github/workflows/Release.yml | 1 - .github/workflows/check-for-resources-update.yml | 1 - 3 files changed, 12 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 98852561f..0a54243f7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -23,8 +23,6 @@ jobs: uses: pnpm/action-setup@v4 - name: Install Node.js uses: actions/setup-node@v6 - with: - cache: pnpm - name: Install Packages run: pnpm install --legacy-peer-deps - name: Lint @@ -45,7 +43,6 @@ jobs: uses: actions/setup-node@v6 with: node-version: ${{ matrix.node }} - cache: pnpm - name: Install Packages run: pnpm install - name: Test @@ -63,7 +60,6 @@ jobs: uses: actions/setup-node@v6 with: node-version: 18 - cache: pnpm - name: Install Packages run: pnpm install - name: Install ESLint v8 @@ -81,8 +77,6 @@ jobs: uses: pnpm/action-setup@v4 - name: Install Node.js uses: actions/setup-node@v6 - with: - cache: pnpm - name: Install Packages run: pnpm install - name: Uninstall @stylistic/eslint-plugin @@ -103,8 +97,6 @@ jobs: uses: pnpm/action-setup@v4 - name: Install Node.js uses: actions/setup-node@v6 - with: - cache: pnpm - name: Install Packages run: pnpm install - name: Install @stylistic/eslint-plugin v${{ matrix.stylistic }} @@ -122,8 +114,6 @@ jobs: uses: pnpm/action-setup@v4 - name: Install Node.js uses: actions/setup-node@v6 - with: - cache: pnpm - name: Install Packages run: pnpm install - name: Install @typescript-eslint/parser v7 diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 9b4430324..7f2624b14 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -26,7 +26,6 @@ jobs: uses: actions/setup-node@v6 with: node-version: 24 - cache: pnpm - name: Install Dependencies run: pnpm install diff --git a/.github/workflows/check-for-resources-update.yml b/.github/workflows/check-for-resources-update.yml index 1b7985138..a06acd5f9 100644 --- a/.github/workflows/check-for-resources-update.yml +++ b/.github/workflows/check-for-resources-update.yml @@ -21,7 +21,6 @@ jobs: uses: actions/setup-node@v6 with: node-version: 18 - cache: pnpm - name: Install Packages run: pnpm install - name: Update From ea70e76e7c52457153e87e378cb734a628cc2939 Mon Sep 17 00:00:00 2001 From: Vida Xie Date: Sat, 22 Nov 2025 13:40:18 +0800 Subject: [PATCH 4/6] chore: remove unnecessary `legacy-peer-deps` --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0a54243f7..9a603daf9 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -24,7 +24,7 @@ jobs: - name: Install Node.js uses: actions/setup-node@v6 - name: Install Packages - run: pnpm install --legacy-peer-deps + run: pnpm install - name: Lint run: pnpm run lint From 66e3df7ba6eb039849bdbf3b1362b5a9a70846eb Mon Sep 17 00:00:00 2001 From: Vida Xie Date: Sat, 22 Nov 2025 14:02:45 +0800 Subject: [PATCH 5/6] chore: update --- eslint.config.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 044005f23..f5907ca7e 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -61,8 +61,8 @@ export default typegen([ '!.vitepress', 'docs/.vitepress/dist', - 'docs/.vitepress/build-system/shim/vue-eslint-parser.mjs', - 'docs/.vitepress/build-system/shim/@typescript-eslint/parser.mjs', + 'docs/.vitepress/build-system/shim/vue-eslint-parser.js', + 'docs/.vitepress/build-system/shim/@typescript-eslint/parser.js', 'docs/.vitepress/.temp', 'docs/.vitepress/cache' ] @@ -109,7 +109,7 @@ export default typegen([ { name: 'typescript/setup', - files: ['**/*.{ts,mts}'], + files: ['docs/**/*.js', '**/*.{ts,mts}'], languageOptions: { parser: tsEslintParser, parserOptions: { From 3cb49090df5c441b859d6cf2277264a9d6a733e1 Mon Sep 17 00:00:00 2001 From: Vida Xie Date: Thu, 27 Nov 2025 21:13:03 +0800 Subject: [PATCH 6/6] chore: update gitignore --- .gitignore | 6 ++++++ docs/.gitignore | 5 ----- 2 files changed, 6 insertions(+), 5 deletions(-) delete mode 100644 docs/.gitignore diff --git a/.gitignore b/.gitignore index 91a1985d4..513941efd 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,9 @@ yarn.lock yarn-error.log typings/eslint/lib/rules eslint-typegen.d.ts + +docs/.vitepress/dist +docs/.vitepress/build-system/shim/@typescript-eslint +docs/.vitepress/build-system/shim/vue-eslint-parser.js +docs/.vitepress/.temp +docs/.vitepress/cache diff --git a/docs/.gitignore b/docs/.gitignore deleted file mode 100644 index 24cd7295c..000000000 --- a/docs/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.vitepress/dist -.vitepress/build-system/shim/@typescript-eslint -.vitepress/build-system/shim/vue-eslint-parser.js -.vitepress/.temp -.vitepress/cache