@ziloen/eslint-config 0.1.3 → 0.1.5

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/dist/index.cjs CHANGED
@@ -1,773 +1 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
33
- format: () => format,
34
- javascript: () => javascript,
35
- react: () => react,
36
- typescript: () => typescript,
37
- vue: () => vue
38
- });
39
- module.exports = __toCommonJS(src_exports);
40
-
41
- // src/configs/javascript.ts
42
- var import_js = __toESM(require("@eslint/js"), 1);
43
-
44
- // src/plugins.ts
45
- var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
46
- var import_eslint_plugin_promise = __toESM(require("eslint-plugin-promise"), 1);
47
- var import_eslint_plugin_vue = __toESM(require("eslint-plugin-vue"), 1);
48
- var import_eslint_plugin = __toESM(require("@typescript-eslint/eslint-plugin"), 1);
49
- var import_eslint_plugin_react = __toESM(require("eslint-plugin-react"), 1);
50
- var import_eslint_plugin_ziloen = __toESM(require("eslint-plugin-ziloen"), 1);
51
- var parserTs = __toESM(require("@typescript-eslint/parser"), 1);
52
- var import_vue_eslint_parser = __toESM(require("vue-eslint-parser"), 1);
53
-
54
- // src/configs/javascript.ts
55
- var javascript = [
56
- import_js.default.configs.recommended,
57
- {
58
- plugins: {
59
- unicorn: import_eslint_plugin_unicorn.default,
60
- promise: import_eslint_plugin_promise.default
61
- },
62
- ignores: [
63
- // files
64
- "*.min.*",
65
- "CHANGELOG.md",
66
- "LICENSE*",
67
- // lock files
68
- "package-lock.json",
69
- "pnpm-lock.yaml",
70
- "yarn.lock",
71
- // directories
72
- "node_modules",
73
- "dist",
74
- // not support yet
75
- "*.html"
76
- ],
77
- rules: {
78
- /** 检查数组方法返回值 */
79
- "array-callback-return": ["error", { allowImplicit: true }],
80
- /** 禁止定义块作用域外的访问 var 变量 */
81
- "block-scoped-var": "error",
82
- /** 派生 class 必须要有 super() */
83
- "constructor-super": "error",
84
- /**
85
- * 倾向使用全等 ===
86
- *
87
- * FIXME: 使用 always 时 autofix 可能导致语义改变,暂时沿用 'smart',
88
- * 如果可以取消 autofix,将 option 设置为 'always'
89
- */
90
- eqeqeq: ["error", "smart"],
91
- /** `a = a || b` 可以简写为 `a ||= b` */
92
- "logical-assignment-operators": ["warn"],
93
- /** 限制最大回调嵌套数量 */
94
- "max-nested-callbacks": ["warn", 5],
95
- /** for 与 await 一起使用会串行阻塞线程,可以使用 Promise.all() 一次发起多个 Promise */
96
- "no-await-in-loop": "warn",
97
- /**
98
- * 不要嵌套 promise
99
- *
100
- * 但有时需要 async executor,如:
101
- * ```js
102
- * new Promise(async (resolve, reject) => {
103
- * const result = await doSomething();
104
- * const result2 = await doSomething2(result);
105
- * resolve(result2);
106
- * })
107
- * ```
108
- * 无法配置,故关闭
109
- */
110
- "no-async-promise-executor": "off",
111
- /** 别用 */
112
- "no-caller": "error",
113
- /** 错误使用 */
114
- "no-constant-binary-expression": "error",
115
- /**
116
- * console.log使用后删除
117
- */
118
- "no-console": ["off", {
119
- allow: ["warn", "error"]
120
- }],
121
- /** `constructor` 中不应有返回值(允许作为控制流使用) */
122
- "no-constructor-return": "warn",
123
- /** 允许空函数声明 */
124
- "no-empty": "off",
125
- /** 禁止使用 eval */
126
- "no-eval": "warn",
127
- /** 防止`switch case`忘写`break` */
128
- "no-fallthrough": ["error", {
129
- allowEmptyCase: true
130
- }],
131
- /** 不允许 new Symbol 与 new BigInt 这种错误用法 */
132
- "no-new-native-nonconstructor": "error",
133
- /**
134
- * Promise 内 return 没有意义,使用 resolve 或 reject
135
- * 无法配置允许箭头函数,故关闭 https://github.com/eslint/eslint/issues/17278
136
- */
137
- "no-promise-executor-return": "off",
138
- /** 令人混淆的 window 上的变量 */
139
- "no-restricted-globals": [
140
- "error",
141
- "event",
142
- "name",
143
- "length",
144
- "status"
145
- ],
146
- /** 禁止不必要的 await */
147
- "no-return-await": "warn",
148
- /** 允许未使用的变量 */
149
- "no-unused-vars": "off",
150
- /** 禁止使用 var 定义变量 */
151
- "no-var": "error",
152
- /**
153
- * 优先使用 const
154
- *
155
- * 有时解构会出现不变的变量也是用 let,autofix 会导致运行时错误,故关闭
156
- */
157
- "prefer-const": ["off", {
158
- destructuring: "all",
159
- ignoreReadBeforeAssign: false
160
- }],
161
- /** 使用 `a ** b` 替代 `Math.pow(a, b)` */
162
- "prefer-exponentiation-operator": "warn",
163
- /** 使用 `Object.hasOwn()` 替代 `Object.prototype.hasOwnProperty.call()` */
164
- "prefer-object-has-own": "warn",
165
- /** 偏好 reject Error 对象 */
166
- "prefer-promise-reject-errors": ["warn", {
167
- allowEmptyReject: true
168
- }],
169
- /**
170
- * 这可能会导致数据竞争
171
- * ```ts
172
- * let a: string | undefined
173
- *
174
- * async function doSomething() {
175
- * const b = a ||= await getA()
176
- * // ^^^^^^^^^^^^^^^^^^确实在多次调用时有数据竞争,但暂未找到两全之法,故关闭
177
- * }
178
- * ```
179
- */
180
- "require-atomic-updates": "off",
181
- // Node 插件 未安装
182
- /** 同步发方法会阻塞线程,使用异步方法代替 */
183
- // 'node/no-sync': 'warn',
184
- // -------------------------------------------------------------
185
- // unicorn https://github.com/sindresorhus/eslint-plugin-unicorn
186
- // -------------------------------------------------------------
187
- /** 🔧更好的正则 */
188
- "unicorn/better-regex": ["warn", {
189
- sortCharacterClasses: false
190
- }],
191
- /** Error 应有错误信息 */
192
- "unicorn/error-message": "warn",
193
- // 暂时未使用
194
- // 'unicorn/expiring-todo-comments': 'warn',
195
- /** 手动操作原生 Cookie 很麻烦容易出错 */
196
- "unicorn/no-document-cookie": "warn",
197
- /** 🔧不要使用 instanceof Array 判断数组 */
198
- "unicorn/no-instanceof-array": "warn",
199
- /** 事件监听移除字面量函数是无效的 */
200
- "unicorn/no-invalid-remove-event-listener": "error",
201
- /** 警告嵌套三元运算符 (可以通过 indent 来表示,不警告) */
202
- // 'no-nested-ternary': 'off',
203
- // 'unicorn/no-nested-ternary': 'warn',
204
- /** 🔧使用 Buffer.from() 或 Buffer.alloc() 代替 */
205
- "unicorn/no-new-buffer": "error",
206
- /** 禁止声明`then`属性,以免和`Promsie`混淆 */
207
- "unicorn/no-thenable": "error",
208
- /** 使用 var === undefined 来检查 而不是 typeof var === 'undefined',除了全局变量 */
209
- "unicorn/no-typeof-undefined": ["warn", {
210
- checkGlobalVariables: false
211
- }],
212
- /** 🔧去除多余的 `await` */
213
- "unicorn/no-unnecessary-await": "off",
214
- /** 禁止令人迷惑的数组解构 */
215
- "unicorn/no-unreadable-array-destructuring": "error",
216
- /** 🔧去除多余的 fallback */
217
- "unicorn/no-useless-fallback-in-spread": "warn",
218
- /** 🔧去除多余的 `Promise.resove/reject` */
219
- "unicorn/no-useless-promise-resolve-reject": "warn",
220
- /** 🔧去除多余的 `...` */
221
- "unicorn/no-useless-spread": "warn",
222
- /** 🔧去除多余的 undefined */
223
- "unicorn/no-useless-undefined": ["warn", {
224
- checkArguments: false
225
- }],
226
- /** 🔧`1`, `1.0`, `1.` 没有区别 */
227
- "unicorn/no-zero-fractions": "warn",
228
- "unicorn/number-literal-case": "warn",
229
- /** 🔧使用 `Array#flat()` 替代 `Array#concat()` */
230
- "unicorn/prefer-array-flat": "warn",
231
- /** 🔧使用 `Array#flatMap()` 替代 `Array#concat().map()` */
232
- "unicorn/prefer-array-flat-map": "warn",
233
- /** 🔧使用 indexOf 代替简单查找 findIndex */
234
- "unicorn/prefer-array-index-of": "warn",
235
- /** 🔧偏好使用 `Array#some()` */
236
- "unicorn/prefer-array-some": "warn",
237
- /** 🔧偏好使用 `Array#at()` 和 `String#at()` */
238
- "unicorn/prefer-at": "warn",
239
- /** 使用 `Blob#arrayBuffer()` 和 `Blob#text()` */
240
- "unicorn/prefer-blob-reading-methods": "warn",
241
- /** */
242
- "unicorn/prefer-code-point": "warn",
243
- /** 🔧使用 `Node#append()` 代替 `Node#appendChild()` */
244
- "unicorn/prefer-dom-node-append": "warn",
245
- /** 🔧使用 HTML#dataset 而不是直接操作 attribute `data-*` */
246
- "unicorn/prefer-dom-node-dataset": "warn",
247
- /** 🔧使用 Node#remove 代替 node.parentNode.removeChild() */
248
- "unicorn/prefer-dom-node-remove": "warn",
249
- /** 使用 textContent 代替 innerText,参考 [Differences from innerText](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent#differences_from_innertext) */
250
- "unicorn/prefer-dom-node-text-content": "warn",
251
- /** 🔧使用 export...from 如果导入导出未使用 */
252
- "unicorn/prefer-export-from": ["warn", {
253
- ignoreUsedVariables: true
254
- }],
255
- /** 🔧使用 Array#includes 代替 indexOf / some 代替存在性检查 */
256
- "unicorn/prefer-includes": "warn",
257
- /** 🔧使用新的 KeyboradEvent#key 而不是 KeyboardEvent#keyCode */
258
- "unicorn/prefer-keyboard-event-key": "warn",
259
- /** 🔧使用更现代的 DOM API */
260
- "unicorn/prefer-modern-dom-apis": "warn",
261
- /** 🔧使用更现代的 Math API */
262
- "unicorn/prefer-modern-math-apis": "warn",
263
- /** 🔧使用负数 -index 代替 xxx.length - index */
264
- "unicorn/prefer-negative-index": "warn",
265
- /** 🔧来自 Node 的方法应添加 node: 协议前缀,避免混淆 */
266
- "unicorn/prefer-node-protocol": "warn",
267
- /** 🔧使用 Object.fromEntries 代替手动 */
268
- "unicorn/prefer-object-from-entries": "warn",
269
- /** 🔧省略 catch 如果未使用 */
270
- "unicorn/prefer-optional-catch-binding": "warn",
271
- /** 🔧使用 prototype 上而不是实例上的 prototype */
272
- "unicorn/prefer-prototype-methods": "warn",
273
- /** 🔧使用同一种方法来选择 DOM 元素,避免混淆 */
274
- "unicorn/prefer-query-selector": "warn",
275
- /** 🔧使用 Set#size 直接获得数量而不是先转换为 Array 再读取 Array#length */
276
- "unicorn/prefer-set-size": "warn",
277
- /** 🔧偏好使用 string.slice 而不是 string.substring / string.substr */
278
- "unicorn/prefer-string-slice": "warn",
279
- /** 🔧throw 应使用 new Error */
280
- "unicorn/throw-new-error": "warn",
281
- // -------------------------------------------------------------
282
- // eslint-plugin-promise
283
- // -------------------------------------------------------------
284
- /** 🔧Promise 上的静态方法应直接使用 */
285
- "promise/no-new-statics": "error"
286
- }
287
- }
288
- ];
289
-
290
- // src/configs/typescript.ts
291
- var typescript = [
292
- ...javascript,
293
- {
294
- files: [
295
- "**/*.?([cm])[tj]s?(x)",
296
- "**/*.vue"
297
- ],
298
- languageOptions: {
299
- parser: parserTs,
300
- sourceType: "module",
301
- parserOptions: {
302
- project: true
303
- // EXPERIMENTAL_useProjectService: true
304
- }
305
- },
306
- plugins: {
307
- "@typescript-eslint": import_eslint_plugin.default
308
- },
309
- rules: {
310
- ...import_eslint_plugin.default.configs["strict-type-checked"].rules,
311
- /** ✅禁止不必要的 await */
312
- // '@typescript-eslint/await-thenable': 'warn',
313
- /** 🎨不限制只使用 interface 或者 type */
314
- "@typescript-eslint/consistent-type-definitions": "off",
315
- /** 可选参数必须放在最后 */
316
- "default-param-last": "off",
317
- "@typescript-eslint/default-param-last": "error",
318
- /** 🎨不强制使用 `.`(点) 来访问属性 */
319
- "dot-notation": "off",
320
- "@typescript-eslint/dot-notation": "off",
321
- /** 🔒禁止使用 void 函数的返回值 ("off" 因为 return voidExpression() 这种缩写 { voidExpress(); return } 也会报错) */
322
- "@typescript-eslint/no-confusing-void-expression": ["off", {
323
- ignoreArrowShorthand: true
324
- }],
325
- /** 不允许 class 有重复的成员 (TypeScript 已检查,禁用此规则) */
326
- "no-dupe-class-members": "off",
327
- "@typescript-eslint/no-dupe-class-members": "off",
328
- /** 🎨允许空函数 */
329
- "@typescript-eslint/no-empty-function": "off",
330
- /** ✅允许显式 any */
331
- "@typescript-eslint/no-explicit-any": "off",
332
- /** ✅允许未处理的 Promise */
333
- "@typescript-eslint/no-floating-promises": "off",
334
- /** 🔒不允许隐式 eval */
335
- // "no-implied-eval": "off",
336
- // "@typescript-eslint/no-implied-eval": "error",
337
- /** 禁止 for 循环内声明的函数引用函数外变量 */
338
- "no-loop-func": "off",
339
- "@typescript-eslint/no-loop-func": "error",
340
- /** 禁止 promise 错误用法 */
341
- "@typescript-eslint/no-misused-promises": ["error", {
342
- /** 允许快捷写法 */
343
- checksVoidReturn: false
344
- }],
345
- /** ✅禁止超出精度范围的数字 */
346
- // 'no-loss-of-precision': 'off',
347
- // '@typescript-eslint/no-loss-of-precision': 'error',
348
- /** 允许非空断言 */
349
- "@typescript-eslint/no-non-null-assertion": "off",
350
- /** 允许 TypeScript 重载声明 */
351
- "no-redeclare": "off",
352
- "@typescript-eslint/no-redeclare": ["error"],
353
- /** ✅禁止冗余类型定义 */
354
- "@typescript-eslint/no-redundant-type-constituents": "warn",
355
- /** 🔒Disallow throwing literals as exceptions. */
356
- "no-throw-literal": "off",
357
- "@typescript-eslint/no-throw-literal": ["error", {
358
- allowThrowingAny: false,
359
- allowThrowingUnknown: false
360
- }],
361
- /** 禁用默认`no-undef`,eslint 不会检查`*.d.ts`,导致误报全局变量与类型不存在 */
362
- "no-undef": "off",
363
- /**
364
- * 🔒不必要的条件判断
365
- *
366
- * 因为有时类型不正确,autofix 会导致运行时错误,故关闭
367
- */
368
- "@typescript-eslint/no-unnecessary-condition": "off",
369
- /**
370
- * ✅不必要的类型断言
371
- *
372
- * 因为有时类型不正确,autofix 会导致 TS 错误,故关闭
373
- */
374
- "@typescript-eslint/no-unnecessary-type-assertion": "off",
375
- /** 警告未使用的表达式 */
376
- "no-unused-expressions": "off",
377
- "@typescript-eslint/no-unused-expressions": ["warn", {
378
- allowShortCircuit: true,
379
- enforceForJSX: true
380
- }],
381
- /** 允许未使用变量 */
382
- "no-unused-vars": "off",
383
- "@typescript-eslint/no-unused-vars": "off",
384
- /**
385
- *
386
- */
387
- "@typescript-eslint/prefer-nullish-coalescing": ["warn", {
388
- ignorePrimitives: {
389
- bigint: true,
390
- boolean: true,
391
- number: true,
392
- string: true
393
- }
394
- }],
395
- /**
396
- * 使用可选链`a?.b`替代`a && a.b`
397
- *
398
- * FIXME:
399
- * ```ts
400
- * if (!a || !a.b)
401
- * // ^ 也会被要求改成 ?.,降低可读性,且无配置,故关闭
402
- * ```
403
- */
404
- "@typescript-eslint/prefer-optional-chain": "off",
405
- /**
406
- * 🔧返回 promise 的函数必须有 async 关键字
407
- *
408
- * 不写也行,不限制此偏好,故关闭
409
- */
410
- "@typescript-eslint/promise-function-async": ["off", {
411
- checkArrowFunctions: false
412
- }],
413
- /**
414
- * 数组排序需显式指明排序方法,默认行为可能并不是想要的结果
415
- * ```ts
416
- * [1, 2, 3, 10, 20, 30].sort(); //→ [1, 10, 2, 20, 3, 30]
417
- * ```
418
- */
419
- "@typescript-eslint/require-array-sort-compare": ["error"],
420
- /** ✅模板字符串只允许数字字符串 */
421
- "@typescript-eslint/restrict-template-expressions": ["error", {
422
- allowNumber: true
423
- }],
424
- /** 允许可合为一个联合类型的函数声明多个函数签名 */
425
- "@typescript-eslint/unified-signatures": "off"
426
- }
427
- }
428
- ];
429
-
430
- // src/configs/vue.ts
431
- var vue = [
432
- ...typescript,
433
- {
434
- files: ["**/*.vue"],
435
- languageOptions: {
436
- parser: import_vue_eslint_parser.default,
437
- parserOptions: {
438
- parser: parserTs,
439
- ecmaFeatures: {
440
- jsx: true
441
- },
442
- extraFileExtensions: [".vue"],
443
- sourceType: "module"
444
- }
445
- },
446
- plugins: {
447
- "@typescript-eslint": import_eslint_plugin.default,
448
- vue: import_eslint_plugin_vue.default
449
- },
450
- processor: import_eslint_plugin_vue.default.processors[".vue"],
451
- rules: {
452
- ...import_eslint_plugin_vue.default.configs["vue3-essential"].rules,
453
- /** allow ununed vars */
454
- "vue/no-unused-vars": "off",
455
- "vue/html-self-closing": "off",
456
- "vue/max-attributes-per-line": "off",
457
- "vue/multi-word-component-names": "off",
458
- // 'vue/no-v-html': 'off',
459
- "vue/require-default-prop": "off",
460
- "vue/require-prop-types": "off",
461
- "vue/singleline-html-element-content-newline": "off"
462
- }
463
- }
464
- ];
465
-
466
- // src/configs/react.ts
467
- var react = [
468
- ...typescript,
469
- {
470
- files: ["**/*.jsx", "**/*.tsx"],
471
- plugins: {
472
- react: import_eslint_plugin_react.default,
473
- ziloen: import_eslint_plugin_ziloen.default
474
- },
475
- languageOptions: {
476
- parser: parserTs,
477
- parserOptions: {
478
- ecmaFeatures: {
479
- jsx: true
480
- }
481
- }
482
- },
483
- rules: {
484
- /** 16+ 不需要此导入 React */
485
- "react/react-in-jsx-scope": "off",
486
- /** ✅需要 key */
487
- "react/jsx-key": ["error", {
488
- // checkFragmentShorthand: true
489
- }],
490
- /** 让 TS 检查 */
491
- "react/jsx-no-undef": "off",
492
- /** 简写 <React.Fragment></React.Fragment> => <></> */
493
- "react/jsx-fragments": ["warn", "syntax"],
494
- /** 避免错误用法 */
495
- "react/no-invalid-html-attribute": "warn",
496
- /** 不允许可能出错的的 render 类型(number | string | object),(即使是 bool 也会报错,太蠢了) */
497
- // 'react/jsx-no-leaked-render': 'error',
498
- /** 严格 jsx render 类型,支持 TS 检查,替代 react/jsx-no-leaked-render */
499
- "ziloen/jsx-strict-logical-expressions": "error"
500
- }
501
- }
502
- ];
503
-
504
- // src/configs/format.ts
505
- var format = [
506
- {
507
- plugins: {
508
- "@typescript-eslint": import_eslint_plugin.default,
509
- ziloen: import_eslint_plugin_ziloen.default
510
- },
511
- rules: {
512
- /** 🔧数组括号换行 */
513
- "array-bracket-newline": ["warn", "consistent"],
514
- /** 🔧数组前后空格 */
515
- "array-bracket-spacing": ["warn", "never"],
516
- /** 🔧数组内元素换行 */
517
- "array-element-newline": ["warn", "consistent"],
518
- /** 🔧箭头函数括号 */
519
- "arrow-parens": ["warn", "as-needed"],
520
- /** 🔧箭头左右空格 */
521
- "arrow-spacing": "warn",
522
- /** 🔧计算属性名内部空格 */
523
- "computed-property-spacing": "warn",
524
- /** 🔧逗号位置 */
525
- "comma-style": "warn",
526
- /** 🔧属性`o.p`点号位置 */
527
- "dot-location": ["warn", "property"],
528
- /** 🔧函数调用参数换行 */
529
- "function-call-argument-newline": ["warn", "consistent"],
530
- /** 🔧生成器函数星号前后空格 */
531
- "generator-star-spacing": ["warn", {
532
- before: false,
533
- after: true,
534
- named: "after",
535
- anonymous: "after",
536
- method: "neither"
537
- }],
538
- /** 最大长度 */
539
- "max-len": ["warn", {
540
- code: 120,
541
- tabWidth: 2,
542
- ignoreComments: true,
543
- ignoreTrailingComments: true,
544
- ignoreStrings: true,
545
- ignoreTemplateLiterals: true,
546
- ignoreRegExpLiterals: true
547
- }],
548
- /** 多行三元表达式 */
549
- // 'multiline-ternary': ['warn'],
550
- /**
551
- * 🔧new 表达式括号
552
- * ```ts
553
- * const a = new A().a()
554
- * // ^ 会被改成 (new A).a(),且无法配置,故关闭
555
- * ```
556
- */
557
- "new-parens": "off",
558
- /** 🔧链式调用换行 */
559
- "newline-per-chained-call": ["warn", { ignoreChainWithDepth: 2 }],
560
- /** 禁止混用空格和 tab 作为 indent */
561
- "no-mixed-spaces-and-tabs": "warn",
562
- /** 多余的空格 */
563
- "no-multi-spaces": "warn",
564
- /** 多行空行 */
565
- "no-multiple-empty-lines": ["warn", { max: 3 }],
566
- /** 尾随空格 */
567
- "no-trailing-spaces": ["warn", {
568
- /** 注释内可能有 markdown,尾随空格会影响显示格式 */
569
- ignoreComments: true
570
- }],
571
- /** 禁止不必要的重命名 */
572
- "no-useless-rename": "warn",
573
- /** 对象与属性间的空格 */
574
- "no-whitespace-before-property": "warn",
575
- /** 对象花括号换行 */
576
- "object-curly-newline": ["warn", { consistent: true }],
577
- /** 对象键快捷写法 */
578
- "object-shorthand": ["warn", "always", {
579
- avoidQuotes: true
580
- }],
581
- /** 偏好模板字符串 */
582
- "prefer-template": "warn",
583
- /** 属性名的引号 */
584
- "quote-props": ["warn", "as-needed"],
585
- /** 展开操作符前后空格 */
586
- "rest-spread-spacing": ["warn", "never"],
587
- /** 分号前后空格 */
588
- "semi-spacing": ["warn", { before: false, after: true }],
589
- /** 分号位置 */
590
- "semi-style": "warn",
591
- /**
592
- * 排序
593
- *
594
- * FIXME: 不支持 import { type foo } from 'bar' type import 语法,故关闭
595
- */
596
- "sort-imports": ["off", {
597
- ignoreDeclarationSort: true
598
- }],
599
- /** 括号中前后空格 */
600
- "space-in-parens": "warn",
601
- /** 一元操作符前后空格 */
602
- "space-unary-ops": ["warn", { words: true, nonwords: false }],
603
- /** switch case 冒号前后空格 */
604
- "switch-colon-spacing": "warn",
605
- /** 模板字符串花括号中前后空格 */
606
- "template-curly-spacing": "warn",
607
- /** 生成器函数星号空格 */
608
- "yield-star-spacing": ["warn", "after"],
609
- // -------------------------------------------------------------
610
- // 以下需要覆盖原配置 以在 ts 文件中生效
611
- // -------------------------------------------------------------
612
- /** 语句块内部前后空格 */
613
- "block-spacing": "off",
614
- "@typescript-eslint/block-spacing": "warn",
615
- /** 括号风格 */
616
- "brace-style": "off",
617
- "@typescript-eslint/brace-style": ["warn", "1tbs", { allowSingleLine: true }],
618
- /** 尾随逗号 */
619
- "comma-dangle": "off",
620
- "@typescript-eslint/comma-dangle": ["warn", "only-multiline"],
621
- /** 逗号前后空格 */
622
- "comma-spacing": "off",
623
- "@typescript-eslint/comma-spacing": "warn",
624
- /** 🔧函数调用空格 */
625
- "func-call-spacing": "off",
626
- "@typescript-eslint/func-call-spacing": "warn",
627
- /** 🔧缩进 */
628
- // https://github.com/typescript-eslint/typescript-eslint/issues/1824
629
- // indent: ['warn', 2, {
630
- // /** 同时定义多个变量时,对齐到第一个变量定义 */
631
- // VariableDeclarator: 'first',
632
- // /** swtich case 增加 1 indent */
633
- // SwitchCase: 1,
634
- // /** 三元表达式偏移 */
635
- // offsetTernaryExpressions: true
636
- // }],
637
- indent: "off",
638
- "@typescript-eslint/indent": ["warn", 2, {
639
- /** 同时定义多个变量时,对齐到第一个变量定义 */
640
- VariableDeclarator: "first",
641
- /** swtich case 增加 1 indent */
642
- SwitchCase: 1,
643
- /** 三元表达式偏移 */
644
- offsetTernaryExpressions: true,
645
- /** 嵌套三元表达式不增加 indent */
646
- flatTernaryExpressions: false,
647
- /** 忽略一些无法正确处理的边缘情况,手动添加 indent */
648
- ignoredNodes: [
649
- "PropertyDefinition[decorators]",
650
- "TSUnionType",
651
- "FunctionExpression[params]:has(Identifier[decorators])",
652
- // 类型泛型参数
653
- "TSTypeParameterInstantiation",
654
- "TSIntersectionType"
655
- ]
656
- }],
657
- /** 🔧对象键名空格 */
658
- "key-spacing": "off",
659
- "@typescript-eslint/key-spacing": ["warn"],
660
- /** 关键词 空格 */
661
- "keyword-spacing": "off",
662
- "@typescript-eslint/keyword-spacing": "warn",
663
- /** 多余的括号 */
664
- "no-extra-parens": "off",
665
- "@typescript-eslint/no-extra-parens": ["warn", "all", {
666
- /** 允许 JSDoc 类型转换 */
667
- allowParensAfterCommentPattern: "@type",
668
- /** 忽略 JSX */
669
- ignoreJSX: "all",
670
- /** 允许条件赋值包围括号 */
671
- conditionalAssign: false,
672
- /** 允许 return 赋值包围括号 */
673
- returnAssign: false,
674
- /** 允许三元表达式内包围括号 */
675
- ternaryOperandBinaryExpressions: false,
676
- /** 允许嵌套二元表达式包围括号 */
677
- nestedBinaryExpressions: false
678
- }],
679
- /** 多余的分号 */
680
- "no-extra-semi": "off",
681
- "@typescript-eslint/no-extra-semi": ["warn"],
682
- /** 对象花括号内部前后空格 */
683
- "object-curly-spacing": "off",
684
- "@typescript-eslint/object-curly-spacing": ["warn", "always"],
685
- /** 🔧字符串引号 */
686
- quotes: "off",
687
- "@typescript-eslint/quotes": ["warn", "single", {
688
- avoidEscape: true,
689
- allowTemplateLiterals: true
690
- }],
691
- /** 分号 */
692
- semi: "off",
693
- "@typescript-eslint/semi": ["warn", "never"],
694
- /** 块语句前的空格 */
695
- "space-before-blocks": "off",
696
- "@typescript-eslint/space-before-blocks": "warn",
697
- /** 函数声明参数括号前的空格 */
698
- "space-before-function-paren": "off",
699
- "@typescript-eslint/space-before-function-paren": ["warn", {
700
- anonymous: "always",
701
- named: "never",
702
- asyncArrow: "always"
703
- }],
704
- /** 操作符左右空格 */
705
- "space-infix-ops": "off",
706
- "@typescript-eslint/space-infix-ops": "warn",
707
- // -------------------------------------------------------------
708
- // 以下为 TS Plugin Rules
709
- // -------------------------------------------------------------
710
- /** 类型定义属性间隔符 `;` / `,` / none */
711
- "@typescript-eslint/member-delimiter-style": ["warn", {
712
- multiline: { delimiter: "none", requireLast: false },
713
- singleline: { requireLast: false },
714
- multilineDetection: "brackets"
715
- }],
716
- /** 🔧多余的限定符 */
717
- "@typescript-eslint/no-unnecessary-qualifier": "warn",
718
- /** 类型标注空格 */
719
- "@typescript-eslint/type-annotation-spacing": ["warn"],
720
- // -------------------------------------------------------------
721
- // 以下为其他规则
722
- // -------------------------------------------------------------
723
- "ziloen/generic-spacing": "warn"
724
- }
725
- },
726
- {
727
- files: ["**/*.jsx", "**/*.tsx"],
728
- plugins: {
729
- react: import_eslint_plugin_react.default
730
- },
731
- rules: {
732
- // -------------------------------------------------------------
733
- // 以下为 React Plugin Rules
734
- // -------------------------------------------------------------
735
- /**
736
- * JSX 自闭合
737
- *
738
- * 经常还没写内容就被自动闭合
739
- */
740
- "react/self-closing-comp": ["off", {
741
- component: true,
742
- html: false
743
- }],
744
- /** JSX 标签空格 */
745
- "react/jsx-tag-spacing": ["warn", {
746
- closingSlash: "never",
747
- beforeSelfClosing: "proportional-always",
748
- afterOpening: "never",
749
- beforeClosing: "never"
750
- }],
751
- /** 括号内前后空格 */
752
- "react/jsx-curly-spacing": ["warn"],
753
- /** 🔧JSX 缩进,会和 TS indent 冲突,关闭 */
754
- "react/jsx-indent": "off",
755
- // 'react/jsx-indent': ['warn', 2, {
756
- // checkAttributes: true,
757
- // indentLogicalExpressions: true,
758
- // }],
759
- /** 🔧属性缩进 */
760
- "react/jsx-indent-props": ["warn", {
761
- indentMode: 2
762
- }]
763
- }
764
- }
765
- ];
766
- // Annotate the CommonJS export names for ESM import in node:
767
- 0 && (module.exports = {
768
- format,
769
- javascript,
770
- react,
771
- typescript,
772
- vue
773
- });
1
+ "use strict";var v=Object.create;var f=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var k=(e,r)=>{for(var t in r)f(e,t,{get:r[t],enumerable:!0})},x=(e,r,t,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of j(r))!C.call(e,a)&&a!==t&&f(e,a,{get:()=>r[a],enumerable:!(d=S(r,a))||d.enumerable});return e};var n=(e,r,t)=>(t=e!=null?v(T(e)):{},x(r||!e||!e.__esModule?f(t,"default",{value:e,enumerable:!0}):t,e)),E=e=>x(f({},"__esModule",{value:!0}),e);var O={};k(O,{format:()=>I,javascript:()=>g,react:()=>F,typescript:()=>c,vue:()=>L});module.exports=E(O);var b=n(require("@eslint/js"),1);var u=n(require("@stylistic/eslint-plugin"),1),o=n(require("@typescript-eslint/eslint-plugin"),1),m=n(require("eslint-plugin-promise"),1),i=n(require("eslint-plugin-react"),1),y=n(require("eslint-plugin-unicorn"),1),l=n(require("eslint-plugin-vue"),1),p=n(require("eslint-plugin-ziloen"),1),s=n(require("@typescript-eslint/parser"),1),w=n(require("vue-eslint-parser"),1);var g=[b.default.configs.recommended,{plugins:{unicorn:y.default,promise:m.default},ignores:["*.min.*","CHANGELOG.md","LICENSE*","package-lock.json","pnpm-lock.yaml","yarn.lock","node_modules","dist","*.html"],rules:{"array-callback-return":["error",{allowImplicit:!0}],"block-scoped-var":"error","constructor-super":"error",eqeqeq:["error","smart"],"logical-assignment-operators":["warn"],"max-nested-callbacks":["warn",5],"no-await-in-loop":"warn","no-async-promise-executor":"off","no-caller":"error","no-constant-binary-expression":"error","no-console":["off",{allow:["warn","error"]}],"no-constructor-return":"warn","no-empty":"off","no-eval":"warn","no-fallthrough":["error",{allowEmptyCase:!0}],"no-new-native-nonconstructor":"error","no-promise-executor-return":"off","no-restricted-globals":["error","event","name","length","status"],"no-return-await":"warn","no-unused-vars":"off","no-var":"error","prefer-const":["off",{destructuring:"all",ignoreReadBeforeAssign:!1}],"prefer-exponentiation-operator":"warn","prefer-object-has-own":"warn","prefer-promise-reject-errors":["warn",{allowEmptyReject:!0}],"require-atomic-updates":"off","unicorn/better-regex":["warn",{sortCharacterClasses:!1}],"unicorn/error-message":"warn","unicorn/no-document-cookie":"warn","unicorn/no-instanceof-array":"warn","unicorn/no-invalid-remove-event-listener":"error","unicorn/no-new-buffer":"error","unicorn/no-thenable":"error","unicorn/no-typeof-undefined":["warn",{checkGlobalVariables:!1}],"unicorn/no-unnecessary-await":"off","unicorn/no-unreadable-array-destructuring":"error","unicorn/no-useless-fallback-in-spread":"warn","unicorn/no-useless-promise-resolve-reject":"warn","unicorn/no-useless-spread":"warn","unicorn/no-useless-undefined":["warn",{checkArguments:!1}],"unicorn/no-zero-fractions":"warn","unicorn/number-literal-case":"warn","unicorn/prefer-array-flat":"warn","unicorn/prefer-array-flat-map":"warn","unicorn/prefer-array-index-of":"warn","unicorn/prefer-array-some":"warn","unicorn/prefer-at":"warn","unicorn/prefer-blob-reading-methods":"warn","unicorn/prefer-code-point":"warn","unicorn/prefer-dom-node-append":"warn","unicorn/prefer-dom-node-dataset":"warn","unicorn/prefer-dom-node-remove":"warn","unicorn/prefer-dom-node-text-content":"warn","unicorn/prefer-export-from":["warn",{ignoreUsedVariables:!0}],"unicorn/prefer-includes":"warn","unicorn/prefer-keyboard-event-key":"warn","unicorn/prefer-modern-dom-apis":"warn","unicorn/prefer-modern-math-apis":"warn","unicorn/prefer-negative-index":"warn","unicorn/prefer-node-protocol":"warn","unicorn/prefer-object-from-entries":"warn","unicorn/prefer-optional-catch-binding":"warn","unicorn/prefer-prototype-methods":"warn","unicorn/prefer-query-selector":"warn","unicorn/prefer-set-size":"warn","unicorn/prefer-string-slice":"warn","unicorn/throw-new-error":"warn","promise/no-new-statics":"error"}}];var h=require("process");function c({tsconfigPath:e}){return[...g,{plugins:{"@typescript-eslint":o.default}},{files:["**/*.?([cm])[tj]s?(x)","**/*.vue"],languageOptions:{parser:s,sourceType:"module",parserOptions:{ecmaVersion:"latest",project:e,tsconfigRootDir:(0,h.cwd)()}},rules:{...o.default.configs["strict-type-checked"].rules,"@typescript-eslint/consistent-type-definitions":"off","default-param-last":"off","@typescript-eslint/default-param-last":"error","dot-notation":"off","@typescript-eslint/dot-notation":"off","@typescript-eslint/no-confusing-void-expression":["off",{ignoreArrowShorthand:!0}],"no-dupe-class-members":"off","@typescript-eslint/no-dupe-class-members":"off","@typescript-eslint/no-empty-function":"off","@typescript-eslint/no-explicit-any":"off","@typescript-eslint/no-floating-promises":"off","no-loop-func":"off","@typescript-eslint/no-loop-func":"error","@typescript-eslint/no-misused-promises":["error",{checksVoidReturn:!1}],"@typescript-eslint/no-non-null-assertion":"off","no-redeclare":"off","@typescript-eslint/no-redeclare":["error"],"@typescript-eslint/no-redundant-type-constituents":"warn","no-throw-literal":"off","@typescript-eslint/no-throw-literal":["error",{allowThrowingAny:!1,allowThrowingUnknown:!1}],"no-undef":"off","@typescript-eslint/no-unnecessary-condition":"off","@typescript-eslint/no-unnecessary-type-assertion":"off","@typescript-eslint/no-unsafe-unary-minus":"error","no-unused-expressions":"off","@typescript-eslint/no-unused-expressions":["warn",{allowShortCircuit:!0,enforceForJSX:!0}],"no-unused-vars":"off","@typescript-eslint/no-unused-vars":"off","@typescript-eslint/prefer-nullish-coalescing":["warn",{ignorePrimitives:{bigint:!0,boolean:!0,number:!0,string:!0}}],"@typescript-eslint/prefer-optional-chain":"off","@typescript-eslint/promise-function-async":["off",{checkArrowFunctions:!1}],"@typescript-eslint/require-array-sort-compare":["error"],"@typescript-eslint/restrict-template-expressions":["error",{allowNumber:!0}],"@typescript-eslint/unified-signatures":"off"}}]}function L({tsconfigPath:e}){return[...c({tsconfigPath:e}),{plugins:{vue:l.default}},{files:["**/*.vue"],languageOptions:{parser:w.default,parserOptions:{ecmaFeatures:{jsx:!0},ecmaVersion:"latest",extraFileExtensions:[".vue"],parser:s,sourceType:"module",project:!0}},processor:l.default.processors[".vue"],rules:{...l.default.configs["vue3-essential"].rules,"vue/no-unused-vars":"off","vue/html-self-closing":"off","vue/max-attributes-per-line":"off","vue/multi-word-component-names":"off","vue/require-default-prop":"off","vue/require-prop-types":"off","vue/singleline-html-element-content-newline":"off"}}]}function F({tsconfigPath:e}){return[...c({tsconfigPath:e}),{files:["**/*.jsx","**/*.tsx"],plugins:{react:i.default,ziloen:p.default},languageOptions:{parser:s,parserOptions:{ecmaFeatures:{jsx:!0}}},rules:{"react/react-in-jsx-scope":"off","react/jsx-key":["error",{}],"react/jsx-no-undef":"off","react/jsx-fragments":["warn","syntax"],"react/no-invalid-html-attribute":"warn","ziloen/jsx-strict-logical-expressions":"error"}}]}var I=[{plugins:{"@typescript-eslint":o.default,ziloen:p.default,style:u.default},rules:{"style/array-bracket-newline":["warn","consistent"],"style/array-bracket-spacing":["warn","never"],"style/array-element-newline":["warn","consistent"],"style/arrow-parens":["warn","as-needed"],"style/arrow-spacing":"warn","style/computed-property-spacing":"warn","style/comma-style":"warn","style/dot-location":["warn","property"],"style/function-call-argument-newline":["warn","consistent"],"style/generator-star-spacing":["warn",{before:!1,after:!0,named:"after",anonymous:"after",method:"neither"}],"style/max-len":["warn",{code:120,tabWidth:2,ignoreComments:!0,ignoreTrailingComments:!0,ignoreStrings:!0,ignoreTemplateLiterals:!0,ignoreRegExpLiterals:!0}],"style/new-parens":"off","style/newline-per-chained-call":["warn",{ignoreChainWithDepth:2}],"style/no-mixed-spaces-and-tabs":"warn","style/no-multi-spaces":"warn","style/no-multiple-empty-lines":["warn",{max:3}],"style/no-trailing-spaces":["warn",{ignoreComments:!0}],"no-useless-rename":"warn","style/no-whitespace-before-property":"warn","style/object-curly-newline":["warn",{consistent:!0}],"object-shorthand":["warn","always",{avoidQuotes:!0}],"prefer-template":"warn","style/quote-props":["warn","as-needed"],"style/rest-spread-spacing":["warn","never"],"style/semi-spacing":["warn",{before:!1,after:!0}],"style/semi-style":"warn","sort-imports":["off",{ignoreDeclarationSort:!0}],"style/space-in-parens":"warn","style/space-unary-ops":["warn",{words:!0,nonwords:!1}],"style/switch-colon-spacing":"warn","style/template-curly-spacing":"warn","style/yield-star-spacing":["warn","after"],"style/block-spacing":"warn","style/brace-style":["warn","1tbs",{allowSingleLine:!0}],"style/comma-dangle":["warn","only-multiline"],"style/comma-spacing":"warn","style/func-call-spacing":"warn","style/indent":["warn",2,{VariableDeclarator:"first",SwitchCase:1,offsetTernaryExpressions:!0,flatTernaryExpressions:!1,ignoredNodes:["PropertyDefinition[decorators]","TSUnionType","FunctionExpression[params]:has(Identifier[decorators])","TSTypeParameterInstantiation","TSIntersectionType"]}],"style/key-spacing":["warn"],"style/keyword-spacing":"warn","style/no-extra-parens":["warn","all",{allowParensAfterCommentPattern:"@type",ignoreJSX:"all",conditionalAssign:!1,returnAssign:!1,ternaryOperandBinaryExpressions:!1,nestedBinaryExpressions:!1}],"style/no-extra-semi":["warn"],"style/object-curly-spacing":["warn","always"],"style/quotes":["warn","single",{avoidEscape:!0,allowTemplateLiterals:!0}],"style/semi":["warn","never"],"style/space-before-blocks":"warn","style/space-before-function-paren":["warn",{anonymous:"always",named:"never",asyncArrow:"always"}],"style/space-infix-ops":"warn","style/member-delimiter-style":["warn",{multiline:{delimiter:"none",requireLast:!1},singleline:{requireLast:!1},multilineDetection:"brackets"}],"@typescript-eslint/no-unnecessary-qualifier":"warn","style/type-annotation-spacing":["warn"],"ziloen/generic-spacing":"warn"}},{files:["**/*.jsx","**/*.tsx"],plugins:{react:i.default,style:u.default},rules:{"react/self-closing-comp":["off",{component:!0,html:!1}],"style/jsx-tag-spacing":["warn",{closingSlash:"never",beforeSelfClosing:"proportional-always",afterOpening:"never",beforeClosing:"never"}],"style/jsx-curly-spacing":["warn"],"style/jsx-indent":"off","style/jsx-indent-props":["warn",{indentMode:2}]}}];0&&(module.exports={format,javascript,react,typescript,vue});