Skip to content

Commit 1eeb0d1

Browse files
committed
Inspect the documentation using lint rules from the upstream repository.
1 parent 846783a commit 1eeb0d1

File tree

8 files changed

+146
-32
lines changed

8 files changed

+146
-32
lines changed

advanced/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ interface GlobReturn {
306306
*/
307307
testFiles: string[]
308308
/**
309-
* 与筛选器匹配的类型检查测试文件。除非 `typecheck.enabled` 为 `true`,否则将为空。
309+
* 与筛选器匹配的类型检查测试文件。除非 `typecheck.enabled` 为 `true`,否则将为空。
310310
*/
311311
typecheckTestFiles: string[]
312312
}

api/expect-typeof.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ This matcher only works with plain object types. It will fail for union types an
9191
```ts
9292
import { expectTypeOf } from 'vitest'
9393

94-
type ResponsiveProp<T> = T | T[] | { xs?: T, sm?: T, md?: T }
94+
type ResponsiveProp<T> = T | T[] | { xs?: T; sm?: T; md?: T }
9595

9696
interface CSSProperties {
9797
margin?: string
@@ -107,10 +107,10 @@ const cssProperties: CSSProperties = { margin: '1px', padding: '2px' }
107107
expectTypeOf(getResponsiveProp(cssProperties))
108108
.extract<{ xs?: any }>() // extracts the last type from a union
109109
.toEqualTypeOf<{
110-
xs?: CSSProperties
111-
sm?: CSSProperties
112-
md?: CSSProperties
113-
}>()
110+
xs?: CSSProperties
111+
sm?: CSSProperties
112+
md?: CSSProperties
113+
}>()
114114

115115
expectTypeOf(getResponsiveProp(cssProperties))
116116
.extract<unknown[]>() // extracts an array from a union

api/expect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ test('expect.soft test', () => {
105105

106106
```ts
107107
interface ExpectPoll extends ExpectStatic {
108-
(actual: () => T, options?: { interval?: number, timeout?: number, message?: string }): Promise<Assertions<T>>
108+
(actual: () => T, options?: { interval?: number; timeout?: number; message?: string }): Promise<Assertions<T>>
109109
}
110110
```
111111

config/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,7 @@ Vitest 会将所有文件,包括那些被 glob 模式覆盖的文件,计入
14851485
{
14861486
coverage: {
14871487
thresholds: {
1488-
// 所有文件的阈值
1488+
// 所有文件的阈值
14891489
functions: 95,
14901490
branches: 70,
14911491

eslint.config.js

Lines changed: 137 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,138 @@
1-
import antfu from '@antfu/eslint-config'
1+
import antfu, { GLOB_SRC } from '@antfu/eslint-config'
22

3-
export default antfu({
4-
stylistic: true,
5-
typescript: true,
6-
vue: true,
7-
jsonc: false,
8-
yaml: false,
9-
ignores: [
10-
'dist',
11-
'node_modules',
12-
'*.svelte',
13-
'*.snap',
14-
'*.d.ts',
15-
'coverage',
16-
'!.vitepress',
17-
],
18-
rules: {
19-
'no-restricted-globals': 'off',
20-
'no-empty-pattern': 'off',
21-
},
22-
})
3+
export default antfu(
4+
{
5+
vue: true,
6+
// Disable tests rules because we need to test with various setup
7+
test: false,
8+
// This replaces the old `.gitignore`
9+
ignores: [
10+
'**/coverage',
11+
'**/*.snap',
12+
'**/bench.json',
13+
'**/fixtures',
14+
'**/assets/**',
15+
'**/*.d.ts',
16+
'**/*.timestamp-*',
17+
'test/core/src/self',
18+
'test/core/test/mocking/already-hoisted.test.ts',
19+
'test/cache/cache/.vitest-base/results.json',
20+
'test/core/src/wasm/wasm-bindgen-no-cyclic',
21+
'test/workspaces/results.json',
22+
'test/workspaces-browser/results.json',
23+
'test/reporters/fixtures/with-syntax-error.test.js',
24+
'test/network-imports/public/slash@3.0.0.js',
25+
'test/coverage-test/src/transpiled.js',
26+
'test/coverage-test/src/original.ts',
27+
'test/cli/deps/error/*',
28+
'examples/**/mockServiceWorker.js',
29+
'examples/sveltekit/.svelte-kit',
30+
'packages/browser/**/esm-client-injector.js',
31+
// contains technically invalid code to display pretty diff
32+
'docs/guide/snapshot.md',
33+
// uses invalid js example
34+
'docs/advanced/api/import-example.md',
35+
'docs/guide/examples/*.md',
36+
],
37+
},
38+
{
39+
rules: {
40+
// prefer global Buffer to not initialize the whole module
41+
'node/prefer-global/buffer': 'off',
42+
'node/prefer-global/process': 'off',
43+
'no-empty-pattern': 'off',
44+
'antfu/indent-binary-ops': 'off',
45+
'unused-imports/no-unused-imports': 'error',
46+
'style/member-delimiter-style': [
47+
'error',
48+
{
49+
multiline: { delimiter: 'none' },
50+
singleline: { delimiter: 'semi' },
51+
},
52+
],
53+
// let TypeScript handle this
54+
'no-undef': 'off',
55+
'ts/no-invalid-this': 'off',
56+
'eslint-comments/no-unlimited-disable': 'off',
57+
'curly': ['error', 'all'],
58+
59+
// TODO: migrate and turn it back on
60+
'ts/ban-types': 'off',
61+
'ts/no-unsafe-function-type': 'off',
62+
63+
'no-restricted-imports': [
64+
'error',
65+
{
66+
paths: ['path'],
67+
},
68+
],
69+
70+
'import/no-named-as-default': 'off',
71+
},
72+
},
73+
{
74+
files: [`packages/*/*.{js,mjs,d.ts}`],
75+
rules: {
76+
'antfu/no-import-dist': 'off',
77+
},
78+
},
79+
{
80+
files: [`packages/${GLOB_SRC}`],
81+
rules: {
82+
'no-restricted-imports': [
83+
'error',
84+
{
85+
paths: ['vitest', 'path', 'vitest/node'],
86+
},
87+
],
88+
},
89+
},
90+
{
91+
// these files define vitest as peer dependency
92+
files: [`packages/{coverage-*,ui,browser,web-worker,browser-*}/${GLOB_SRC}`],
93+
rules: {
94+
'no-restricted-imports': [
95+
'error',
96+
{
97+
paths: ['path'],
98+
},
99+
],
100+
},
101+
},
102+
{
103+
files: [
104+
`docs/${GLOB_SRC}`,
105+
`**/*.md`,
106+
`**/*.md/${GLOB_SRC}`,
107+
],
108+
rules: {
109+
'perfectionist/sort-imports': 'off',
110+
'style/max-statements-per-line': 'off',
111+
'import/newline-after-import': 'off',
112+
'import/first': 'off',
113+
'unused-imports/no-unused-imports': 'off',
114+
'ts/method-signature-style': 'off',
115+
'no-self-compare': 'off',
116+
'import/no-mutable-exports': 'off',
117+
},
118+
},
119+
{
120+
files: [
121+
`docs/${GLOB_SRC}`,
122+
`packages/web-worker/${GLOB_SRC}`,
123+
`test/core/${GLOB_SRC}`,
124+
],
125+
rules: {
126+
'no-restricted-globals': 'off',
127+
},
128+
},
129+
{
130+
files: [
131+
`test/${GLOB_SRC}`,
132+
],
133+
rules: {
134+
'antfu/no-top-level-await': 'off',
135+
'unicorn/consistent-function-scoping': 'off',
136+
},
137+
},
138+
)

guide/browser/assertion-api.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,6 @@ function toMatchScreenshot(
10191019

10201020
该断言通过将元素或整页的截图与预先保存的基准图像进行比对,实现视觉回归测试。
10211021

1022-
10231022
若差异超出设定阈值,测试即告失败。为便于定位变更,断言会自动生成:
10241023

10251024
- 测试过程中的实际截图

guide/browser/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ export default defineConfig({
145145
import { defineConfig } from 'vitest/config'
146146
import { playwright } from '@vitest/browser-playwright'
147147
import vue from '@vitejs/plugin-vue'
148-
import { defineConfig } from 'vitest/config'
149148

150149
export default defineConfig({
151150
plugins: [vue()],

guide/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ import { defineConfig } from 'vitest/config'
176176
export default defineConfig({
177177
test: {
178178
projects: [
179-
// 你可以使用全局模式的列表来定义你的项目
179+
// 你可以使用全局模式的列表来定义你的项目
180180
// Vitest 需要一个配置文件列表
181181
// 或有配置文件的目录
182182
'packages/*',

0 commit comments

Comments
 (0)