From c166be986b8d90cc28b5a2c609479d643f5d4dd3 Mon Sep 17 00:00:00 2001 From: yosuke ota Date: Tue, 1 Jul 2025 15:09:09 +0900 Subject: [PATCH 01/11] chore: Use ESLint v9 in development env --- .gitignore | 4 +- docs/.vitepress/build-system/build.mts | 44 ++++++++-- .../shim/{globby.mjs => empty.mjs} | 0 .../shim/eslint/use-at-your-own-risk.mjs | 3 - docs/.vitepress/build-system/shim/esquery.mjs | 5 -- docs/.vitepress/build-system/shim/path.mjs | 38 --------- docs/.vitepress/build-system/src/eslint.mjs | 8 -- docs/.vitepress/config.mts | 27 ++++-- .../theme/components/eslint-code-block.vue | 83 ++++++++----------- docs/rules/comment-directive.md | 6 +- docs/rules/eqeqeq.md | 1 + docs/rules/index.md | 4 +- docs/rules/no-implicit-coercion.md | 1 + eslint.config.js | 5 +- lib/rules/no-restricted-call-after-await.js | 2 +- lib/rules/no-unsupported-features.js | 2 +- lib/utils/index.js | 2 +- lib/utils/selector.js | 4 +- package.json | 9 +- tests/integrations/flat-config/a.vue | 1 - 20 files changed, 108 insertions(+), 141 deletions(-) rename docs/.vitepress/build-system/shim/{globby.mjs => empty.mjs} (100%) delete mode 100644 docs/.vitepress/build-system/shim/eslint/use-at-your-own-risk.mjs delete mode 100644 docs/.vitepress/build-system/shim/esquery.mjs delete mode 100644 docs/.vitepress/build-system/shim/path.mjs delete mode 100644 docs/.vitepress/build-system/src/eslint.mjs diff --git a/.gitignore b/.gitignore index 797d0cbcd..0458765cd 100644 --- a/.gitignore +++ b/.gitignore @@ -8,8 +8,8 @@ yarn.lock yarn-error.log /docs/.vitepress/dist -/docs/.vitepress/build-system/shim/eslint.mjs -/docs/.vitepress/build-system/shim/assert.mjs +/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 diff --git a/docs/.vitepress/build-system/build.mts b/docs/.vitepress/build-system/build.mts index 9dce53faf..76126d5d5 100644 --- a/docs/.vitepress/build-system/build.mts +++ b/docs/.vitepress/build-system/build.mts @@ -9,14 +9,42 @@ import { fileURLToPath } from 'url' const dirname = path.dirname(fileURLToPath(import.meta.url)) build( - path.join(dirname, './src/eslint.mjs'), - path.join(dirname, './shim/eslint.mjs'), - ['path', 'assert', 'util', 'esquery'] + path.join( + dirname, + '../../../node_modules/@typescript-eslint/parser/dist/index.js' + ), + path.join(dirname, './shim/@typescript-eslint/parser.mjs'), + [ + 'stream', + 'node:stream', + 'os', + 'node:os', + 'util', + 'node:util', + 'path', + 'node:path', + 'fs', + 'node:fs', + 'semver', + 'fast-glob', + 'debug' + ] ) + build( - path.join(dirname, '../../../node_modules/assert'), - path.join(dirname, './shim/assert.mjs'), - ['path'] + path.join(dirname, '../../../node_modules/vue-eslint-parser/index.js'), + path.join(dirname, './shim/vue-eslint-parser.mjs'), + [ + 'path', + 'debug', + 'semver', + 'assert', + 'module', + 'events', + 'esquery', + 'fs', + 'eslint' + ] ) function build(input: string, out: string, injects: string[] = []) { @@ -47,11 +75,11 @@ function transform(code: string, injects: string[]) { ${injects .map( (inject) => - `import $inject_${inject.replace(/-/gu, '_')}$ from '${inject}';` + `import $inject_${inject.replace(/[\-:]/gu, '_')}$ from '${inject}';` ) .join('\n')} const $_injects_$ = {${injects - .map((inject) => `${inject.replace(/-/gu, '_')}:$inject_${inject}$`) + .map((inject) => `"${inject}":$inject_${inject.replace(/[\-:]/gu, '_')}$`) .join(',\n')}}; function require(module, ...args) { return $_injects_$[module] || {} diff --git a/docs/.vitepress/build-system/shim/globby.mjs b/docs/.vitepress/build-system/shim/empty.mjs similarity index 100% rename from docs/.vitepress/build-system/shim/globby.mjs rename to docs/.vitepress/build-system/shim/empty.mjs diff --git a/docs/.vitepress/build-system/shim/eslint/use-at-your-own-risk.mjs b/docs/.vitepress/build-system/shim/eslint/use-at-your-own-risk.mjs deleted file mode 100644 index 0db0b01c2..000000000 --- a/docs/.vitepress/build-system/shim/eslint/use-at-your-own-risk.mjs +++ /dev/null @@ -1,3 +0,0 @@ -export default { - /* empty */ -} diff --git a/docs/.vitepress/build-system/shim/esquery.mjs b/docs/.vitepress/build-system/shim/esquery.mjs deleted file mode 100644 index 5652b09f1..000000000 --- a/docs/.vitepress/build-system/shim/esquery.mjs +++ /dev/null @@ -1,5 +0,0 @@ -import esquery from '../../../../node_modules/esquery/dist/esquery.esm.js' - -export const { parse, match, traverse, matches, query } = esquery - -export { default } from '../../../../node_modules/esquery/dist/esquery.esm.js' diff --git a/docs/.vitepress/build-system/shim/path.mjs b/docs/.vitepress/build-system/shim/path.mjs deleted file mode 100644 index 544792b00..000000000 --- a/docs/.vitepress/build-system/shim/path.mjs +++ /dev/null @@ -1,38 +0,0 @@ -// @ts-nocheck -export const sep = '/' -export function basename(path, ext) { - const b = (/[^\/]*$/u.exec(path) || [''])[0] - return ext && b.endsWith(ext) ? b.slice(0, -ext.length) : b -} -export function extname(path) { - return (/[^.\/]*$/u.exec(path) || [''])[0] -} -export function isAbsolute() { - return false -} -export function join(...args) { - return args.length > 0 ? normalize(args.join('/')) : '.' -} - -function normalize(path) { - const result = [] - for (const part of path.replace(/\/+/gu, '/').split('/')) { - if (part === '..') { - if (result[0] && result[0] !== '..' && result[0] !== '.') result.shift() - } else if (part === '.' && result.length > 0) { - // noop - } else { - result.unshift(part) - } - } - return result.reverse().join('/') -} -const posix = { - sep, - basename, - extname, - isAbsolute, - join -} -posix.posix = posix -export default posix diff --git a/docs/.vitepress/build-system/src/eslint.mjs b/docs/.vitepress/build-system/src/eslint.mjs deleted file mode 100644 index ed193b58b..000000000 --- a/docs/.vitepress/build-system/src/eslint.mjs +++ /dev/null @@ -1,8 +0,0 @@ -// @ts-nocheck -/* eslint-disable unicorn/prefer-export-from -- exporting as named and default is less duplication without `export…from` */ - -import { Linter } from '../../../../node_modules/eslint/lib/linter/linter.js' -import SourceCode from '../../../../node_modules/eslint/lib/source-code/source-code.js' - -export { Linter, SourceCode } -export default { Linter, SourceCode } diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index afa635d7e..eaad761e2 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -3,6 +3,7 @@ import { defineConfig } from 'vitepress' import path from 'pathe' import { fileURLToPath } from 'url' import { viteCommonjs, vitePluginRequireResolve } from './vite-plugin.mjs' +import eslint4b, { requireESLintUseAtYourOwnRisk4b } from 'vite-plugin-eslint4b' // Pre-build cjs packages that cannot be bundled well. import './build-system/build.mjs' @@ -142,24 +143,32 @@ export default async () => { vite: { publicDir: path.resolve(dirname, './public'), - plugins: [vitePluginRequireResolve(), viteCommonjs()], + plugins: [ + vitePluginRequireResolve(), + viteCommonjs(), + eslint4b() as any, + requireESLintUseAtYourOwnRisk4b() + ], resolve: { alias: { - 'eslint/use-at-your-own-risk': path.join( + 'vue-eslint-parser': path.join( + dirname, + './build-system/shim/vue-eslint-parser.mjs' + ), + '@typescript-eslint/parser': path.join( dirname, - './build-system/shim/eslint/use-at-your-own-risk.mjs' + './build-system/shim/@typescript-eslint/parser.mjs' ), - eslint: path.join(dirname, './build-system/shim/eslint.mjs'), - assert: path.join(dirname, './build-system/shim/assert.mjs'), - path: path.join(dirname, './build-system/shim/path.mjs'), tslib: path.join(dirname, '../../node_modules/tslib/tslib.es6.js'), - esquery: path.join(dirname, './build-system/shim/esquery.mjs'), - globby: path.join(dirname, './build-system/shim/globby.mjs') + globby: path.join(dirname, './build-system/shim/empty.mjs'), + 'fast-glob': path.join(dirname, './build-system/shim/empty.mjs'), + 'node:fs': 'fs', + 'node:path': 'path', + 'node:util': 'util' } }, define: { - 'process.env.NODE_DEBUG': 'false', 'require.cache': '{}' } }, diff --git a/docs/.vitepress/theme/components/eslint-code-block.vue b/docs/.vitepress/theme/components/eslint-code-block.vue index 77d4fd7cf..12cd1ff8b 100644 --- a/docs/.vitepress/theme/components/eslint-code-block.vue +++ b/docs/.vitepress/theme/components/eslint-code-block.vue @@ -8,8 +8,6 @@ class="eslint-code-block" :filename="filename" :language="language" - :preprocess="preprocess" - :postprocess="postprocess" dark :format="format" :fix="fix" @@ -20,8 +18,6 @@