@bhsd/code-standard 3.0.0 → 3.2.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 (2) hide show
  1. package/eslint.js +216 -128
  2. package/package.json +14 -14
package/eslint.js CHANGED
@@ -42,10 +42,218 @@ export const ignores = {
42
42
  '**/build/',
43
43
  ],
44
44
  },
45
+ unicornConfigs = {
46
+ plugins: {unicorn},
47
+ rules: {
48
+ 'unicorn/catch-error-name': [
49
+ 2,
50
+ {
51
+ name: 'e',
52
+ },
53
+ ],
54
+ 'unicorn/class-reference-in-static-methods': 2,
55
+ 'unicorn/consistent-assert': 2,
56
+ 'unicorn/consistent-conditional-object-spread': 2,
57
+ 'unicorn/consistent-date-clone': 2,
58
+ 'unicorn/consistent-empty-array-spread': 2,
59
+ 'unicorn/consistent-existence-index-check': 2,
60
+ 'unicorn/consistent-export-decorator-position': 2,
61
+ 'unicorn/consistent-function-scoping': [
62
+ 2,
63
+ {
64
+ checkArrowFunctions: false,
65
+ },
66
+ ],
67
+ 'unicorn/consistent-template-literal-escape': 2,
68
+ 'unicorn/default-export-style': 2,
69
+ 'unicorn/empty-brace-spaces': 2,
70
+ 'unicorn/error-message': 2,
71
+ 'unicorn/explicit-length-check': 2,
72
+ 'unicorn/explicit-timer-delay': 2,
73
+ 'unicorn/new-for-builtins': 2,
74
+ 'unicorn/no-abusive-eslint-disable': 2,
75
+ 'unicorn/no-accessor-recursion': 2,
76
+ 'unicorn/no-array-callback-reference': 2,
77
+ 'unicorn/no-array-fill-with-reference-type': 2,
78
+ 'unicorn/no-boolean-sort-comparator': 2,
79
+ 'unicorn/no-for-each': 2,
80
+ 'unicorn/no-array-from-fill': 2,
81
+ 'unicorn/no-array-method-this-argument': 2,
82
+ 'unicorn/no-array-reduce': 2,
83
+ 'unicorn/no-array-splice': 2,
84
+ 'unicorn/no-await-in-promise-methods': 2,
85
+ 'unicorn/no-chained-comparison': 2,
86
+ 'unicorn/no-confusing-array-splice': 2,
87
+ 'unicorn/no-constant-zero-expression': 2,
88
+ 'unicorn/no-declarations-before-early-exit': 2,
89
+ 'unicorn/no-double-comparison': 2,
90
+ 'unicorn/no-duplicate-if-branches': 2,
91
+ 'unicorn/no-duplicate-logical-operands': 2,
92
+ 'unicorn/no-duplicate-loops': 2,
93
+ 'unicorn/no-duplicate-set-values': 2,
94
+ 'unicorn/no-exports-in-scripts': 2,
95
+ 'unicorn/no-immediate-mutation': 2,
96
+ 'unicorn/no-incorrect-query-selector': 2,
97
+ 'unicorn/no-incorrect-template-string-interpolation': 2,
98
+ 'unicorn/no-instanceof-builtins': 2,
99
+ 'unicorn/no-invalid-character-comparison': 2,
100
+ 'unicorn/no-invalid-fetch-options': 2,
101
+ 'unicorn/no-invalid-remove-event-listener': 2,
102
+ 'unicorn/no-invalid-well-known-symbol-methods': 2,
103
+ 'unicorn/no-late-current-target-access': 2,
104
+ 'unicorn/no-late-event-control': 2,
105
+ 'unicorn/no-lonely-if': 2,
106
+ 'unicorn/no-loop-iterable-mutation': 2,
107
+ 'unicorn/no-mismatched-map-key': 2,
108
+ 'unicorn/no-misrefactored-assignment': 2,
109
+ 'unicorn/no-named-default': 2,
110
+ 'unicorn/no-negated-comparison': 2,
111
+ 'unicorn/no-negated-condition': 2,
112
+ 'unicorn/no-negation-in-equality-check': 2,
113
+ 'unicorn/no-new-array': 2,
114
+ 'unicorn/no-object-as-default-parameter': 2,
115
+ 'unicorn/no-object-methods-with-collections': 2,
116
+ 'unicorn/no-redundant-comparison': 2,
117
+ 'unicorn/no-return-array-push': 2,
118
+ 'unicorn/no-selector-as-dom-name': 2,
119
+ 'unicorn/no-single-promise-in-promise-methods': 2,
120
+ 'unicorn/no-static-only-class': 2,
121
+ 'unicorn/no-subtraction-comparison': 2,
122
+ 'unicorn/no-this-assignment': 2,
123
+ 'unicorn/no-top-level-side-effects': 2,
124
+ 'unicorn/no-typeof-undefined': 2,
125
+ 'unicorn/no-uncalled-method': 2,
126
+ 'unicorn/no-undeclared-class-members': 2,
127
+ 'unicorn/no-unnecessary-array-flat-depth': 2,
128
+ 'unicorn/no-unnecessary-array-splice-count': 2,
129
+ 'unicorn/no-unnecessary-await': 2,
130
+ 'unicorn/no-unnecessary-boolean-comparison': 2,
131
+ 'unicorn/no-unnecessary-fetch-options': 2,
132
+ 'unicorn/no-unnecessary-global-this': 2,
133
+ 'unicorn/no-unnecessary-splice': 2,
134
+ 'unicorn/no-unreadable-iife': 2,
135
+ 'unicorn/no-unsafe-buffer-conversion': 2,
136
+ 'unicorn/no-unsafe-promise-all-settled-values': 2,
137
+ 'unicorn/no-unsafe-string-replacement': 2,
138
+ 'unicorn/no-unused-array-method-return': 2,
139
+ 'unicorn/no-unused-properties': 2,
140
+ 'unicorn/no-useless-boolean-cast': 2,
141
+ 'unicorn/no-useless-coercion': 2,
142
+ 'unicorn/no-useless-collection-argument': 2,
143
+ 'unicorn/no-useless-compound-assignment': 2,
144
+ 'unicorn/no-useless-concat': 2,
145
+ 'unicorn/no-useless-continue': 2,
146
+ 'unicorn/no-useless-delete-check': 2,
147
+ 'unicorn/no-useless-fallback-in-spread': 2,
148
+ 'unicorn/no-useless-length-check': 2,
149
+ 'unicorn/no-useless-logical-operand': 2,
150
+ 'unicorn/no-useless-override': 2,
151
+ 'unicorn/no-useless-promise-resolve-reject': 2,
152
+ 'unicorn/no-useless-recursion': 2,
153
+ 'unicorn/no-useless-spread': 2,
154
+ 'unicorn/no-useless-switch-case': 2,
155
+ 'unicorn/no-useless-template-literals': 2,
156
+ 'unicorn/number-literal-case': 2,
157
+ 'unicorn/numeric-separators-style': 2,
158
+ 'unicorn/operator-assignment': 2,
159
+ 'unicorn/prefer-add-event-listener-options': 2,
160
+ 'unicorn/prefer-array-find': 2,
161
+ 'unicorn/prefer-array-flat': 2,
162
+ 'unicorn/prefer-array-flat-map': 2,
163
+ 'unicorn/prefer-array-from-map': 2,
164
+ 'unicorn/prefer-array-index-of': 2,
165
+ 'unicorn/prefer-array-iterable-methods': 2,
166
+ 'unicorn/prefer-array-last-methods': 2,
167
+ 'unicorn/prefer-array-some': 2,
168
+ 'unicorn/prefer-at': 2,
169
+ 'unicorn/prefer-await': 2,
170
+ 'unicorn/prefer-bigint-literals': 2,
171
+ 'unicorn/prefer-block-statement-over-iife': 2,
172
+ 'unicorn/prefer-boolean-return': 2,
173
+ 'unicorn/prefer-class-fields': 2,
174
+ 'unicorn/prefer-classlist-toggle': 2,
175
+ 'unicorn/prefer-code-point': 2,
176
+ 'unicorn/prefer-default-parameters': 2,
177
+ 'unicorn/prefer-direct-iteration': 2,
178
+ 'unicorn/prefer-dispose': 2,
179
+ 'unicorn/prefer-else-if': 2,
180
+ 'unicorn/prefer-export-from': [
181
+ 2,
182
+ {
183
+ checkUsedVariables: false,
184
+ },
185
+ ],
186
+ 'unicorn/prefer-flat-math-min-max': 2,
187
+ 'unicorn/prefer-global-this': 2,
188
+ 'unicorn/prefer-has-check': 2,
189
+ 'unicorn/prefer-hoisting-branch-code': 2,
190
+ 'unicorn/prefer-import-meta-properties': 2,
191
+ 'unicorn/prefer-includes': 2,
192
+ 'unicorn/prefer-includes-over-repeated-comparisons': 2,
193
+ 'unicorn/prefer-iterable-in-constructor': 2,
194
+ 'unicorn/prefer-keyboard-event-key': 2,
195
+ 'unicorn/prefer-location-assign': 2,
196
+ 'unicorn/prefer-logical-operator-over-ternary': 2,
197
+ 'unicorn/prefer-map-from-entries': 2,
198
+ 'unicorn/prefer-math-abs': 2,
199
+ 'unicorn/prefer-math-constants': 2,
200
+ 'unicorn/prefer-math-min-max': 2,
201
+ 'unicorn/prefer-minimal-ternary': 2,
202
+ 'unicorn/prefer-native-coercion-functions': 2,
203
+ 'unicorn/prefer-negative-index': 2,
204
+ 'unicorn/prefer-number-is-safe-integer': 2,
205
+ 'unicorn/prefer-object-define-properties': 2,
206
+ 'unicorn/prefer-object-destructuring-defaults': 2,
207
+ 'unicorn/prefer-object-from-entries': 2,
208
+ 'unicorn/prefer-object-iterable-methods': 2,
209
+ 'unicorn/prefer-optional-catch-binding': 2,
210
+ 'unicorn/prefer-private-class-fields': 2,
211
+ 'unicorn/prefer-prototype-methods': 2,
212
+ 'unicorn/prefer-reflect-apply': 2,
213
+ 'unicorn/prefer-regexp-test': 2,
214
+ 'unicorn/prefer-simple-condition-first': 2,
215
+ 'unicorn/prefer-simple-sort-comparator': 2,
216
+ 'unicorn/prefer-simplified-conditions': 2,
217
+ 'unicorn/prefer-single-array-predicate': 2,
218
+ 'unicorn/prefer-single-call': 2,
219
+ 'unicorn/prefer-single-object-destructuring': 2,
220
+ 'unicorn/prefer-single-replace': 2,
221
+ 'unicorn/prefer-smaller-scope': 2,
222
+ 'unicorn/prefer-split-limit': 2,
223
+ 'unicorn/prefer-spread': 2,
224
+ 'unicorn/prefer-string-pad-start-end': 2,
225
+ 'unicorn/prefer-string-raw': 2,
226
+ 'unicorn/prefer-string-repeat': 2,
227
+ 'unicorn/prefer-string-replace-all': 2,
228
+ 'unicorn/prefer-string-starts-ends-with': 2,
229
+ 'unicorn/prefer-structured-clone': 2,
230
+ 'unicorn/prefer-switch': 2,
231
+ 'unicorn/prefer-ternary': 2,
232
+ 'unicorn/prefer-toggle-attribute': 2,
233
+ 'unicorn/prefer-uint8array-base64': 2,
234
+ 'unicorn/prefer-url-href': 2,
235
+ 'unicorn/prefer-url-search-parameters': 2,
236
+ 'unicorn/prefer-while-loop-condition': 2,
237
+ 'unicorn/require-css-escape': 2,
238
+ 'unicorn/require-module-attributes': 2,
239
+ 'unicorn/require-array-sort-compare': 2,
240
+ 'unicorn/require-number-to-fixed-digits-argument': 2,
241
+ 'unicorn/require-passive-events': 2,
242
+ 'unicorn/require-proxy-trap-boolean-return': 2,
243
+ 'unicorn/switch-case-braces': [
244
+ 2,
245
+ 'avoid',
246
+ ],
247
+ 'unicorn/switch-case-break-position': 2,
248
+ 'unicorn/text-encoding-identifier-case': 2,
249
+ 'unicorn/throw-new-error': 2,
250
+ },
251
+ },
45
252
  general = [
46
253
  js.configs.recommended,
47
254
  promise.configs['flat/recommended'],
48
255
  regexp.configs['flat/recommended'],
256
+ unicornConfigs,
49
257
  {
50
258
  languageOptions: {
51
259
  ecmaVersion: 'latest',
@@ -271,7 +479,6 @@ export const ignores = {
271
479
  },
272
480
  ],
273
481
  'object-shorthand': 2,
274
- 'operator-assignment': 2,
275
482
  'prefer-arrow-callback': 2,
276
483
  'prefer-const': 2,
277
484
  'prefer-destructuring': [
@@ -556,131 +763,6 @@ export const ignores = {
556
763
  ],
557
764
  },
558
765
  },
559
- {
560
- plugins: {unicorn},
561
- rules: {
562
- 'unicorn/catch-error-name': [
563
- 2,
564
- {
565
- name: 'e',
566
- },
567
- ],
568
- 'unicorn/consistent-assert': 2,
569
- 'unicorn/consistent-date-clone': 2,
570
- 'unicorn/consistent-empty-array-spread': 2,
571
- 'unicorn/consistent-existence-index-check': 2,
572
- 'unicorn/consistent-function-scoping': [
573
- 2,
574
- {
575
- checkArrowFunctions: false,
576
- },
577
- ],
578
- 'unicorn/consistent-template-literal-escape': 2,
579
- 'unicorn/empty-brace-spaces': 2,
580
- 'unicorn/error-message': 2,
581
- 'unicorn/explicit-length-check': 2,
582
- 'unicorn/new-for-builtins': 2,
583
- 'unicorn/no-abusive-eslint-disable': 2,
584
- 'unicorn/no-accessor-recursion': 2,
585
- 'unicorn/no-array-callback-reference': 2,
586
- 'unicorn/no-array-fill-with-reference-type': 2,
587
- 'unicorn/no-array-for-each': 2,
588
- 'unicorn/no-array-from-fill': 2,
589
- 'unicorn/no-array-method-this-argument': 2,
590
- 'unicorn/no-array-reduce': 2,
591
- 'unicorn/no-await-in-promise-methods': 2,
592
- 'unicorn/no-confusing-array-splice': 2,
593
- 'unicorn/no-duplicate-set-values': 2,
594
- 'unicorn/no-exports-in-scripts': 2,
595
- 'unicorn/no-immediate-mutation': 2,
596
- 'unicorn/no-incorrect-query-selector': 2,
597
- 'unicorn/no-instanceof-builtins': 2,
598
- 'unicorn/no-invalid-fetch-options': 2,
599
- 'unicorn/no-invalid-remove-event-listener': 2,
600
- 'unicorn/no-late-current-target-access': 2,
601
- 'unicorn/no-lonely-if': 2,
602
- 'unicorn/no-named-default': 2,
603
- 'unicorn/no-negated-condition': 2,
604
- 'unicorn/no-negation-in-equality-check': 2,
605
- 'unicorn/no-nested-ternary': 2,
606
- 'unicorn/no-new-array': 2,
607
- 'unicorn/no-object-as-default-parameter': 2,
608
- 'unicorn/no-single-promise-in-promise-methods': 2,
609
- 'unicorn/no-static-only-class': 2,
610
- 'unicorn/no-this-assignment': 2,
611
- 'unicorn/no-typeof-undefined': 2,
612
- 'unicorn/no-unnecessary-array-flat-depth': 2,
613
- 'unicorn/no-unnecessary-array-splice-count': 2,
614
- 'unicorn/no-unnecessary-await': 2,
615
- 'unicorn/no-unreadable-iife': 2,
616
- 'unicorn/no-unused-array-method-return': 2,
617
- 'unicorn/no-unused-properties': 2,
618
- 'unicorn/no-useless-collection-argument': 2,
619
- 'unicorn/no-useless-fallback-in-spread': 2,
620
- 'unicorn/no-useless-length-check': 2,
621
- 'unicorn/no-useless-promise-resolve-reject': 2,
622
- 'unicorn/no-useless-spread': 2,
623
- 'unicorn/no-useless-switch-case': 2,
624
- 'unicorn/number-literal-case': 2,
625
- 'unicorn/numeric-separators-style': 2,
626
- 'unicorn/prefer-array-find': 2,
627
- 'unicorn/prefer-array-flat': 2,
628
- 'unicorn/prefer-array-flat-map': 2,
629
- 'unicorn/prefer-array-index-of': 2,
630
- 'unicorn/prefer-array-last-methods': 2,
631
- 'unicorn/prefer-array-some': 2,
632
- 'unicorn/prefer-at': 2,
633
- 'unicorn/prefer-bigint-literals': 2,
634
- 'unicorn/prefer-class-fields': 2,
635
- 'unicorn/prefer-classlist-toggle': 2,
636
- 'unicorn/prefer-code-point': 2,
637
- 'unicorn/prefer-default-parameters': 2,
638
- 'unicorn/prefer-export-from': [
639
- 2,
640
- {
641
- checkUsedVariables: false,
642
- },
643
- ],
644
- 'unicorn/prefer-global-this': 2,
645
- 'unicorn/prefer-import-meta-properties': 2,
646
- 'unicorn/prefer-includes': 2,
647
- 'unicorn/prefer-includes-over-repeated-comparisons': 2,
648
- 'unicorn/prefer-keyboard-event-key': 2,
649
- 'unicorn/prefer-logical-operator-over-ternary': 2,
650
- 'unicorn/prefer-math-abs': 2,
651
- 'unicorn/prefer-math-min-max': 2,
652
- 'unicorn/prefer-native-coercion-functions': 2,
653
- 'unicorn/prefer-negative-index': 2,
654
- 'unicorn/prefer-object-from-entries': 2,
655
- 'unicorn/prefer-optional-catch-binding': 2,
656
- 'unicorn/prefer-prototype-methods': 2,
657
- 'unicorn/prefer-reflect-apply': 2,
658
- 'unicorn/prefer-regexp-test': 2,
659
- 'unicorn/prefer-simple-condition-first': 2,
660
- 'unicorn/prefer-single-call': 2,
661
- 'unicorn/prefer-split-limit': 2,
662
- 'unicorn/prefer-spread': 2,
663
- 'unicorn/prefer-string-pad-start-end': 2,
664
- 'unicorn/prefer-string-raw': 2,
665
- 'unicorn/prefer-string-repeat': 2,
666
- 'unicorn/prefer-string-replace-all': 2,
667
- 'unicorn/prefer-string-starts-ends-with': 2,
668
- 'unicorn/prefer-structured-clone': 2,
669
- 'unicorn/prefer-switch': 2,
670
- 'unicorn/prefer-ternary': 2,
671
- 'unicorn/require-css-escape': 2,
672
- 'unicorn/require-module-attributes': 2,
673
- 'unicorn/require-number-to-fixed-digits-argument': 2,
674
- 'unicorn/require-passive-events': 2,
675
- 'unicorn/switch-case-braces': [
676
- 2,
677
- 'avoid',
678
- ],
679
- 'unicorn/switch-case-break-position': 2,
680
- 'unicorn/text-encoding-identifier-case': 2,
681
- 'unicorn/throw-new-error': 2,
682
- },
683
- },
684
766
  {
685
767
  plugins: {'@eslint-community/eslint-comments': eslintComments},
686
768
  rules: {
@@ -772,11 +854,17 @@ export const ignores = {
772
854
  },
773
855
  },
774
856
  },
857
+ noUnicorn = {
858
+ 'unicorn/no-array-reverse': 0,
859
+ 'unicorn/no-array-sort': 0,
860
+ ...Object.fromEntries(Object.keys(unicornConfigs.rules).map(rule => [rule, 0])),
861
+ },
775
862
  json = [
776
863
  ...jsonc.configs['recommended-with-json'],
777
864
  {
778
865
  files: ['**/*.json'],
779
866
  rules: {
867
+ ...noUnicorn,
780
868
  'jsonc/array-bracket-newline': [
781
869
  2,
782
870
  {
@@ -817,6 +905,7 @@ export const ignores = {
817
905
  {
818
906
  files: ['**/*.yaml', '**/*.yml'],
819
907
  rules: {
908
+ ...noUnicorn,
820
909
  'yml/quotes': [
821
910
  2,
822
911
  {
@@ -1093,7 +1182,6 @@ export const ignores = {
1093
1182
  },
1094
1183
  ],
1095
1184
  browser = getConfig({
1096
- 'es-x/no-array-prototype-findlast-findlastindex': 2,
1097
1185
  'es-x/no-array-prototype-toreversed': 2,
1098
1186
  'es-x/no-array-prototype-tosorted': 2,
1099
1187
  'es-x/no-array-prototype-tospliced': 2,
@@ -1122,7 +1210,6 @@ export const ignores = {
1122
1210
  'es-x/no-set-prototype-union': 2,
1123
1211
  'es-x/no-string-prototype-iswellformed': 2,
1124
1212
  'es-x/no-string-prototype-towellformed': 2,
1125
- 'unicorn/prefer-array-last-methods': 0,
1126
1213
  'unicorn/prefer-structured-clone': 0,
1127
1214
  }),
1128
1215
  browserES8 = getConfig({
@@ -1150,6 +1237,7 @@ export const ignores = {
1150
1237
  }),
1151
1238
  dist = getConfig({
1152
1239
  ...esX.configs['flat/restrict-to-es2022'].rules,
1240
+ 'es-x/no-array-prototype-findlast-findlastindex': 0,
1153
1241
  'es-x/no-iterator-prototype-flatmap': 0,
1154
1242
  }),
1155
1243
  distES8 = getConfig({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bhsd/code-standard",
3
- "version": "3.0.0",
3
+ "version": "3.2.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"
@@ -45,22 +45,22 @@
45
45
  "@eslint-community/eslint-plugin-eslint-comments": "^4.7.1",
46
46
  "@stylistic/eslint-plugin": "^5.10.0",
47
47
  "@stylistic/stylelint-plugin": "^5.2.0",
48
- "@types/node": "^25.9.3",
49
- "@typescript-eslint/eslint-plugin": "^8.61.0",
50
- "@typescript-eslint/parser": "^8.61.0",
51
- "eslint-plugin-es-x": "^9.6.0",
52
- "eslint-plugin-jsdoc": "^62.9.0",
53
- "eslint-plugin-jsonc": "^3.1.2",
54
- "eslint-plugin-n": "^18.1.0",
48
+ "@types/node": "^26.1.1",
49
+ "@typescript-eslint/eslint-plugin": "^8.64.0",
50
+ "@typescript-eslint/parser": "^8.64.0",
51
+ "eslint-plugin-es-x": "^10.0.0",
52
+ "eslint-plugin-jsdoc": "^63.0.13",
53
+ "eslint-plugin-jsonc": "^3.3.0",
54
+ "eslint-plugin-n": "^18.2.2",
55
55
  "eslint-plugin-promise": "^7.3.0",
56
- "eslint-plugin-regexp": "^3.1.0",
57
- "eslint-plugin-unicorn": "^65.0.1",
58
- "eslint-plugin-yml": "^3.3.2",
59
- "globals": "^17.6.0",
60
- "stylelint-plugin-use-baseline": "^1.4.2",
56
+ "eslint-plugin-regexp": "^3.1.1",
57
+ "eslint-plugin-unicorn": "^71.1.0",
58
+ "eslint-plugin-yml": "^3.6.0",
59
+ "globals": "^17.7.0",
60
+ "stylelint-plugin-use-baseline": "^1.4.4",
61
61
  "stylelint-config-recommended": "^18.0.0"
62
62
  },
63
63
  "devDependencies": {
64
- "eslint": "^10.4.1"
64
+ "eslint": "^10.7.0"
65
65
  }
66
66
  }