Skip to content

Commit c50d399

Browse files
committed
style: fix lint errors
1 parent f204afd commit c50d399

File tree

22 files changed

+116
-132
lines changed

22 files changed

+116
-132
lines changed

docs/.vuepress/components/NpmBadge.vue

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<script setup lang="ts">
22
import { computed } from 'vue'
33
4-
const props = defineProps({
5-
package: {
6-
type: String,
7-
required: true,
4+
const props = withDefaults(
5+
defineProps<{
6+
/** package name */
7+
package: string
8+
/** dist-tag to use */
9+
distTag?: string
10+
}>(),
11+
{
12+
distTag: 'next',
813
},
9-
distTag: {
10-
type: String,
11-
required: false,
12-
default: 'next',
13-
},
14-
})
14+
)
1515
1616
const badgeLink = computed(
1717
() => `https://www.npmjs.com/package/${props.package}`,

docs/.vuepress/configs/head.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { HeadConfig } from 'vuepress/core'
22

3+
// eslint-disable-next-line @typescript-eslint/naming-convention
34
export const head: HeadConfig[] = [
45
[
56
'link',

docs/.vuepress/configs/meta.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { fs } from 'vuepress/utils'
33

44
const require = createRequire(import.meta.url)
55

6-
export const version = fs.readJsonSync(
7-
require.resolve('vuepress/package.json'),
6+
export const VERSION = (
7+
fs.readJsonSync(require.resolve('vuepress/package.json')) as {
8+
version: string
9+
}
810
).version

docs/.vuepress/configs/navbar/en.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { NavbarConfig } from '@vuepress/theme-default'
2-
import { version } from '../meta.js'
1+
import type { NavbarOptions } from '@vuepress/theme-default'
2+
import { VERSION } from '../meta.js'
33

4-
export const navbarEn: NavbarConfig = [
4+
export const navbarEn: NavbarOptions = [
55
{
66
text: 'Guide',
77
children: [
@@ -97,7 +97,7 @@ export const navbarEn: NavbarConfig = [
9797
],
9898
},
9999
{
100-
text: `v${version}`,
100+
text: `v${VERSION}`,
101101
children: [
102102
{
103103
text: 'Changelog',
@@ -113,4 +113,5 @@ export const navbarEn: NavbarConfig = [
113113
},
114114
],
115115
},
116-
]
116+
// TODO: remove the type assertion
117+
] as NavbarOptions

docs/.vuepress/configs/navbar/zh.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { NavbarConfig } from '@vuepress/theme-default'
2-
import { version } from '../meta.js'
1+
import type { NavbarOptions } from '@vuepress/theme-default'
2+
import { VERSION } from '../meta.js'
33

4-
export const navbarZh: NavbarConfig = [
4+
export const navbarZh: NavbarOptions = [
55
{
66
text: '指南',
77
children: [
@@ -93,7 +93,7 @@ export const navbarZh: NavbarConfig = [
9393
],
9494
},
9595
{
96-
text: `v${version}`,
96+
text: `v${VERSION}`,
9797
children: [
9898
{
9999
text: '更新日志',
@@ -109,4 +109,5 @@ export const navbarZh: NavbarConfig = [
109109
},
110110
],
111111
},
112-
]
112+
// TODO: remove the type assertion
113+
] as NavbarOptions

docs/.vuepress/configs/sidebar/en.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { SidebarConfig } from '@vuepress/theme-default'
1+
import type { SidebarOptions } from '@vuepress/theme-default'
22

3-
export const sidebarEn: SidebarConfig = {
3+
export const sidebarEn: SidebarOptions = {
44
'/guide/': [
55
{
66
text: 'Guide',

docs/.vuepress/configs/sidebar/zh.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { SidebarConfig } from '@vuepress/theme-default'
1+
import type { SidebarOptions } from '@vuepress/theme-default'
22

3-
export const sidebarZh: SidebarConfig = {
3+
export const sidebarZh: SidebarOptions = {
44
'/zh/guide/': [
55
{
66
text: '指南',

docs/advanced/cookbook/making-a-theme-extendable.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,14 @@ import { getDirname } from 'vuepress/utils'
3434

3535
const __dirname = getDirname(import.meta.url)
3636

37-
export const fooTheme = (options): Theme => {
38-
return {
39-
name: 'vuepress-theme-foo',
40-
alias: {
41-
// set alias for replaceable components
42-
'@theme/Navbar.vue': path.resolve(__dirname, 'components/Navbar.vue'),
43-
'@theme/Sidebar.vue': path.resolve(__dirname, 'components/Sidebar.vue'),
44-
},
45-
}
46-
}
37+
export const fooTheme = (options): Theme => ({
38+
name: 'vuepress-theme-foo',
39+
alias: {
40+
// set alias for replaceable components
41+
'@theme/Navbar.vue': path.resolve(__dirname, 'components/Navbar.vue'),
42+
'@theme/Sidebar.vue': path.resolve(__dirname, 'components/Sidebar.vue'),
43+
},
44+
})
4745
```
4846

4947
Next, use those components via aliases in your theme:

docs/advanced/cookbook/usage-of-client-config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ In the `setup` function, the [`__VUEPRESS_SSR__`](../../reference/client-api.md#
130130
Another way to use non-ssr-friendly features is to put them inside the [onMounted](https://vuejs.org/api/composition-api-lifecycle.html#onmounted) hook:
131131

132132
```ts
133-
import { defineClientConfig } from 'vuepress/client'
134133
import { onMounted } from 'vue'
134+
import { defineClientConfig } from 'vuepress/client'
135135

136136
export default defineClientConfig({
137137
setup() {

docs/advanced/plugin.md

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,24 @@ const fooPlugin = {
1818
A plugin could also be a function that receives the [app instance](../reference/node-api.md#app) as the param and returns a _Plugin Object_, which is called a _Plugin Function_:
1919

2020
```ts
21-
const barPlugin = (app) => {
22-
return {
23-
name: 'vuepress-plugin-bar',
24-
// ...
25-
}
26-
}
21+
const barPlugin = (app) => ({
22+
name: 'vuepress-plugin-bar',
23+
// ...
24+
})
2725
```
2826

2927
A plugin usually needs to allow user options, so we typically provide users with a function to receive options, and returns a _Plugin Object_ or a _Plugin Function_. Then your plugin should be converted like this:
3028

3129
```ts
32-
const fooPlugin = (options) => {
33-
return {
34-
name: 'vuepress-plugin-foo',
35-
// ...
36-
}
37-
}
30+
const fooPlugin = (options) => ({
31+
name: 'vuepress-plugin-foo',
32+
// ...
33+
})
3834

39-
const barPlugin = (options) => {
40-
return (app) => {
41-
return {
42-
name: 'vuepress-plugin-bar',
43-
// ...
44-
}
45-
}
46-
}
35+
const barPlugin = (options) => (app) => ({
36+
name: 'vuepress-plugin-bar',
37+
// ...
38+
})
4739
```
4840

4941
## Publish to NPM

0 commit comments

Comments
 (0)