@bhsd/code-standard 2.4.1 → 2.5.0

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 +0 -1
  2. package/eslint.mjs +62 -11
  3. package/package.json +8 -8
package/README.md CHANGED
@@ -1,4 +1,3 @@
1
1
  # @bhsd/code-standard
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/@bhsd%2Fcode-standard.svg)](https://www.npmjs.com/package/@bhsd/code-standard)
4
- [![License](https://img.shields.io/badge/License-MIT-brightgreen.svg)](LICENSE)
package/eslint.mjs CHANGED
@@ -14,9 +14,10 @@ import globals from 'globals';
14
14
 
15
15
  const tsRecommended = typescriptEslint.configs['flat/recommended-type-checked'],
16
16
  files = ['**/*.ts'];
17
- const getConfig = rules => ({
17
+ const getConfig = (rules, ecmaVersion) => ({
18
18
  languageOptions: {
19
19
  globals: globals.browser,
20
+ ...ecmaVersion && {ecmaVersion},
20
21
  },
21
22
  plugins: {'es-x': esX},
22
23
  settings: {
@@ -24,7 +25,16 @@ const getConfig = rules => ({
24
25
  aggressive: true,
25
26
  },
26
27
  },
27
- rules,
28
+ rules: {
29
+ ...rules,
30
+ 'es-x/no-iterator-prototype-every': 0,
31
+ 'es-x/no-iterator-prototype-filter': 0,
32
+ 'es-x/no-iterator-prototype-find': 0,
33
+ 'es-x/no-iterator-prototype-foreach': 0,
34
+ 'es-x/no-iterator-prototype-map': 0,
35
+ 'es-x/no-iterator-prototype-reduce': 0,
36
+ 'es-x/no-iterator-prototype-some': 0,
37
+ },
28
38
  });
29
39
  export const ignores = {
30
40
  ignores: [
@@ -557,6 +567,7 @@ export const ignores = {
557
567
  ],
558
568
  'unicorn/consistent-assert': 2,
559
569
  'unicorn/consistent-date-clone': 2,
570
+ 'unicorn/consistent-empty-array-spread': 2,
560
571
  'unicorn/consistent-existence-index-check': 2,
561
572
  'unicorn/consistent-function-scoping': [
562
573
  2,
@@ -571,17 +582,21 @@ export const ignores = {
571
582
  'unicorn/new-for-builtins': 2,
572
583
  'unicorn/no-abusive-eslint-disable': 2,
573
584
  'unicorn/no-accessor-recursion': 2,
585
+ 'unicorn/no-array-callback-reference': 2,
574
586
  'unicorn/no-array-for-each': 2,
575
587
  'unicorn/no-array-method-this-argument': 2,
576
588
  'unicorn/no-array-reduce': 2,
577
589
  'unicorn/no-await-in-promise-methods': 2,
578
590
  'unicorn/no-immediate-mutation': 2,
579
591
  'unicorn/no-instanceof-builtins': 2,
592
+ 'unicorn/no-invalid-fetch-options': 2,
580
593
  'unicorn/no-invalid-remove-event-listener': 2,
581
594
  'unicorn/no-lonely-if': 2,
582
595
  'unicorn/no-named-default': 2,
583
596
  'unicorn/no-negated-condition': 2,
584
597
  'unicorn/no-negation-in-equality-check': 2,
598
+ 'unicorn/no-nested-ternary': 2,
599
+ 'unicorn/no-new-array': 2,
585
600
  'unicorn/no-object-as-default-parameter': 2,
586
601
  'unicorn/no-single-promise-in-promise-methods': 2,
587
602
  'unicorn/no-static-only-class': 2,
@@ -589,11 +604,13 @@ export const ignores = {
589
604
  'unicorn/no-typeof-undefined': 2,
590
605
  'unicorn/no-unnecessary-array-flat-depth': 2,
591
606
  'unicorn/no-unnecessary-array-splice-count': 2,
607
+ 'unicorn/no-unnecessary-await': 2,
592
608
  'unicorn/no-unreadable-iife': 2,
593
609
  'unicorn/no-unused-properties': 2,
594
610
  'unicorn/no-useless-collection-argument': 2,
595
611
  'unicorn/no-useless-fallback-in-spread': 2,
596
612
  'unicorn/no-useless-length-check': 2,
613
+ 'unicorn/no-useless-promise-resolve-reject': 2,
597
614
  'unicorn/no-useless-spread': 2,
598
615
  'unicorn/no-useless-switch-case': 2,
599
616
  'unicorn/number-literal-case': 2,
@@ -603,28 +620,42 @@ export const ignores = {
603
620
  'unicorn/prefer-array-flat-map': 2,
604
621
  'unicorn/prefer-array-index-of': 2,
605
622
  'unicorn/prefer-array-some': 2,
623
+ 'unicorn/prefer-at': 2,
606
624
  'unicorn/prefer-bigint-literals': 2,
607
625
  'unicorn/prefer-class-fields': 2,
608
626
  'unicorn/prefer-classlist-toggle': 2,
609
627
  'unicorn/prefer-code-point': 2,
610
628
  'unicorn/prefer-default-parameters': 2,
629
+ 'unicorn/prefer-export-from': [
630
+ 2,
631
+ {
632
+ ignoreUsedVariables: true,
633
+ },
634
+ ],
611
635
  'unicorn/prefer-global-this': 2,
636
+ 'unicorn/prefer-import-meta-properties': 2,
612
637
  'unicorn/prefer-includes': 2,
613
638
  'unicorn/prefer-keyboard-event-key': 2,
614
639
  'unicorn/prefer-logical-operator-over-ternary': 2,
615
640
  'unicorn/prefer-math-min-max': 2,
616
641
  'unicorn/prefer-native-coercion-functions': 2,
617
642
  'unicorn/prefer-negative-index': 2,
643
+ 'unicorn/prefer-object-from-entries': 2,
618
644
  'unicorn/prefer-optional-catch-binding': 2,
619
645
  'unicorn/prefer-prototype-methods': 2,
646
+ 'unicorn/prefer-reflect-apply': 2,
647
+ 'unicorn/prefer-regexp-test': 2,
620
648
  'unicorn/prefer-simple-condition-first': 2,
621
649
  'unicorn/prefer-single-call': 2,
622
650
  'unicorn/prefer-spread': 2,
623
651
  'unicorn/prefer-string-raw': 2,
652
+ 'unicorn/prefer-string-replace-all': 2,
624
653
  'unicorn/prefer-string-starts-ends-with': 2,
654
+ 'unicorn/prefer-structured-clone': 2,
625
655
  'unicorn/prefer-switch': 2,
626
656
  'unicorn/prefer-ternary': 2,
627
657
  'unicorn/require-module-attributes': 2,
658
+ 'unicorn/require-number-to-fixed-digits-argument': 2,
628
659
  'unicorn/switch-case-braces': [
629
660
  2,
630
661
  'avoid',
@@ -669,7 +700,6 @@ export const ignores = {
669
700
  'jsdoc/no-bad-blocks': [
670
701
  1,
671
702
  {
672
- ignore: ['__PURE__'],
673
703
  preventAllMultiAsteriskBlocks: true,
674
704
  },
675
705
  ],
@@ -996,6 +1026,7 @@ export const ignores = {
996
1026
  '@stylistic/type-generic-spacing': 2,
997
1027
  '@stylistic/type-named-tuple-spacing': 2,
998
1028
  'jsdoc/check-types': 0,
1029
+ 'unicorn/no-array-callback-reference': 0,
999
1030
  },
1000
1031
  },
1001
1032
  ].map(obj => ({files, ...obj})),
@@ -1031,6 +1062,8 @@ export const ignores = {
1031
1062
  allowExperimental: true,
1032
1063
  },
1033
1064
  ],
1065
+ 'unicorn/no-array-reverse': 2,
1066
+ 'unicorn/no-array-sort': 2,
1034
1067
  },
1035
1068
  settings: {
1036
1069
  n: {
@@ -1072,19 +1105,37 @@ export const ignores = {
1072
1105
  'es-x/no-set-prototype-union': 2,
1073
1106
  'es-x/no-string-prototype-iswellformed': 2,
1074
1107
  'es-x/no-string-prototype-towellformed': 2,
1108
+ 'unicorn/prefer-structured-clone': 0,
1109
+ }),
1110
+ browserES8 = getConfig({
1111
+ ...esX.configs['flat/restrict-to-es2017'].rules,
1112
+ 'es-x/no-class-instance-fields': 0,
1113
+ 'es-x/no-class-private-fields': 0,
1114
+ 'es-x/no-class-private-methods': 0,
1115
+ 'es-x/no-class-static-blocks': 0,
1116
+ 'es-x/no-class-static-fields': 0,
1117
+ 'es-x/no-private-in': 0,
1118
+ 'es-x/no-logical-assignment-operators': 0,
1119
+ 'es-x/no-numeric-separators': 0,
1120
+ 'es-x/no-nullish-coalescing-operator': 0,
1121
+ 'es-x/no-optional-chaining': 0,
1122
+ 'es-x/no-optional-catch-binding': 0,
1123
+ 'es-x/no-rest-spread-properties': 0,
1124
+ 'unicorn/prefer-array-flat': 0,
1125
+ 'unicorn/prefer-array-flat-map': 0,
1126
+ 'unicorn/prefer-at': 0,
1127
+ 'unicorn/prefer-bigint-literals': 0,
1128
+ 'unicorn/prefer-global-this': 0,
1129
+ 'unicorn/prefer-object-from-entries': 0,
1130
+ 'unicorn/prefer-string-replace-all': 0,
1131
+ 'unicorn/prefer-structured-clone': 0,
1075
1132
  }),
1076
1133
  dist = getConfig({
1077
1134
  ...esX.configs['flat/restrict-to-es2022'].rules,
1078
1135
  'es-x/no-array-prototype-findlast-findlastindex': 0,
1079
- 'es-x/no-iterator-prototype-every': 0,
1080
- 'es-x/no-iterator-prototype-filter': 0,
1081
- 'es-x/no-iterator-prototype-find': 0,
1082
1136
  'es-x/no-iterator-prototype-flatmap': 0,
1083
- 'es-x/no-iterator-prototype-foreach': 0,
1084
- 'es-x/no-iterator-prototype-map': 0,
1085
- 'es-x/no-iterator-prototype-reduce': 0,
1086
- 'es-x/no-iterator-prototype-some': 0,
1087
- });
1137
+ }),
1138
+ distES8 = getConfig(esX.configs['flat/restrict-to-es2017'].rules, 8);
1088
1139
 
1089
1140
  /**
1090
1141
  * 添加ESLint配置项
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bhsd/code-standard",
3
- "version": "2.4.1",
3
+ "version": "2.5.0",
4
4
  "homepage": "https://github.com/bhsd-harry/code-standard#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/bhsd-harry/code-standard/issues"
@@ -22,21 +22,21 @@
22
22
  "@eslint/js": "^10.0.1",
23
23
  "@eslint-community/eslint-plugin-eslint-comments": "^4.7.1",
24
24
  "@stylistic/eslint-plugin": "^5.10.0",
25
- "@typescript-eslint/eslint-plugin": "^8.59.1",
25
+ "@typescript-eslint/eslint-plugin": "^8.59.2",
26
26
  "eslint-plugin-es-x": "^9.6.0",
27
27
  "eslint-plugin-jsdoc": "^62.9.0",
28
28
  "eslint-plugin-jsonc": "^3.1.2",
29
- "eslint-plugin-n": "^17.24.0",
29
+ "eslint-plugin-n": "^18.0.1",
30
30
  "eslint-plugin-promise": "^7.3.0",
31
31
  "eslint-plugin-regexp": "^3.1.0",
32
32
  "eslint-plugin-unicorn": "^64.0.0",
33
33
  "eslint-plugin-yml": "^3.3.2",
34
- "globals": "^17.5.0"
34
+ "globals": "^17.6.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@types/node": "^24.11.0",
38
- "@typescript-eslint/parser": "^8.59.1",
39
- "eslint": "^10.3.0",
40
- "stylelint-plugin-use-baseline": "^1.4.1"
37
+ "@types/node": "^25.8.0",
38
+ "@typescript-eslint/parser": "^8.59.2",
39
+ "eslint": "^10.4.0",
40
+ "stylelint-plugin-use-baseline": "^1.4.2"
41
41
  }
42
42
  }