-
Notifications
You must be signed in to change notification settings - Fork 43
/
eslint.config.js
145 lines (142 loc) · 4.22 KB
/
eslint.config.js
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
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { vuepress } from 'eslint-config-vuepress'
const ROOT = path.resolve(fileURLToPath(import.meta.url), '..')
const DOCS_DIR = path.resolve(ROOT, 'docs')
const E2E_DIR = path.resolve(ROOT, 'e2e')
const PLUGINS_DIRS = fs
.readdirSync(path.resolve(ROOT, 'plugins'))
.filter((category) =>
fs.statSync(path.resolve(ROOT, `./plugins/${category}`)).isDirectory(),
)
.flatMap((category) =>
fs
.readdirSync(path.resolve(ROOT, `./plugins/${category}`))
.map((plugin) => path.resolve(ROOT, `./plugins/${category}/${plugin}`)),
)
const THEMES_DIRS = fs
.readdirSync(path.resolve(ROOT, 'themes'))
.map((item) => path.resolve(ROOT, `./themes/${item}`))
const TOOLS_DIRS = fs
.readdirSync(path.resolve(ROOT, 'tools'))
.map((item) => path.resolve(ROOT, `./tools/${item}`))
export default vuepress(
{
ignores: ['**/lib/**', '**/template/**'],
imports: {
packageDir: [
ROOT,
DOCS_DIR,
E2E_DIR,
...PLUGINS_DIRS,
...THEMES_DIRS,
...TOOLS_DIRS,
],
},
typescript: {
overrides: {
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/naming-convention': [
'warn',
{
selector: 'default',
format: ['camelCase'],
leadingUnderscore: 'allowSingleOrDouble',
trailingUnderscore: 'allow',
},
// allow global variables like __VUEPRESS_DEV__
{
selector: ['variable'],
filter: '^__.*__$',
format: ['UPPER_CASE'],
leadingUnderscore: 'requireDouble',
trailingUnderscore: 'requireDouble',
},
{
selector: ['variable'],
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
leadingUnderscore: 'allowSingleOrDouble',
trailingUnderscore: 'allowSingleOrDouble',
},
// stop checking object literal properties type properties
// the format can be `og:title` `line-width` `__raw` `__VUEPRESS_DEV` `++` ...
{
selector: ['objectLiteralProperty', 'typeProperty'],
format: null,
},
// allow slots like `navbar-start`
{
selector: ['typeMethod'],
filter: '^[a-z]+(?:-[a-z]+)*?$',
format: null,
},
{
selector: ['property'],
format: ['camelCase', 'PascalCase'],
},
{
selector: ['parameter'],
format: ['camelCase', 'PascalCase'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
},
{
selector: 'import',
format: ['PascalCase', 'camelCase'],
},
{
selector: 'typeLike',
format: ['PascalCase'],
},
{
selector: 'enumMember',
format: ['PascalCase'],
},
],
'@typescript-eslint/no-dynamic-delete': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/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',
},
],
},
],
'@typescript-eslint/promise-function-async': 'off',
'no-underscore-dangle': 'off',
'no-labels': 'off',
},
},
vue: {
overrides: {
// TODO: false positive in vue sfc
'no-useless-assignment': 'off',
'vue/multi-word-component-names': [
'error',
{ ignores: ['Badge', 'Layout'] },
],
'vue/static-class-names-order': 'off',
},
},
},
{
files: ['**/tests/**'],
rules: {
'import/no-unresolved': 'off',
'no-console': 'off',
},
},
)