@cuiqg/eslint-config 2.5.6 → 2.5.8

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.
Files changed (2) hide show
  1. package/dist/index.js +114 -541
  2. package/package.json +2 -10
package/dist/index.js CHANGED
@@ -3,33 +3,6 @@ import globals from "globals";
3
3
  import process from "node:process";
4
4
  import { isPackageExists } from "local-pkg";
5
5
 
6
- //#region src/utils.js
7
- async function interopDefault(module) {
8
- try {
9
- let resolved = await module;
10
- return resolved?.default || resolved;
11
- } catch (error) {
12
- throw new Error(`Cannot import module: ${String(error)}`);
13
- }
14
- }
15
- function renameRules(rules, map) {
16
- return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
17
- for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
18
- return [key, value];
19
- }));
20
- }
21
-
22
- //#endregion
23
- //#region src/configs/de-morgan.js
24
- async function deMorgan() {
25
- const pluginDeMorgan = await interopDefault(import("eslint-plugin-de-morgan"));
26
- return [{
27
- ...pluginDeMorgan.configs.recommended,
28
- name: "cuiqg/de-morgan"
29
- }];
30
- }
31
-
32
- //#endregion
33
6
  //#region src/globs.js
34
7
  const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
35
8
  const GLOB_SRC = `**/*.${GLOB_SRC_EXT}`;
@@ -53,17 +26,6 @@ const GLOB_TOML = "**/*.toml";
53
26
  const GLOB_XML = "**/*.xml";
54
27
  const GLOB_SVG = "**/*.svg";
55
28
  const GLOB_HTML = "**/*.htm?(l)";
56
- const GLOB_ALL_SRC = [
57
- GLOB_SRC,
58
- GLOB_STYLE,
59
- GLOB_HTML,
60
- GLOB_VUE,
61
- GLOB_YAML,
62
- GLOB_XML,
63
- GLOB_JSONC,
64
- GLOB_JSON5,
65
- GLOB_JSON
66
- ];
67
29
  const GLOB_EXCLUDE = [
68
30
  "**/node_modules",
69
31
  "**/dist",
@@ -96,9 +58,27 @@ const GLOB_EXCLUDE = [
96
58
  "**/__snapshots__",
97
59
  "**/auto-import?(s).d.ts",
98
60
  "**/components.d.ts",
61
+ "**/typed-router.d.ts",
99
62
  "**/.eslint-config-inspector"
100
63
  ];
101
64
 
65
+ //#endregion
66
+ //#region src/utils.js
67
+ async function interopDefault(module) {
68
+ try {
69
+ let resolved = await module;
70
+ return resolved?.default || resolved;
71
+ } catch (error) {
72
+ throw new Error(`Cannot import module: ${String(error)}`);
73
+ }
74
+ }
75
+ function renameRules(rules, map) {
76
+ return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
77
+ for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
78
+ return [key, value];
79
+ }));
80
+ }
81
+
102
82
  //#endregion
103
83
  //#region src/configs/ignores.js
104
84
  async function ignores() {
@@ -112,50 +92,11 @@ async function ignores() {
112
92
  })];
113
93
  }
114
94
 
115
- //#endregion
116
- //#region src/configs/imports.js
117
- async function imports() {
118
- const pluginImportLite = await interopDefault(import("eslint-plugin-import-lite"));
119
- return [{
120
- name: "cuiqg/imports",
121
- plugins: { import: pluginImportLite },
122
- rules: {
123
- "import/consistent-type-specifier-style": ["error", "top-level"],
124
- "import/first": "error",
125
- "import/newline-after-import": ["error", { count: 1 }],
126
- "import/no-duplicates": "error",
127
- "import/no-mutable-exports": "error",
128
- "import/no-named-default": "error"
129
- }
130
- }];
131
- }
132
-
133
- //#endregion
134
- //#region src/env.js
135
- const isInGitHookOrLintStaged = () => {
136
- return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
137
- };
138
- const isInEditor = () => {
139
- if (process.env.CI) return false;
140
- if (isInGitHookOrLintStaged()) return false;
141
- return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
142
- };
143
- const hasVue = () => [
144
- "vue",
145
- "nuxt",
146
- "vitepress",
147
- "@slidev/cli"
148
- ].some((i) => isPackageExists("vue"));
149
- const hasTypeScript = () => isPackageExists("typescript");
150
- const hasUnoCss = () => isPackageExists("unocss");
151
- const hasNextjs = () => isPackageExists("next");
152
-
153
95
  //#endregion
