diff --git a/.vscode/settings.json b/.vscode/settings.json index 6113874ca8..8bbae20cf8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -10,7 +10,9 @@ "[markdown]": { "files.trimTrailingWhitespace": false }, - "typescript.tsdk": "node_modules/typescript/lib", + "eslint.options": { + "flags": ["unstable_ts_config"] + }, "eslint.validate": [ "javascript", "javascriptreact", @@ -41,5 +43,6 @@ "vuepress", "vueuse", "zoomable" - ] + ], + "typescript.tsdk": "node_modules/typescript/lib" } diff --git a/commitlint.config.ts b/commitlint.config.ts index 859187f3de..88222d886d 100644 --- a/commitlint.config.ts +++ b/commitlint.config.ts @@ -1,13 +1,5 @@ -import * as fs from 'node:fs' -import * as path from 'node:path' import type { UserConfig } from '@commitlint/types' - -const getSubDirectories = (dir: string): string[] => - fs - .readdirSync(dir) - .filter((item) => fs.statSync(path.join(dir, item)).isDirectory()) - -const PACKAGES = getSubDirectories(path.resolve(__dirname, 'packages')) +import { PACKAGES } from './scripts/constants.js' export default { extends: ['@commitlint/config-conventional'], diff --git a/e2e/docs/.vuepress/plugins/foo/fooPlugin.ts b/e2e/docs/.vuepress/plugins/foo/fooPlugin.ts index ac2c07663f..93ef0c8cff 100644 --- a/e2e/docs/.vuepress/plugins/foo/fooPlugin.ts +++ b/e2e/docs/.vuepress/plugins/foo/fooPlugin.ts @@ -1,8 +1,11 @@ import { getDirname, path } from 'vuepress/utils' -const DIRNAME = getDirname(import.meta.url) +const __dirname = getDirname(import.meta.url) export const fooPlugin = { name: 'test-plugin', - clientConfigFile: path.resolve(DIRNAME, './nonDefaultExportClientConfig.js'), + clientConfigFile: path.resolve( + __dirname, + './nonDefaultExportClientConfig.js', + ), } diff --git a/e2e/docs/.vuepress/theme/node/e2eTheme.ts b/e2e/docs/.vuepress/theme/node/e2eTheme.ts index 7d2f5d1288..9da94d50f7 100644 --- a/e2e/docs/.vuepress/theme/node/e2eTheme.ts +++ b/e2e/docs/.vuepress/theme/node/e2eTheme.ts @@ -1,7 +1,7 @@ import type { Theme } from 'vuepress/core' import { getDirname, path } from 'vuepress/utils' -const DIRNAME = getDirname(import.meta.url) +const __dirname = getDirname(import.meta.url) export const e2eTheme = (): Theme => ({ name: '@vuepress/theme-e2e', @@ -14,7 +14,7 @@ export const e2eTheme = (): Theme => ({ // ... }, - clientConfigFile: path.resolve(DIRNAME, '../client/config.ts'), + clientConfigFile: path.resolve(__dirname, '../client/config.ts'), extendsPage: () => { // ... diff --git a/e2e/utils/source.ts b/e2e/utils/source.ts index 6f07073446..2f9c2eba37 100644 --- a/e2e/utils/source.ts +++ b/e2e/utils/source.ts @@ -1,9 +1,9 @@ import { fs, getDirname, path } from 'vuepress/utils' -const DIRNAME = getDirname(import.meta.url) +const __dirname = getDirname(import.meta.url) const resolveSourceMarkdownPath = (...args: string[]): string => - path.resolve(DIRNAME, '../docs', ...args) + path.resolve(__dirname, '../docs', ...args) export const readSourceMarkdown = async (filePath: string): Promise => fs.readFile(resolveSourceMarkdownPath(filePath), 'utf-8') diff --git a/eslint.config.js b/eslint.config.js deleted file mode 100644 index 955989f874..0000000000 --- a/eslint.config.js +++ /dev/null @@ -1,41 +0,0 @@ -import fs from 'node:fs' -import path from 'node:path' -import { fileURLToPath } from 'node:url' -import { vuepress } from 'eslint-config-vuepress' - -const ROOT = path.resolve(fileURLToPath(import.meta.url), '..') -const E2E_DIR = path.resolve(ROOT, 'e2e') -const PACKAGES_DIRS = fs - .readdirSync(path.resolve(ROOT, 'packages')) - .map((item) => `./packages/${item}`) - -export default vuepress( - { - imports: { - packageDir: [ROOT, E2E_DIR, ...PACKAGES_DIRS], - }, - typescript: { - overrides: { - '@typescript-eslint/no-dynamic-delete': 'off', - '@typescript-eslint/no-non-null-assertion': 'off', - 'no-underscore-dangle': [ - 'warn', - { allow: ['_context', '_pageChunk', '_registeredComponents'] }, - ], - }, - }, - vue: { - overrides: { - 'no-useless-assignment': 'off', // TODO: false positive in vue sfc - }, - }, - }, - { - files: ['**/tests/**'], - rules: { - 'import/no-unresolved': 'off', - 'no-console': 'off', - 'prefer-template': 'off', - }, - }, -) diff --git a/eslint.config.ts b/eslint.config.ts new file mode 100644 index 0000000000..fa0eed31d7 --- /dev/null +++ b/eslint.config.ts @@ -0,0 +1,43 @@ +import path from 'node:path' +import { vuepress } from 'eslint-config-vuepress' +import { PACKAGES, ROOT } from './scripts/constants.js' + +export default vuepress( + { + imports: { + packageDir: [ + ROOT, + path.resolve(ROOT, 'e2e'), + ...PACKAGES.map((item) => path.resolve(ROOT, `packages/${item}`)), + ], + }, + javascript: { + overrides: { + 'no-underscore-dangle': [ + 'warn', + { + allow: [ + '__dirname', + '_context', + '_pageChunk', + '_registeredComponents', + ], + }, + ], + }, + }, + vue: { + overrides: { + 'no-useless-assignment': 'off', // TODO: false positive in vue sfc + }, + }, + }, + { + files: ['**/tests/**'], + rules: { + 'import/no-unresolved': 'off', + 'no-console': 'off', + 'prefer-template': 'off', + }, + }, +) diff --git a/package.json b/package.json index 5b6a8419c2..36b142a566 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,8 @@ "check-types": "vue-tsc --noEmit", "clean": "pnpm --parallel --stream clean", "format": "prettier --write .", - "lint": "eslint . && prettier --check .", - "lint:fix": "eslint --fix . && prettier --write .", + "lint": "eslint --flag unstable_ts_config . && prettier --check .", + "lint:fix": "eslint --flag unstable_ts_config --fix . && prettier --write .", "prepare": "husky", "release": "pnpm release:check && pnpm release:version && pnpm release:publish", "release:changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", @@ -24,7 +24,7 @@ "lint-staged": { "*.!(cjs|js|ts|vue)": "prettier --write --ignore-unknown", "*.(cjs|js|ts|vue)": [ - "eslint --fix", + "eslint --flag unstable_ts_config --fix", "prettier --write" ], "package.json": "sort-package-json" @@ -42,6 +42,7 @@ "eslint": "^9.9.0", "eslint-config-vuepress": "^5.1.4", "husky": "^9.1.4", + "jiti": "^1.21.6", "lint-staged": "^15.2.9", "prettier": "^3.3.3", "prettier-config-vuepress": "^5.0.0", diff --git a/packages/client/src/types/internal/clientConfigs.d.ts b/packages/client/src/types/internal/clientConfigs.d.ts index 718d04cb22..c98c7420ee 100644 --- a/packages/client/src/types/internal/clientConfigs.d.ts +++ b/packages/client/src/types/internal/clientConfigs.d.ts @@ -1,5 +1,6 @@ import type { ClientConfig } from '../clientConfig.js' declare module '@internal/clientConfigs' { + // eslint-disable-next-line @typescript-eslint/naming-convention export const clientConfigs: ClientConfig[] } diff --git a/packages/shared/tests/routes/resolveLocalePath.spec.ts b/packages/shared/tests/routes/resolveLocalePath.spec.ts index 02b933aec6..c50ccb9dbf 100644 --- a/packages/shared/tests/routes/resolveLocalePath.spec.ts +++ b/packages/shared/tests/routes/resolveLocalePath.spec.ts @@ -2,7 +2,7 @@ import { expect, it } from 'vitest' import type { LocaleConfig } from '../../src/index.js' import { resolveLocalePath } from '../../src/index.js' -const locales: LocaleConfig = { +const LOCALES: LocaleConfig = { '/': { lang: 'en-US', }, @@ -29,6 +29,6 @@ const TEST_CASES: [string, string][] = [ TEST_CASES.forEach(([routePath, expected]) => { it(routePath, () => { - expect(resolveLocalePath(locales, routePath)).toEqual(expected) + expect(resolveLocalePath(LOCALES, routePath)).toEqual(expected) }) }) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 85aa963a2b..97519a2346 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41,6 +41,9 @@ importers: husky: specifier: ^9.1.4 version: 9.1.4 + jiti: + specifier: ^1.21.6 + version: 1.21.6 lint-staged: specifier: ^15.2.9 version: 15.2.9 diff --git a/scripts/constants.ts b/scripts/constants.ts new file mode 100644 index 0000000000..d27510f9d4 --- /dev/null +++ b/scripts/constants.ts @@ -0,0 +1,6 @@ +import fs from 'node:fs' +import path from 'node:path' +import { fileURLToPath } from 'node:url' + +export const ROOT = path.resolve(fileURLToPath(import.meta.url), '../..') +export const PACKAGES = fs.readdirSync(path.resolve(ROOT, 'packages')) diff --git a/tsconfig.json b/tsconfig.json index 4a0e90869a..903939176f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,6 +2,7 @@ "extends": "./tsconfig.base.json", "compilerOptions": { "baseUrl": ".", + "declaration": false, "jsx": "preserve", "paths": { "@internal/*": ["./packages/client/src/types/internal/*.d.ts"], @@ -14,8 +15,8 @@ "**/.vuepress/**/*", "e2e/**/*", "packages/**/*", - "commitlint.config.ts", - "vitest.config.ts" + "scripts/**/*", + "*.config.ts" ], "exclude": ["node_modules", ".temp", "lib", "dist"] } diff --git a/vitest.config.ts b/vitest.config.ts index 71f9ca68b4..0527a7b0fe 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -1,17 +1,6 @@ -import fs from 'node:fs' import path from 'node:path' -import { fileURLToPath } from 'node:url' import { defineConfig } from 'vitest/config' - -const getSubDirectories = (dir: string): string[] => - fs - .readdirSync(dir) - .filter((item) => fs.statSync(path.join(dir, item)).isDirectory()) - -const ROOT = path.dirname(fileURLToPath(import.meta.url)) -const PACKAGES = getSubDirectories(path.resolve(ROOT, 'packages')).filter( - (item) => item !== 'vuepress', -) +import { PACKAGES, ROOT } from './scripts/constants.js' export default defineConfig({ resolve: {