diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 69cac752d..9a603daf9 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -19,12 +19,14 @@ 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 - name: Install Packages - run: npm install --legacy-peer-deps + run: pnpm install - name: Lint - run: npm run lint + run: pnpm run lint test: name: Test @@ -35,14 +37,16 @@ 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 }} - 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 +54,18 @@ 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 - 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 +73,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 - 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 +93,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 - 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 +110,13 @@ 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 - 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..7f2624b14 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -20,18 +20,20 @@ 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 - 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..a06acd5f9 100644 --- a/.github/workflows/check-for-resources-update.yml +++ b/.github/workflows/check-for-resources-update.yml @@ -15,14 +15,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: node-version: 18 - 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 diff --git a/.gitignore b/.gitignore index d6fadf92c..513941efd 100644 --- a/.gitignore +++ b/.gitignore @@ -7,10 +7,11 @@ /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 + +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/.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 39117fe84..88ef6262c 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', @@ -30,7 +30,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', @@ -60,7 +60,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 96% rename from docs/.vitepress/config.mts rename to docs/.vitepress/config.ts index 471d58414..ff7eb72f4 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)) @@ -152,18 +152,18 @@ 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'), - tinyglobby: 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'), + tinyglobby: 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 34f6ee9b0..07dadbf16 100644 --- a/docs/.vitepress/theme/index.ts +++ b/docs/.vitepress/theme/index.ts @@ -1,22 +1,16 @@ -// @ts-expect-error -- Browser +import type { Theme } from 'vitepress' +import DefaultTheme from 'vitepress/theme' +import Layout from './Layout.vue' +import ESLintCodeBlock from './components/eslint-code-block.vue' +import RulesTable from './components/rules-table.vue' + if (typeof window !== 'undefined' && 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' const theme: Theme = { ...DefaultTheme, 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 bd9c9090b..54f436bd4 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/eslint.config.mjs b/eslint.config.mjs index f5c8aee09..3b3ba84e0 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -100,7 +100,7 @@ export default typegen([ { name: 'typescript/setup', - files: ['**/*.{ts,mts}'], + files: ['docs/**/*.js', '**/*.{ts,mts}'], languageOptions: { parser: tsEslintParser, parserOptions: { diff --git a/package.json b/package.json index 4a4db09a7..72103ac64 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", @@ -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" ] }