154
96
  //#region src/configs/javascript.js
155
97
  async function javascript() {
156
- const [pluginUnuseImports, pluginJs] = await Promise.all([interopDefault(import("eslint-plugin-unused-imports")), interopDefault(import("@eslint/js"))]);
98
+ const [pluginJs] = await Promise.all([interopDefault(import("@eslint/js"))]);
157
99
  return [{
158
- name: "cuiqg/javascript",
159
100
  languageOptions: {
160
101
  ecmaVersion: "latest",
161
102
  globals: {
@@ -171,200 +112,9 @@ async function javascript() {
171
112
  sourceType: "module"
172
113
  },
173
114
  linterOptions: { reportUnusedDisableDirectives: true },
174
- plugins: {
175
- "unused-imports": pluginUnuseImports,
176
- js: pluginJs
177
- },
178
- rules: {
179
- ...pluginJs.configs.recommended.rules,
180
- "accessor-pairs": ["error", {
181
- enforceForClassMembers: true,
182
- setWithoutGet: true
183
- }],
184
- "array-callback-return": "error",
185
- "block-scoped-var": "error",
186
- "constructor-super": "error",
187
- "default-case-last": "error",
188
- "dot-notation": ["error", { allowKeywords: true }],
189
- eqeqeq: ["error", "smart"],
190
- "new-cap": ["error", {
191
- capIsNew: false,
192
- newIsCap: true,
193
- properties: true
194
- }],
195
- "no-alert": "error",
196
- "no-array-constructor": "error",
197
- "no-async-promise-executor": "error",
198
- "no-caller": "error",
199
- "no-case-declarations": "error",
200
- "no-class-assign": "error",
201
- "no-compare-neg-zero": "error",
202
- "no-cond-assign": ["error", "always"],
203
- "no-console": ["error", { allow: ["warn", "error"] }],
204
- "no-const-assign": "error",
205
- "no-control-regex": "error",
206
- "no-debugger": "error",
207
- "no-delete-var": "error",
208
- "no-dupe-args": "error",
209
- "no-dupe-class-members": "error",
210
- "no-dupe-keys": "error",
211
- "no-duplicate-case": "error",
212
- "no-empty": ["error", { allowEmptyCatch: true }],
213
- "no-empty-character-class": "error",
214
- "no-empty-pattern": "error",
215
- "no-eval": "error",
216
- "no-ex-assign": "error",
217
- "no-extend-native": "error",
218
- "no-extra-bind": "error",
219
- "no-extra-boolean-cast": "error",
220
- "no-fallthrough": "error",
221
- "no-func-assign": "error",
222
- "no-global-assign": "error",
223
- "no-implied-eval": "error",
224
- "no-import-assign": "error",
225
- "no-invalid-regexp": "error",
226
- "no-irregular-whitespace": "error",
227
- "no-iterator": "error",
228
- "no-labels": ["error", {
229
- allowLoop: false,
230
- allowSwitch: false
231
- }],
232
- "no-lone-blocks": "error",
233
- "no-loss-of-precision": "error",
234
- "no-misleading-character-class": "error",
235
- "no-multi-str": "error",
236
- "no-new": "error",
237
- "no-new-func": "error",
238
- "no-new-native-nonconstructor": "error",
239
- "no-new-wrappers": "error",
240
- "no-obj-calls": "error",
241
- "no-octal": "error",
242
- "no-octal-escape": "error",
243
- "no-proto": "error",
244
- "no-prototype-builtins": "error",
245
- "no-redeclare": ["error", { builtinGlobals: false }],
246
- "no-regex-spaces": "error",
247
- "no-restricted-globals": [
248
- "error",
249
- {
250
- message: "Use `globalThis` instead.",
251
- name: "global"
252
- },
253
- {
254
- message: "Use `globalThis` instead.",
255
- name: "self"
256
- }
257
- ],
258
- "no-restricted-properties": [
259
- "error",
260
- {
261
- message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
262
- property: "__proto__"
263
- },
264
- {
265
- message: "Use `Object.defineProperty` instead.",
266
- property: "__defineGetter__"
267
- },
268
- {
269
- message: "Use `Object.defineProperty` instead.",
270
- property: "__defineSetter__"
271
- },
272
- {
273
- message: "Use `Object.getOwnPropertyDescriptor` instead.",
274
- property: "__lookupGetter__"
275
- },
276
- {
277
- message: "Use `Object.getOwnPropertyDescriptor` instead.",
278
- property: "__lookupSetter__"
279
- }
280
- ],
281
- "no-restricted-syntax": [
282
- "error",
283
- "TSEnumDeclaration[const=true]",
284
- "TSExportAssignment"
285
- ],
286
- "no-self-assign": ["error", { props: true }],
287
- "no-self-compare": "error",
288
- "no-sequences": "error",
289
- "no-shadow-restricted-names": "error",
290
- "no-sparse-arrays": "error",
291
- "no-template-curly-in-string": "error",
292
- "no-this-before-super": "error",
293
- "no-throw-literal": "error",
294
- "no-undef": "error",
295
- "no-undef-init": "error",
296
- "no-unexpected-multiline": "error",
297
- "no-unmodified-loop-condition": "error",
298
- "no-unneeded-ternary": ["error", { defaultAssignment: false }],
299
- "no-unreachable": "error",
300
- "no-unreachable-loop": "error",
301
- "no-unsafe-finally": "error",
302
- "no-unsafe-negation": "error",
303
- "no-unused-expressions": ["error", {
304
- allowShortCircuit: true,
305
- allowTaggedTemplates: true,
306
- allowTernary: true
307
- }],
308
- "no-unused-vars": ["error", {
309
- args: "none",
310
- caughtErrors: "none",
311
- ignoreRestSiblings: true,
312
- vars: "all"
313
- }],
314
- "no-use-before-define": ["error", {
315
- classes: false,
316
- functions: false,
317
- variables: true
318
- }],
319
- "no-useless-backreference": "error",
320
- "no-useless-call": "error",
321
- "no-useless-catch": "error",
322
- "no-useless-computed-key": "error",
323
- "no-useless-constructor": "error",
324
- "no-useless-rename": "error",
325
- "no-var": "error",
326
- "no-with": "error",
327
- "object-shorthand": [
328
- "error",
329
- "always",
330
- {
331
- avoidQuotes: true,
332
- ignoreConstructors: false
333
- }
334
- ],
335
- "one-var": ["error", { initialized: "never" }],
336
- "prefer-arrow-callback": ["error", {
337
- allowNamedFunctions: false,
338
- allowUnboundThis: true
339
- }],
340
- "prefer-const": [isInEditor() ? "warn" : "error", {
341
- destructuring: "all",
342
- ignoreReadBeforeAssign: true
343
- }],
344
- "prefer-exponentiation-operator": "error",
345
- "prefer-promise-reject-errors": "error",
346
- "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
347
- "prefer-rest-params": "error",
348
- "prefer-spread": "error",
349
- "prefer-template": "error",
350
- "symbol-description": "error",
351
- "unicode-bom": ["error", "never"],
352
- "unused-imports/no-unused-imports": isInEditor() ? "warn" : "error",
353
- "unused-imports/no-unused-vars": ["error", {
354
- args: "after-used",
355
- argsIgnorePattern: "^_",
356
- ignoreRestSiblings: true,
357
- vars: "all",
358
- varsIgnorePattern: "^_"
359
- }],
360
- "use-isnan": ["error", {
361
- enforceForIndexOf: true,
362
- enforceForSwitchCase: true
363
- }],
364
- "valid-typeof": ["error", { requireStringLiterals: true }],
365
- "vars-on-top": "error",
366
- yoda: ["error", "never"]
367
- }
115
+ name: "cuiqg/javascript",
116
+ plugins: { js: pluginJs },
117
+ rules: { ...pluginJs.configs.recommended.rules }
368
118
  }];
369
119
  }
370
120
 
@@ -398,194 +148,36 @@ async function jsdoc() {
398
148
  }
399
149
 
400
150
  //#endregion
401
- //#region src/configs/jsonc.js
402
- async function jsonc() {
403
- const files = [
404
- GLOB_JSON,
405
- GLOB_JSON5,
406
- GLOB_JSONC
407
- ];
408
- const [pluginJsonc, parserJsonc] = await Promise.all([interopDefault(import("eslint-plugin-jsonc")), interopDefault(import("jsonc-eslint-parser"))]);
409
- return [{
410
- files,
411
- name: "cuiqg/jsonc",
412
- plugins: { jsonc: pluginJsonc },
413
- languageOptions: { parser: parserJsonc },
414
- rules: {
415
- "jsonc/no-bigint-literals": "error",
416
- "jsonc/no-binary-expression": "error",
417
- "jsonc/no-binary-numeric-literals": "error",
418
- "jsonc/no-dupe-keys": "error",
419
- "jsonc/no-escape-sequence-in-identifier": "error",
420
- "jsonc/no-floating-decimal": "error",
421
- "jsonc/no-hexadecimal-numeric-literals": "error",
422
- "jsonc/no-infinity": "error",
423
- "jsonc/no-multi-str": "error",
424
- "jsonc/no-nan": "error",
425
- "jsonc/no-number-props": "error",
426
- "jsonc/no-numeric-separators": "error",
427
- "jsonc/no-octal": "error",
428
- "jsonc/no-octal-escape": "error",
429
- "jsonc/no-octal-numeric-literals": "error",
430
- "jsonc/no-parenthesized": "error",
431
- "jsonc/no-plus-sign": "error",
432
- "jsonc/no-regexp-literals": "error",
433
- "jsonc/no-sparse-arrays": "error",
434
- "jsonc/no-template-literals": "error",
435
- "jsonc/no-undefined-value": "error",
436
- "jsonc/no-unicode-codepoint-escapes": "error",
437
- "jsonc/no-useless-escape": "error",
438
- "jsonc/space-unary-ops": "error",
439
- "jsonc/valid-json-number": "error",
440
- "jsonc/vue-custom-block/no-parsing-error": "error",
441
- "jsonc/array-bracket-spacing": ["error", "never"],
442
- "jsonc/comma-dangle": ["error", "never"],
443
- "jsonc/comma-style": ["error", "last"],
444
- "jsonc/indent": ["error", 2],
445
- "jsonc/key-spacing": ["error", {
446
- afterColon: true,
447
- beforeColon: false
448
- }],
449
- "jsonc/object-curly-newline": ["error", {
450
- consistent: true,
451
- multiline: true
452
- }],
453
- "jsonc/object-curly-spacing": ["error", "always"],
454
- "jsonc/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
455
- "jsonc/quote-props": "error",
456
- "jsonc/quotes": "error"
457
- }
458
- }];
459
- }
460
-
461
- //#endregion
462
- //#region src/configs/nextjs.js
463
- function normalizeRules(rules) {
464
- return Object.fromEntries(Object.entries(rules).map(([key, value]) => [key, typeof value === "string" ? [value] : value]));
465
- }
466
- async function nextjs() {
467
- const files = [GLOB_SRC];
468
- const pluginNextJS = await interopDefault(import("@next/eslint-plugin-next"));
469
- return [{
470
- name: "cuiqg/nextjs",
471
- files,
472
- plugins: { next: pluginNextJS },
473
- languageOptions: {
474
- parserOptions: { ecmaFeatures: { jsx: true } },
475
- sourceType: "module"
476
- },
477
- rules: {
478
- ...normalizeRules(pluginNextJS.configs.recommended.rules),
479
- ...normalizeRules(pluginNextJS.configs["core-web-vitals"].rules)
480
- },
481
- settings: { react: { version: "detect" } }
482
- }];
483
- }
484
-
485
- //#endregion
486
- //#region src/configs/node.js
487
- async function node() {
488
- const pluginNode = await interopDefault(import("eslint-plugin-n"));
151
+ //#region src/configs/macros.js
152
+ async function macros() {
153
+ const configMacros = await interopDefault(import("@vue-macros/eslint-config"));
489
154
  return [{
490
- name: "cuiqg/node",
491
- plugins: { node: pluginNode },
492
- rules: {
493
- "node/handle-callback-err": ["error", "^(err|error)$"],
494
- "node/no-deprecated-api": "error",
495
- "node/no-exports-assign": "error",
496
- "node/no-new-require": "error",
497
- "node/no-path-concat": "error",
498
- "node/prefer-global/buffer": ["error", "never"],
499
- "node/prefer-global/process": ["error", "never"],
500
- "node/process-exit-as-throw": "error"
501
- }
155
+ ...configMacros,
156
+ name: "cuiqg/macros"
502
157
  }];
503
158
  }
504
159
 
505
160
  //#endregion
506
161
  //#region src/configs/package-json.js
507
162
  async function packageJson() {
508
- const [pluginPackageJson, pluginDepend, parserJsonc] = await Promise.all([
509
- interopDefault(import("eslint-plugin-package-json")),
510
- interopDefault(import("eslint-plugin-depend")),
511
- interopDefault(import("jsonc-eslint-parser"))
512
- ]);
163
+ const [pluginPackageJson, parserJsonc] = await Promise.all([interopDefault(import("eslint-plugin-package-json")), interopDefault(import("jsonc-eslint-parser"))]);
513
164
  return [{
514
165
  files: ["**/package.json"],
515
- plugins: {
516
- depend: pluginDepend,
517
- "package-json": pluginPackageJson
518
- },
519
166
  languageOptions: { parser: parserJsonc },
520
167
  name: "cuiqg/package-json",
521
- rules: {
522
- "depend/ban-dependencies": "error",
523
- ...pluginPackageJson.configs.recommended.rules
524
- },
168
+ plugins: { "package-json": pluginPackageJson },
169
+ rules: { ...pluginPackageJson.configs.recommended.rules },
525
170
  settings: { packageJson: { enforceForPrivate: false } }
526
171
  }];
527
172
  }
528
173
 
529
- //#endregion
530
- //#region src/configs/perfectionist.js
531
- async function perfectionist() {
532
- const pluginPerfectionist = await interopDefault(import("eslint-plugin-perfectionist"));
533
- return [{
534
- name: "cuiqg/perfectionist",
535
- plugins: { perfectionist: pluginPerfectionist },
536
- rules: {
537
- "perfectionist/sort-exports": ["error", {
538
- order: "asc",
539
- type: "natural"
540
- }],
541
- "perfectionist/sort-imports": ["error", {
542
- groups: [
543
- "type",
544
- [
545
- "parent-type",
546
- "sibling-type",
547
- "index-type",
548
- "internal-type"
549
- ],
550
- "builtin",
551
- "external",
552
- "internal",
553
- [
554
- "parent",
555
- "sibling",
556
- "index"
557
- ],
558
- "side-effect",
559
- "object",
560
- "unknown"
561
- ],
562
- newlinesBetween: "ignore",
563
- order: "asc",
564
- type: "natural"
565
- }],
566
- "perfectionist/sort-named-exports": ["error", {
567
- order: "asc",
568
- type: "natural"
569
- }],
570
- "perfectionist/sort-named-imports": ["error", {
571
- order: "asc",
572
- type: "natural"
573
- }]
574
- },
575
- settings: { perfectionist: {
576
- order: "desc",
577
- type: "line-length"
578
- } }
579
- }];
580
- }
581
-
582
174
  //#endregion
583
175
  //#region src/configs/prettier.js
584
176
  async function prettier() {
585
177
  const [pluginPrettier, recommendedPrettier] = await Promise.all([interopDefault(import("eslint-plugin-prettier")), interopDefault(import("eslint-plugin-prettier/recommended"))]);
586
178
  return [{
587
- plugins: { prettier: pluginPrettier },
588
179
  name: "cuiqg/prettier",
180
+ plugins: { prettier: pluginPrettier },
589
181
  rules: {
590
182
  ...recommendedPrettier.rules,
591
183
  "prettier/prettier": "warn"
@@ -598,33 +190,23 @@ async function prettier() {
598
190
  async function stylistic() {
599
191
  const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
600
192
  const config = pluginStylistic.configs.customize({
601
- pluginName: "style",
193
+ commaDangle: "never",
602
194
  indent: 2,
195
+ pluginName: "style",
603
196
  quotes: "single",
604
- semi: false,
605
- commaDangle: "never"
197
+ semi: false
606
198
  });
607
199
  return [{
608
200
  name: "cuiqg/stylistic",
609
201
  plugins: { style: pluginStylistic },
610
- rules: {
611
- ...config.rules,
612
- "style/generator-star-spacing": ["error", {
613
- after: true,
614
- before: false
615
- }],
616
- "style/yield-star-spacing": ["error", {
617
- after: true,
618
- before: false
619
- }]
620
- }
202
+ rules: { ...config.rules }
621
203
  }];
622
204
  }
623
205
 
624
206
  //#endregion
625
207
  //#region src/configs/unocss.js
626
208
  async function unocss() {
627
- const [pluginUnoCSS] = await Promise.all([interopDefault(import("@unocss/eslint-plugin"))]);
209
+ const pluginUnoCSS = await interopDefault(import("@unocss/eslint-plugin"));
628
210
  return [{
629
211
  name: "cuiqg/unocss",
630
212
  plugins: { unocss: pluginUnoCSS },
@@ -638,25 +220,26 @@ async function vue() {
638
220
  const files = [GLOB_VUE];
639
221
  const [pluginVue, parserVue] = await Promise.all([interopDefault(import("eslint-plugin-vue")), interopDefault(import("vue-eslint-parser"))]);
640
222
  return [{
223
+ files,
641
224
  languageOptions: {
642
225
  globals: {
643
- ref: "readonly",
644
226
  computed: "readonly",
645
- reactive: "readonly",
646
- defineProps: "readonly",
647
227
  defineEmits: "readonly",
648
- defineModel: "readonly",
649
228
  defineExpose: "readonly",
229
+ defineModel: "readonly",
650
230
  defineOptions: "readonly",
231
+ defineProps: "readonly",
651
232
  defineSlots: "readonly",
652
- useSlots: "readonly",
653
- useAttrs: "readonly",
654
- onMounted: "readonly",
655
- onUnmounted: "readonly",
656
233
  onActivated: "readonly",
657
234
  onDeactivated: "readonly",
235
+ onMounted: "readonly",
236
+ onUnmounted: "readonly",
237
+ reactive: "readonly",
238
+ ref: "readonly",
658
239
  toRef: "readonly",
659
240
  toRefs: "readonly",
241
+ useAttrs: "readonly",
242
+ useSlots: "readonly",
660
243
  watch: "readonly",
661
244
  watchEffect: "readonly"
662
245
  },
@@ -670,31 +253,39 @@ async function vue() {
670
253
  },
671
254
  name: "cuiqg/vue",
672
255
  plugins: { vue: pluginVue },
673
- files,
674
256
  processor: pluginVue.processors[".vue"],
675
257
  rules: {
676
- ...pluginVue.configs.base.rules,
677
- ...pluginVue.configs["flat/essential"].map((c) => c.rules).reduce((acc, c) => ({
678
- ...acc,
679
- ...c
680
- }), {}),
681
- ...pluginVue.configs["flat/strongly-recommended"].map((c) => c.rules).reduce((acc, c) => ({
682
- ...acc,
683
- ...c
684
- }), {}),
685
258
  ...pluginVue.configs["flat/recommended"].map((c) => c.rules).reduce((acc, c) => ({
686
259
  ...acc,
687
260
  ...c
688
261
  }), {}),
689
262
  "node/prefer-global/process": "off",
263
+ "vue/array-bracket-spacing": ["error", "never"],
264
+ "vue/arrow-spacing": ["error", {
265
+ after: true,
266
+ before: true
267
+ }],
690
268
  "vue/block-order": ["error", { order: [
691
269
  "script",
692
270
  "template",
693
271
  "style"
694
272
  ] }],
695
- "vue/component-name-in-template-casing": ["error", "PascalCase"],
696
- "vue/component-options-name-casing": ["error", "PascalCase"],
697
- "vue/component-tags-order": "off",
273
+ "vue/block-spacing": ["error", "always"],
274
+ "vue/block-tag-newline": ["error", {
275
+ multiline: "always",
276
+ singleline: "always"
277
+ }],
278
+ "vue/brace-style": [
279
+ "error",
280
+ "stroustrup",
281
+ { allowSingleLine: true }
282
+ ],
283
+ "vue/comma-dangle": ["error", "always-multiline"],
284
+ "vue/comma-spacing": ["error", {
285
+ after: true,
286
+ before: false
287
+ }],
288
+ "vue/comma-style": ["error", "last"],
698
289
  "vue/custom-event-name-casing": ["error", "camelCase"],
699
290
  "vue/define-macros-order": ["error", { order: [
700
291
  "defineOptions",
@@ -705,8 +296,21 @@ async function vue() {
705
296
  "vue/dot-location": ["error", "property"],
706
297
  "vue/dot-notation": ["error", { allowKeywords: true }],
707
298
  "vue/eqeqeq": ["error", "smart"],
299
+ "vue/html-comment-content-spacing": [
300
+ "error",
301
+ "always",
302
+ { exceptions: ["-"] }
303
+ ],
708
304
  "vue/html-indent": ["error", 2],
709
305
  "vue/html-quotes": ["error", "double"],
306
+ "vue/key-spacing": ["error", {
307
+ afterColon: true,
308
+ beforeColon: false
309
+ }],
310
+ "vue/keyword-spacing": ["error", {
311
+ after: true,
312
+ before: true
313
+ }],
710
314
  "vue/max-attributes-per-line": "off",
711
315
  "vue/multi-word-component-names": "off",
712
316
  "vue/no-dupe-keys": "off",
@@ -725,6 +329,9 @@ async function vue() {
725
329
  "vue/no-unused-refs": "error",
726
330
  "vue/no-useless-v-bind": "error",
727
331
  "vue/no-v-html": "off",
332
+ "vue/object-curly-newline": "off",
333
+ "vue/object-curly-spacing": ["error", "always"],
334
+ "vue/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
728
335
  "vue/object-shorthand": [
729
336
  "error",
730
337
  "always",
@@ -733,96 +340,62 @@ async function vue() {
733
340
  ignoreConstructors: false
734
341
  }
735
342
  ],
343
+ "vue/operator-linebreak": ["error", "before"],
344
+ "vue/padding-line-between-blocks": ["error", "always"],
736
345
  "vue/prefer-separate-static-class": "error",
737
346
  "vue/prefer-template": "error",
738
347
  "vue/prop-name-casing": ["error", "camelCase"],
348
+ "vue/quote-props": ["error", "consistent-as-needed"],
739
349
  "vue/require-default-prop": "off",
740
350
  "vue/require-prop-types": "off",
351
+ "vue/space-in-parens": ["error", "never"],
741
352
  "vue/space-infix-ops": "error",
742
353
  "vue/space-unary-ops": ["error", {
743
354
  nonwords: false,
744
355
  words: true
745
356
  }],
746
- "vue/array-bracket-spacing": ["error", "never"],
747
- "vue/arrow-spacing": ["error", {
748
- after: true,
749
- before: true
750
- }],
751
- "vue/block-spacing": ["error", "always"],
752
- "vue/block-tag-newline": ["error", {
753
- multiline: "always",
754
- singleline: "always"
755
- }],
756
- "vue/brace-style": [
757
- "error",
758
- "stroustrup",
759
- { allowSingleLine: true }
760
- ],
761
- "vue/comma-dangle": ["error", "always-multiline"],
762
- "vue/comma-spacing": ["error", {
763
- after: true,
764
- before: false
765
- }],
766
- "vue/comma-style": ["error", "last"],
767
- "vue/html-comment-content-spacing": [
768
- "error",
769
- "always",
770
- { exceptions: ["-"] }
771
- ],
772
- "vue/key-spacing": ["error", {
773
- afterColon: true,
774
- beforeColon: false
775
- }],
776
- "vue/keyword-spacing": ["error", {
777
- after: true,
778
- before: true
779
- }],
780
- "vue/object-curly-newline": "off",
781
- "vue/object-curly-spacing": ["error", "always"],
782
- "vue/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
783
- "vue/operator-linebreak": ["error", "before"],
784
- "vue/padding-line-between-blocks": ["error", "always"],
785
- "vue/quote-props": ["error", "consistent-as-needed"],
786
- "vue/space-in-parens": ["error", "never"],
787
357
  "vue/template-curly-spacing": "error"
788
358
  }
789
359
  }];
790
360
  }
791
361
 
792
362
  //#endregion
793
- //#region src/configs/macros.js
794
- async function macros() {
795
- const configMacros = await interopDefault(import("@vue-macros/eslint-config"));
796
- return [{
797
- ...configMacros,
798
- name: "cuiqg/macros"
799
- }];
800
- }
363
+ //#region src/env.js
364
+ const isInGitHookOrLintStaged = () => {
365
+ return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
366
+ };
367
+ const isInEditor = () => {
368
+ if (process.env.CI) return false;
369
+ if (isInGitHookOrLintStaged()) return false;
370
+ return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
371
+ };
372
+ const hasVue = () => [
373
+ "vue",
374
+ "nuxt",
375
+ "vitepress",
376
+ "@slidev/cli"
377
+ ].some((i) => isPackageExists(i));
378
+ const hasTypeScript = () => isPackageExists("typescript");
379
+ const hasUnoCss = () => isPackageExists("unocss");
801
380
 
802
381
  //#endregion
803
382
  //#region src/presets.js
804
- const defaultPluginRenaming = {
805
- "@next/next": "next",
806
- n: "node",
807
- vitest: "test",
808
- "import-lite": "import",
809
- "@stylistic": "style"
810
- };
383
+ const defaultPluginRenaming = { "@stylistic": "style" };
384
+ /**
385
+ *
386
+ * @param {object} options - 设置选项
387
+ * @param {...any} userConfigs - 用户配置
388
+ * @returns {Promise<any[]>} 合并后的配置
389
+ */
811
390
  function cuiqg(options = {}, ...userConfigs) {
812
- const { prettier: enablePrettier = false, imports: enableImports = true, vue: enableVue = hasVue(), unocss: enableUnocss = hasUnoCss(), nextjs: enableNextjs = hasNextjs() } = options;
391
+ const { prettier: enablePrettier = false, unocss: enableUnocss = hasUnoCss(), vue: enableVue = hasVue() } = options;
813
392
  const configs = [];
814
- configs.push(deMorgan(), ignores(), javascript(), jsdoc(), jsonc(), stylistic(), node(), packageJson(), perfectionist());
815
- if (enableImports) configs.push(imports());
816
- if (enableVue) {
817
- configs.push(vue());
818
- configs.push(macros());
819
- }
393
+ configs.push(ignores(), javascript(), jsdoc(), stylistic(), packageJson());
394
+ if (enableVue) configs.push(vue(), macros());
820
395
  if (enableUnocss) configs.push(unocss());
821
- if (enableNextjs) configs.push(nextjs());
822
396
  if (enablePrettier) configs.push(prettier());
823
397
  let composer = new FlatConfigComposer();
824
398
  composer = composer.append(...configs, ...userConfigs).renamePlugins(defaultPluginRenaming);
825
- if (isInEditor()) composer = composer.disableRulesFix(["unused-imports/no-unused-imports", "prefer-const"], { builtinRules: () => import(["eslint", "use-at-your-own-risk"].join("/")).then((r) => r.builtinRules) });
826
399
  return composer;
827
400
  }
828
401
 
@@ -831,4 +404,4 @@ function cuiqg(options = {}, ...userConfigs) {
831
404
  var src_default = cuiqg;
832
405
 
833
406
  //#endregion
834
- export { GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_STYLUS, GLOB_SVG, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, cuiqg, deMorgan, src_default as default, defaultPluginRenaming, hasNextjs, hasTypeScript, hasUnoCss, hasVue, ignores, imports, isInEditor, isInGitHookOrLintStaged, javascript, jsdoc, jsonc, macros, nextjs, node, packageJson, perfectionist, prettier, stylistic, unocss, vue };
407
+ export { GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_STYLUS, GLOB_SVG, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, cuiqg, src_default as default, defaultPluginRenaming, hasTypeScript, hasUnoCss, hasVue, ignores, isInEditor, isInGitHookOrLintStaged, javascript, jsdoc, macros, packageJson, prettier, stylistic, unocss, vue };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuiqg/eslint-config",
3
- "version": "2.5.6",
3
+ "version": "2.5.8",
4
4
  "description": "Eslint config for @cuiqg",
5
5
  "keywords": [
6
6
  "eslint-config"
@@ -20,7 +20,6 @@
20
20
  "@eslint/eslintrc": "^3.3.1",
21
21
  "bumpp": "^10.2.2",
22
22
  "eslint": "^9.32.0",
23
- "prettier": "^3.6.2",
24
23
  "publint": "^0.3.12",
25
24
  "tsdown": "^0.13.3"
26
25
  },
@@ -29,30 +28,23 @@
29
28
  },
30
29
  "dependencies": {
31
30
  "@eslint/js": "^9.32.0",
32
- "@next/eslint-plugin-next": "^15.4.6",
33
31
  "@stylistic/eslint-plugin": "^5.2.3",
34
32
  "@unocss/eslint-plugin": "^66.4.2",
35
33
  "@vue-macros/eslint-config": "3.0.0-beta.21",
36
34
  "eslint-config-flat-gitignore": "^2.1.0",
37
35
  "eslint-config-prettier": "^10.1.8",
38
36
  "eslint-flat-config-utils": "^2.1.1",
39
- "eslint-plugin-de-morgan": "^1.3.1",
40
- "eslint-plugin-depend": "^1.2.0",
41
- "eslint-plugin-import-lite": "^0.3.0",
42
37
  "eslint-plugin-jsdoc": "^52.0.4",
43
- "eslint-plugin-jsonc": "^2.20.1",
44
- "eslint-plugin-n": "^17.21.3",
45
38
  "eslint-plugin-package-json": "^0.52.1",
46
39
  "eslint-plugin-perfectionist": "^4.15.0",
47
40
  "eslint-plugin-prettier": "^5.5.4",
48
- "eslint-plugin-unused-imports": "^4.1.4",
41
+ "eslint-plugin-unicorn": "^61.0.2",
49
42
  "eslint-plugin-vue": "^10.4.0",
50
43
  "globals": "^16.3.0",
51
44
  "jsonc-eslint-parser": "^2.4.0",
52
45
  "local-pkg": "^1.1.1",
53
46
  "vue-eslint-parser": "^10.2.0"
54
47
  },
55
- "prettier": "@cuiqg/prettier-config",
56
48
  "main": "./dist/index.js",
57
49
  "exports": {
58
50
  ".": "./dist/index.js"