-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathoxlint.config.ts
More file actions
177 lines (168 loc) · 5.03 KB
/
Copy pathoxlint.config.ts
File metadata and controls
177 lines (168 loc) · 5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import { defineHopeConfig } from 'oxc-config-hope/oxlint'
export default defineHopeConfig(
{
ignore: ['template/', '**/tests/__fixtures__/'],
node: [
'**/src/{cli,node}/**/*.ts',
'tools/**/*.ts',
'**/.vuepress/config.ts',
'*.config.ts',
'.ncurc.cjs',
],
vue: true,
vitest: [
'plugins/*/*/tests/**/*.spec.ts',
'themes/*/tests/**/*.spec.ts',
'tools/*/tests/**/*.spec.ts',
],
playwright: true,
rules: {
// The following rules are not working properly, so they have been temporarily disabled
'vitest/consistent-test-filename': 'off',
'sort-vars': 'off',
'one-var': 'off',
'promise/always-return': 'off',
// ----------- end --------------
// complex states may be needed for some functions
'max-params': ['warn', 5],
// allow undefined usage
'no-undefined': 'off',
// define variables are preferred with UPPERCASE surrounded by underscores
'no-underscore-dangle': 'off',
// allow warning comments, like todo, fixme
'no-warning-comments': 'off',
// object assign can be performant
'prefer-object-spread': 'off',
// @recommended is used to mark recommended fields in options interfaces, which are not required but recommended to be provided
'jsdoc/check-tag-names': [
'warn',
{ definedTags: ['recommended'], typed: true },
],
// we only use this when necessary
'typescript/no-non-null-assertion': 'off',
// this can introduce false positives, as though type is required, users might not provide such
'typescript/prefer-nullish-coalescing': 'off',
// we often check other types
'typescript/strict-boolean-expressions': 'off',
// disabled due to performance consideration
'unicorn/prefer-code-point': 'off',
// globalThis is not supported in some environments, and we already handle SSR carefully
// so window is still preferred in client codes
'unicorn/prefer-global-this': 'off',
// relax max-nested restrictions
'unicorn/max-nested-calls': ['warn', { max: 5 }],
// sometimes we need to check if a defined variable is injected
'unicorn/no-typeof-undefined': 'off',
},
},
// node files
{
files: ['**/src/{cli,node}/**/*.ts'],
plugins: ['node'],
rules: {
'no-restricted-imports': [
'error',
'@vuepress/helper/client',
'vuepress/client',
],
'node/no-process-env': 'off',
},
},
// client files
{
files: ['**/src/client/**/*.{ts,vue}'],
plugins: ['vue'],
rules: {
'no-restricted-imports': [
'error',
'@vuepress/helper',
'@vuepress/helper/node',
'vuepress/core',
'vuepress/markdown',
'vuepress/utils',
],
'typescript/no-floating-promises': [
'error',
{
allowForKnownSafeCalls: [
// Avoid explicit marking void for router.push
{
from: 'package',
name: 'push',
package: 'vue-router',
},
// Avoid explicit marking void for router.replace
{
from: 'package',
name: 'replace',
package: 'vue-router',
},
],
},
],
},
},
// component files
{
files: ['**/src/client/components/**/*.{ts,vue}'],
plugins: ['vue'],
rules: {
'vue/require-default-prop': 'off',
'unicorn/max-nested-calls': 'off',
},
},
{
files: ['tools/**/*.ts'],
plugins: ['node'],
rules: {
// alow accessing env variables in tools
'node/no-process-env': 'off',
},
},
{
files: ['tools/create-vuepress/**/*.ts', 'tools/vp-update/**/*.ts'],
plugins: ['node'],
rules: {
'node/no-sync': 'off',
},
},
{
files: ['**/template/**'],
rules: {
// to simplify template code, we use some single-word component names
// 'vue/multi-word-component-names': [
// 'error',
// {
// ignores: ['Article', 'Category', 'Tag', 'Timeline'],
// },
// ],
},
},
{
files: ['**/declare.ts'],
rules: {
// export {} are needed to become a module
'unicorn/require-module-specifiers': 'off',
},
},
{
files: ['**/src/node/*Plugin.ts', '**/src/node/*Theme.ts'],
rules: {
// plugin entrypoints can be complex and have many dependencies,
// as they need to export a function that returns a VuePress plugin
'complexity': 'off',
'max-dependencies': 'off',
'max-lines-per-function': 'off',
'import/max-dependencies': 'off',
// jsdoc is not needed for plugin entrypoints, as the options are already typed
// and a VuePress plugin type is expected to be returned
'jsdoc/require-param': 'off',
'jsdoc/require-returns': 'off',
// avoid redundant return type annotations in plugin objects
'typescript/explicit-function-return-type': [
'warn',
{ allowExpressions: true },
],
},
},
)