Skip to content

Commit 3ca0230

Browse files
authored
refactor: upgrade eslint and fix lint and type errors (#1600)
1 parent f88106f commit 3ca0230

File tree

179 files changed

+2193
-2715
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+2193
-2715
lines changed

.eslintignore

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

.eslintrc.cjs

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

commitlint.config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ const getSubDirectories = (dir: string): string[] =>
66
fs
77
.readdirSync(dir)
88
.filter((item) => fs.statSync(path.join(dir, item)).isDirectory())
9-
const packages = getSubDirectories(path.resolve(__dirname, 'packages'))
9+
10+
const PACKAGES = getSubDirectories(path.resolve(__dirname, 'packages'))
1011

1112
export default {
1213
extends: ['@commitlint/config-conventional'],
1314
rules: {
14-
'scope-enum': [2, 'always', [...packages, 'e2e']],
15+
'scope-enum': [2, 'always', [...PACKAGES, 'e2e']],
1516
'footer-max-line-length': [0],
1617
},
1718
} satisfies UserConfig
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
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(
8-
__dirname,
9-
'./nonDefaultExportClientConfig.js',
10-
),
7+
clientConfigFile: path.resolve(DIRNAME, './nonDefaultExportClientConfig.js'),
118
}

e2e/docs/.vuepress/theme/client/config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,22 @@ import NotFound from './layouts/NotFound.vue'
88
import './styles/index.scss'
99

1010
export default defineClientConfig({
11-
enhance({ app, router }) {
11+
enhance() {
1212
// ...
1313
},
1414

1515
setup() {
1616
// ...
1717
},
1818

19+
/* eslint-disable @typescript-eslint/no-unsafe-assignment -- vue sfc type info is not available in eslint scope */
1920
layouts: {
2021
CssModulesLayout,
2122
CustomLayout,
2223
Layout,
2324
NotFound,
2425
},
26+
/* eslint-enable @typescript-eslint/no-unsafe-assignment */
2527

2628
rootComponents: [RootComponentFromTheme],
2729
})

e2e/docs/.vuepress/theme/client/layouts/Layout.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ const siteData = useSiteData()
2121
</div>
2222
</template>
2323

24-
<style lang="scss" scoped></style>
24+
<style lang="scss" scoped>
25+
// ...
26+
</style>
Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
1-
import type { Page, Theme } from 'vuepress/core'
1+
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

6-
export const e2eTheme = (): Theme => {
7-
return {
8-
name: '@vuepress/theme-e2e',
6+
export const e2eTheme = (): Theme => ({
7+
name: '@vuepress/theme-e2e',
98

10-
alias: {
11-
// ...
12-
},
9+
alias: {
10+
// ...
11+
},
1312

14-
define: {
15-
// ...
16-
},
13+
define: {
14+
// ...
15+
},
1716

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

20-
extendsPage: (page: Page) => {
21-
// ...
22-
},
19+
extendsPage: () => {
20+
// ...
21+
},
2322

24-
plugins: [],
25-
}
26-
}
23+
plugins: [],
24+
})
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
declare const str: string
2-
export default str
1+
declare const STR: string
2+
export default STR

e2e/playwright.config.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { defineConfig, devices } from '@playwright/test'
2-
import { BASE, BUNDLER, isCI, isDev } from './utils/env'
2+
import { BASE, BUNDLER, IS_CI, IS_DEV } from './utils/env'
33

4-
const commandPart1 = isDev ? 'docs:dev' : 'docs:build'
5-
const commandPart2 = BUNDLER === 'vite' ? '' : `-${BUNDLER}`
6-
const commandPart3 = isDev ? '' : ' && pnpm docs:serve'
4+
const COMMAND_PART1 = IS_DEV ? 'docs:dev' : 'docs:build'
5+
const COMMAND_PART2 = BUNDLER === 'vite' ? '' : `-${BUNDLER}`
6+
const COMMAND_PART3 = IS_DEV ? '' : ' && pnpm docs:serve'
77

88
export default defineConfig({
99
testDir: 'tests',
10-
forbidOnly: isCI,
11-
reporter: isCI ? 'github' : 'line',
12-
retries: isCI ? 2 : 0,
13-
workers: isDev ? 1 : undefined,
10+
forbidOnly: IS_CI,
11+
reporter: IS_CI ? 'github' : 'line',
12+
retries: IS_CI ? 2 : 0,
13+
workers: IS_DEV ? 1 : undefined,
1414
projects: [
1515
{
1616
name: 'chromium',
@@ -22,8 +22,8 @@ export default defineConfig({
2222
trace: 'on-first-retry',
2323
},
2424
webServer: {
25-
command: `pnpm docs:clean && pnpm ${commandPart1}${commandPart2}${commandPart3}`,
25+
command: `pnpm docs:clean && pnpm ${COMMAND_PART1}${COMMAND_PART2}${COMMAND_PART3}`,
2626
url: 'http://127.0.0.1:9080',
27-
reuseExistingServer: !isCI,
27+
reuseExistingServer: !IS_CI,
2828
},
2929
})

e2e/tests/hmr.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect, test } from '@playwright/test'
2-
import { isDev } from '../utils/env'
2+
import { IS_DEV } from '../utils/env'
33
import { readSourceMarkdown, writeSourceMarkdown } from '../utils/source'
44

55
const hmrUpdateTitle = async (): Promise<void> => {
@@ -33,7 +33,7 @@ const hmrRestore = async (): Promise<void> => {
3333
)
3434
}
3535

36-
if (isDev) {
36+
if (IS_DEV) {
3737
test.beforeEach(async () => {
3838
await hmrRestore()
3939
})

0 commit comments

Comments
 (0)