@cuiqg/eslint-config 2.8.8 → 2.8.9
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 +354 -156
- 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
|
|
@@ -93,19 +87,14 @@ async function ignores() {
|
|
|
93
87
|
//#endregion
|
|
94
88
|
//#region src/env.js
|
|
95
89
|
const isInGitHookOrLintStaged = () => {
|
|
96
|
-
return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
90
|
+
return !!(process$1.env.GIT_PARAMS || process$1.env.VSCODE_GIT_COMMAND || process$1.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
97
91
|
};
|
|
98
92
|
const isInEditor = () => {
|
|
99
|
-
if (process.env.CI) return false;
|
|
93
|
+
if (process$1.env.CI) return false;
|
|
100
94
|
if (isInGitHookOrLintStaged()) return false;
|
|
101
|
-
return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
|
|
95
|
+
return !!(process$1.env.VSCODE_PID || process$1.env.VSCODE_CWD || process$1.env.JETBRAINS_IDE || process$1.env.VIM || process$1.env.NVIM);
|
|
102
96
|
};
|
|
103
|
-
const hasVue = () =>
|
|
104
|
-
"vue",
|
|
105
|
-
"nuxt",
|
|
106
|
-
"vitepress",
|
|
107
|
-
"@slidev/cli"
|
|
108
|
-
].some((i) => isPackageExists(i));
|
|
97
|
+
const hasVue = () => isPackageExists("vue");
|
|
109
98
|
const hasTypeScript = () => isPackageExists("typescript");
|
|
110
99
|
const hasUnocss = () => isPackageExists("unocss");
|
|
111
100
|
const hasTailwindcss = () => isPackageExists("tailwindcss");
|
|
@@ -416,20 +405,6 @@ async function packageJson() {
|
|
|
416
405
|
}];
|
|
417
406
|
}
|
|
418
407
|
|
|
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
408
|
//#endregion
|
|
434
409
|
//#region src/configs/stylistic.js
|
|
435
410
|
const stylisticConfigDefaults = {
|
|
@@ -443,7 +418,8 @@ async function stylistic() {
|
|
|
443
418
|
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
444
419
|
const config = pluginStylistic.configs.customize({
|
|
445
420
|
...stylisticConfigDefaults,
|
|
446
|
-
commaDangle: "never"
|
|
421
|
+
commaDangle: "never",
|
|
422
|
+
pluginName: "@stylistic"
|
|
447
423
|
});
|
|
448
424
|
return [{
|
|
449
425
|
name: "cuiqg/stylistic",
|
|
@@ -458,153 +434,188 @@ 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
447
|
async function vue() {
|
|
448
|
+
let additionalParserOptions = {};
|
|
469
449
|
const files = [GLOB_VUE];
|
|
470
450
|
const [pluginVue, parserVue] = await Promise.all([interopDefault(import("eslint-plugin-vue")), interopDefault(import("vue-eslint-parser"))]);
|
|
451
|
+
if (hasTypeScript) {
|
|
452
|
+
const parserTs = await interopDefault(import("@typescript-eslint/parser"));
|
|
453
|
+
additionalParserOptions = {
|
|
454
|
+
...additionalParserOptions,
|
|
455
|
+
parser: parserTs,
|
|
456
|
+
projectService: true,
|
|
457
|
+
tsconfigRootDir: process.cwd()
|
|
458
|
+
};
|
|
459
|
+
}
|
|
471
460
|
return [{
|
|
472
461
|
files,
|
|
462
|
+
name: "cuiqg/vue",
|
|
463
|
+
plugins: { vue: pluginVue },
|
|
473
464
|
languageOptions: {
|
|
474
|
-
globals: {
|
|
475
|
-
computed: "readonly",
|
|
476
|
-
defineEmits: "readonly",
|
|
477
|
-
defineExpose: "readonly",
|
|
478
|
-
definePage: "readonly",
|
|
479
|
-
defineModel: "readonly",
|
|
480
|
-
defineOptions: "readonly",
|
|
481
|
-
defineProps: "readonly",
|
|
482
|
-
defineSlots: "readonly",
|
|
483
|
-
onActivated: "readonly",
|
|
484
|
-
onDeactivated: "readonly",
|
|
485
|
-
onMounted: "readonly",
|
|
486
|
-
onUnmounted: "readonly",
|
|
487
|
-
reactive: "readonly",
|
|
488
|
-
ref: "readonly",
|
|
489
|
-
toRef: "readonly",
|
|
490
|
-
toRefs: "readonly",
|
|
491
|
-
useAttrs: "readonly",
|
|
492
|
-
useSlots: "readonly",
|
|
493
|
-
watch: "readonly",
|
|
494
|
-
watchEffect: "readonly"
|
|
495
|
-
},
|
|
496
465
|
parser: parserVue,
|
|
497
466
|
parserOptions: {
|
|
498
|
-
|
|
467
|
+
ecmaVersion: "latest",
|
|
499
468
|
extraFileExtensions: [".vue"],
|
|
500
|
-
|
|
501
|
-
|
|
469
|
+
sourceType: "module",
|
|
470
|
+
...additionalParserOptions
|
|
502
471
|
}
|
|
503
472
|
},
|
|
504
|
-
name: "cuiqg/vue",
|
|
505
|
-
plugins: { vue: pluginVue },
|
|
506
473
|
processor: pluginVue.processors[".vue"],
|
|
507
474
|
rules: {
|
|
508
|
-
|
|
509
|
-
...acc,
|
|
510
|
-
...c
|
|
511
|
-
}), {}),
|
|
512
|
-
"node/prefer-global/process": "off",
|
|
513
|
-
"vue/array-bracket-spacing": ["error", "never"],
|
|
514
|
-
"vue/arrow-spacing": ["error", {
|
|
515
|
-
after: true,
|
|
516
|
-
before: true
|
|
517
|
-
}],
|
|
475
|
+
"vue/attribute-hyphenation": ["error", "always"],
|
|
518
476
|
"vue/block-order": ["error", { order: [
|
|
519
477
|
"script",
|
|
520
478
|
"template",
|
|
521
479
|
"style"
|
|
522
480
|
] }],
|
|
523
|
-
"vue/
|
|
524
|
-
"vue/
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
"vue/
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
],
|
|
533
|
-
"vue/
|
|
534
|
-
"vue/
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
"vue/
|
|
539
|
-
"vue/
|
|
540
|
-
"vue/
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
"vue/
|
|
547
|
-
"vue/
|
|
548
|
-
"vue/
|
|
549
|
-
"vue/
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
"vue/
|
|
555
|
-
"vue/
|
|
556
|
-
"vue/
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
"vue/
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
"vue/
|
|
565
|
-
"vue/
|
|
566
|
-
"vue/no-
|
|
567
|
-
"vue/no-
|
|
568
|
-
"vue/no-
|
|
569
|
-
"vue/no-
|
|
570
|
-
"vue/no-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
"vue/no-
|
|
577
|
-
"vue/no-
|
|
578
|
-
"vue/no-
|
|
579
|
-
"vue/no-
|
|
481
|
+
"vue/comment-directive": "error",
|
|
482
|
+
"vue/component-api-style": "error",
|
|
483
|
+
"vue/component-definition-name-casing": ["error", "kebab-case"],
|
|
484
|
+
"vue/component-name-in-template-casing": ["error", "kebab-case"],
|
|
485
|
+
"vue/component-options-name-casing": ["error", "kebab-case"],
|
|
486
|
+
"vue/custom-event-name-casing": ["error", "kebab-case"],
|
|
487
|
+
"vue/define-emits-declaration": "error",
|
|
488
|
+
"vue/define-props-declaration": "error",
|
|
489
|
+
"vue/define-props-destructuring": ["error", { destructure: "always" }],
|
|
490
|
+
"vue/enforce-style-attribute": ["error", { allow: ["scoped", "plain"] }],
|
|
491
|
+
"vue/html-button-has-type": "error",
|
|
492
|
+
"vue/html-end-tags": "error",
|
|
493
|
+
"vue/jsx-uses-vars": "error",
|
|
494
|
+
"vue/no-async-in-computed-properties": "error",
|
|
495
|
+
"vue/no-child-content": "error",
|
|
496
|
+
"vue/no-computed-properties-in-data": "error",
|
|
497
|
+
"vue/no-deprecated-data-object-declaration": "error",
|
|
498
|
+
"vue/no-deprecated-delete-set": "error",
|
|
499
|
+
"vue/no-deprecated-destroyed-lifecycle": "error",
|
|
500
|
+
"vue/no-deprecated-dollar-listeners-api": "error",
|
|
501
|
+
"vue/no-deprecated-dollar-scopedslots-api": "error",
|
|
502
|
+
"vue/no-deprecated-events-api": "error",
|
|
503
|
+
"vue/no-deprecated-filter": "error",
|
|
504
|
+
"vue/no-deprecated-functional-template": "error",
|
|
505
|
+
"vue/no-deprecated-html-element-is": "error",
|
|
506
|
+
"vue/no-deprecated-inline-template": "error",
|
|
507
|
+
"vue/no-deprecated-model-definition": "error",
|
|
508
|
+
"vue/no-deprecated-props-default-this": "error",
|
|
509
|
+
"vue/no-deprecated-router-link-tag-prop": "error",
|
|
510
|
+
"vue/no-deprecated-scope-attribute": "error",
|
|
511
|
+
"vue/no-deprecated-slot-attribute": "error",
|
|
512
|
+
"vue/no-deprecated-slot-scope-attribute": "error",
|
|
513
|
+
"vue/no-deprecated-v-bind-sync": "error",
|
|
514
|
+
"vue/no-deprecated-v-is": "error",
|
|
515
|
+
"vue/no-deprecated-v-on-native-modifier": "error",
|
|
516
|
+
"vue/no-deprecated-v-on-number-modifiers": "error",
|
|
517
|
+
"vue/no-deprecated-vue-config-keycodes": "error",
|
|
518
|
+
"vue/no-dupe-keys": "error",
|
|
519
|
+
"vue/no-dupe-v-else-if": "error",
|
|
520
|
+
"vue/no-duplicate-attr-inheritance": "error",
|
|
521
|
+
"vue/no-duplicate-attributes": "error",
|
|
522
|
+
"vue/no-duplicate-class-names": "error",
|
|
523
|
+
"vue/no-empty-component-block": "error",
|
|
524
|
+
"vue/no-export-in-script-setup": "error",
|
|
525
|
+
"vue/no-expose-after-await": "error",
|
|
526
|
+
"vue/no-lifecycle-after-await": "error",
|
|
527
|
+
"vue/no-lone-template": "error",
|
|
528
|
+
"vue/no-multiple-objects-in-class": "error",
|
|
529
|
+
"vue/no-multiple-slot-args": "error",
|
|
530
|
+
"vue/no-mutating-props": "error",
|
|
531
|
+
"vue/no-negated-condition": "error",
|
|
532
|
+
"vue/no-negated-v-if-condition": "error",
|
|
533
|
+
"vue/no-parsing-error": "error",
|
|
534
|
+
"vue/no-potential-component-option-typo": "error",
|
|
535
|
+
"vue/no-ref-as-operand": "error",
|
|
536
|
+
"vue/no-ref-object-reactivity-loss": "error",
|
|
537
|
+
"vue/no-required-prop-with-default": "error",
|
|
538
|
+
"vue/no-reserved-component-names": "error",
|
|
539
|
+
"vue/no-reserved-keys": "error",
|
|
540
|
+
"vue/no-reserved-props": "error",
|
|
541
|
+
"vue/no-setup-props-reactivity-loss": "error",
|
|
542
|
+
"vue/no-shared-component-data": "error",
|
|
543
|
+
"vue/no-side-effects-in-computed-properties": "error",
|
|
544
|
+
"vue/no-template-key": "error",
|
|
545
|
+
"vue/no-template-shadow": "error",
|
|
546
|
+
"vue/no-template-target-blank": "error",
|
|
547
|
+
"vue/no-textarea-mustache": "error",
|
|
548
|
+
"vue/no-this-in-before-route-enter": "error",
|
|
549
|
+
"vue/no-undef-components": "error",
|
|
550
|
+
"vue/no-undef-properties": "error",
|
|
551
|
+
"vue/no-unused-components": "error",
|
|
552
|
+
"vue/no-unused-emit-declarations": "error",
|
|
553
|
+
"vue/no-unused-vars": "error",
|
|
554
|
+
"vue/no-use-computed-property-like-method": "error",
|
|
555
|
+
"vue/no-use-v-else-with-v-for": "error",
|
|
556
|
+
"vue/no-use-v-if-with-v-for": "error",
|
|
557
|
+
"vue/no-useless-mustaches": "error",
|
|
558
|
+
"vue/no-useless-template-attributes": "error",
|
|
580
559
|
"vue/no-useless-v-bind": "error",
|
|
581
|
-
"vue/no-v-
|
|
582
|
-
"vue/
|
|
583
|
-
"vue/
|
|
584
|
-
"vue/
|
|
585
|
-
"vue/
|
|
586
|
-
|
|
587
|
-
"always",
|
|
588
|
-
{
|
|
589
|
-
avoidQuotes: true,
|
|
590
|
-
ignoreConstructors: false
|
|
591
|
-
}
|
|
592
|
-
],
|
|
593
|
-
"vue/operator-linebreak": ["error", "before"],
|
|
594
|
-
"vue/padding-line-between-blocks": ["error", "always"],
|
|
560
|
+
"vue/no-v-for-template-key-on-child": "error",
|
|
561
|
+
"vue/no-v-html": "error",
|
|
562
|
+
"vue/no-v-text-v-html-on-component": "error",
|
|
563
|
+
"vue/no-watch-after-await": "error",
|
|
564
|
+
"vue/prefer-define-options": "error",
|
|
565
|
+
"vue/prefer-import-from-vue": "error",
|
|
595
566
|
"vue/prefer-separate-static-class": "error",
|
|
596
|
-
"vue/prefer-
|
|
567
|
+
"vue/prefer-true-attribute-shorthand": "error",
|
|
597
568
|
"vue/prop-name-casing": ["error", "camelCase"],
|
|
598
|
-
"vue/
|
|
599
|
-
"vue/require-default-prop": "
|
|
600
|
-
"vue/require-
|
|
601
|
-
"vue/
|
|
602
|
-
"vue/
|
|
603
|
-
"vue/
|
|
604
|
-
|
|
605
|
-
|
|
569
|
+
"vue/require-component-is": "error",
|
|
570
|
+
"vue/require-default-prop": "error",
|
|
571
|
+
"vue/require-emit-validator": "error",
|
|
572
|
+
"vue/require-explicit-emits": "error",
|
|
573
|
+
"vue/require-explicit-slots": "error",
|
|
574
|
+
"vue/require-macro-variable-name": ["error", {
|
|
575
|
+
defineEmits: "emit",
|
|
576
|
+
defineProps: "props",
|
|
577
|
+
defineSlots: "slots",
|
|
578
|
+
useAttrs: "attrs",
|
|
579
|
+
useSlots: "slots"
|
|
606
580
|
}],
|
|
607
|
-
"vue/
|
|
581
|
+
"vue/require-name-property": "error",
|
|
582
|
+
"vue/require-prop-type-constructor": "error",
|
|
583
|
+
"vue/require-render-return": "error",
|
|
584
|
+
"vue/require-slots-as-functions": "error",
|
|
585
|
+
"vue/require-toggle-inside-transition": "error",
|
|
586
|
+
"vue/require-typed-ref": "error",
|
|
587
|
+
"vue/require-v-for-key": "error",
|
|
588
|
+
"vue/require-valid-default-prop": "error",
|
|
589
|
+
"vue/return-in-computed-property": "error",
|
|
590
|
+
"vue/return-in-emits-validator": "error",
|
|
591
|
+
"vue/this-in-template": "error",
|
|
592
|
+
"vue/use-v-on-exact": "error",
|
|
593
|
+
"vue/v-bind-style": "error",
|
|
594
|
+
"vue/v-on-event-hyphenation": "error",
|
|
595
|
+
"vue/v-on-style": "error",
|
|
596
|
+
"vue/v-slot-style": "error",
|
|
597
|
+
"vue/valid-attribute-name": "error",
|
|
598
|
+
"vue/valid-define-emits": "error",
|
|
599
|
+
"vue/valid-define-options": "error",
|
|
600
|
+
"vue/valid-define-props": "error",
|
|
601
|
+
"vue/valid-next-tick": "error",
|
|
602
|
+
"vue/valid-template-root": "error",
|
|
603
|
+
"vue/valid-v-bind": "error",
|
|
604
|
+
"vue/valid-v-cloak": "error",
|
|
605
|
+
"vue/valid-v-else": "error",
|
|
606
|
+
"vue/valid-v-else-if": "error",
|
|
607
|
+
"vue/valid-v-for": "error",
|
|
608
|
+
"vue/valid-v-html": "error",
|
|
609
|
+
"vue/valid-v-if": "error",
|
|
610
|
+
"vue/valid-v-is": "error",
|
|
611
|
+
"vue/valid-v-memo": "error",
|
|
612
|
+
"vue/valid-v-model": "error",
|
|
613
|
+
"vue/valid-v-on": "error",
|
|
614
|
+
"vue/valid-v-once": "error",
|
|
615
|
+
"vue/valid-v-pre": "error",
|
|
616
|
+
"vue/valid-v-show": "error",
|
|
617
|
+
"vue/valid-v-slot": "error",
|
|
618
|
+
"vue/valid-v-text": "error"
|
|
608
619
|
}
|
|
609
620
|
}];
|
|
610
621
|
}
|
|
@@ -638,9 +649,195 @@ async function comments() {
|
|
|
638
649
|
}];
|
|
639
650
|
}
|
|
640
651
|
|
|
652
|
+
//#endregion
|
|
653
|
+
//#region src/configs/typescript.js
|
|
654
|
+
async function typescript() {
|
|
655
|
+
const files = [GLOB_TS, GLOB_TSX];
|
|
656
|
+
const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
|
|
657
|
+
return [{
|
|
658
|
+
files,
|
|
659
|
+
name: "cuiqg/typescript",
|
|
660
|
+
languageOptions: {
|
|
661
|
+
parser: parserTs,
|
|
662
|
+
parserOptions: {
|
|
663
|
+
ecmaFeatures: { jsx: true },
|
|
664
|
+
ecmaVersion: "latest",
|
|
665
|
+
projectService: true,
|
|
666
|
+
sourceType: "module",
|
|
667
|
+
tsconfigRootDir: process.cwd()
|
|
668
|
+
}
|
|
669
|
+
},
|
|
670
|
+
plugins: { "@typescript-eslint": pluginTs },
|
|
671
|
+
rules: {
|
|
672
|
+
"jsdoc/check-tag-names": ["error", { typed: true }],
|
|
673
|
+
"jsdoc/no-types": "error",
|
|
674
|
+
"jsdoc/no-undefined-types": "off",
|
|
675
|
+
"jsdoc/require-param-type": "off",
|
|
676
|
+
"jsdoc/require-property-type": "off",
|
|
677
|
+
"jsdoc/require-returns-type": "off",
|
|
678
|
+
"@typescript-eslint/array-type": ["error", {
|
|
679
|
+
default: "array",
|
|
680
|
+
readonly: "array"
|
|
681
|
+
}],
|
|
682
|
+
"@typescript-eslint/await-thenable": "error",
|
|
683
|
+
"@typescript-eslint/class-literal-property-style": "error",
|
|
684
|
+
"@typescript-eslint/class-methods-use-this": "error",
|
|
685
|
+
"@typescript-eslint/consistent-generic-constructors": ["error", "constructor"],
|
|
686
|
+
"@typescript-eslint/consistent-indexed-object-style": ["error", "record"],
|
|
687
|
+
"@typescript-eslint/consistent-type-definitions": "error",
|
|
688
|
+
"@typescript-eslint/consistent-type-exports": "error",
|
|
689
|
+
"@typescript-eslint/consistent-type-imports": "error",
|
|
690
|
+
"@typescript-eslint/default-param-last": "error",
|
|
691
|
+
"@typescript-eslint/dot-notation": "error",
|
|
692
|
+
"@typescript-eslint/explicit-function-return-type": ["error", {
|
|
693
|
+
allowedNames: [],
|
|
694
|
+
allowExpressions: true,
|
|
695
|
+
allowHigherOrderFunctions: true,
|
|
696
|
+
allowIIFEs: true
|
|
697
|
+
}],
|
|
698
|
+
"@typescript-eslint/explicit-member-accessibility": "error",
|
|
699
|
+
"@typescript-eslint/explicit-module-boundary-types": ["error", { allowedNames: [] }],
|
|
700
|
+
"@typescript-eslint/max-params": ["error", { max: 3 }],
|
|
701
|
+
"@typescript-eslint/method-signature-style": ["error", "method"],
|
|
702
|
+
"@typescript-eslint/naming-convention": [
|
|
703
|
+
"error",
|
|
704
|
+
{
|
|
705
|
+
format: [
|
|
706
|
+
"camelCase",
|
|
707
|
+
"PascalCase",
|
|
708
|
+
"UPPER_CASE"
|
|
709
|
+
],
|
|
710
|
+
selector: "import"
|
|
711
|
+
},
|
|
712
|
+
{
|
|
713
|
+
format: ["UPPER_CASE"],
|
|
714
|
+
modifiers: ["const"],
|
|
715
|
+
selector: "variable"
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
format: ["PascalCase", "UPPER_CASE"],
|
|
719
|
+
selector: "typeLike"
|
|
720
|
+
}
|
|
721
|
+
],
|
|
722
|
+
"@typescript-eslint/no-array-constructor": "error",
|
|
723
|
+
"@typescript-eslint/no-array-delete": "error",
|
|
724
|
+
"@typescript-eslint/no-base-to-string": "error",
|
|
725
|
+
"@typescript-eslint/no-duplicate-enum-values": "error",
|
|
726
|
+
"@typescript-eslint/no-duplicate-type-constituents": "error",
|
|
727
|
+
"@typescript-eslint/no-empty-object-type": "error",
|
|
728
|
+
"@typescript-eslint/no-explicit-any": "error",
|
|
729
|
+
"@typescript-eslint/no-extra-non-null-assertion": "error",
|
|
730
|
+
"@typescript-eslint/no-floating-promises": ["error", {
|
|
731
|
+
allowForKnownSafeCalls: [{
|
|
732
|
+
from: "package",
|
|
733
|
+
name: ["task"],
|
|
734
|
+
package: "nanostores"
|
|
735
|
+
}],
|
|
736
|
+
checkThenables: true,
|
|
737
|
+
ignoreIIFE: true,
|
|
738
|
+
ignoreVoid: true
|
|
739
|
+
}],
|
|
740
|
+
"@typescript-eslint/no-for-in-array": "error",
|
|
741
|
+
"@typescript-eslint/no-implied-eval": "error",
|
|
742
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
743
|
+
"@typescript-eslint/no-invalid-void-type": "error",
|
|
744
|
+
"@typescript-eslint/no-loop-func": "error",
|
|
745
|
+
"@typescript-eslint/no-meaningless-void-operator": "error",
|
|
746
|
+
"@typescript-eslint/no-misused-new": "error",
|
|
747
|
+
"@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: false }],
|
|
748
|
+
"@typescript-eslint/no-mixed-enums": "error",
|
|
749
|
+
"@typescript-eslint/no-namespace": "error",
|
|
750
|
+
"@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
|
|
751
|
+
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
|
|
752
|
+
"@typescript-eslint/no-require-imports": "error",
|
|
753
|
+
"@typescript-eslint/no-shadow": "error",
|
|
754
|
+
"@typescript-eslint/no-this-alias": "error",
|
|
755
|
+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
|
|
756
|
+
"@typescript-eslint/no-unnecessary-condition": "error",
|
|
757
|
+
"@typescript-eslint/no-unnecessary-parameter-property-assignment": "error",
|
|
758
|
+
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
|
759
|
+
"@typescript-eslint/no-unnecessary-template-expression": "error",
|
|
760
|
+
"@typescript-eslint/no-unnecessary-type-arguments": "error",
|
|
761
|
+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
|
762
|
+
"@typescript-eslint/no-unnecessary-type-constraint": "error",
|
|
763
|
+
"@typescript-eslint/no-unnecessary-type-conversion": "error",
|
|
764
|
+
"@typescript-eslint/no-unnecessary-type-parameters": "error",
|
|
765
|
+
"@typescript-eslint/no-unsafe-argument": "error",
|
|
766
|
+
"@typescript-eslint/no-unsafe-assignment": "error",
|
|
767
|
+
"@typescript-eslint/no-unsafe-call": "error",
|
|
768
|
+
"@typescript-eslint/no-unsafe-declaration-merging": "error",
|
|
769
|
+
"@typescript-eslint/no-unsafe-function-type": "error",
|
|
770
|
+
"@typescript-eslint/no-unsafe-member-access": "error",
|
|
771
|
+
"@typescript-eslint/no-unsafe-return": "error",
|
|
772
|
+
"@typescript-eslint/no-unsafe-unary-minus": "error",
|
|
773
|
+
"@typescript-eslint/no-unused-expressions": ["error", {
|
|
774
|
+
allowShortCircuit: true,
|
|
775
|
+
allowTaggedTemplates: true,
|
|
776
|
+
allowTernary: true
|
|
777
|
+
}],
|
|
778
|
+
"@typescript-eslint/no-unused-private-class-members": "error",
|
|
779
|
+
"@typescript-eslint/no-unused-vars": ["error", {
|
|
780
|
+
argsIgnorePattern: "^_",
|
|
781
|
+
caughtErrorsIgnorePattern: "^_",
|
|
782
|
+
ignoreRestSiblings: true,
|
|
783
|
+
varsIgnorePattern: "^_"
|
|
784
|
+
}],
|
|
785
|
+
"@typescript-eslint/no-use-before-define": ["error", {
|
|
786
|
+
classes: false,
|
|
787
|
+
functions: false,
|
|
788
|
+
variables: false
|
|
789
|
+
}],
|
|
790
|
+
"@typescript-eslint/no-useless-constructor": "error",
|
|
791
|
+
"@typescript-eslint/no-useless-default-assignment": "error",
|
|
792
|
+
"@typescript-eslint/no-useless-empty-export": "error",
|
|
793
|
+
"@typescript-eslint/no-wrapper-object-types": "error",
|
|
794
|
+
"@typescript-eslint/non-nullable-type-assertion-style": "error",
|
|
795
|
+
"@typescript-eslint/only-throw-error": "error",
|
|
796
|
+
"@typescript-eslint/prefer-as-const": "error",
|
|
797
|
+
"@typescript-eslint/prefer-destructuring": "error",
|
|
798
|
+
"@typescript-eslint/prefer-enum-initializers": "error",
|
|
799
|
+
"@typescript-eslint/prefer-for-of": "error",
|
|
800
|
+
"@typescript-eslint/prefer-function-type": "error",
|
|
801
|
+
"@typescript-eslint/prefer-literal-enum-member": "error",
|
|
802
|
+
"@typescript-eslint/prefer-namespace-keyword": "error",
|
|
803
|
+
"@typescript-eslint/prefer-nullish-coalescing": "error",
|
|
804
|
+
"@typescript-eslint/prefer-optional-chain": "error",
|
|
805
|
+
"@typescript-eslint/prefer-promise-reject-errors": "error",
|
|
806
|
+
"@typescript-eslint/prefer-readonly": "error",
|
|
807
|
+
"@typescript-eslint/prefer-reduce-type-parameter": "error",
|
|
808
|
+
"@typescript-eslint/prefer-return-this-type": "error",
|
|
809
|
+
"@typescript-eslint/related-getter-setter-pairs": "error",
|
|
810
|
+
"@typescript-eslint/require-array-sort-compare": "error",
|
|
811
|
+
"@typescript-eslint/require-await": "error",
|
|
812
|
+
"@typescript-eslint/restrict-plus-operands": "error",
|
|
813
|
+
"@typescript-eslint/restrict-template-expressions": "error",
|
|
814
|
+
"@typescript-eslint/triple-slash-reference": "error",
|
|
815
|
+
"@typescript-eslint/unified-signatures": "error",
|
|
816
|
+
"class-methods-use-this": "off",
|
|
817
|
+
"consistent-return": "off",
|
|
818
|
+
"default-param-last": "off",
|
|
819
|
+
"dot-notation": "off",
|
|
820
|
+
"max-params": "off",
|
|
821
|
+
"no-array-constructor": "off",
|
|
822
|
+
"no-dupe-class-members": "off",
|
|
823
|
+
"no-implied-eval": "off",
|
|
824
|
+
"no-loop-func": "off",
|
|
825
|
+
"no-shadow": "off",
|
|
826
|
+
"no-undef": "off",
|
|
827
|
+
"no-unused-expressions": "off",
|
|
828
|
+
"no-unused-private-class-members": "off",
|
|
829
|
+
"no-unused-vars": "off",
|
|
830
|
+
"no-use-before-define": "off",
|
|
831
|
+
"no-useless-constructor": "off",
|
|
832
|
+
"prefer-destructuring": "off",
|
|
833
|
+
"require-await": "off"
|
|
834
|
+
},
|
|
835
|
+
settings: { jsdoc: { mode: "typescript" } }
|
|
836
|
+
}];
|
|
837
|
+
}
|
|
838
|
+
|
|
641
839
|
//#endregion
|
|
642
840
|
//#region src/presets.js
|
|
643
|
-
const defaultPluginRenaming = {};
|
|
644
841
|
/**
|
|
645
842
|
*
|
|
646
843
|
* @param {object} options - 设置选项
|
|
@@ -654,16 +851,17 @@ const defaultPluginRenaming = {};
|
|
|
654
851
|
* @returns {Promise<Object[]>} 合并后的配置
|
|
655
852
|
*/
|
|
656
853
|
function cuiqg(options = {}, ...userConfigs) {
|
|
657
|
-
const { jsdoc: enableJsdoc = true,
|
|
854
|
+
const { jsdoc: enableJsdoc = true, unocss: enableUnocss = hasUnocss(), tailwindcss: enableTailwindcss = hasTailwindcss(), typescript: enableTypescript = hasTypeScript(), vue: enableVue = hasVue() } = options;
|
|
658
855
|
const configs = [];
|
|
659
856
|
configs.push(ignores(), comments(), javascript(), stylistic(), packageJson());
|
|
857
|
+
if (enableTypescript) configs.push(typescript());
|
|
660
858
|
if (enableJsdoc) configs.push(jsdoc());
|
|
661
859
|
if (enableVue) configs.push(vue(), macros());
|
|
662
860
|
if (enableUnocss) configs.push(unocss());
|
|
663
861
|
if (enableTailwindcss) configs.push(tailwindcss());
|
|
664
|
-
if (enablePrettier) configs.push(prettier());
|
|
665
862
|
let composer = new FlatConfigComposer();
|
|
666
|
-
composer = composer.append(...configs, ...userConfigs)
|
|
863
|
+
composer = composer.append(...configs, ...userConfigs);
|
|
864
|
+
if (isInEditor) composer = composer.disableRulesFix(["unused-imports/no-unused-imports"], { builtinRules: () => import(["eslint", "use-at-your-own-risk"].join("/")).then((r) => r.builtinRules) });
|
|
667
865
|
return composer;
|
|
668
866
|
}
|
|
669
867
|
|
|
@@ -672,4 +870,4 @@ function cuiqg(options = {}, ...userConfigs) {
|
|
|
672
870
|
var src_default = cuiqg;
|
|
673
871
|
|
|
674
872
|
//#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,
|
|
873
|
+
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.9",
|
|
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",
|