@cuiqg/eslint-config 2.8.8 → 2.8.10
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.mjs +330 -127
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import { isPackageExists } from "local-pkg";
|
|
4
4
|
import globals from "globals";
|
|
5
|
-
import process from "node:process";
|
|
5
|
+
import process$1 from "node:process";
|
|
6
6
|
|
|
7
7
|
//#region src/globs.js
|
|
8
8
|
const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
@@ -70,12 +70,6 @@ async function interopDefault(module) {
|
|
|
70
70
|
throw new Error(`Cannot import module: ${String(error)}`);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
function renameRules(rules, map) {
|
|
74
|
-
return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
|
|
75
|
-
for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
|
|
76
|
-
return [key, value];
|
|
77
|
-
}));
|
|
78
|
-
}
|
|
79
73
|
|
|
80
74
|
//#endregion
|
|
81
75
|
//#region src/configs/ignores.js
|
|
@@ -90,48 +84,24 @@ async function ignores() {
|
|
|
90
84
|
})];
|
|
91
85
|
}
|
|
92
86
|
|
|
93
|
-
//#endregion
|
|
94
|
-
//#region src/env.js
|
|
95
|
-
const isInGitHookOrLintStaged = () => {
|
|
96
|
-
return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
97
|
-
};
|
|
98
|
-
const isInEditor = () => {
|
|
99
|
-
if (process.env.CI) return false;
|
|
100
|
-
if (isInGitHookOrLintStaged()) return false;
|
|
101
|
-
return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
|
|
102
|
-
};
|
|
103
|
-
const hasVue = () => [
|
|
104
|
-
"vue",
|
|
105
|
-
"nuxt",
|
|
106
|
-
"vitepress",
|
|
107
|
-
"@slidev/cli"
|
|
108
|
-
].some((i) => isPackageExists(i));
|
|
109
|
-
const hasTypeScript = () => isPackageExists("typescript");
|
|
110
|
-
const hasUnocss = () => isPackageExists("unocss");
|
|
111
|
-
const hasTailwindcss = () => isPackageExists("tailwindcss");
|
|
112
|
-
|
|
113
87
|
//#endregion
|
|
114
88
|
//#region src/configs/javascript.js
|
|
115
|
-
async function javascript() {
|
|
116
|
-
const
|
|
89
|
+
async function javascript(options = {}) {
|
|
90
|
+
const { isInEditor: isInEditor$1 = false } = options;
|
|
117
91
|
const pluginUnusedImports = await interopDefault(import("eslint-plugin-unused-imports"));
|
|
118
92
|
return [{
|
|
119
|
-
files,
|
|
120
93
|
name: "cuiqg/javascript",
|
|
121
94
|
plugins: { "unused-imports": pluginUnusedImports },
|
|
122
95
|
languageOptions: {
|
|
123
|
-
ecmaVersion: "latest",
|
|
124
96
|
globals: {
|
|
125
97
|
...globals.browser,
|
|
126
98
|
...globals.es2025,
|
|
127
99
|
...globals.node
|
|
128
100
|
},
|
|
129
101
|
parserOptions: {
|
|
130
|
-
ecmaFeatures: { jsx: true },
|
|
131
102
|
ecmaVersion: "latest",
|
|
132
103
|
sourceType: "module"
|
|
133
|
-
}
|
|
134
|
-
sourceType: "module"
|
|
104
|
+
}
|
|
135
105
|
},
|
|
136
106
|
linterOptions: { reportUnusedDisableDirectives: true },
|
|
137
107
|
rules: {
|
|
@@ -296,7 +266,7 @@ async function javascript() {
|
|
|
296
266
|
allowNamedFunctions: false,
|
|
297
267
|
allowUnboundThis: true
|
|
298
268
|
}],
|
|
299
|
-
"prefer-const": [isInEditor ? "warn" : "error", {
|
|
269
|
+
"prefer-const": [isInEditor$1 ? "warn" : "error", {
|
|
300
270
|
destructuring: "all",
|
|
301
271
|
ignoreReadBeforeAssign: true
|
|
302
272
|
}],
|
|
@@ -308,7 +278,7 @@ async function javascript() {
|
|
|
308
278
|
"prefer-template": "error",
|
|
309
279
|
"symbol-description": "error",
|
|
310
280
|
"unicode-bom": ["error", "never"],
|
|
311
|
-
"unused-imports/no-unused-imports": isInEditor ? "warn" : "error",
|
|
281
|
+
"unused-imports/no-unused-imports": isInEditor$1 ? "warn" : "error",
|
|
312
282
|
"unused-imports/no-unused-vars": ["error", {
|
|
313
283
|
args: "after-used",
|
|
314
284
|
argsIgnorePattern: "^_",
|
|
@@ -351,7 +321,8 @@ async function jsdoc() {
|
|
|
351
321
|
"jsdoc/require-yields-check": "warn",
|
|
352
322
|
"jsdoc/check-alignment": "warn",
|
|
353
323
|
"jsdoc/multiline-blocks": "warn"
|
|
354
|
-
}
|
|
324
|
+
},
|
|
325
|
+
settings: { jsdoc: { mode: "jsdoc" } }
|
|
355
326
|
}];
|
|
356
327
|
}
|
|
357
328
|
|
|
@@ -416,20 +387,6 @@ async function packageJson() {
|
|
|
416
387
|
}];
|
|
417
388
|
}
|
|
418
389
|
|
|
419
|
-
//#endregion
|
|
420
|
-
//#region src/configs/prettier.js
|
|
421
|
-
async function prettier() {
|
|
422
|
-
const [pluginPrettier, recommendedPrettier] = await Promise.all([interopDefault(import("eslint-plugin-prettier")), interopDefault(import("eslint-plugin-prettier/recommended"))]);
|
|
423
|
-
return [{
|
|
424
|
-
name: "cuiqg/prettier",
|
|
425
|
-
plugins: { prettier: pluginPrettier },
|
|
426
|
-
rules: {
|
|
427
|
-
...recommendedPrettier.rules,
|
|
428
|
-
"prettier/prettier": "warn"
|
|
429
|
-
}
|
|
430
|
-
}];
|
|
431
|
-
}
|
|
432
|
-
|
|
433
390
|
//#endregion
|
|
434
391
|
//#region src/configs/stylistic.js
|
|
435
392
|
const stylisticConfigDefaults = {
|
|
@@ -439,16 +396,35 @@ const stylisticConfigDefaults = {
|
|
|
439
396
|
quotes: "single",
|
|
440
397
|
semi: false
|
|
441
398
|
};
|
|
442
|
-
async function stylistic() {
|
|
399
|
+
async function stylistic(options = {}) {
|
|
400
|
+
const { commaDangle = "never", experimental, indent, jsx, quotes, semi } = {
|
|
401
|
+
...stylisticConfigDefaults,
|
|
402
|
+
...options
|
|
403
|
+
};
|
|
443
404
|
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
444
405
|
const config = pluginStylistic.configs.customize({
|
|
445
|
-
|
|
446
|
-
|
|
406
|
+
commaDangle,
|
|
407
|
+
experimental,
|
|
408
|
+
indent,
|
|
409
|
+
jsx,
|
|
410
|
+
pluginName: "@stylistic",
|
|
411
|
+
quotes,
|
|
412
|
+
semi
|
|
447
413
|
});
|
|
448
414
|
return [{
|
|
449
415
|
name: "cuiqg/stylistic",
|
|
450
416
|
plugins: { "@stylistic": pluginStylistic },
|
|
451
|
-
rules: {
|
|
417
|
+
rules: {
|
|
418
|
+
...config.rules,
|
|
419
|
+
"@stylistic/generator-star-spacing": ["error", {
|
|
420
|
+
after: true,
|
|
421
|
+
before: false
|
|
422
|
+
}],
|
|
423
|
+
"@stylistic/yield-star-spacing": ["error", {
|
|
424
|
+
after: true,
|
|
425
|
+
before: false
|
|
426
|
+
}]
|
|
427
|
+
}
|
|
452
428
|
}];
|
|
453
429
|
}
|
|
454
430
|
|
|
@@ -458,84 +434,82 @@ async function unocss() {
|
|
|
458
434
|
const pluginUnoCSS = await interopDefault(import("@unocss/eslint-plugin"));
|
|
459
435
|
return [{
|
|
460
436
|
name: "cuiqg/unocss",
|
|
461
|
-
plugins: { unocss: pluginUnoCSS },
|
|
462
|
-
rules: {
|
|
437
|
+
plugins: { "@unocss": pluginUnoCSS },
|
|
438
|
+
rules: {
|
|
439
|
+
"@unocss/order": "warn",
|
|
440
|
+
"@unocss/order-attributify": "warn"
|
|
441
|
+
}
|
|
463
442
|
}];
|
|
464
443
|
}
|
|
465
444
|
|
|
466
445
|
//#endregion
|
|
467
446
|
//#region src/configs/vue.js
|
|
468
|
-
async function vue() {
|
|
447
|
+
async function vue(options = {}) {
|
|
448
|
+
const { typescript: typescript$1 = false, stylistic: stylistic$1 = true, vueVersion = 3 } = options;
|
|
449
|
+
let parserOptions = null;
|
|
469
450
|
const files = [GLOB_VUE];
|
|
451
|
+
const { indent = 2 } = typeof stylistic$1 === "boolean" ? {} : stylistic$1;
|
|
470
452
|
const [pluginVue, parserVue] = await Promise.all([interopDefault(import("eslint-plugin-vue")), interopDefault(import("vue-eslint-parser"))]);
|
|
453
|
+
if (typescript$1) parserOptions = { parser: await interopDefault(import("@typescript-eslint/parser")) };
|
|
471
454
|
return [{
|
|
472
455
|
files,
|
|
456
|
+
name: "cuiqg/vue",
|
|
457
|
+
plugins: { vue: pluginVue },
|
|
473
458
|
languageOptions: {
|
|
474
459
|
globals: {
|
|
475
460
|
computed: "readonly",
|
|
476
461
|
defineEmits: "readonly",
|
|
477
462
|
defineExpose: "readonly",
|
|
478
|
-
definePage: "readonly",
|
|
479
|
-
defineModel: "readonly",
|
|
480
|
-
defineOptions: "readonly",
|
|
481
463
|
defineProps: "readonly",
|
|
482
|
-
defineSlots: "readonly",
|
|
483
|
-
onActivated: "readonly",
|
|
484
|
-
onDeactivated: "readonly",
|
|
485
464
|
onMounted: "readonly",
|
|
486
465
|
onUnmounted: "readonly",
|
|
487
466
|
reactive: "readonly",
|
|
488
467
|
ref: "readonly",
|
|
468
|
+
shallowReactive: "readonly",
|
|
469
|
+
shallowRef: "readonly",
|
|
489
470
|
toRef: "readonly",
|
|
490
471
|
toRefs: "readonly",
|
|
491
|
-
useAttrs: "readonly",
|
|
492
|
-
useSlots: "readonly",
|
|
493
472
|
watch: "readonly",
|
|
494
473
|
watchEffect: "readonly"
|
|
495
474
|
},
|
|
496
475
|
parser: parserVue,
|
|
497
476
|
parserOptions: {
|
|
498
477
|
ecmaFeatures: { jsx: true },
|
|
478
|
+
ecmaVersion: "latest",
|
|
499
479
|
extraFileExtensions: [".vue"],
|
|
500
|
-
|
|
501
|
-
|
|
480
|
+
sourceType: "module",
|
|
481
|
+
...parserOptions
|
|
502
482
|
}
|
|
503
483
|
},
|
|
504
|
-
name: "cuiqg/vue",
|
|
505
|
-
plugins: { vue: pluginVue },
|
|
506
484
|
processor: pluginVue.processors[".vue"],
|
|
507
485
|
rules: {
|
|
508
|
-
...pluginVue.configs
|
|
509
|
-
|
|
510
|
-
...
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
486
|
+
...pluginVue.configs.base.rules,
|
|
487
|
+
...vueVersion === 2 ? {
|
|
488
|
+
...pluginVue.configs["vue2-essential"].rules,
|
|
489
|
+
...pluginVue.configs["vue2-strongly-recommended"].rules,
|
|
490
|
+
...pluginVue.configs["vue2-recommended"].rules
|
|
491
|
+
} : {
|
|
492
|
+
...pluginVue.configs["flat/essential"].map((c) => c.rules).reduce((acc, c) => ({
|
|
493
|
+
...acc,
|
|
494
|
+
...c
|
|
495
|
+
}), {}),
|
|
496
|
+
...pluginVue.configs["flat/strongly-recommended"].map((c) => c.rules).reduce((acc, c) => ({
|
|
497
|
+
...acc,
|
|
498
|
+
...c
|
|
499
|
+
}), {}),
|
|
500
|
+
...pluginVue.configs["flat/recommended"].map((c) => c.rules).reduce((acc, c) => ({
|
|
501
|
+
...acc,
|
|
502
|
+
...c
|
|
503
|
+
}), {})
|
|
504
|
+
},
|
|
518
505
|
"vue/block-order": ["error", { order: [
|
|
519
506
|
"script",
|
|
520
507
|
"template",
|
|
521
508
|
"style"
|
|
522
509
|
] }],
|
|
523
|
-
"vue/
|
|
524
|
-
"vue/
|
|
525
|
-
|
|
526
|
-
singleline: "always"
|
|
527
|
-
}],
|
|
528
|
-
"vue/brace-style": [
|
|
529
|
-
"error",
|
|
530
|
-
"stroustrup",
|
|
531
|
-
{ allowSingleLine: true }
|
|
532
|
-
],
|
|
533
|
-
"vue/comma-dangle": ["error", "always-multiline"],
|
|
534
|
-
"vue/comma-spacing": ["error", {
|
|
535
|
-
after: true,
|
|
536
|
-
before: false
|
|
537
|
-
}],
|
|
538
|
-
"vue/comma-style": ["error", "last"],
|
|
510
|
+
"vue/component-name-in-template-casing": ["error", "PascalCase"],
|
|
511
|
+
"vue/component-options-name-casing": ["error", "PascalCase"],
|
|
512
|
+
"vue/component-tags-order": "off",
|
|
539
513
|
"vue/custom-event-name-casing": ["error", "camelCase"],
|
|
540
514
|
"vue/define-macros-order": ["error", { order: [
|
|
541
515
|
"defineOptions",
|
|
@@ -546,21 +520,8 @@ async function vue() {
|
|
|
546
520
|
"vue/dot-location": ["error", "property"],
|
|
547
521
|
"vue/dot-notation": ["error", { allowKeywords: true }],
|
|
548
522
|
"vue/eqeqeq": ["error", "smart"],
|
|
549
|
-
"vue/html-
|
|
550
|
-
"error",
|
|
551
|
-
"always",
|
|
552
|
-
{ exceptions: ["-"] }
|
|
553
|
-
],
|
|
554
|
-
"vue/html-indent": ["error", 2],
|
|
523
|
+
"vue/html-indent": ["error", indent],
|
|
555
524
|
"vue/html-quotes": ["error", "double"],
|
|
556
|
-
"vue/key-spacing": ["error", {
|
|
557
|
-
afterColon: true,
|
|
558
|
-
beforeColon: false
|
|
559
|
-
}],
|
|
560
|
-
"vue/keyword-spacing": ["error", {
|
|
561
|
-
after: true,
|
|
562
|
-
before: true
|
|
563
|
-
}],
|
|
564
525
|
"vue/max-attributes-per-line": "off",
|
|
565
526
|
"vue/multi-word-component-names": "off",
|
|
566
527
|
"vue/no-dupe-keys": "off",
|
|
@@ -579,9 +540,6 @@ async function vue() {
|
|
|
579
540
|
"vue/no-unused-refs": "error",
|
|
580
541
|
"vue/no-useless-v-bind": "error",
|
|
581
542
|
"vue/no-v-html": "off",
|
|
582
|
-
"vue/object-curly-newline": "off",
|
|
583
|
-
"vue/object-curly-spacing": ["error", "always"],
|
|
584
|
-
"vue/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
|
|
585
543
|
"vue/object-shorthand": [
|
|
586
544
|
"error",
|
|
587
545
|
"always",
|
|
@@ -590,21 +548,60 @@ async function vue() {
|
|
|
590
548
|
ignoreConstructors: false
|
|
591
549
|
}
|
|
592
550
|
],
|
|
593
|
-
"vue/operator-linebreak": ["error", "before"],
|
|
594
|
-
"vue/padding-line-between-blocks": ["error", "always"],
|
|
595
551
|
"vue/prefer-separate-static-class": "error",
|
|
596
552
|
"vue/prefer-template": "error",
|
|
597
553
|
"vue/prop-name-casing": ["error", "camelCase"],
|
|
598
|
-
"vue/quote-props": ["error", "consistent-as-needed"],
|
|
599
554
|
"vue/require-default-prop": "off",
|
|
600
555
|
"vue/require-prop-types": "off",
|
|
601
|
-
"vue/space-in-parens": ["error", "never"],
|
|
602
556
|
"vue/space-infix-ops": "error",
|
|
603
557
|
"vue/space-unary-ops": ["error", {
|
|
604
558
|
nonwords: false,
|
|
605
559
|
words: true
|
|
606
560
|
}],
|
|
607
|
-
|
|
561
|
+
...stylistic$1 ? {
|
|
562
|
+
"vue/array-bracket-spacing": ["error", "never"],
|
|
563
|
+
"vue/arrow-spacing": ["error", {
|
|
564
|
+
after: true,
|
|
565
|
+
before: true
|
|
566
|
+
}],
|
|
567
|
+
"vue/block-spacing": ["error", "always"],
|
|
568
|
+
"vue/block-tag-newline": ["error", {
|
|
569
|
+
multiline: "always",
|
|
570
|
+
singleline: "always"
|
|
571
|
+
}],
|
|
572
|
+
"vue/brace-style": [
|
|
573
|
+
"error",
|
|
574
|
+
"stroustrup",
|
|
575
|
+
{ allowSingleLine: true }
|
|
576
|
+
],
|
|
577
|
+
"vue/comma-dangle": ["error", "always-multiline"],
|
|
578
|
+
"vue/comma-spacing": ["error", {
|
|
579
|
+
after: true,
|
|
580
|
+
before: false
|
|
581
|
+
}],
|
|
582
|
+
"vue/comma-style": ["error", "last"],
|
|
583
|
+
"vue/html-comment-content-spacing": [
|
|
584
|
+
"error",
|
|
585
|
+
"always",
|
|
586
|
+
{ exceptions: ["-"] }
|
|
587
|
+
],
|
|
588
|
+
"vue/key-spacing": ["error", {
|
|
589
|
+
afterColon: true,
|
|
590
|
+
beforeColon: false
|
|
591
|
+
}],
|
|
592
|
+
"vue/keyword-spacing": ["error", {
|
|
593
|
+
after: true,
|
|
594
|
+
before: true
|
|
595
|
+
}],
|
|
596
|
+
"vue/object-curly-newline": "off",
|
|
597
|
+
"vue/object-curly-spacing": ["error", "always"],
|
|
598
|
+
"vue/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
|
|
599
|
+
"vue/operator-linebreak": ["error", "before"],
|
|
600
|
+
"vue/padding-line-between-blocks": ["error", "always"],
|
|
601
|
+
"vue/quote-props": ["error", "consistent-as-needed"],
|
|
602
|
+
"vue/space-in-parens": ["error", "never"],
|
|
603
|
+
"vue/template-curly-spacing": "error"
|
|
604
|
+
} : {}
|
|
608
605
|
}
|
|
609
606
|
}];
|
|
610
607
|
}
|
|
@@ -638,15 +635,220 @@ async function comments() {
|
|
|
638
635
|
}];
|
|
639
636
|
}
|
|
640
637
|
|
|
638
|
+
//#endregion
|
|
639
|
+
//#region src/configs/typescript.js
|
|
640
|
+
async function typescript() {
|
|
641
|
+
const files = [
|
|
642
|
+
GLOB_TS,
|
|
643
|
+
GLOB_TSX,
|
|
644
|
+
GLOB_VUE
|
|
645
|
+
];
|
|
646
|
+
const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
|
|
647
|
+
return [{
|
|
648
|
+
files,
|
|
649
|
+
name: "cuiqg/typescript",
|
|
650
|
+
languageOptions: {
|
|
651
|
+
parser: parserTs,
|
|
652
|
+
parserOptions: {
|
|
653
|
+
ecmaFeatures: { jsx: true },
|
|
654
|
+
ecmaVersion: "latest",
|
|
655
|
+
projectService: true,
|
|
656
|
+
sourceType: "module",
|
|
657
|
+
tsconfigRootDir: process.cwd()
|
|
658
|
+
}
|
|
659
|
+
},
|
|
660
|
+
plugins: { "@typescript-eslint": pluginTs },
|
|
661
|
+
rules: {
|
|
662
|
+
"jsdoc/check-tag-names": ["error", { typed: true }],
|
|
663
|
+
"jsdoc/no-types": "error",
|
|
664
|
+
"jsdoc/no-undefined-types": "off",
|
|
665
|
+
"jsdoc/require-param-type": "off",
|
|
666
|
+
"jsdoc/require-property-type": "off",
|
|
667
|
+
"jsdoc/require-returns-type": "off",
|
|
668
|
+
"@typescript-eslint/array-type": ["error", {
|
|
669
|
+
default: "array",
|
|
670
|
+
readonly: "array"
|
|
671
|
+
}],
|
|
672
|
+
"@typescript-eslint/await-thenable": "error",
|
|
673
|
+
"@typescript-eslint/class-literal-property-style": "error",
|
|
674
|
+
"@typescript-eslint/class-methods-use-this": "error",
|
|
675
|
+
"@typescript-eslint/consistent-generic-constructors": ["error", "constructor"],
|
|
676
|
+
"@typescript-eslint/consistent-indexed-object-style": ["error", "record"],
|
|
677
|
+
"@typescript-eslint/consistent-type-definitions": "error",
|
|
678
|
+
"@typescript-eslint/consistent-type-exports": "error",
|
|
679
|
+
"@typescript-eslint/consistent-type-imports": "error",
|
|
680
|
+
"@typescript-eslint/default-param-last": "error",
|
|
681
|
+
"@typescript-eslint/dot-notation": "error",
|
|
682
|
+
"@typescript-eslint/explicit-function-return-type": ["error", {
|
|
683
|
+
allowedNames: [],
|
|
684
|
+
allowExpressions: true,
|
|
685
|
+
allowHigherOrderFunctions: true,
|
|
686
|
+
allowIIFEs: true
|
|
687
|
+
}],
|
|
688
|
+
"@typescript-eslint/explicit-member-accessibility": "error",
|
|
689
|
+
"@typescript-eslint/explicit-module-boundary-types": ["error", { allowedNames: [] }],
|
|
690
|
+
"@typescript-eslint/max-params": ["error", { max: 3 }],
|
|
691
|
+
"@typescript-eslint/method-signature-style": ["error", "method"],
|
|
692
|
+
"@typescript-eslint/naming-convention": [
|
|
693
|
+
"error",
|
|
694
|
+
{
|
|
695
|
+
format: [
|
|
696
|
+
"camelCase",
|
|
697
|
+
"PascalCase",
|
|
698
|
+
"UPPER_CASE"
|
|
699
|
+
],
|
|
700
|
+
selector: "import"
|
|
701
|
+
},
|
|
702
|
+
{
|
|
703
|
+
format: ["UPPER_CASE"],
|
|
704
|
+
modifiers: ["const"],
|
|
705
|
+
selector: "variable"
|
|
706
|
+
},
|
|
707
|
+
{
|
|
708
|
+
format: ["PascalCase", "UPPER_CASE"],
|
|
709
|
+
selector: "typeLike"
|
|
710
|
+
}
|
|
711
|
+
],
|
|
712
|
+
"@typescript-eslint/no-array-constructor": "error",
|
|
713
|
+
"@typescript-eslint/no-array-delete": "error",
|
|
714
|
+
"@typescript-eslint/no-base-to-string": "error",
|
|
715
|
+
"@typescript-eslint/no-duplicate-enum-values": "error",
|
|
716
|
+
"@typescript-eslint/no-duplicate-type-constituents": "error",
|
|
717
|
+
"@typescript-eslint/no-empty-object-type": "error",
|
|
718
|
+
"@typescript-eslint/no-explicit-any": "error",
|
|
719
|
+
"@typescript-eslint/no-extra-non-null-assertion": "error",
|
|
720
|
+
"@typescript-eslint/no-floating-promises": ["error", {
|
|
721
|
+
allowForKnownSafeCalls: [{
|
|
722
|
+
from: "package",
|
|
723
|
+
name: ["task"],
|
|
724
|
+
package: "nanostores"
|
|
725
|
+
}],
|
|
726
|
+
checkThenables: true,
|
|
727
|
+
ignoreIIFE: true,
|
|
728
|
+
ignoreVoid: true
|
|
729
|
+
}],
|
|
730
|
+
"@typescript-eslint/no-for-in-array": "error",
|
|
731
|
+
"@typescript-eslint/no-implied-eval": "error",
|
|
732
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
733
|
+
"@typescript-eslint/no-invalid-void-type": "error",
|
|
734
|
+
"@typescript-eslint/no-loop-func": "error",
|
|
735
|
+
"@typescript-eslint/no-meaningless-void-operator": "error",
|
|
736
|
+
"@typescript-eslint/no-misused-new": "error",
|
|
737
|
+
"@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: false }],
|
|
738
|
+
"@typescript-eslint/no-mixed-enums": "error",
|
|
739
|
+
"@typescript-eslint/no-namespace": "error",
|
|
740
|
+
"@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
|
|
741
|
+
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
|
|
742
|
+
"@typescript-eslint/no-require-imports": "error",
|
|
743
|
+
"@typescript-eslint/no-shadow": "error",
|
|
744
|
+
"@typescript-eslint/no-this-alias": "error",
|
|
745
|
+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
|
|
746
|
+
"@typescript-eslint/no-unnecessary-condition": "error",
|
|
747
|
+
"@typescript-eslint/no-unnecessary-parameter-property-assignment": "error",
|
|
748
|
+
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
|
749
|
+
"@typescript-eslint/no-unnecessary-template-expression": "error",
|
|
750
|
+
"@typescript-eslint/no-unnecessary-type-arguments": "error",
|
|
751
|
+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
|
752
|
+
"@typescript-eslint/no-unnecessary-type-constraint": "error",
|
|
753
|
+
"@typescript-eslint/no-unnecessary-type-conversion": "error",
|
|
754
|
+
"@typescript-eslint/no-unnecessary-type-parameters": "error",
|
|
755
|
+
"@typescript-eslint/no-unsafe-argument": "error",
|
|
756
|
+
"@typescript-eslint/no-unsafe-assignment": "error",
|
|
757
|
+
"@typescript-eslint/no-unsafe-call": "error",
|
|
758
|
+
"@typescript-eslint/no-unsafe-declaration-merging": "error",
|
|
759
|
+
"@typescript-eslint/no-unsafe-function-type": "error",
|
|
760
|
+
"@typescript-eslint/no-unsafe-member-access": "error",
|
|
761
|
+
"@typescript-eslint/no-unsafe-return": "error",
|
|
762
|
+
"@typescript-eslint/no-unsafe-unary-minus": "error",
|
|
763
|
+
"@typescript-eslint/no-unused-expressions": ["error", {
|
|
764
|
+
allowShortCircuit: true,
|
|
765
|
+
allowTaggedTemplates: true,
|
|
766
|
+
allowTernary: true
|
|
767
|
+
}],
|
|
768
|
+
"@typescript-eslint/no-unused-private-class-members": "error",
|
|
769
|
+
"@typescript-eslint/no-unused-vars": ["error", {
|
|
770
|
+
argsIgnorePattern: "^_",
|
|
771
|
+
caughtErrorsIgnorePattern: "^_",
|
|
772
|
+
ignoreRestSiblings: true,
|
|
773
|
+
varsIgnorePattern: "^_"
|
|
774
|
+
}],
|
|
775
|
+
"@typescript-eslint/no-use-before-define": ["error", {
|
|
776
|
+
classes: false,
|
|
777
|
+
functions: false,
|
|
778
|
+
variables: false
|
|
779
|
+
}],
|
|
780
|
+
"@typescript-eslint/no-useless-constructor": "error",
|
|
781
|
+
"@typescript-eslint/no-useless-default-assignment": "error",
|
|
782
|
+
"@typescript-eslint/no-useless-empty-export": "error",
|
|
783
|
+
"@typescript-eslint/no-wrapper-object-types": "error",
|
|
784
|
+
"@typescript-eslint/non-nullable-type-assertion-style": "error",
|
|
785
|
+
"@typescript-eslint/only-throw-error": "error",
|
|
786
|
+
"@typescript-eslint/prefer-as-const": "error",
|
|
787
|
+
"@typescript-eslint/prefer-destructuring": "error",
|
|
788
|
+
"@typescript-eslint/prefer-enum-initializers": "error",
|
|
789
|
+
"@typescript-eslint/prefer-for-of": "error",
|
|
790
|
+
"@typescript-eslint/prefer-function-type": "error",
|
|
791
|
+
"@typescript-eslint/prefer-literal-enum-member": "error",
|
|
792
|
+
"@typescript-eslint/prefer-namespace-keyword": "error",
|
|
793
|
+
"@typescript-eslint/prefer-nullish-coalescing": "error",
|
|
794
|
+
"@typescript-eslint/prefer-optional-chain": "error",
|
|
795
|
+
"@typescript-eslint/prefer-promise-reject-errors": "error",
|
|
796
|
+
"@typescript-eslint/prefer-readonly": "error",
|
|
797
|
+
"@typescript-eslint/prefer-reduce-type-parameter": "error",
|
|
798
|
+
"@typescript-eslint/prefer-return-this-type": "error",
|
|
799
|
+
"@typescript-eslint/related-getter-setter-pairs": "error",
|
|
800
|
+
"@typescript-eslint/require-array-sort-compare": "error",
|
|
801
|
+
"@typescript-eslint/require-await": "error",
|
|
802
|
+
"@typescript-eslint/restrict-plus-operands": "error",
|
|
803
|
+
"@typescript-eslint/restrict-template-expressions": "error",
|
|
804
|
+
"@typescript-eslint/triple-slash-reference": "error",
|
|
805
|
+
"@typescript-eslint/unified-signatures": "error",
|
|
806
|
+
"class-methods-use-this": "off",
|
|
807
|
+
"consistent-return": "off",
|
|
808
|
+
"default-param-last": "off",
|
|
809
|
+
"dot-notation": "off",
|
|
810
|
+
"max-params": "off",
|
|
811
|
+
"no-array-constructor": "off",
|
|
812
|
+
"no-dupe-class-members": "off",
|
|
813
|
+
"no-implied-eval": "off",
|
|
814
|
+
"no-loop-func": "off",
|
|
815
|
+
"no-shadow": "off",
|
|
816
|
+
"no-undef": "off",
|
|
817
|
+
"no-unused-expressions": "off",
|
|
818
|
+
"no-unused-private-class-members": "off",
|
|
819
|
+
"no-unused-vars": "off",
|
|
820
|
+
"no-use-before-define": "off",
|
|
821
|
+
"no-useless-constructor": "off",
|
|
822
|
+
"prefer-destructuring": "off",
|
|
823
|
+
"require-await": "off"
|
|
824
|
+
},
|
|
825
|
+
settings: { jsdoc: { mode: "typescript" } }
|
|
826
|
+
}];
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
//#endregion
|
|
830
|
+
//#region src/env.js
|
|
831
|
+
const isInGitHookOrLintStaged = () => {
|
|
832
|
+
return !!(process$1.env.GIT_PARAMS || process$1.env.VSCODE_GIT_COMMAND || process$1.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
833
|
+
};
|
|
834
|
+
const isInEditor = () => {
|
|
835
|
+
if (process$1.env.CI) return false;
|
|
836
|
+
if (isInGitHookOrLintStaged()) return false;
|
|
837
|
+
return !!(process$1.env.VSCODE_PID || process$1.env.VSCODE_CWD || process$1.env.JETBRAINS_IDE || process$1.env.VIM || process$1.env.NVIM);
|
|
838
|
+
};
|
|
839
|
+
const hasVue = () => isPackageExists("vue");
|
|
840
|
+
const hasTypeScript = () => isPackageExists("typescript");
|
|
841
|
+
const hasUnocss = () => isPackageExists("unocss");
|
|
842
|
+
const hasTailwindcss = () => isPackageExists("tailwindcss");
|
|
843
|
+
|
|
641
844
|
//#endregion
|
|
642
845
|
//#region src/presets.js
|
|
643
|
-
const defaultPluginRenaming = {};
|
|
644
846
|
/**
|
|
645
847
|
*
|
|
646
848
|
* @param {object} options - 设置选项
|
|
647
|
-
* @param {boolean} [options.
|
|
849
|
+
* @param {boolean} [options.typescript] - 是否启用 TypeScript 格式化
|
|
648
850
|
* @param {boolean} [options.unocss] - 是否启用 Unocss 格式化
|
|
649
|
-
* @param {boolean} [options.tailwindcss] - 是否启用
|
|
851
|
+
* @param {boolean} [options.tailwindcss] - 是否启用 TailwindCSS 格式化
|
|
650
852
|
* @param {boolean} [options.vue] - 是否启用 VUE 格式化
|
|
651
853
|
* @param {boolean} [options.jsdoc=true] - 是否启用 JSDoc 格式化
|
|
652
854
|
* @param {...Object} userConfigs - 用户配置
|
|
@@ -654,16 +856,17 @@ const defaultPluginRenaming = {};
|
|
|
654
856
|
* @returns {Promise<Object[]>} 合并后的配置
|
|
655
857
|
*/
|
|
656
858
|
function cuiqg(options = {}, ...userConfigs) {
|
|
657
|
-
const { jsdoc: enableJsdoc = true,
|
|
859
|
+
const { jsdoc: enableJsdoc = true, unocss: enableUnocss = hasUnocss(), tailwindcss: enableTailwindcss = hasTailwindcss(), typescript: enableTypescript = hasTypeScript(), vue: enableVue = hasVue() } = options;
|
|
658
860
|
const configs = [];
|
|
659
|
-
configs.push(ignores(), comments(), javascript(), stylistic(), packageJson());
|
|
861
|
+
configs.push(ignores(), comments(), javascript({ isInEditor }), stylistic(), packageJson());
|
|
862
|
+
if (enableTypescript) configs.push(typescript());
|
|
660
863
|
if (enableJsdoc) configs.push(jsdoc());
|
|
661
|
-
if (enableVue) configs.push(vue(), macros());
|
|
864
|
+
if (enableVue) configs.push(vue({ typescript: enableTypescript }), macros());
|
|
662
865
|
if (enableUnocss) configs.push(unocss());
|
|
663
866
|
if (enableTailwindcss) configs.push(tailwindcss());
|
|
664
|
-
if (enablePrettier) configs.push(prettier());
|
|
665
867
|
let composer = new FlatConfigComposer();
|
|
666
|
-
composer = composer.append(...configs, ...userConfigs)
|
|
868
|
+
composer = composer.append(...configs, ...userConfigs);
|
|
869
|
+
if (isInEditor) composer = composer.disableRulesFix(["unused-imports/no-unused-imports"], { builtinRules: () => import(["eslint", "use-at-your-own-risk"].join("/")).then((r) => r.builtinRules) });
|
|
667
870
|
return composer;
|
|
668
871
|
}
|
|
669
872
|
|
|
@@ -672,4 +875,4 @@ function cuiqg(options = {}, ...userConfigs) {
|
|
|
672
875
|
var src_default = cuiqg;
|
|
673
876
|
|
|
674
877
|
//#endregion
|
|
675
|
-
export { GLOB_CSS, GLOB_EXCLUDE, GLOB_JS, GLOB_JSX, GLOB_LESS, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_STYLUS, GLOB_TS, GLOB_TSX, GLOB_VUE, comments, cuiqg, src_default as default,
|
|
878
|
+
export { GLOB_CSS, GLOB_EXCLUDE, GLOB_JS, GLOB_JSX, GLOB_LESS, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_STYLUS, GLOB_TS, GLOB_TSX, GLOB_VUE, comments, cuiqg, src_default as default, hasTailwindcss, hasTypeScript, hasUnocss, hasVue, ignores, isInEditor, isInGitHookOrLintStaged, javascript, jsdoc, macros, packageJson, stylistic, stylisticConfigDefaults, tailwindcss, typescript, unocss, vue };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuiqg/eslint-config",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.10",
|
|
4
4
|
"description": "Eslint config for @cuiqg",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint-config"
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@eslint/config-inspector": "^1.4.2",
|
|
36
|
-
"@eslint/eslintrc": "^3.3.3",
|
|
37
36
|
"bumpp": "^10.3.2",
|
|
38
37
|
"eslint": "^9.39.2",
|
|
39
|
-
"tsdown": "^0.18.2"
|
|
38
|
+
"tsdown": "^0.18.2",
|
|
39
|
+
"typescript": "^5.9.3"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"eslint": ">=9.28.0"
|
|
@@ -44,16 +44,16 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
|
|
46
46
|
"@stylistic/eslint-plugin": "^5.6.1",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^8.50.1",
|
|
48
|
+
"@typescript-eslint/parser": "^8.50.1",
|
|
47
49
|
"@unocss/eslint-plugin": "^66.5.10",
|
|
48
50
|
"@vue-macros/eslint-config": "3.0.0-beta.21",
|
|
49
51
|
"eslint-config-flat-gitignore": "^2.1.0",
|
|
50
|
-
"eslint-config-prettier": "^10.1.8",
|
|
51
52
|
"eslint-flat-config-utils": "^2.1.4",
|
|
52
53
|
"eslint-plugin-depend": "^1.4.0",
|
|
53
54
|
"eslint-plugin-import-x": "^4.16.1",
|
|
54
55
|
"eslint-plugin-jsdoc": "^61.5.0",
|
|
55
56
|
"eslint-plugin-package-json": "^0.85.0",
|
|
56
|
-
"eslint-plugin-prettier": "^5.5.4",
|
|
57
57
|
"eslint-plugin-tailwindcss": "4.0.0-beta.0",
|
|
58
58
|
"eslint-plugin-unused-imports": "^4.3.0",
|
|
59
59
|
"eslint-plugin-vue": "^10.6.2",
|