@component-hook/eslint-plugin 1.4.1 → 1.4.3

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 CHANGED
@@ -23,7 +23,7 @@ import pluginJsdoc from "eslint-plugin-jsdoc";
23
23
  import pluginJsonc from "eslint-plugin-jsonc";
24
24
  import parserJsonc from "jsonc-eslint-parser";
25
25
  import pluginYaml from "eslint-plugin-yml";
26
- import parserYaml from "yaml-eslint-parser";
26
+ import { defineConfig } from "eslint/config";
27
27
 
28
28
  //#region configs/comments.ts
29
29
  const commentsConfigs = [{
@@ -86,7 +86,7 @@ const VUE = "**/*.vue";
86
86
  const BLOB_JSON = "**/*.json";
87
87
  const JSON5 = "**/*.json5";
88
88
  const JSONC = "**/*.jsonc";
89
- const YAML = "**/*.y?(a)ml";
89
+ const RESTRICTED_SYNTAX = ["ForInStatement", "LabeledStatement"];
90
90
 
91
91
  //#endregion
92
92
  //#region configs/import.ts
@@ -131,33 +131,31 @@ const importConfigs = [{
131
131
 
132
132
  //#endregion
133
133
  //#region configs/javascript.ts
134
- const rules$3 = {
135
- "no-useless-call": "error",
136
- "no-useless-computed-key": "error",
137
- "no-useless-constructor": "error",
138
- "no-useless-rename": "error",
139
- "no-var": "error",
140
- "no-console": ["warn", { allow: [
141
- "warn",
142
- "error",
143
- "info",
144
- "clear"
145
- ] }],
146
- "no-debugger": "warn",
147
- "no-eval": "error",
148
- "no-loop-func": "error",
149
- "no-dupe-class-members": "error",
150
- "no-duplicate-imports": "error",
151
- "object-shorthand": "error",
152
- "prefer-const": "error",
153
- "prefer-template": "error",
154
- eqeqeq: "error"
155
- };
156
134
  const jsConfigs = [{
157
135
  name: "component-hook/javascript",
158
136
  rules: {
159
137
  ...pluginJs.configs.recommended.rules,
160
- ...rules$3
138
+ "no-useless-call": "error",
139
+ "no-useless-computed-key": "error",
140
+ "no-useless-constructor": "error",
141
+ "no-useless-rename": "error",
142
+ "no-var": "error",
143
+ "no-console": ["warn", { allow: [
144
+ "warn",
145
+ "error",
146
+ "info",
147
+ "clear"
148
+ ] }],
149
+ "no-debugger": "warn",
150
+ "no-eval": "error",
151
+ "no-loop-func": "error",
152
+ "no-dupe-class-members": "error",
153
+ "no-duplicate-imports": "error",
154
+ "object-shorthand": "error",
155
+ "prefer-const": "error",
156
+ "prefer-template": "error",
157
+ eqeqeq: "error",
158
+ "no-restricted-syntax": ["error", ...RESTRICTED_SYNTAX]
161
159
  }
162
160
  }, {
163
161
  name: "component-hook/globals",
@@ -165,7 +163,8 @@ const jsConfigs = [{
165
163
  ecmaVersion: "latest",
166
164
  globals: {
167
165
  ...globals.node,
168
- ...globals.browser
166
+ ...globals.browser,
167
+ ...globals.es2026
169
168
  }
170
169
  }
171
170
  }];
@@ -281,8 +280,8 @@ const jsoncConfigs = [
281
280
  {
282
281
  order: [
283
282
  "types",
284
- "require",
285
283
  "import",
284
+ "require",
286
285
  "default"
287
286
  ],
288
287
  pathPattern: "^exports.*$"
@@ -433,7 +432,6 @@ const markdownConfigs = [...pluginMarkdown.configs.processor.map((config) => ({
433
432
  "@typescript-eslint/no-unused-expressions": "off",
434
433
  "@typescript-eslint/no-unused-vars": "off",
435
434
  "@typescript-eslint/no-use-before-define": "off",
436
- "import/no-default-export": "off",
437
435
  "sonarjs/no-dead-store": "off",
438
436
  "sonarjs/unused-import": "off",
439
437
  "sonarjs/no-unused-vars": "off",
@@ -486,13 +484,13 @@ const playwrightConfig = {
486
484
 
487
485
  //#endregion
488
486
  //#region configs/prettier.ts
489
- const rules$2 = { ...pluginPrettierRecommended.rules };
490
- delete rules$2["vue/html-self-closing"];
487
+ const rules$1 = { ...pluginPrettierRecommended.rules };
488
+ delete rules$1["vue/html-self-closing"];
491
489
  const prettierConfig = {
492
490
  name: "component-hook/prettier",
493
491
  plugins: { prettier: pluginPrettier },
494
492
  rules: {
495
- ...rules$2,
493
+ ...rules$1,
496
494
  "prettier/prettier": "warn"
497
495
  }
498
496
  };
@@ -542,12 +540,13 @@ const securityConfig = {
542
540
  //#endregion
543
541
  //#region configs/sonarjs.ts
544
542
  const plugins$1 = { sonarjs: pluginSonarjs };
545
- const { settings } = pluginSonarjs.configs.recommended;
543
+ const recommended = pluginSonarjs.configs?.recommended;
544
+ const { settings } = recommended;
546
545
  const sonarjsConfigs = [{
547
546
  name: "component-hook/sonarjs",
548
547
  plugins: plugins$1,
549
548
  rules: {
550
- ...pluginSonarjs.configs.recommended.rules,
549
+ ...recommended.rules,
551
550
  "sonarjs/no-commented-code": "warn"
552
551
  },
553
552
  settings
@@ -594,26 +593,51 @@ const testingLibraryMarkoConfig = {
594
593
 
595
594
  //#endregion
596
595
  //#region configs/typescript.ts
597
- const rules$1 = {
598
- "@typescript-eslint/ban-ts-comment": "off",
599
- "@typescript-eslint/no-explicit-any": "off",
600
- "@typescript-eslint/no-unsafe-function-type": "off",
601
- "@typescript-eslint/no-shadow": "error",
602
- "@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "_" }],
603
- "@typescript-eslint/no-useless-constructor": "error",
604
- "@typescript-eslint/prefer-literal-enum-member": ["error", { allowBitwiseExpressions: true }],
605
- "@typescript-eslint/no-unused-expressions": ["error", {
606
- allowShortCircuit: true,
607
- allowTaggedTemplates: true,
608
- allowTernary: true
609
- }]
610
- };
611
- const typescriptConfigs = typescriptEslint.config({
596
+ const typescriptCoreConfig = defineConfig({
612
597
  extends: [...typescriptEslint.configs.recommended],
613
598
  files: ["**/*.ts", "**/*.tsx"],
614
599
  name: "component-hook/typescript",
615
- rules: rules$1
600
+ rules: {
601
+ "@typescript-eslint/ban-ts-comment": "off",
602
+ "@typescript-eslint/no-explicit-any": "off",
603
+ "@typescript-eslint/no-unsafe-function-type": "off",
604
+ "@typescript-eslint/no-shadow": "error",
605
+ "@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "_" }],
606
+ "@typescript-eslint/no-useless-constructor": "error",
607
+ "@typescript-eslint/prefer-literal-enum-member": ["error", { allowBitwiseExpressions: true }],
608
+ "@typescript-eslint/no-unused-expressions": ["error", {
609
+ allowShortCircuit: true,
610
+ allowTaggedTemplates: true,
611
+ allowTernary: true
612
+ }],
613
+ "@typescript-eslint/consistent-type-assertions": ["error", {
614
+ assertionStyle: "as",
615
+ objectLiteralTypeAssertions: "allow-as-parameter"
616
+ }],
617
+ "@typescript-eslint/consistent-type-imports": ["error", {
618
+ disallowTypeAnnotations: false,
619
+ fixStyle: "inline-type-imports"
620
+ }],
621
+ "@typescript-eslint/method-signature-style": ["error", "property"],
622
+ "@typescript-eslint/no-import-type-side-effects": "error",
623
+ "@typescript-eslint/no-redeclare": "error",
624
+ "no-restricted-syntax": [
625
+ "error",
626
+ "TSEnumDeclaration[const=true]",
627
+ ...RESTRICTED_SYNTAX
628
+ ]
629
+ }
616
630
  });
631
+ const typescriptConfigs = [...typescriptCoreConfig, {
632
+ files: ["**/*.d.ts"],
633
+ name: "component-hook/typescript/dts-rules",
634
+ rules: {
635
+ "eslint-comments/no-unlimited-disable": "off",
636
+ "import/no-duplicates": "off",
637
+ "no-restricted-syntax": "off",
638
+ "unused-imports/no-unused-vars": "off"
639
+ }
640
+ }];
617
641
 
618
642
  //#endregion
619
643
  //#region configs/unicorn.ts
@@ -665,9 +689,9 @@ const unicornConfigs = [
665
689
 
666
690
  //#endregion
667
691
  //#region configs/vue.ts
668
- const recommendedRules = pluginVue.configs["flat/recommended"].map((config) => config.rules).reduce((acc, rules$4) => ({
692
+ const recommendedRules = pluginVue.configs["flat/recommended"].map((config) => config.rules).reduce((acc, rules) => ({
669
693
  ...acc,
670
- ...rules$4
694
+ ...rules
671
695
  }), {});
672
696
  const rules = {
673
697
  "vue/block-order": ["error", { order: [
@@ -711,72 +735,55 @@ const rules = {
711
735
  "vue/no-setup-props-reactivity-loss": "off",
712
736
  "vue/return-in-computed-property": ["error", { treatUndefinedAsUnspecified: false }]
713
737
  };
714
- const extendsTypescript = typescriptEslint.configs.recommended.filter(({ name }) => name !== "typescript-eslint/base").map((config) => ({
738
+ const eslintVueTypescript = typescriptCoreConfig.filter(({ name }) => name !== "component-hook/typescript > typescript-eslint/base").map((config) => ({
715
739
  ...config,
716
- name: `component-hook/vue/${config.name}`
740
+ files: [VUE],
741
+ name: `component-hook/vue/${config.name?.replace("component-hook/", "")}`
717
742
  }));
718
- const eslintConfigTypescript = typescriptEslint.config({
719
- extends: extendsTypescript,
743
+ const vueConfigs = [...eslintVueTypescript, {
744
+ name: "component-hook/vue",
720
745
  files: [VUE],
721
- name: "component-hook/vue/typescript",
722
- rules: rules$1
723
- });
724
- const vueConfigs = [
725
- ...eslintConfigTypescript,
726
- {
727
- name: "component-hook/vue/globals",
728
- files: [VUE],
729
- languageOptions: { globals: {
730
- defineProps: "readonly",
731
- defineEmits: "readonly",
732
- defineExpose: "readonly",
733
- defineModel: "readonly",
734
- withDefaults: "readonly",
735
- $: "readonly",
736
- $$: "readonly",
737
- $computed: "readonly",
738
- $customRef: "readonly",
739
- $ref: "readonly",
740
- $shallowRef: "readonly",
741
- $toRef: "readonly"
742
- } }
746
+ plugins: {
747
+ "@typescript-eslint": typescriptEslint.plugin,
748
+ vue: pluginVue
743
749
  },
744
- {
745
- name: "component-hook/vue",
746
- files: [VUE],
747
- plugins: {
748
- "@typescript-eslint": typescriptEslint.plugin,
749
- vue: pluginVue
750
- },
751
- languageOptions: {
752
- parser: vueParser,
753
- parserOptions: {
754
- parser: "@typescript-eslint/parser",
755
- extraFileExtensions: [".vue"],
756
- sourceType: "module",
757
- ecmaFeatures: { jsx: true }
758
- }
759
- },
760
- processor: pluginVue.processors[".vue"],
761
- rules: {
762
- ...recommendedRules,
763
- ...rules
750
+ languageOptions: {
751
+ parser: vueParser,
752
+ parserOptions: {
753
+ parser: typescriptEslint.parser,
754
+ extraFileExtensions: [".vue"],
755
+ sourceType: "module",
756
+ ecmaFeatures: { jsx: true }
764
757
  }
758
+ },
759
+ processor: pluginVue.processors[".vue"],
760
+ rules: {
761
+ ...recommendedRules,
762
+ "no-useless-assignment": "off",
763
+ ...rules
765
764
  }
766
- ];
765
+ }];
767
766
 
768
767
  //#endregion
769
768
  //#region configs/yaml.ts
769
+ const initialRules = { rules: { "yml/no-empty-mapping-value": "off" } };
770
+ const mergedConfig = Array.from(new Set([
771
+ ...pluginYaml.configs.standard,
772
+ ...pluginYaml.configs.prettier,
773
+ initialRules
774
+ ])).reduce((map, config) => {
775
+ return {
776
+ ...map,
777
+ ...config,
778
+ rules: {
779
+ ...map.rules,
780
+ ...config.rules
781
+ }
782
+ };
783
+ }, {});
770
784
  const yamlConfigs = [{
771
- name: "component-hook/yaml",
772
- files: [YAML],
773
- plugins: { yml: pluginYaml },
774
- languageOptions: { parser: parserYaml },
775
- rules: {
776
- ...pluginYaml.configs.standard.rules,
777
- ...pluginYaml.configs.prettier.rules,
778
- "yml/no-empty-mapping-value": "off"
779
- }
785
+ ...mergedConfig,
786
+ name: "component-hook/yaml"
780
787
  }, {
781
788
  name: "component-hook/yaml/pnpm-workspace",
782
789
  files: ["**/pnpm-workspace.yaml"],
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@component-hook/eslint-plugin",
3
3
  "type": "module",
4
- "version": "1.4.1",
4
+ "version": "1.4.3",
5
5
  "description": "ESLint config for component hook",
6
6
  "author": "Tzuyi",
7
7
  "license": "MIT",
8
8
  "homepage": "https://github.com/tzuyi0817/component-hook/tree/master/packages/eslint-plugin#readme",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/tzuyi0817/component-hook.git",
11
+ "url": "git+https://github.com/tzuyi0817/component-hook.git",
12
12
  "directory": "packages/eslint-plugin"
13
13
  },
14
14
  "bugs": {
@@ -21,13 +21,13 @@
21
21
  ],
22
22
  "exports": {
23
23
  ".": {
24
- "require": {
25
- "types": "./dist/index.d.cts",
26
- "default": "./dist/index.cjs"
27
- },
28
24
  "import": {
29
25
  "types": "./dist/index.d.mts",
30
26
  "default": "./dist/index.mjs"
27
+ },
28
+ "require": {
29
+ "types": "./dist/index.d.cts",
30
+ "default": "./dist/index.cjs"
31
31
  }
32
32
  }
33
33
  },
@@ -41,38 +41,37 @@
41
41
  "eslint": "^9.39.2"
42
42
  },
43
43
  "dependencies": {
44
- "@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
44
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.6.0",
45
45
  "@eslint/js": "^9.39.2",
46
46
  "@eslint/markdown": "^7.5.1",
47
47
  "eslint-config-prettier": "^10.1.8",
48
48
  "eslint-plugin-de-morgan": "^2.0.0",
49
49
  "eslint-plugin-import": "^2.32.0",
50
- "eslint-plugin-jsdoc": "^61.7.1",
51
- "eslint-plugin-jsonc": "^2.21.0",
50
+ "eslint-plugin-jsdoc": "^62.5.4",
51
+ "eslint-plugin-jsonc": "^2.21.1",
52
52
  "eslint-plugin-jsx-a11y": "^6.10.2",
53
- "eslint-plugin-perfectionist": "^5.3.1",
54
- "eslint-plugin-playwright": "^2.4.0",
55
- "eslint-plugin-prettier": "^5.5.4",
53
+ "eslint-plugin-perfectionist": "^5.5.0",
54
+ "eslint-plugin-playwright": "^2.5.1",
55
+ "eslint-plugin-prettier": "^5.5.5",
56
56
  "eslint-plugin-react": "^7.37.5",
57
57
  "eslint-plugin-react-hooks": "^7.0.1",
58
- "eslint-plugin-regexp": "^2.10.0",
58
+ "eslint-plugin-regexp": "^3.0.0",
59
59
  "eslint-plugin-security": "^3.0.1",
60
- "eslint-plugin-sonarjs": "^3.0.5",
60
+ "eslint-plugin-sonarjs": "^3.0.7",
61
61
  "eslint-plugin-testing-library": "^7.15.4",
62
62
  "eslint-plugin-unicorn": "^62.0.0",
63
- "eslint-plugin-vue": "^10.6.2",
64
- "eslint-plugin-yml": "^1.19.1",
65
- "globals": "^17.0.0",
63
+ "eslint-plugin-vue": "^10.7.0",
64
+ "eslint-plugin-yml": "^3.1.2",
65
+ "globals": "^17.3.0",
66
66
  "jsonc-eslint-parser": "^2.4.2",
67
- "typescript-eslint": "^8.52.0",
68
- "vue-eslint-parser": "^10.2.0",
69
- "yaml-eslint-parser": "^1.3.2"
67
+ "typescript-eslint": "^8.55.0",
68
+ "vue-eslint-parser": "^10.2.0"
70
69
  },
71
70
  "devDependencies": {
72
71
  "@eslint/config-inspector": "^1.4.2",
73
- "@types/eslint-plugin-security": "^3.0.0",
72
+ "@types/eslint-plugin-security": "^3.0.1",
74
73
  "eslint-typegen": "^2.3.0",
75
- "unrun": "^0.2.24"
74
+ "unrun": "^0.2.27"
76
75
  },
77
76
  "scripts": {
78
77
  "dev": "eslint-config-inspector --config ../../eslint.config.js",