@cuiqg/eslint-config 2.8.10 → 2.8.12

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 (3) hide show
  1. package/README.md +1 -9
  2. package/dist/index.mjs +166 -144
  3. package/package.json +3 -4
package/README.md CHANGED
@@ -22,17 +22,9 @@ npm i -D eslint @cuiqg/eslint-config
22
22
  创建 `eslint.config.mjs` 文件
23
23
 
24
24
  ```js
25
- import fs from 'node:fs'
26
25
  import cuiqg from '@cuiqg/eslint-config'
27
- import { FlatCompat } from '@eslint/eslintrc'
28
26
 
29
- const compat = new FlatCompat()
30
-
31
- export default cuiqg({},
32
- fs.existsSync('.eslintrc-auto-import.json')
33
- ? compat.extend('./.eslintrc-auto-import.json')
34
- : []
35
- )
27
+ export default cuiqg()
36
28
  ```
37
29
 
38
30
  ## 插件配置
package/dist/index.mjs CHANGED
@@ -1,7 +1,9 @@
1
1
  import { FlatConfigComposer } from "eslint-flat-config-utils";
2
+ import globals from "globals";
2
3
  import { fileURLToPath } from "node:url";
3
4
  import { isPackageExists } from "local-pkg";
4
- import globals from "globals";
5
+ import path from "node:path";
6
+ import fs from "node:fs";
5
7
  import process$1 from "node:process";
6
8
 
7
9
  //#region src/globs.js
@@ -59,6 +61,15 @@ const GLOB_EXCLUDE = [
59
61
  "**/.eslint-config-inspector"
60
62
  ];
61
63
 
64
+ //#endregion
65
+ //#region src/configs/ignores.js
66
+ async function ignores() {
67
+ return [{
68
+ ignores: [...GLOB_EXCLUDE],
69
+ name: "cuiqg/ignores"
70
+ }];
71
+ }
72
+
62
73
  //#endregion
63
74
  //#region src/utils.js
64
75
  const scopeUrl = fileURLToPath(new URL(".", import.meta.url));
@@ -71,19 +82,6 @@ async function interopDefault(module) {
71
82
  }
72
83
  }
73
84
 
74
- //#endregion
75
- //#region src/configs/ignores.js
76
- async function ignores() {
77
- const configGitignore = await interopDefault(import("eslint-config-flat-gitignore"));
78
- return [{
79
- ignores: [...GLOB_EXCLUDE],
80
- name: "cuiqg/ignores"
81
- }, configGitignore({
82
- name: "cuiqg/gitignore",
83
- strict: false
84
- })];
85
- }
86
-
87
85
  //#endregion
88
86
  //#region src/configs/javascript.js
