-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
195 lines (169 loc) · 4.59 KB
/
Copy patheslint.config.js
File metadata and controls
195 lines (169 loc) · 4.59 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
// eslint.config.js
import antfu from '@antfu/eslint-config'
export default antfu({
formatters: true,
// pnpm: true,
ignores: [
'**/components.d.ts',
'**/dist/**',
'**/iconFont.js',
'**/assets/**',
],
vue: {
overrides: {
// 强制执行第一个属性的位置
'vue/first-attribute-linebreak': [
'warn',
{
singleline: 'below',
multiline: 'below',
},
],
// 强制每行的最大属性数
'vue/max-attributes-per-line': [
'warn',
{
singleline: { max: 1 },
multiline: { max: 1 },
},
],
// 强制在多行元素的内容之前和之后进行换行
'vue/multiline-html-element-content-newline': [
'warn',
{
ignoreWhenEmpty: true, // 忽略空元素
allowEmptyLines: true, // 允许空行
},
],
// vue 单行元素内容换行
'vue/singleline-html-element-content-newline': [
'warn',
{
ignoreWhenNoAttributes: false,
},
],
// 要求或禁止模板中同级标签之间的换行符
'vue/padding-line-between-tags': [
'warn',
[
{
blankLine: 'always',
prev: '*',
next: '*',
},
],
],
// 强制要求每个 prop 都有一个记录它的注释
'vue/require-prop-comment': [
'warn',
{
type: 'JSDoc',
},
],
// 强制块标签换行
'vue/block-tag-newline': [
'warn',
{
singleline: 'always', // 单行标签后需要换行
multiline: 'always', // 多行标签后也需要换行
maxEmptyLines: 1, // 设置空行的最大数量为 1
},
],
},
},
typescript: {
overrides: {
// 禁止使用 alert
'no-alert': 'off',
// 禁止使用 console
'no-console': 'off',
// 强制块的括号样式一致
// 'brace-style': [
// 'warn',
// '1tbs',
// { allowSingleLine: false },
// ],
// 空行最多不能超过 3 行
// 'no-multiple-empty-lines': ['error', { max: 2 }],
// 禁止使用禁止 process
'node/prefer-global/process': 'off',
// 强制链式调用在每次调用后换行
'newline-per-chained-call': 'warn',
// 强制将对象属性放在单独的行上
'object-property-newline': 'warn',
// 强制在开括号后和闭括号前使用一致的换行符
'object-curly-newline': [
'warn',
{
ImportDeclaration: { multiline: true, minProperties: 3 },
ExportDeclaration: { multiline: true, minProperties: 1 },
ObjectExpression: 'always',
ObjectPattern: { multiline: true },
},
],
// 强制使用一致的换行风格
'curly': 'warn',
// 行注释位置
// 'line-comment-position': ['warn', { position: 'above' }],
// 强制在注释中 // 或 /* 使用一致的空行
'lines-around-comment': [
'warn',
{
beforeBlockComment: true,
beforeLineComment: true,
allowBlockStart: true,
allowObjectStart: true,
allowArrayStart: true,
ignorePattern: 'eslint|jshint|jslint|istanbul|global|exported|jscs|组件|弹窗',
},
],
// 在特定语句之前和之后添加空行
'padding-line-between-statements': [
'warn',
{
blankLine: 'always',
prev: [
'const',
'let',
'var',
'block',
'block-like',
'import',
'export',
'class',
'try',
'return',
],
next: '*',
},
],
// 强制所有的对象类型定义使用 type
'ts/consistent-type-definitions': ['warn', 'type'],
// 在注释中的 // 或 /*后面强制保持一致的间距
'spaced-comment': [
'warn',
'always',
{
markers: ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')'],
},
],
// 要求三元表达式始终使用多行格式,除了在 JSX 中忽略此规则
'style/multiline-ternary': [
'warn',
'always-multiline',
{ ignoreJSX: true },
],
// 限制每行的最大语句数
'max-statements-per-line': [
'warn',
{
max: 1,
},
],
},
},
rules: {
// '@stylistic/no-multiple-empty-lines': ['error', { max: 2 }],
'pnpm/json-enforce-catalog': 'off',
},
})