@polymarbot/eslint-config-shared 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +18 -0
- package/index.js +602 -0
- package/package.json +28 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Linter } from 'eslint';
|
|
2
|
+
|
|
3
|
+
type Options = {
|
|
4
|
+
scopes?: {
|
|
5
|
+
js?: boolean | object;
|
|
6
|
+
ts?: boolean | object;
|
|
7
|
+
stylistic?: boolean | object;
|
|
8
|
+
json?: boolean | object;
|
|
9
|
+
markdown?: boolean | object;
|
|
10
|
+
tailwindcss?: boolean | object;
|
|
11
|
+
react?: boolean | object;
|
|
12
|
+
vue?: boolean | object;
|
|
13
|
+
};
|
|
14
|
+
ignores?: string[];
|
|
15
|
+
};
|
|
16
|
+
declare function export_default(options?: Options): Linter.Config[];
|
|
17
|
+
|
|
18
|
+
export { type Options, export_default as default };
|
package/index.js
ADDED
|
@@ -0,0 +1,602 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { defineConfig } from "eslint/config";
|
|
3
|
+
import { globalIgnores } from "eslint/config";
|
|
4
|
+
import globals from "globals";
|
|
5
|
+
|
|
6
|
+
// src/configs/javascript.ts
|
|
7
|
+
import js from "@eslint/js";
|
|
8
|
+
import typescript from "typescript-eslint";
|
|
9
|
+
function javascript_default(scopes) {
|
|
10
|
+
const extensions = [
|
|
11
|
+
"js",
|
|
12
|
+
"cjs",
|
|
13
|
+
"mjs",
|
|
14
|
+
"ts",
|
|
15
|
+
"cts",
|
|
16
|
+
"mts",
|
|
17
|
+
"html"
|
|
18
|
+
];
|
|
19
|
+
if (scopes?.react) {
|
|
20
|
+
extensions.push("jsx", "tsx");
|
|
21
|
+
}
|
|
22
|
+
if (scopes?.vue) {
|
|
23
|
+
extensions.push("vue", "jsx", "tsx");
|
|
24
|
+
}
|
|
25
|
+
let languageOptions;
|
|
26
|
+
if (scopes?.ts) {
|
|
27
|
+
languageOptions = {
|
|
28
|
+
parserOptions: { parser: typescript.parser }
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return [
|
|
32
|
+
{
|
|
33
|
+
files: [`**/*.{${extensions.join(",")}}`],
|
|
34
|
+
languageOptions,
|
|
35
|
+
extends: [
|
|
36
|
+
js.configs.recommended
|
|
37
|
+
],
|
|
38
|
+
plugins: {
|
|
39
|
+
...typeof scopes?.js === "object" ? scopes.js.plugins : {}
|
|
40
|
+
},
|
|
41
|
+
rules: {
|
|
42
|
+
"no-console": ["error", {
|
|
43
|
+
allow: [
|
|
44
|
+
"debug",
|
|
45
|
+
"error",
|
|
46
|
+
"info",
|
|
47
|
+
"table",
|
|
48
|
+
"warn"
|
|
49
|
+
]
|
|
50
|
+
}],
|
|
51
|
+
"no-undef": "error",
|
|
52
|
+
// 未定义变量是否有效的规则
|
|
53
|
+
"no-unused-vars": [
|
|
54
|
+
// 未使用的变量是否有效的规则
|
|
55
|
+
"error",
|
|
56
|
+
{
|
|
57
|
+
argsIgnorePattern: "^_",
|
|
58
|
+
varsIgnorePattern: "^_",
|
|
59
|
+
destructuredArrayIgnorePattern: "^_",
|
|
60
|
+
args: "all",
|
|
61
|
+
vars: "all",
|
|
62
|
+
ignoreRestSiblings: true,
|
|
63
|
+
ignoreClassWithStaticInitBlock: true
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"no-unused-expressions": ["error", {
|
|
67
|
+
// 未使用表达式是否有效的规则
|
|
68
|
+
allowShortCircuit: true,
|
|
69
|
+
allowTernary: true
|
|
70
|
+
}],
|
|
71
|
+
...typeof scopes?.js === "object" ? scopes.js.rules : {}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// src/configs/typescript.ts
|
|
78
|
+
import typescript2 from "typescript-eslint";
|
|
79
|
+
function typescript_default(scopes) {
|
|
80
|
+
const extensions = [
|
|
81
|
+
"ts",
|
|
82
|
+
"cts",
|
|
83
|
+
"mts"
|
|
84
|
+
];
|
|
85
|
+
if (scopes?.react) {
|
|
86
|
+
extensions.push("tsx");
|
|
87
|
+
}
|
|
88
|
+
if (scopes?.vue) {
|
|
89
|
+
extensions.push("vue", "tsx");
|
|
90
|
+
}
|
|
91
|
+
return [
|
|
92
|
+
{
|
|
93
|
+
files: [`**/*.{${extensions.join(",")}}`],
|
|
94
|
+
extends: [
|
|
95
|
+
...typescript2.configs.recommended
|
|
96
|
+
],
|
|
97
|
+
plugins: {
|
|
98
|
+
...typeof scopes?.ts === "object" ? scopes.ts.plugins : {}
|
|
99
|
+
},
|
|
100
|
+
rules: {
|
|
101
|
+
"@typescript-eslint/no-unused-vars": [
|
|
102
|
+
"error",
|
|
103
|
+
{
|
|
104
|
+
argsIgnorePattern: "^_",
|
|
105
|
+
varsIgnorePattern: "^_",
|
|
106
|
+
destructuredArrayIgnorePattern: "^_",
|
|
107
|
+
args: "all",
|
|
108
|
+
vars: "all",
|
|
109
|
+
ignoreRestSiblings: true,
|
|
110
|
+
ignoreClassWithStaticInitBlock: true
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
"@typescript-eslint/ban-ts-comment": "off",
|
|
114
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
115
|
+
"@typescript-eslint/no-unused-expressions": "off",
|
|
116
|
+
...typeof scopes?.ts === "object" ? scopes.ts.rules : {}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// src/configs/stylistic.ts
|
|
123
|
+
import stylistic from "@stylistic/eslint-plugin";
|
|
124
|
+
import typescript3 from "typescript-eslint";
|
|
125
|
+
function stylistic_default(scopes) {
|
|
126
|
+
const extensions = [
|
|
127
|
+
"js",
|
|
128
|
+
"cjs",
|
|
129
|
+
"mjs",
|
|
130
|
+
"ts",
|
|
131
|
+
"cts",
|
|
132
|
+
"mts",
|
|
133
|
+
"html"
|
|
134
|
+
];
|
|
135
|
+
if (scopes?.react) {
|
|
136
|
+
extensions.push("jsx", "tsx");
|
|
137
|
+
}
|
|
138
|
+
if (scopes?.vue) {
|
|
139
|
+
extensions.push("vue", "jsx", "tsx");
|
|
140
|
+
}
|
|
141
|
+
let languageOptions;
|
|
142
|
+
if (scopes?.ts) {
|
|
143
|
+
languageOptions = {
|
|
144
|
+
parserOptions: { parser: typescript3.parser }
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return [
|
|
148
|
+
{
|
|
149
|
+
files: [`**/*.{${extensions.join(",")}}`],
|
|
150
|
+
languageOptions,
|
|
151
|
+
extends: [
|
|
152
|
+
stylistic.configs["recommended"]
|
|
153
|
+
],
|
|
154
|
+
plugins: {
|
|
155
|
+
...typeof scopes?.stylistic === "object" ? scopes.stylistic.plugins : {}
|
|
156
|
+
},
|
|
157
|
+
rules: {
|
|
158
|
+
"@stylistic/template-tag-spacing": "error",
|
|
159
|
+
// Good: foo`bar` | Bad: foo `bar` // 模板字符串标签函数调用时,标签和模板字符串之间不允许空格
|
|
160
|
+
"@stylistic/brace-style": ["error", "1tbs"],
|
|
161
|
+
// Good: if (foo) { bar() } | Bad: if (foo) {bar()} // 大括号风格
|
|
162
|
+
"@stylistic/arrow-parens": ["error", "as-needed"],
|
|
163
|
+
// Good: foo => bar | Bad: foo => (bar) // 箭头函数参数括号规则
|
|
164
|
+
"@stylistic/comma-dangle": ["error", "always-multiline"],
|
|
165
|
+
// 尾行逗号检查
|
|
166
|
+
"@stylistic/space-infix-ops": "error",
|
|
167
|
+
// Good: foo + bar | Bad: foo+bar // 单位与单位间需要空格
|
|
168
|
+
"@stylistic/block-spacing": "error",
|
|
169
|
+
// Good: { foo } | Bad: {foo} // 大括号间需要空格
|
|
170
|
+
"@stylistic/key-spacing": ["error", {
|
|
171
|
+
beforeColon: false,
|
|
172
|
+
afterColon: true
|
|
173
|
+
}],
|
|
174
|
+
// Good: { foo: 'bar' } | Bad: { foo:'bar' } // 对象属性冒号前后空格规则
|
|
175
|
+
"@stylistic/keyword-spacing": ["error", { before: true }],
|
|
176
|
+
// Good: if (foo) {} | Bad: if(foo) {} // 关键字前后空格规则
|
|
177
|
+
"@stylistic/arrow-spacing": ["error", {
|
|
178
|
+
before: true,
|
|
179
|
+
after: true
|
|
180
|
+
}],
|
|
181
|
+
// Good: foo => bar | Bad: foo=>bar // 箭头(=>)左右空格规则
|
|
182
|
+
"@stylistic/comma-spacing": ["error", {
|
|
183
|
+
before: false,
|
|
184
|
+
after: true
|
|
185
|
+
}],
|
|
186
|
+
// Good: foo, bar | Bad: foo , bar // 逗号前后空格规则
|
|
187
|
+
"@stylistic/function-call-spacing": ["error", "never"],
|
|
188
|
+
// Good: foo() | Bad: foo () // 函数调用时,函数名和括号之间不允许空格
|
|
189
|
+
"@stylistic/template-curly-spacing": ["error", "never"],
|
|
190
|
+
// Good: `${foo}` | Bad: `${ foo }` // 模板字符串中的空格规则
|
|
191
|
+
"@stylistic/array-bracket-spacing": ["error", "always", {
|
|
192
|
+
arraysInArrays: false,
|
|
193
|
+
objectsInArrays: false
|
|
194
|
+
}],
|
|
195
|
+
// Good: [ foo ] | Bad: [foo] // 数组左右括号空格规则
|
|
196
|
+
"@stylistic/object-curly-spacing": ["error", "always", {
|
|
197
|
+
arraysInObjects: false,
|
|
198
|
+
objectsInObjects: false
|
|
199
|
+
}],
|
|
200
|
+
// Good: { foo: 'bar' } | Bad: {foo: 'bar'} // 对象左右括号空格规则
|
|
201
|
+
"@stylistic/switch-colon-spacing": "error",
|
|
202
|
+
// Good: case 'bar': | Bad: case 'bar' : // switch 语句中冒号前后不允许空格
|
|
203
|
+
"@stylistic/semi": ["error", "never"],
|
|
204
|
+
// Good: foo() | Bad: foo(); // 语句末尾不允许分号
|
|
205
|
+
"@stylistic/semi-spacing": "error",
|
|
206
|
+
// Good: foo(); | Bad: foo() ;
|
|
207
|
+
"@stylistic/rest-spread-spacing": ["error", "never"],
|
|
208
|
+
// Good: [...foo] | Bad: [ ... foo ]
|
|
209
|
+
"@stylistic/computed-property-spacing": ["error", "never"],
|
|
210
|
+
// Good: obj[foo] | Bad: obj[ foo ]
|
|
211
|
+
"@stylistic/quotes": ["error", "single"],
|
|
212
|
+
// Good: 'foo' | Bad: "foo"
|
|
213
|
+
"@stylistic/quote-props": ["error", "consistent-as-needed"],
|
|
214
|
+
// Good: { foo: 'bar' } | Bad: { 'foo': 'bar' } // 在同一对象中,所有属性使用一致的引号
|
|
215
|
+
"@stylistic/space-before-function-paren": ["error", "always"],
|
|
216
|
+
// Good: function foo () {} | Bad: function foo() {}
|
|
217
|
+
"@stylistic/indent": ["error", 2, {
|
|
218
|
+
SwitchCase: 1,
|
|
219
|
+
ignoredNodes: ["TemplateLiteral"]
|
|
220
|
+
// see https://github.com/babel/babel-eslint/issues/681#issuecomment-451336031
|
|
221
|
+
}],
|
|
222
|
+
// 缩进规则
|
|
223
|
+
...typeof scopes?.stylistic === "object" ? scopes.stylistic.rules : {}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
];
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// src/configs/json.ts
|
|
230
|
+
import json from "@eslint/json";
|
|
231
|
+
function json_default(scopes) {
|
|
232
|
+
return [
|
|
233
|
+
{
|
|
234
|
+
files: ["**/*.json"],
|
|
235
|
+
plugins: {
|
|
236
|
+
json,
|
|
237
|
+
...typeof scopes?.json === "object" ? scopes.json.plugins : {}
|
|
238
|
+
},
|
|
239
|
+
language: "json/json",
|
|
240
|
+
rules: {
|
|
241
|
+
"json/no-duplicate-keys": "error",
|
|
242
|
+
...typeof scopes?.json === "object" ? scopes.json.rules : {}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
];
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// src/configs/markdown.ts
|
|
249
|
+
import markdown from "@eslint/markdown";
|
|
250
|
+
function markdown_default(scopes) {
|
|
251
|
+
return [
|
|
252
|
+
{
|
|
253
|
+
files: ["**/*.md"],
|
|
254
|
+
plugins: {
|
|
255
|
+
markdown,
|
|
256
|
+
...typeof scopes?.markdown === "object" ? scopes.markdown.plugins : {}
|
|
257
|
+
},
|
|
258
|
+
language: "markdown/commonmark",
|
|
259
|
+
rules: {
|
|
260
|
+
"markdown/no-html": "error",
|
|
261
|
+
...typeof scopes?.markdown === "object" ? scopes.markdown.rules : {}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
];
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// src/configs/tailwindcss.ts
|
|
268
|
+
import tailwindcss from "eslint-plugin-better-tailwindcss";
|
|
269
|
+
function tailwindcss_default(scopes) {
|
|
270
|
+
const extensions = [
|
|
271
|
+
"js",
|
|
272
|
+
"ts",
|
|
273
|
+
"css",
|
|
274
|
+
"less",
|
|
275
|
+
"sass",
|
|
276
|
+
"scss",
|
|
277
|
+
"html"
|
|
278
|
+
];
|
|
279
|
+
if (scopes?.react) {
|
|
280
|
+
extensions.push("jsx", "tsx");
|
|
281
|
+
}
|
|
282
|
+
if (scopes?.vue) {
|
|
283
|
+
extensions.push("vue", "jsx", "tsx");
|
|
284
|
+
}
|
|
285
|
+
return [
|
|
286
|
+
{
|
|
287
|
+
files: [`**/*.{${extensions.join(",")}}`],
|
|
288
|
+
plugins: {
|
|
289
|
+
"better-tailwindcss": tailwindcss,
|
|
290
|
+
...typeof scopes?.tailwindcss === "object" ? scopes.tailwindcss.plugins : {}
|
|
291
|
+
},
|
|
292
|
+
rules: {
|
|
293
|
+
// enable all recommended rules to report a warning
|
|
294
|
+
...tailwindcss.configs["recommended-warn"].rules,
|
|
295
|
+
// enable all recommended rules to report an error
|
|
296
|
+
...tailwindcss.configs["recommended-error"].rules,
|
|
297
|
+
// disable specific rules
|
|
298
|
+
"better-tailwindcss/no-unregistered-classes": "off",
|
|
299
|
+
// 关闭未注册类的检查
|
|
300
|
+
...typeof scopes?.tailwindcss === "object" ? scopes.tailwindcss.rules : {}
|
|
301
|
+
},
|
|
302
|
+
settings: {
|
|
303
|
+
"better-tailwindcss": typeof scopes?.tailwindcss === "object" && "settings" in scopes.tailwindcss ? scopes.tailwindcss.settings : {}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
];
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// src/configs/react.ts
|
|
310
|
+
import eslintReact from "@eslint-react/eslint-plugin";
|
|
311
|
+
import reactRefresh from "eslint-plugin-react-refresh";
|
|
312
|
+
import typescript4 from "typescript-eslint";
|
|
313
|
+
function react_default(scopes) {
|
|
314
|
+
const extensions = [
|
|
315
|
+
"jsx",
|
|
316
|
+
"tsx"
|
|
317
|
+
];
|
|
318
|
+
const preset = scopes?.ts ? eslintReact.configs["recommended-typescript"] : eslintReact.configs.recommended;
|
|
319
|
+
return [
|
|
320
|
+
{
|
|
321
|
+
files: [`**/*.{${extensions.join(",")}}`],
|
|
322
|
+
...preset,
|
|
323
|
+
languageOptions: {
|
|
324
|
+
...preset.languageOptions,
|
|
325
|
+
...scopes?.ts ? { parserOptions: { parser: typescript4.parser } } : {},
|
|
326
|
+
globals: {
|
|
327
|
+
React: "readonly"
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
plugins: {
|
|
331
|
+
...preset.plugins,
|
|
332
|
+
...typeof scopes?.react === "object" ? scopes.react.plugins : {}
|
|
333
|
+
},
|
|
334
|
+
rules: {
|
|
335
|
+
...preset.rules,
|
|
336
|
+
...typeof scopes?.react === "object" ? scopes.react.rules : {}
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
files: [`**/*.{${extensions.join(",")}}`],
|
|
341
|
+
extends: [
|
|
342
|
+
reactRefresh.configs.recommended
|
|
343
|
+
]
|
|
344
|
+
}
|
|
345
|
+
];
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// src/configs/vue.ts
|
|
349
|
+
import vue from "eslint-plugin-vue";
|
|
350
|
+
import typescript5 from "typescript-eslint";
|
|
351
|
+
function vue_default(scopes) {
|
|
352
|
+
const extensions = [
|
|
353
|
+
"jsx",
|
|
354
|
+
"tsx",
|
|
355
|
+
"vue"
|
|
356
|
+
];
|
|
357
|
+
let languageOptions;
|
|
358
|
+
if (scopes?.ts) {
|
|
359
|
+
languageOptions = { parserOptions: { parser: typescript5.parser } };
|
|
360
|
+
}
|
|
361
|
+
return [
|
|
362
|
+
{
|
|
363
|
+
files: [`**/*.{${extensions.join(",")}}`],
|
|
364
|
+
languageOptions,
|
|
365
|
+
extends: [
|
|
366
|
+
...vue.configs["flat/strongly-recommended"]
|
|
367
|
+
],
|
|
368
|
+
plugins: {
|
|
369
|
+
...typeof scopes?.vue === "object" ? scopes.vue.plugins : {}
|
|
370
|
+
},
|
|
371
|
+
rules: {
|
|
372
|
+
"vue/comma-dangle": ["error", "always-multiline"],
|
|
373
|
+
// 尾行逗号检查
|
|
374
|
+
"vue/quote-props": ["error", "consistent-as-needed"],
|
|
375
|
+
// 在同一对象中,所有属性使用一致的引号
|
|
376
|
+
"vue/no-unused-vars": ["error", { ignorePattern: "^_" }],
|
|
377
|
+
// 未使用的变量是否有效的规则
|
|
378
|
+
"vue/space-infix-ops": "error",
|
|
379
|
+
// Good: foo + bar | Bad: foo+bar // 单位与单位间需要空格
|
|
380
|
+
"vue/block-spacing": "error",
|
|
381
|
+
// Good: { foo } | Bad: {foo} // 大括号间需要空格
|
|
382
|
+
"vue/key-spacing": ["error", {
|
|
383
|
+
beforeColon: false,
|
|
384
|
+
afterColon: true
|
|
385
|
+
}],
|
|
386
|
+
// Good: { foo: 'bar' } | Bad: { foo:'bar' } // 对象属性冒号前后空格规则
|
|
387
|
+
"vue/keyword-spacing": ["error", { before: true }],
|
|
388
|
+
// Good: if (foo) {} | Bad: if(foo) {} // 关键字前后空格规则
|
|
389
|
+
"vue/arrow-spacing": ["error", {
|
|
390
|
+
before: true,
|
|
391
|
+
after: true
|
|
392
|
+
}],
|
|
393
|
+
// Good: foo => bar | Bad: foo=>bar // 箭头(=>)左右空格规则
|
|
394
|
+
"vue/comma-spacing": ["error", {
|
|
395
|
+
before: false,
|
|
396
|
+
after: true
|
|
397
|
+
}],
|
|
398
|
+
// Good: foo, bar | Bad: foo , bar // 逗号前后空格规则
|
|
399
|
+
"vue/func-call-spacing": ["error", "never"],
|
|
400
|
+
// Good: foo() | Bad: foo () // 函数调用时,函数名和括号之间不允许空格
|
|
401
|
+
"vue/template-curly-spacing": ["error", "never"],
|
|
402
|
+
// Good: `${foo}` | Bad: `${ foo }` // 模板字符串中的空格规则
|
|
403
|
+
"vue/array-bracket-spacing": ["error", "always", {
|
|
404
|
+
arraysInArrays: false,
|
|
405
|
+
objectsInArrays: false
|
|
406
|
+
}],
|
|
407
|
+
// Good: [ foo ] | Bad: [foo] // 数组左右括号空格规则
|
|
408
|
+
"vue/object-curly-spacing": ["error", "always", {
|
|
409
|
+
arraysInObjects: false,
|
|
410
|
+
objectsInObjects: false
|
|
411
|
+
}],
|
|
412
|
+
// Good: { foo: 'bar' } | Bad: {foo: 'bar'} // 对象左右括号空格规则
|
|
413
|
+
"vue/no-unused-components": "error",
|
|
414
|
+
// 未使用組件是否有效的规则
|
|
415
|
+
"vue/no-v-html": "off",
|
|
416
|
+
// 允许使用 v-html
|
|
417
|
+
"vue/v-bind-style": ["error", "shorthand"],
|
|
418
|
+
// 强制 v-bind 使用 :
|
|
419
|
+
"vue/v-on-style": ["error", "shorthand"],
|
|
420
|
+
// 强制 v-on 使用 @
|
|
421
|
+
"vue/this-in-template": ["error", "never"],
|
|
422
|
+
// 模板中不允许出现 this
|
|
423
|
+
"vue/attribute-hyphenation": ["error", "never"],
|
|
424
|
+
// 使用组件时,属性名必须使用驼峰命名
|
|
425
|
+
"vue/v-on-event-hyphenation": ["error", "never"],
|
|
426
|
+
// 事件名必须使用驼峰命名
|
|
427
|
+
"vue/html-closing-bracket-newline": ["error", {
|
|
428
|
+
singleline: "never",
|
|
429
|
+
// 如果没有换行属性,标签右括号不允许换行
|
|
430
|
+
multiline: "always"
|
|
431
|
+
// 如果有换行属性,标签右括号必须换行
|
|
432
|
+
}],
|
|
433
|
+
"vue/html-closing-bracket-spacing": ["error", {
|
|
434
|
+
startTag: "never",
|
|
435
|
+
// 标签开始括号不允许空格
|
|
436
|
+
endTag: "never",
|
|
437
|
+
// 标签结束括号不允许空格
|
|
438
|
+
selfClosingTag: "always"
|
|
439
|
+
// 自关闭标签右括号前必须空格
|
|
440
|
+
}],
|
|
441
|
+
"vue/html-end-tags": "error",
|
|
442
|
+
// 不允许未闭合的标签
|
|
443
|
+
"vue/html-indent": ["error", 2, {
|
|
444
|
+
// html 缩进
|
|
445
|
+
attribute: 1,
|
|
446
|
+
baseIndent: 1,
|
|
447
|
+
closeBracket: 0,
|
|
448
|
+
alignAttributesVertically: true,
|
|
449
|
+
// 在多行情况下属性是否应与第一个属性垂直对齐的条件。
|
|
450
|
+
ignores: []
|
|
451
|
+
// 忽略节点的选择器。
|
|
452
|
+
}],
|
|
453
|
+
"vue/script-indent": ["error", 2, {
|
|
454
|
+
// script 缩进
|
|
455
|
+
baseIndent: 0,
|
|
456
|
+
switchCase: 1,
|
|
457
|
+
ignores: []
|
|
458
|
+
}],
|
|
459
|
+
"vue/html-quotes": ["error", "double"],
|
|
460
|
+
// 属性值强制使用双引号
|
|
461
|
+
"vue/html-self-closing": "off",
|
|
462
|
+
// 不强制自闭和标签
|
|
463
|
+
"vue/max-attributes-per-line": ["error", {
|
|
464
|
+
// 标签同一行属性允许数量
|
|
465
|
+
singleline: 1,
|
|
466
|
+
multiline: { max: 1 }
|
|
467
|
+
}],
|
|
468
|
+
"vue/singleline-html-element-content-newline": ["error", {
|
|
469
|
+
// 元素内容单行时的规则
|
|
470
|
+
ignoreWhenNoAttributes: true,
|
|
471
|
+
ignoreWhenEmpty: true,
|
|
472
|
+
ignores: ["pre", "textarea"]
|
|
473
|
+
}],
|
|
474
|
+
"vue/multiline-html-element-content-newline": ["error", {
|
|
475
|
+
// 元素内容多行时的规则
|
|
476
|
+
ignoreWhenEmpty: true,
|
|
477
|
+
// 在元素没有内容时禁用报告
|
|
478
|
+
ignores: ["pre", "textarea"],
|
|
479
|
+
// 忽略规则的元素
|
|
480
|
+
allowEmptyLines: false
|
|
481
|
+
// 不允许内容周围有空行
|
|
482
|
+
}],
|
|
483
|
+
"vue/no-multi-spaces": ["error", {
|
|
484
|
+
// 标签内属性名之前不允许多个空格
|
|
485
|
+
ignoreProperties: true
|
|
486
|
+
// 忽略对象的属性
|
|
487
|
+
}],
|
|
488
|
+
"vue/mustache-interpolation-spacing": "error",
|
|
489
|
+
// 大括号内必须有空格
|
|
490
|
+
"vue/multi-word-component-names": "off",
|
|
491
|
+
// vue 组件 name 中使用多个单词
|
|
492
|
+
"vue/component-name-in-template-casing": "error",
|
|
493
|
+
"vue/prop-name-casing": ["error", "camelCase"],
|
|
494
|
+
// 组件 prop 强制小驼峰命名
|
|
495
|
+
"vue/require-default-prop": "error",
|
|
496
|
+
// 组件 prop 必须设置默认值,不包括 Boolean 值属性
|
|
497
|
+
"vue/require-prop-types": "error",
|
|
498
|
+
// 组件 prop 必须指定类型
|
|
499
|
+
"vue/require-explicit-emits": "error",
|
|
500
|
+
// 组件必须显式声明 emits
|
|
501
|
+
"vue/no-spaces-around-equal-signs-in-attribute": "error",
|
|
502
|
+
// 标签中属性的等号两侧不允许空格
|
|
503
|
+
"vue/no-template-shadow": "error",
|
|
504
|
+
// 子 v-for 中不允许覆盖父 v-for 中的变量
|
|
505
|
+
"vue/block-order": ["error", {
|
|
506
|
+
// 强制组件中的顺序
|
|
507
|
+
order: [["script", "template"], "style"]
|
|
508
|
+
}],
|
|
509
|
+
"vue/padding-line-between-blocks": "error",
|
|
510
|
+
// 强制组件中 template, script, style 之间用空行分割
|
|
511
|
+
"vue/require-direct-export": "error",
|
|
512
|
+
// 规范组件的 export
|
|
513
|
+
"vue/attributes-order": ["error", {
|
|
514
|
+
// 标签内属性排序
|
|
515
|
+
order: [
|
|
516
|
+
"DEFINITION",
|
|
517
|
+
"LIST_RENDERING",
|
|
518
|
+
"CONDITIONALS",
|
|
519
|
+
"RENDER_MODIFIERS",
|
|
520
|
+
"GLOBAL",
|
|
521
|
+
["UNIQUE", "SLOT"],
|
|
522
|
+
"TWO_WAY_BINDING",
|
|
523
|
+
"OTHER_DIRECTIVES",
|
|
524
|
+
"OTHER_ATTR",
|
|
525
|
+
"EVENTS",
|
|
526
|
+
"CONTENT"
|
|
527
|
+
],
|
|
528
|
+
alphabetical: false
|
|
529
|
+
}],
|
|
530
|
+
"vue/order-in-components": ["error", {
|
|
531
|
+
// 组件内属性排序
|
|
532
|
+
order: [
|
|
533
|
+
"name",
|
|
534
|
+
"mixins",
|
|
535
|
+
"components",
|
|
536
|
+
"model",
|
|
537
|
+
["provide", "inject"],
|
|
538
|
+
["props", "propsData"],
|
|
539
|
+
"data",
|
|
540
|
+
"computed",
|
|
541
|
+
"methods",
|
|
542
|
+
"watch",
|
|
543
|
+
"watchQuery",
|
|
544
|
+
"LIFECYCLE_HOOKS"
|
|
545
|
+
]
|
|
546
|
+
}],
|
|
547
|
+
"vue/v-slot-style": "error",
|
|
548
|
+
"vue/no-deprecated-scope-attribute": "error",
|
|
549
|
+
// Disallow deprecated scope attribute (in Vue.js 2.5.0+)
|
|
550
|
+
"vue/no-deprecated-slot-attribute": "error",
|
|
551
|
+
// Disallow deprecated slot attribute (in Vue.js 2.6.0+)
|
|
552
|
+
"vue/no-deprecated-slot-scope-attribute": "error",
|
|
553
|
+
// Disallow deprecated slot-scope attribute (in Vue.js 2.6.0+)
|
|
554
|
+
...typeof scopes?.vue === "object" ? scopes.vue.rules : {}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
];
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// src/index.ts
|
|
561
|
+
import { defaultsDeep } from "lodash-es";
|
|
562
|
+
var defaultOptions = {
|
|
563
|
+
ignores: [],
|
|
564
|
+
scopes: {
|
|
565
|
+
js: true,
|
|
566
|
+
ts: true,
|
|
567
|
+
stylistic: true,
|
|
568
|
+
json: true,
|
|
569
|
+
markdown: true,
|
|
570
|
+
tailwindcss: false,
|
|
571
|
+
react: false,
|
|
572
|
+
vue: false
|
|
573
|
+
}
|
|
574
|
+
};
|
|
575
|
+
function index_default(options = defaultOptions) {
|
|
576
|
+
const {
|
|
577
|
+
ignores,
|
|
578
|
+
scopes
|
|
579
|
+
} = defaultsDeep(options, defaultOptions);
|
|
580
|
+
return defineConfig([
|
|
581
|
+
{
|
|
582
|
+
languageOptions: {
|
|
583
|
+
globals: {
|
|
584
|
+
...globals.browser,
|
|
585
|
+
...globals.node
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
},
|
|
589
|
+
ignores.length && globalIgnores(ignores),
|
|
590
|
+
scopes.js && javascript_default(scopes),
|
|
591
|
+
scopes.ts && typescript_default(scopes),
|
|
592
|
+
scopes.stylistic && stylistic_default(scopes),
|
|
593
|
+
scopes.json && json_default(scopes),
|
|
594
|
+
scopes.markdown && markdown_default(scopes),
|
|
595
|
+
scopes.tailwindcss && tailwindcss_default(scopes),
|
|
596
|
+
scopes.react && react_default(scopes),
|
|
597
|
+
scopes.vue && vue_default(scopes)
|
|
598
|
+
].filter(Boolean));
|
|
599
|
+
}
|
|
600
|
+
export {
|
|
601
|
+
index_default as default
|
|
602
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@polymarbot/eslint-config-shared",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Eslint@10 shared config",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./index.js",
|
|
7
|
+
"types": "./index.d.ts",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@eslint/js": "^10.0.0",
|
|
13
|
+
"@eslint/json": "^1.1.0",
|
|
14
|
+
"@eslint/markdown": "^7.0.0",
|
|
15
|
+
"@eslint-react/eslint-plugin": "^3.0.0",
|
|
16
|
+
"@stylistic/eslint-plugin": "^5.2.0",
|
|
17
|
+
"eslint-plugin-better-tailwindcss": "^4.3.0",
|
|
18
|
+
"eslint-plugin-react-refresh": "^0.5.0",
|
|
19
|
+
"eslint-plugin-vue": "^10.1.0",
|
|
20
|
+
"globals": "^17.0.0",
|
|
21
|
+
"lodash-es": "^4.17.21",
|
|
22
|
+
"typescript-eslint": "^8.32.1",
|
|
23
|
+
"vue-eslint-parser": "^10.1.3"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"eslint": ">= 10"
|
|
27
|
+
}
|
|
28
|
+
}
|