89
87
  async function javascript(options = {}) {
@@ -445,10 +443,9 @@ async function unocss() {
445
443
  //#endregion
446
444
  //#region src/configs/vue.js
447
445
  async function vue(options = {}) {
448
- const { typescript: typescript$1 = false, stylistic: stylistic$1 = true, vueVersion = 3 } = options;
446
+ const { typescript: typescript$1 = false } = options;
449
447
  let parserOptions = null;
450
448
  const files = [GLOB_VUE];
451
- const { indent = 2 } = typeof stylistic$1 === "boolean" ? {} : stylistic$1;
452
449
  const [pluginVue, parserVue] = await Promise.all([interopDefault(import("eslint-plugin-vue")), interopDefault(import("vue-eslint-parser"))]);
453
450
  if (typescript$1) parserOptions = { parser: await interopDefault(import("@typescript-eslint/parser")) };
454
451
  return [{
@@ -456,22 +453,6 @@ async function vue(options = {}) {
456
453
  name: "cuiqg/vue",
457
454
  plugins: { vue: pluginVue },
458
455
  languageOptions: {
459
- globals: {
460
- computed: "readonly",
461
- defineEmits: "readonly",
462
- defineExpose: "readonly",
463
- defineProps: "readonly",
464
- onMounted: "readonly",
465
- onUnmounted: "readonly",
466
- reactive: "readonly",
467
- ref: "readonly",
468
- shallowReactive: "readonly",
469
- shallowRef: "readonly",
470
- toRef: "readonly",
471
- toRefs: "readonly",
472
- watch: "readonly",
473
- watchEffect: "readonly"
474
- },
475
456
  parser: parserVue,
476
457
  parserOptions: {
477
458
  ecmaFeatures: { jsx: true },
@@ -483,125 +464,150 @@ async function vue(options = {}) {
483
464
  },
484
465
  processor: pluginVue.processors[".vue"],
485
466
  rules: {
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
- },
467
+ "vue/attribute-hyphenation": ["error", "always"],
505
468
  "vue/block-order": ["error", { order: [
506
469
  "script",
507
470
  "template",
508
471
  "style"
509
472
  ] }],
510
- "vue/component-name-in-template-casing": ["error", "PascalCase"],
511
- "vue/component-options-name-casing": ["error", "PascalCase"],
512
- "vue/component-tags-order": "off",
513
- "vue/custom-event-name-casing": ["error", "camelCase"],
514
- "vue/define-macros-order": ["error", { order: [
515
- "defineOptions",
516
- "defineProps",
517
- "defineEmits",
518
- "defineSlots"
519
- ] }],
520
- "vue/dot-location": ["error", "property"],
521
- "vue/dot-notation": ["error", { allowKeywords: true }],
522
- "vue/eqeqeq": ["error", "smart"],
523
- "vue/html-indent": ["error", indent],
524
- "vue/html-quotes": ["error", "double"],
525
- "vue/max-attributes-per-line": "off",
526
- "vue/multi-word-component-names": "off",
527
- "vue/no-dupe-keys": "off",
528
- "vue/no-empty-pattern": "error",
529
- "vue/no-irregular-whitespace": "error",
530
- "vue/no-loss-of-precision": "error",
531
- "vue/no-restricted-syntax": [
532
- "error",
533
- "DebuggerStatement",
534
- "LabeledStatement",
535
- "WithStatement"
536
- ],
537
- "vue/no-restricted-v-bind": ["error", "/^v-/"],
538
- "vue/no-setup-props-reactivity-loss": "off",
539
- "vue/no-sparse-arrays": "error",
540
- "vue/no-unused-refs": "error",
473
+ "vue/comment-directive": "error",
474
+ "vue/component-api-style": "error",
475
+ "vue/component-definition-name-casing": ["error", "kebab-case"],
476
+ "vue/component-name-in-template-casing": ["error", "kebab-case"],
477
+ "vue/component-options-name-casing": ["error", "kebab-case"],
478
+ "vue/custom-event-name-casing": ["error", "kebab-case"],
479
+ "vue/define-emits-declaration": "error",
480
+ "vue/define-props-declaration": "error",
481
+ "vue/define-props-destructuring": ["error", { destructure: "always" }],
482
+ "vue/enforce-style-attribute": ["error", { allow: ["scoped", "plain"] }],
483
+ "vue/html-button-has-type": "error",
484
+ "vue/html-end-tags": "error",
485
+ "vue/jsx-uses-vars": "error",
486
+ "vue/no-async-in-computed-properties": "error",
487
+ "vue/no-child-content": "error",
488
+ "vue/no-computed-properties-in-data": "error",
489
+ "vue/no-deprecated-data-object-declaration": "error",
490
+ "vue/no-deprecated-delete-set": "error",
491
+ "vue/no-deprecated-destroyed-lifecycle": "error",
492
+ "vue/no-deprecated-dollar-listeners-api": "error",
493
+ "vue/no-deprecated-dollar-scopedslots-api": "error",
494
+ "vue/no-deprecated-events-api": "error",
495
+ "vue/no-deprecated-filter": "error",
496
+ "vue/no-deprecated-functional-template": "error",
497
+ "vue/no-deprecated-html-element-is": "error",
498
+ "vue/no-deprecated-inline-template": "error",
499
+ "vue/no-deprecated-model-definition": "error",
500
+ "vue/no-deprecated-props-default-this": "error",
501
+ "vue/no-deprecated-router-link-tag-prop": "error",
502
+ "vue/no-deprecated-scope-attribute": "error",
503
+ "vue/no-deprecated-slot-attribute": "error",
504
+ "vue/no-deprecated-slot-scope-attribute": "error",
505
+ "vue/no-deprecated-v-bind-sync": "error",
506
+ "vue/no-deprecated-v-is": "error",
507
+ "vue/no-deprecated-v-on-native-modifier": "error",
508
+ "vue/no-deprecated-v-on-number-modifiers": "error",
509
+ "vue/no-deprecated-vue-config-keycodes": "error",
510
+ "vue/no-dupe-keys": "error",
511
+ "vue/no-dupe-v-else-if": "error",
512
+ "vue/no-duplicate-attr-inheritance": "error",
513
+ "vue/no-duplicate-attributes": "error",
514
+ "vue/no-duplicate-class-names": "error",
515
+ "vue/no-empty-component-block": "error",
516
+ "vue/no-export-in-script-setup": "error",
517
+ "vue/no-expose-after-await": "error",
518
+ "vue/no-lifecycle-after-await": "error",
519
+ "vue/no-lone-template": "error",
520
+ "vue/no-multiple-objects-in-class": "error",
521
+ "vue/no-multiple-slot-args": "error",
522
+ "vue/no-mutating-props": "error",
523
+ "vue/no-negated-condition": "error",
524
+ "vue/no-negated-v-if-condition": "error",
525
+ "vue/no-parsing-error": "error",
526
+ "vue/no-potential-component-option-typo": "error",
527
+ "vue/no-ref-as-operand": "error",
528
+ "vue/no-ref-object-reactivity-loss": "error",
529
+ "vue/no-required-prop-with-default": "error",
530
+ "vue/no-reserved-component-names": "error",
531
+ "vue/no-reserved-keys": "error",
532
+ "vue/no-reserved-props": "error",
533
+ "vue/no-setup-props-reactivity-loss": "error",
534
+ "vue/no-shared-component-data": "error",
535
+ "vue/no-side-effects-in-computed-properties": "error",
536
+ "vue/no-template-key": "error",
537
+ "vue/no-template-shadow": "error",
538
+ "vue/no-template-target-blank": "error",
539
+ "vue/no-textarea-mustache": "error",
540
+ "vue/no-this-in-before-route-enter": "error",
541
+ "vue/no-undef-components": "error",
542
+ "vue/no-undef-properties": "error",
543
+ "vue/no-unused-components": "error",
544
+ "vue/no-unused-emit-declarations": "error",
545
+ "vue/no-unused-vars": "error",
546
+ "vue/no-use-computed-property-like-method": "error",
547
+ "vue/no-use-v-else-with-v-for": "error",
548
+ "vue/no-use-v-if-with-v-for": "error",
549
+ "vue/no-useless-mustaches": "error",
550
+ "vue/no-useless-template-attributes": "error",
541
551
  "vue/no-useless-v-bind": "error",
542
- "vue/no-v-html": "off",
543
- "vue/object-shorthand": [
544
- "error",
545
- "always",
546
- {
547
- avoidQuotes: true,
548
- ignoreConstructors: false
549
- }
550
- ],
552
+ "vue/no-v-for-template-key-on-child": "error",
553
+ "vue/no-v-html": "error",
554
+ "vue/no-v-text-v-html-on-component": "error",
555
+ "vue/no-watch-after-await": "error",
556
+ "vue/prefer-define-options": "error",
557
+ "vue/prefer-import-from-vue": "error",
551
558
  "vue/prefer-separate-static-class": "error",
552
- "vue/prefer-template": "error",
559
+ "vue/prefer-true-attribute-shorthand": "error",
553
560
  "vue/prop-name-casing": ["error", "camelCase"],
554
- "vue/require-default-prop": "off",
555
- "vue/require-prop-types": "off",
556
- "vue/space-infix-ops": "error",
557
- "vue/space-unary-ops": ["error", {
558
- nonwords: false,
559
- words: true
561
+ "vue/require-component-is": "error",
562
+ "vue/require-default-prop": "error",
563
+ "vue/require-emit-validator": "error",
564
+ "vue/require-explicit-emits": "error",
565
+ "vue/require-explicit-slots": "error",
566
+ "vue/require-macro-variable-name": ["error", {
567
+ defineEmits: "emit",
568
+ defineProps: "props",
569
+ defineSlots: "slots",
570
+ useAttrs: "attrs",
571
+ useSlots: "slots"
560
572
  }],
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
- } : {}
573
+ "vue/require-name-property": "error",
574
+ "vue/require-prop-type-constructor": "error",
575
+ "vue/require-render-return": "error",
576
+ "vue/require-slots-as-functions": "error",
577
+ "vue/require-toggle-inside-transition": "error",
578
+ "vue/require-typed-ref": "error",
579
+ "vue/require-v-for-key": "error",
580
+ "vue/require-valid-default-prop": "error",
581
+ "vue/return-in-computed-property": "error",
582
+ "vue/return-in-emits-validator": "error",
583
+ "vue/this-in-template": "error",
584
+ "vue/use-v-on-exact": "error",
585
+ "vue/v-bind-style": "error",
586
+ "vue/v-on-event-hyphenation": "error",
587
+ "vue/v-on-style": "error",
588
+ "vue/v-slot-style": "error",
589
+ "vue/valid-attribute-name": "error",
590
+ "vue/valid-define-emits": "error",
591
+ "vue/valid-define-options": "error",
592
+ "vue/valid-define-props": "error",
593
+ "vue/valid-next-tick": "error",
594
+ "vue/valid-template-root": "error",
595
+ "vue/valid-v-bind": "error",
596
+ "vue/valid-v-cloak": "error",
597
+ "vue/valid-v-else": "error",
598
+ "vue/valid-v-else-if": "error",
599
+ "vue/valid-v-for": "error",
600
+ "vue/valid-v-html": "error",
601
+ "vue/valid-v-if": "error",
602
+ "vue/valid-v-is": "error",
603
+ "vue/valid-v-memo": "error",
604
+ "vue/valid-v-model": "error",
605
+ "vue/valid-v-on": "error",
606
+ "vue/valid-v-once": "error",
607
+ "vue/valid-v-pre": "error",
608
+ "vue/valid-v-show": "error",
609
+ "vue/valid-v-slot": "error",
610
+ "vue/valid-v-text": "error"
605
611
  }
606
612
  }];
607
613
  }
@@ -826,6 +832,22 @@ async function typescript() {
826
832
  }];
827
833
  }
828
834
 
835
+ //#endregion
836
+ //#region src/configs/auto-imports.js
837
+ async function autoImports(options = {}) {
838
+ const { cwd = process.cwd(), filename = ".eslintrc-auto-import.json", strict = true } = options;
839
+ const config = [];
840
+ if (fs.existsSync(path.join(cwd, filename))) try {
841
+ config.push({
842
+ name: "cuiqg/auto-imports",
843
+ languageOptions: { ...JSON.parse(fs.readFileSync(path.join(cwd, filename), "utf8")) }
844
+ });
845
+ } catch (error) {
846
+ if (strict) throw error;
847
+ }
848
+ return config;
849
+ }
850
+
829
851
  //#endregion
830
852
  //#region src/env.js
831
853
  const isInGitHookOrLintStaged = () => {
@@ -858,7 +880,7 @@ const hasTailwindcss = () => isPackageExists("tailwindcss");
858
880
  function cuiqg(options = {}, ...userConfigs) {
859
881
  const { jsdoc: enableJsdoc = true, unocss: enableUnocss = hasUnocss(), tailwindcss: enableTailwindcss = hasTailwindcss(), typescript: enableTypescript = hasTypeScript(), vue: enableVue = hasVue() } = options;
860
882
  const configs = [];
861
- configs.push(ignores(), comments(), javascript({ isInEditor }), stylistic(), packageJson());
883
+ configs.push(autoImports(), ignores(), comments(), javascript({ isInEditor }), stylistic(), packageJson());
862
884
  if (enableTypescript) configs.push(typescript());
863
885
  if (enableJsdoc) configs.push(jsdoc());
864
886
  if (enableVue) configs.push(vue({ typescript: enableTypescript }), macros());
@@ -875,4 +897,4 @@ function cuiqg(options = {}, ...userConfigs) {
875
897
  var src_default = cuiqg;
876
898
 
877
899
  //#endregion
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 };
900
+ 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, autoImports, 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.10",
3
+ "version": "2.8.12",
4
4
  "description": "Eslint config for @cuiqg",
5
5
  "keywords": [
6
6
  "eslint-config"
@@ -28,8 +28,8 @@
28
28
  "build:inspect": "npx @eslint/config-inspector build --config eslint-inspector.config.js",
29
29
  "lint": "eslint .",
30
30
  "lint:inspect": "npx @eslint/config-inspector --open false --config eslint-inspector.config.js",
31
- "prepublishOnly": "npm run build",
32
- "release": "bumpp"
31
+ "prerelease": "npm run build",
32
+ "release": "bumpp && npm publish"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@eslint/config-inspector": "^1.4.2",
@@ -48,7 +48,6 @@
48
48
  "@typescript-eslint/parser": "^8.50.1",
49
49
  "@unocss/eslint-plugin": "^66.5.10",
50
50
  "@vue-macros/eslint-config": "3.0.0-beta.21",
51
- "eslint-config-flat-gitignore": "^2.1.0",
52
51
  "eslint-flat-config-utils": "^2.1.4",
53
52
  "eslint-plugin-depend": "^1.4.0",
54
53
  "eslint-plugin-import-x": "^4.16.1",