Skip to content

Commit 85af10b

Browse files
committed
refactor: migrate to eslint.config.ts and format code
1 parent 6ff4424 commit 85af10b

File tree

14 files changed

+78
-77
lines changed

14 files changed

+78
-77
lines changed

.vscode/settings.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
"[markdown]": {
1111
"files.trimTrailingWhitespace": false
1212
},
13-
"typescript.tsdk": "node_modules/typescript/lib",
13+
"eslint.options": {
14+
"flags": ["unstable_ts_config"]
15+
},
1416
"eslint.validate": [
1517
"javascript",
1618
"javascriptreact",
@@ -41,5 +43,6 @@
4143
"vuepress",
4244
"vueuse",
4345
"zoomable"
44-
]
46+
],
47+
"typescript.tsdk": "node_modules/typescript/lib"
4548
}

commitlint.config.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
import * as fs from 'node:fs'
2-
import * as path from 'node:path'
31
import type { UserConfig } from '@commitlint/types'
4-
5-
const getSubDirectories = (dir: string): string[] =>
6-
fs
7-
.readdirSync(dir)
8-
.filter((item) => fs.statSync(path.join(dir, item)).isDirectory())
9-
10-
const PACKAGES = getSubDirectories(path.resolve(__dirname, 'packages'))
2+
import { PACKAGES } from './scripts/constants.js'
113

124
export default {
135
extends: ['@commitlint/config-conventional'],
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import { getDirname, path } from 'vuepress/utils'
22

3-
const DIRNAME = getDirname(import.meta.url)
3+
const __dirname = getDirname(import.meta.url)
44

55
export const fooPlugin = {
66
name: 'test-plugin',
7-
clientConfigFile: path.resolve(DIRNAME, './nonDefaultExportClientConfig.js'),
7+
clientConfigFile: path.resolve(
8+
__dirname,
9+
'./nonDefaultExportClientConfig.js',
10+
),
811
}

e2e/docs/.vuepress/theme/node/e2eTheme.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Theme } from 'vuepress/core'
22
import { getDirname, path } from 'vuepress/utils'
33

4-
const DIRNAME = getDirname(import.meta.url)
4+
const __dirname = getDirname(import.meta.url)
55

66
export const e2eTheme = (): Theme => ({
77
name: '@vuepress/theme-e2e',
@@ -14,7 +14,7 @@ export const e2eTheme = (): Theme => ({
1414
// ...
1515
},
1616

17-
clientConfigFile: path.resolve(DIRNAME, '../client/config.ts'),
17+
clientConfigFile: path.resolve(__dirname, '../client/config.ts'),
1818

1919
extendsPage: () => {
2020
// ...

e2e/utils/source.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { fs, getDirname, path } from 'vuepress/utils'
22

3-
const DIRNAME = getDirname(import.meta.url)
3+
const __dirname = getDirname(import.meta.url)
44

55
const resolveSourceMarkdownPath = (...args: string[]): string =>
6-
path.resolve(DIRNAME, '../docs', ...args)
6+
path.resolve(__dirname, '../docs', ...args)
77

88
export const readSourceMarkdown = async (filePath: string): Promise<string> =>
99
fs.readFile(resolveSourceMarkdownPath(filePath), 'utf-8')

eslint.config.js

Lines changed: 0 additions & 41 deletions
This file was deleted.

eslint.config.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import path from 'node:path'
2+
import { vuepress } from 'eslint-config-vuepress'
3+
import { PACKAGES, ROOT } from './scripts/constants.js'
4+
5+
export default vuepress(
6+
{
7+
imports: {
8+
packageDir: [
9+
ROOT,
10+
path.resolve(ROOT, 'e2e'),
11+
...PACKAGES.map((item) => path.resolve(ROOT, `packages/${item}`)),
12+
],
13+
},
14+
javascript: {
15+
overrides: {
16+
'no-underscore-dangle': [
17+
'warn',
18+
{
19+
allow: [
20+
'__dirname',
21+
'_context',
22+
'_pageChunk',
23+
'_registeredComponents',
24+
],
25+
},
26+
],
27+
},
28+
},
29+
vue: {
30+
overrides: {
31+
'no-useless-assignment': 'off', // TODO: false positive in vue sfc
32+
},
33+
},
34+
},
35+
{
36+
files: ['**/tests/**'],
37+
rules: {
38+
'import/no-unresolved': 'off',
39+
'no-console': 'off',
40+
'prefer-template': 'off',
41+
},
42+
},
43+
)

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"check-types": "vue-tsc --noEmit",
99
"clean": "pnpm --parallel --stream clean",
1010
"format": "prettier --write .",
11-
"lint": "eslint . && prettier --check .",
12-
"lint:fix": "eslint --fix . && prettier --write .",
11+
"lint": "eslint --flag unstable_ts_config . && prettier --check .",
12+
"lint:fix": "eslint --flag unstable_ts_config --fix . && prettier --write .",
1313
"prepare": "husky",
1414
"release": "pnpm release:check && pnpm release:version && pnpm release:publish",
1515
"release:changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
@@ -24,7 +24,7 @@
2424
"lint-staged": {
2525
"*.!(cjs|js|ts|vue)": "prettier --write --ignore-unknown",
2626
"*.(cjs|js|ts|vue)": [
27-
"eslint --fix",
27+
"eslint --flag unstable_ts_config --fix",
2828
"prettier --write"
2929
],
3030
"package.json": "sort-package-json"
@@ -42,6 +42,7 @@
4242
"eslint": "^9.9.0",
4343
"eslint-config-vuepress": "^5.1.4",
4444
"husky": "^9.1.4",
45+
"jiti": "^1.21.6",
4546
"lint-staged": "^15.2.9",
4647
"prettier": "^3.3.3",
4748
"prettier-config-vuepress": "^5.0.0",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { ClientConfig } from '../clientConfig.js'
22

33
declare module '@internal/clientConfigs' {
4+
// eslint-disable-next-line @typescript-eslint/naming-convention
45
export const clientConfigs: ClientConfig[]
56
}

packages/shared/tests/routes/resolveLocalePath.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect, it } from 'vitest'
22
import type { LocaleConfig } from '../../src/index.js'
33
import { resolveLocalePath } from '../../src/index.js'
44

5-
const locales: LocaleConfig = {
5+
const LOCALES: LocaleConfig = {
66
'/': {
77
lang: 'en-US',
88
},
@@ -29,6 +29,6 @@ const TEST_CASES: [string, string][] = [
2929

3030
TEST_CASES.forEach(([routePath, expected]) => {
3131
it(routePath, () => {
32-
expect(resolveLocalePath(locales, routePath)).toEqual(expected)
32+
expect(resolveLocalePath(LOCALES, routePath)).toEqual(expected)
3333
})
3434
})

0 commit comments

Comments
 (0)