@bhsd/code-standard 1.0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Bhsd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,4 @@
1
+ # @bhsd/common
2
+
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)
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ const config = require('./eslintrc.cjs');
4
+
5
+ module.exports = {
6
+ ...config,
7
+ env: {
8
+ ...config.env,
9
+ browser: true,
10
+ },
11
+ plugins: [
12
+ ...config.plugins,
13
+ 'es-x',
14
+ ],
15
+ rules: {
16
+ ...config.rules,
17
+ 'prefer-object-has-own': 0,
18
+ 'es-x/no-array-prototype-at': 2,
19
+ 'es-x/no-array-prototype-findlast-findlastindex': 2,
20
+ 'es-x/no-array-prototype-toreversed': 2,
21
+ 'es-x/no-array-prototype-tosorted': 2,
22
+ 'es-x/no-array-prototype-tospliced': 2,
23
+ 'es-x/no-array-prototype-with': 2,
24
+ 'es-x/no-error-cause': 2,
25
+ 'es-x/no-map-groupby': 2,
26
+ 'es-x/no-math-f16round': 2,
27
+ 'es-x/no-object-groupby': 2,
28
+ 'es-x/no-object-hasown': 2,
29
+ 'es-x/no-promise-any': 2,
30
+ 'es-x/no-promise-try': 2,
31
+ 'es-x/no-promise-withresolvers': 2,
32
+ 'es-x/no-regexp-d-flag': 2,
33
+ 'es-x/no-regexp-escape': 2,
34
+ 'es-x/no-regexp-lookbehind-assertions': 2,
35
+ 'es-x/no-regexp-v-flag': 2,
36
+ 'es-x/no-set-prototype-difference': 2,
37
+ 'es-x/no-set-prototype-intersection': 2,
38
+ 'es-x/no-set-prototype-isdisjointfrom': 2,
39
+ 'es-x/no-set-prototype-issubsetof': 2,
40
+ 'es-x/no-set-prototype-issupersetof': 2,
41
+ 'es-x/no-set-prototype-symmetricdifference': 2,
42
+ 'es-x/no-set-prototype-union': 2,
43
+ 'es-x/no-string-prototype-at': 2,
44
+ 'es-x/no-string-prototype-iswellformed': 2,
45
+ 'es-x/no-string-prototype-replaceall': 2,
46
+ 'es-x/no-string-prototype-towellformed': 2,
47
+ },
48
+ settings: {
49
+ ...config.settings,
50
+ 'es-x': {
51
+ aggressive: true,
52
+ },
53
+ },
54
+ };
package/eslintrc.cjs ADDED
@@ -0,0 +1,950 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ root: true,
5
+ env: {
6
+ es2024: true,
7
+ },
8
+ plugins: [
9
+ '@stylistic',
10
+ 'promise',
11
+ 'regexp',
12
+ 'unicorn',
13
+ 'jsdoc',
14
+ ],
15
+ extends: [
16
+ 'eslint:recommended',
17
+ 'plugin:promise/recommended',
18
+ 'plugin:regexp/recommended',
19
+ 'plugin:eslint-comments/recommended',
20
+ ],
21
+ parserOptions: {
22
+ ecmaVersion: 'latest',
23
+ },
24
+ ignorePatterns: [
25
+ 'dist/',
26
+ 'build/',
27
+ ],
28
+ rules: {
29
+ 'array-callback-return': 2,
30
+ 'no-cond-assign': [
31
+ 2,
32
+ 'always',
33
+ ],
34
+ 'no-constant-binary-expression': 2,
35
+ 'no-constructor-return': 2,
36
+ 'no-fallthrough': 2,
37
+ 'no-inner-declarations': [
38
+ 2,
39
+ 'both',
40
+ ],
41
+ 'no-irregular-whitespace': [
42
+ 2,
43
+ {
44
+ skipStrings: false,
45
+ },
46
+ ],
47
+ 'no-promise-executor-return': 2,
48
+ 'no-self-compare': 2,
49
+ 'no-template-curly-in-string': 2,
50
+ 'no-undef': [
51
+ 2,
52
+ {
53
+ typeof: true,
54
+ },
55
+ ],
56
+ 'no-unmodified-loop-condition': 2,
57
+ 'no-unreachable-loop': 2,
58
+ 'no-unsafe-negation': [
59
+ 2,
60
+ {
61
+ enforceForOrderingRelations: true,
62
+ },
63
+ ],
64
+ 'no-unsafe-optional-chaining': [
65
+ 2,
66
+ {
67
+ disallowArithmeticOperators: true,
68
+ },
69
+ ],
70
+ 'no-unused-private-class-members': 2,
71
+ 'no-unused-vars': [
72
+ 2,
73
+ {
74
+ args: 'all',
75
+ argsIgnorePattern: '^_+$',
76
+ caughtErrors: 'all',
77
+ ignoreRestSiblings: true,
78
+ },
79
+ ],
80
+ 'no-use-before-define': [
81
+ 2,
82
+ {
83
+ functions: false,
84
+ variables: false,
85
+ },
86
+ ],
87
+ 'require-atomic-updates': [
88
+ 2,
89
+ {
90
+ allowProperties: true,
91
+ },
92
+ ],
93
+ 'use-isnan': [
94
+ 2,
95
+ {
96
+ enforceForIndexOf: true,
97
+ },
98
+ ],
99
+ 'valid-typeof': [
100
+ 2,
101
+ {
102
+ requireStringLiterals: true,
103
+ },
104
+ ],
105
+ 'accessor-pairs': 2,
106
+ 'arrow-body-style': 2,
107
+ 'block-scoped-var': 2,
108
+ camelcase: 2,
109
+ 'class-methods-use-this': 2,
110
+ 'consistent-return': 2,
111
+ curly: 2,
112
+ 'default-case': 2,
113
+ 'default-case-last': 2,
114
+ 'default-param-last': 2,
115
+ 'dot-notation': 2,
116
+ eqeqeq: 2,
117
+ 'func-name-matching': [
118
+ 2,
119
+ {
120
+ considerPropertyDescriptor: true,
121
+ },
122
+ ],
123
+ 'func-names': [
124
+ 2,
125
+ 'never',
126
+ ],
127
+ 'func-style': 2,
128
+ 'grouped-accessor-pairs': [
129
+ 2,
130
+ 'getBeforeSet',
131
+ ],
132
+ 'guard-for-in': 2,
133
+ 'logical-assignment-operators': [
134
+ 2,
135
+ 'always',
136
+ {
137
+ enforceForIfStatements: true,
138
+ },
139
+ ],
140
+ 'new-cap': 2,
141
+ 'no-alert': 2,
142
+ 'no-array-constructor': 2,
143
+ 'no-bitwise': 2,
144
+ 'no-caller': 2,
145
+ 'no-else-return': 2,
146
+ 'no-empty': [
147
+ 2,
148
+ {
149
+ allowEmptyCatch: true,
150
+ },
151
+ ],
152
+ 'no-empty-function': [
153
+ 2,
154
+ {
155
+ allow: ['arrowFunctions'],
156
+ },
157
+ ],
158
+ 'no-empty-static-block': 2,
159
+ 'no-eval': 2,
160
+ 'no-extend-native': 2,
161
+ 'no-extra-bind': 2,
162
+ 'no-extra-boolean-cast': [
163
+ 2,
164
+ {
165
+ enforceForLogicalOperands: true,
166
+ },
167
+ ],
168
+ 'no-implicit-coercion': 2,
169
+ 'no-implicit-globals': 2,
170
+ 'no-implied-eval': 2,
171
+ 'no-invalid-this': [
172
+ 2,
173
+ {
174
+ capIsConstructor: false,
175
+ },
176
+ ],
177
+ 'no-lone-blocks': 2,
178
+ 'no-lonely-if': 2,
179
+ 'no-loop-func': 2,
180
+ 'no-multi-assign': 2,
181
+ 'no-multi-str': 2,
182
+ 'no-nested-ternary': 2,
183
+ 'no-new': 2,
184
+ 'no-new-func': 2,
185
+ 'no-new-object': 2,
186
+ 'no-new-wrappers': 2,
187
+ 'no-octal-escape': 2,
188
+ 'no-param-reassign': 2,
189
+ 'no-return-assign': [
190
+ 2,
191
+ 'always',
192
+ ],
193
+ 'no-return-await': 2,
194
+ 'no-script-url': 2,
195
+ 'no-sequences': [
196
+ 2,
197
+ {
198
+ allowInParentheses: false,
199
+ },
200
+ ],
201
+ 'no-shadow': [
202
+ 2,
203
+ {
204
+ builtinGlobals: true,
205
+ },
206
+ ],
207
+ 'no-throw-literal': 2,
208
+ 'no-undef-init': 2,
209
+ 'no-underscore-dangle': [
210
+ 2,
211
+ {
212
+ allow: [
213
+ '_',
214
+ '__',
215
+ ],
216
+ enforceInMethodNames: true,
217
+ enforceInClassFields: true,
218
+ allowInArrayDestructuring: false,
219
+ allowInObjectDestructuring: false,
220
+ allowFunctionParams: false,
221
+ },
222
+ ],
223
+ 'no-unneeded-ternary': [
224
+ 2,
225
+ {
226
+ defaultAssignment: false,
227
+ },
228
+ ],
229
+ 'no-unused-expressions': 2,
230
+ 'no-useless-call': 2,
231
+ 'no-useless-computed-key': [
232
+ 2,
233
+ {
234
+ enforceForClassMembers: true,
235
+ },
236
+ ],
237
+ 'no-useless-concat': 2,
238
+ 'no-useless-constructor': 2,
239
+ 'no-useless-return': 2,
240
+ 'no-var': 2,
241
+ 'no-void': [
242
+ 2,
243
+ {
244
+ allowAsStatement: true,
245
+ },
246
+ ],
247
+ 'object-shorthand': 2,
248
+ 'operator-assignment': 2,
249
+ 'prefer-arrow-callback': 2,
250
+ 'prefer-const': 2,
251
+ 'prefer-destructuring': [
252
+ 2,
253
+ {
254
+ VariableDeclarator: {
255
+ array: true,
256
+ object: true,
257
+ },
258
+ AssignmentExpression: {
259
+ array: true,
260
+ object: true,
261
+ },
262
+ },
263
+ ],
264
+ 'prefer-exponentiation-operator': 2,
265
+ 'prefer-numeric-literals': 2,
266
+ 'prefer-object-has-own': 2,
267
+ 'prefer-object-spread': 2,
268
+ 'prefer-regex-literals': [
269
+ 2,
270
+ {
271
+ disallowRedundantWrapping: true,
272
+ },
273
+ ],
274
+ 'prefer-rest-params': 2,
275
+ 'prefer-spread': 2,
276
+ 'prefer-template': 2,
277
+ radix: [
278
+ 2,
279
+ 'as-needed',
280
+ ],
281
+ 'require-await': 2,
282
+ 'require-unicode-regexp': 2,
283
+ strict: 2,
284
+ 'symbol-description': 2,
285
+ 'vars-on-top': 2,
286
+ yoda: 2,
287
+ '@stylistic/array-bracket-newline': [
288
+ 2,
289
+ {
290
+ multiline: true,
291
+ },
292
+ ],
293
+ '@stylistic/array-bracket-spacing': 2,
294
+ '@stylistic/array-element-newline': [
295
+ 2,
296
+ 'consistent',
297
+ ],
298
+ '@stylistic/arrow-parens': [
299
+ 2,
300
+ 'as-needed',
301
+ ],
302
+ '@stylistic/arrow-spacing': 2,
303
+ '@stylistic/block-spacing': [
304
+ 2,
305
+ 'never',
306
+ ],
307
+ '@stylistic/brace-style': 2,
308
+ '@stylistic/comma-dangle': [
309
+ 2,
310
+ 'always-multiline',
311
+ ],
312
+ '@stylistic/comma-spacing': 2,
313
+ '@stylistic/comma-style': 2,
314
+ '@stylistic/computed-property-spacing': 2,
315
+ '@stylistic/dot-location': [
316
+ 2,
317
+ 'property',
318
+ ],
319
+ '@stylistic/eol-last': 2,
320
+ '@stylistic/function-call-argument-newline': [
321
+ 2,
322
+ 'consistent',
323
+ ],
324
+ '@stylistic/function-call-spacing': 2,
325
+ '@stylistic/function-paren-newline': [
326
+ 2,
327
+ 'multiline-arguments',
328
+ ],
329
+ '@stylistic/indent': [
330
+ 2,
331
+ 'tab',
332
+ {
333
+ SwitchCase: 1,
334
+ },
335
+ ],
336
+ '@stylistic/indent-binary-ops': [
337
+ 2,
338
+ 'tab',
339
+ ],
340
+ '@stylistic/key-spacing': 2,
341
+ '@stylistic/keyword-spacing': 2,
342
+ '@stylistic/linebreak-style': 2,
343
+ '@stylistic/lines-around-comment': [
344
+ 2,
345
+ {
346
+ allowBlockStart: true,
347
+ ignorePattern: String.raw`^\* @`,
348
+ },
349
+ ],
350
+ '@stylistic/lines-between-class-members': [
351
+ 2,
352
+ 'always',
353
+ {
354
+ exceptAfterSingleLine: true,
355
+ },
356
+ ],
357
+ '@stylistic/max-len': [
358
+ 2,
359
+ {
360
+ code: 120,
361
+ },
362
+ ],
363
+ '@stylistic/multiline-comment-style': [
364
+ 2,
365
+ 'separate-lines',
366
+ ],
367
+ '@stylistic/multiline-ternary': [
368
+ 2,
369
+ 'always-multiline',
370
+ ],
371
+ '@stylistic/new-parens': 2,
372
+ '@stylistic/newline-per-chained-call': [
373
+ 2,
374
+ {
375
+ ignoreChainWithDepth: 4,
376
+ },
377
+ ],
378
+ '@stylistic/no-extra-parens': [
379
+ 2,
380
+ 'all',
381
+ {
382
+ allowParensAfterCommentPattern: '@type',
383
+ },
384
+ ],
385
+ '@stylistic/no-extra-semi': 2,
386
+ '@stylistic/no-floating-decimal': 2,
387
+ '@stylistic/no-mixed-spaces-and-tabs': 2,
388
+ '@stylistic/no-multi-spaces': [
389
+ 2,
390
+ {
391
+ exceptions: {},
392
+ },
393
+ ],
394
+ '@stylistic/no-multiple-empty-lines': [
395
+ 2,
396
+ {
397
+ max: 1,
398
+ maxBOF: 0,
399
+ },
400
+ ],
401
+ '@stylistic/no-tabs': [
402
+ 2,
403
+ {
404
+ allowIndentationTabs: true,
405
+ },
406
+ ],
407
+ '@stylistic/no-trailing-spaces': 2,
408
+ '@stylistic/no-whitespace-before-property': 2,
409
+ '@stylistic/object-curly-newline': [
410
+ 2,
411
+ {
412
+ multiline: true,
413
+ consistent: true,
414
+ },
415
+ ],
416
+ '@stylistic/object-curly-spacing': 2,
417
+ '@stylistic/object-property-newline': [
418
+ 2,
419
+ {
420
+ allowAllPropertiesOnSameLine: true,
421
+ },
422
+ ],
423
+ '@stylistic/one-var-declaration-per-line': 2,
424
+ '@stylistic/operator-linebreak': [
425
+ 2,
426
+ 'before',
427
+ {
428
+ overrides: {
429
+ '=': 'after',
430
+ },
431
+ },
432
+ ],
433
+ '@stylistic/padded-blocks': [
434
+ 2,
435
+ 'never',
436
+ ],
437
+ '@stylistic/quote-props': [
438
+ 2,
439
+ 'as-needed',
440
+ ],
441
+ '@stylistic/quotes': [
442
+ 2,
443
+ 'single',
444
+ {
445
+ allowTemplateLiterals: 'avoidEscape',
446
+ avoidEscape: true,
447
+ },
448
+ ],
449
+ '@stylistic/rest-spread-spacing': 2,
450
+ '@stylistic/semi': 2,
451
+ '@stylistic/semi-spacing': 2,
452
+ '@stylistic/semi-style': 2,
453
+ '@stylistic/space-before-blocks': 2,
454
+ '@stylistic/space-before-function-paren': [
455
+ 2,
456
+ {
457
+ anonymous: 'never',
458
+ named: 'never',
459
+ asyncArrow: 'always',
460
+ },
461
+ ],
462
+ '@stylistic/space-in-parens': 2,
463
+ '@stylistic/space-infix-ops': 2,
464
+ '@stylistic/space-unary-ops': 2,
465
+ '@stylistic/spaced-comment': 2,
466
+ '@stylistic/switch-colon-spacing': 2,
467
+ '@stylistic/template-curly-spacing': 2,
468
+ '@stylistic/wrap-iife': [
469
+ 2,
470
+ 'inside',
471
+ ],
472
+ 'promise/always-return': [
473
+ 2,
474
+ {
475
+ ignoreLastCallback: true,
476
+ },
477
+ ],
478
+ 'promise/catch-or-return': [
479
+ 2,
480
+ {
481
+ allowThen: true,
482
+ },
483
+ ],
484
+ 'promise/no-multiple-resolved': 2,
485
+ 'promise/prefer-await-to-then': 2,
486
+ 'promise/spec-only': 2,
487
+ 'regexp/no-contradiction-with-assertion': 2,
488
+ 'regexp/no-dupe-disjunctions': [
489
+ 2,
490
+ {
491
+ report: 'interesting',
492
+ },
493
+ ],
494
+ 'regexp/no-empty-character-class': 2,
495
+ 'regexp/no-misleading-capturing-group': [
496
+ 2,
497
+ {
498
+ reportBacktrackingEnds: false,
499
+ },
500
+ ],
501
+ 'regexp/no-misleading-unicode-character': 2,
502
+ 'regexp/no-missing-g-flag': 2,
503
+ 'regexp/no-super-linear-backtracking': 2,
504
+ 'regexp/no-super-linear-move': 2,
505
+ 'regexp/no-extra-lookaround-assertions': 2,
506
+ 'regexp/no-octal': 2,
507
+ 'regexp/no-standalone-backslash': 2,
508
+ 'regexp/no-useless-character-class': [
509
+ 2,
510
+ {
511
+ ignores: [],
512
+ },
513
+ ],
514
+ 'regexp/prefer-escape-replacement-dollar-char': 2,
515
+ 'regexp/prefer-quantifier': 2,
516
+ 'regexp/prefer-regexp-exec': 2,
517
+ 'regexp/prefer-regexp-test': 2,
518
+ 'regexp/use-ignore-case': 2,
519
+ 'regexp/hexadecimal-escape': 2,
520
+ 'regexp/letter-case': [
521
+ 2,
522
+ {
523
+ unicodeEscape: 'uppercase',
524
+ hexadecimalEscape: 'uppercase',
525
+ controlEscape: 'uppercase',
526
+ },
527
+ ],
528
+ 'regexp/prefer-character-class': [
529
+ 2,
530
+ {
531
+ minAlternatives: 2,
532
+ },
533
+ ],
534
+ 'regexp/prefer-lookaround': [
535
+ 2,
536
+ {
537
+ lookbehind: false,
538
+ },
539
+ ],
540
+ 'regexp/unicode-property': 2,
541
+ 'unicorn/catch-error-name': [
542
+ 2,
543
+ {
544
+ name: 'e',
545
+ },
546
+ ],
547
+ 'unicorn/consistent-existence-index-check': 2,
548
+ 'unicorn/consistent-function-scoping': [
549
+ 2,
550
+ {
551
+ checkArrowFunctions: false,
552
+ },
553
+ ],
554
+ 'unicorn/empty-brace-spaces': 2,
555
+ 'unicorn/error-message': 2,
556
+ 'unicorn/explicit-length-check': 2,
557
+ 'unicorn/new-for-builtins': 2,
558
+ 'unicorn/no-abusive-eslint-disable': 2,
559
+ 'unicorn/no-array-for-each': 2,
560
+ 'unicorn/no-array-method-this-argument': 2,
561
+ 'unicorn/no-array-push-push': 2,
562
+ 'unicorn/no-array-reduce': 2,
563
+ 'unicorn/no-await-in-promise-methods': 2,
564
+ 'unicorn/no-instanceof-array': 2,
565
+ 'unicorn/no-invalid-remove-event-listener': 2,
566
+ 'unicorn/no-lonely-if': 2,
567
+ 'unicorn/no-negated-condition': 2,
568
+ 'unicorn/no-negation-in-equality-check': 2,
569
+ 'unicorn/no-object-as-default-parameter': 2,
570
+ 'unicorn/no-single-promise-in-promise-methods': 2,
571
+ 'unicorn/no-static-only-class': 2,
572
+ 'unicorn/no-this-assignment': 2,
573
+ 'unicorn/no-typeof-undefined': [
574
+ 2,
575
+ {
576
+ checkGlobalVariables: true,
577
+ },
578
+ ],
579
+ 'unicorn/no-unreadable-iife': 2,
580
+ 'unicorn/no-unused-properties': 2,
581
+ 'unicorn/no-useless-fallback-in-spread': 2,
582
+ 'unicorn/no-useless-length-check': 2,
583
+ 'unicorn/no-useless-spread': 2,
584
+ 'unicorn/no-useless-switch-case': 2,
585
+ 'unicorn/number-literal-case': 2,
586
+ 'unicorn/numeric-separators-style': 2,
587
+ 'unicorn/prefer-array-find': 2,
588
+ 'unicorn/prefer-array-flat': 2,
589
+ 'unicorn/prefer-array-flat-map': 2,
590
+ 'unicorn/prefer-array-index-of': 2,
591
+ 'unicorn/prefer-array-some': 2,
592
+ 'unicorn/prefer-code-point': 2,
593
+ 'unicorn/prefer-default-parameters': 2,
594
+ 'unicorn/prefer-global-this': 2,
595
+ 'unicorn/prefer-includes': 2,
596
+ 'unicorn/prefer-keyboard-event-key': 2,
597
+ 'unicorn/prefer-logical-operator-over-ternary': 2,
598
+ 'unicorn/prefer-math-min-max': 2,
599
+ 'unicorn/prefer-native-coercion-functions': 2,
600
+ 'unicorn/prefer-negative-index': 2,
601
+ 'unicorn/prefer-optional-catch-binding': 2,
602
+ 'unicorn/prefer-prototype-methods': 2,
603
+ 'unicorn/prefer-spread': 2,
604
+ 'unicorn/prefer-string-raw': 2,
605
+ 'unicorn/prefer-string-starts-ends-with': 2,
606
+ 'unicorn/prefer-switch': 2,
607
+ 'unicorn/prefer-ternary': 2,
608
+ 'unicorn/switch-case-braces': [
609
+ 2,
610
+ 'avoid',
611
+ ],
612
+ 'unicorn/text-encoding-identifier-case': 2,
613
+ 'unicorn/throw-new-error': 2,
614
+ 'jsdoc/check-alignment': 1,
615
+ 'jsdoc/check-indentation': [
616
+ 1,
617
+ {
618
+ excludeTags: ['description'],
619
+ },
620
+ ],
621
+ 'jsdoc/check-param-names': [
622
+ 1,
623
+ {
624
+ disableMissingParamChecks: true,
625
+ },
626
+ ],
627
+ 'jsdoc/check-tag-names': 1,
628
+ 'jsdoc/check-types': 1,
629
+ 'jsdoc/multiline-blocks': 1,
630
+ 'jsdoc/no-bad-blocks': [
631
+ 1,
632
+ {
633
+ preventAllMultiAsteriskBlocks: true,
634
+ },
635
+ ],
636
+ 'jsdoc/no-multi-asterisks': 1,
637
+ 'jsdoc/require-asterisk-prefix': 1,
638
+ 'jsdoc/require-description': [
639
+ 1,
640
+ {
641
+ exemptedBy: [
642
+ 'license',
643
+ 'type',
644
+ ],
645
+ checkConstructors: false,
646
+ checkSetters: false,
647
+ },
648
+ ],
649
+ 'jsdoc/require-hyphen-before-param-description': [
650
+ 1,
651
+ 'never',
652
+ ],
653
+ 'jsdoc/require-jsdoc': [
654
+ 1,
655
+ {
656
+ contexts: [
657
+ 'FunctionDeclaration:not(TSDeclareFunction + FunctionDeclaration)',
658
+ 'TSDeclareFunction:not(TSDeclareFunction + TSDeclareFunction)',
659
+ 'MethodDefinition:not('
660
+ + 'MethodDefinition:has(TSEmptyBodyFunctionExpression) + MethodDefinition,'
661
+ + "[kind='get'] + [kind='set'],"
662
+ + '[override=true]'
663
+ + ')',
664
+ ],
665
+ exemptEmptyConstructors: true,
666
+ checkGetters: true,
667
+ checkSetters: 'no-getter',
668
+ },
669
+ ],
670
+ 'jsdoc/require-param-description': 1,
671
+ 'jsdoc/require-param-name': 1,
672
+ 'jsdoc/require-param': [
673
+ 1,
674
+ {
675
+ checkConstructors: false,
676
+ },
677
+ ],
678
+ 'jsdoc/require-throws': 1,
679
+ 'eslint-comments/disable-enable-pair': [
680
+ 2,
681
+ {
682
+ allowWholeFile: true,
683
+ },
684
+ ],
685
+ },
686
+ overrides: [
687
+ {
688
+ files: '**/*.json',
689
+ parser: 'eslint-plugin-json-es',
690
+ extends: ['plugin:eslint-plugin-json-es/recommended'],
691
+ rules: {
692
+ '@stylistic/array-bracket-newline': [
693
+ 2,
694
+ {
695
+ minItems: 1,
696
+ },
697
+ ],
698
+ '@stylistic/array-element-newline': [
699
+ 2,
700
+ 'always',
701
+ ],
702
+ '@stylistic/comma-dangle': 0,
703
+ '@stylistic/max-len': 0,
704
+ '@stylistic/no-multiple-empty-lines': [
705
+ 2,
706
+ {
707
+ max: 0,
708
+ },
709
+ ],
710
+ '@stylistic/object-curly-newline': [
711
+ 2,
712
+ {
713
+ minProperties: 1,
714
+ },
715
+ ],
716
+ '@stylistic/object-property-newline': [
717
+ 2,
718
+ {
719
+ allowAllPropertiesOnSameLine: false,
720
+ },
721
+ ],
722
+ '@stylistic/quote-props': 0,
723
+ '@stylistic/quotes': 0,
724
+ strict: 0,
725
+ 'unicorn/prefer-string-raw': 0,
726
+ 'unicorn/numeric-separators-style': 0,
727
+ },
728
+ },
729
+ {
730
+ files: '**/*.ts',
731
+ parser: '@typescript-eslint/parser',
732
+ parserOptions: {
733
+ ecmaVersion: 'latest',
734
+ project: './tsconfig.json',
735
+ },
736
+ plugins: ['@typescript-eslint'],
737
+ extends: [
738
+ 'plugin:@typescript-eslint/recommended',
739
+ 'plugin:@typescript-eslint/recommended-requiring-type-checking',
740
+ ],
741
+ rules: {
742
+ 'class-methods-use-this': 0,
743
+ '@typescript-eslint/class-methods-use-this': [
744
+ 2,
745
+ {
746
+ ignoreOverrideMethods: true,
747
+ },
748
+ ],
749
+ 'default-param-last': 0,
750
+ '@typescript-eslint/default-param-last': 2,
751
+ 'dot-notation': 0,
752
+ '@typescript-eslint/dot-notation': [
753
+ 2,
754
+ {
755
+ allowIndexSignaturePropertyAccess: true,
756
+ },
757
+ ],
758
+ 'no-dupe-class-members': 0,
759
+ '@typescript-eslint/no-dupe-class-members': 2,
760
+ 'no-empty-function': 0,
761
+ '@typescript-eslint/no-empty-function': [
762
+ 2,
763
+ {
764
+ allow: ['arrowFunctions'],
765
+ },
766
+ ],
767
+ 'no-invalid-this': 0,
768
+ '@typescript-eslint/no-invalid-this': [
769
+ 2,
770
+ {
771
+ capIsConstructor: false,
772
+ },
773
+ ],
774
+ 'no-loop-func': 0,
775
+ '@typescript-eslint/no-loop-func': 2,
776
+ 'no-redeclare': 0,
777
+ '@typescript-eslint/no-redeclare': 2,
778
+ 'no-shadow': 0,
779
+ '@typescript-eslint/no-shadow': [
780
+ 2,
781
+ {
782
+ builtinGlobals: true,
783
+ },
784
+ ],
785
+ 'no-throw-literal': 0,
786
+ '@typescript-eslint/only-throw-error': 2,
787
+ 'no-unused-expressions': 0,
788
+ '@typescript-eslint/no-unused-expressions': 2,
789
+ 'no-unused-vars': 0,
790
+ '@typescript-eslint/no-unused-vars': [
791
+ 2,
792
+ {
793
+ args: 'all',
794
+ argsIgnorePattern: '^_+$',
795
+ caughtErrors: 'all',
796
+ ignoreRestSiblings: true,
797
+ },
798
+ ],
799
+ 'no-use-before-define': 0,
800
+ '@typescript-eslint/no-use-before-define': [
801
+ 2,
802
+ {
803
+ functions: false,
804
+ variables: false,
805
+ },
806
+ ],
807
+ 'no-useless-constructor': 0,
808
+ '@typescript-eslint/no-useless-constructor': 2,
809
+ 'prefer-destructuring': 0,
810
+ '@typescript-eslint/prefer-destructuring': [
811
+ 2,
812
+ {
813
+ VariableDeclarator: {
814
+ array: true,
815
+ object: true,
816
+ },
817
+ AssignmentExpression: {
818
+ array: true,
819
+ object: true,
820
+ },
821
+ },
822
+ ],
823
+ 'require-await': 0,
824
+ '@typescript-eslint/require-await': 2,
825
+ 'unicorn/prefer-string-starts-ends-with': 0,
826
+ '@typescript-eslint/prefer-string-starts-ends-with': 2,
827
+ '@typescript-eslint/consistent-generic-constructors': 2,
828
+ '@typescript-eslint/consistent-indexed-object-style': 2,
829
+ '@typescript-eslint/consistent-type-assertions': 2,
830
+ '@typescript-eslint/consistent-type-definitions': 2,
831
+ '@typescript-eslint/consistent-type-exports': 2,
832
+ '@typescript-eslint/consistent-type-imports': [
833
+ 2,
834
+ {
835
+ disallowTypeAnnotations: false,
836
+ },
837
+ ],
838
+ '@typescript-eslint/explicit-function-return-type': [
839
+ 2,
840
+ {
841
+ allowIIFEs: true,
842
+ },
843
+ ],
844
+ '@typescript-eslint/method-signature-style': [
845
+ 2,
846
+ 'method',
847
+ ],
848
+ '@typescript-eslint/no-confusing-non-null-assertion': 2,
849
+ '@typescript-eslint/no-confusing-void-expression': 2,
850
+ '@typescript-eslint/no-duplicate-type-constituents': 2,
851
+ '@typescript-eslint/no-empty-object-type': [
852
+ 2,
853
+ {
854
+ allowInterfaces: 'with-single-extends',
855
+ },
856
+ ],
857
+ '@typescript-eslint/no-explicit-any': [
858
+ 2,
859
+ {
860
+ ignoreRestArgs: true,
861
+ },
862
+ ],
863
+ '@typescript-eslint/no-floating-promises': [
864
+ 2,
865
+ {
866
+ ignoreIIFE: true,
867
+ },
868
+ ],
869
+ '@typescript-eslint/no-invalid-void-type': [
870
+ 2,
871
+ {
872
+ allowAsThisParameter: true,
873
+ },
874
+ ],
875
+ '@typescript-eslint/no-misused-spread': 2,
876
+ '@typescript-eslint/no-namespace': [
877
+ 2,
878
+ {
879
+ allowDeclarations: true,
880
+ },
881
+ ],
882
+ '@typescript-eslint/no-non-null-asserted-nullish-coalescing': 2,
883
+ '@typescript-eslint/no-redundant-type-constituents': 2,
884
+ '@typescript-eslint/no-this-alias': [
885
+ 2,
886
+ {
887
+ allowedNames: ['self'],
888
+ },
889
+ ],
890
+ '@typescript-eslint/no-unnecessary-boolean-literal-compare': 2,
891
+ '@typescript-eslint/no-unnecessary-condition': [
892
+ 2,
893
+ {
894
+ allowConstantLoopConditions: true,
895
+ },
896
+ ],
897
+ '@typescript-eslint/no-unnecessary-qualifier': 2,
898
+ '@typescript-eslint/no-unsafe-assignment': 0,
899
+ '@typescript-eslint/no-unsafe-call': 0,
900
+ '@typescript-eslint/no-unsafe-return': 0,
901
+ '@typescript-eslint/no-useless-empty-export': 2,
902
+ '@typescript-eslint/no-var-requires': 0,
903
+ '@typescript-eslint/non-nullable-type-assertion-style': 2,
904
+ '@typescript-eslint/prefer-for-of': 2,
905
+ '@typescript-eslint/prefer-reduce-type-parameter': 2,
906
+ '@typescript-eslint/prefer-return-this-type': 2,
907
+ '@typescript-eslint/related-getter-setter-pairs': 2,
908
+ '@typescript-eslint/switch-exhaustiveness-check': [
909
+ 2,
910
+ {
911
+ considerDefaultExhaustiveForUnions: true,
912
+ },
913
+ ],
914
+ '@typescript-eslint/unified-signatures': 2,
915
+ 'func-style': 0,
916
+ '@stylistic/member-delimiter-style': [
917
+ 2,
918
+ {
919
+ singleline: {
920
+ delimiter: 'comma',
921
+ },
922
+ },
923
+ ],
924
+ '@stylistic/type-annotation-spacing': [
925
+ 2,
926
+ {
927
+ before: false,
928
+ after: true,
929
+ overrides: {
930
+ arrow: {
931
+ before: true,
932
+ },
933
+ },
934
+ },
935
+ ],
936
+ '@stylistic/type-generic-spacing': 2,
937
+ '@stylistic/type-named-tuple-spacing': 2,
938
+ 'jsdoc/check-types': 0,
939
+ },
940
+ },
941
+ ],
942
+ settings: {
943
+ jsdoc: {
944
+ tagNamePreference: {
945
+ augments: 'extends',
946
+ },
947
+ ignorePrivate: true,
948
+ },
949
+ },
950
+ };
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ root: true,
5
+ env: {
6
+ browser: true,
7
+ es2024: true,
8
+ },
9
+ plugins: ['es-x'],
10
+ extends: ['plugin:es-x/restrict-to-es2020'],
11
+ parserOptions: {
12
+ ecmaVersion: 'latest',
13
+ },
14
+ rules: {
15
+ 'es-x/no-regexp-lookbehind-assertions': 2,
16
+ 'es-x/no-regexp-unicode-property-escapes-2020': 2,
17
+ },
18
+ settings: {
19
+ 'es-x': {
20
+ aggressive: true,
21
+ },
22
+ },
23
+ };
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+
3
+ const config = require('./eslintrc.cjs');
4
+
5
+ module.exports = {
6
+ ...config,
7
+ env: {
8
+ ...config.env,
9
+ node: true,
10
+ },
11
+ extends: [
12
+ ...config.extends,
13
+ 'plugin:n/recommended-script',
14
+ ],
15
+ rules: {
16
+ ...config.rules,
17
+ 'n/exports-style': [
18
+ 2,
19
+ 'module.exports',
20
+ ],
21
+ 'n/no-missing-import': [
22
+ 2,
23
+ {
24
+ ignoreTypeImport: true,
25
+ },
26
+ ],
27
+ 'n/no-missing-require': 2,
28
+ 'n/no-mixed-requires': 2,
29
+ 'n/no-new-require': 2,
30
+ 'n/no-path-concat': 2,
31
+ 'n/no-unsupported-features/node-builtins': [
32
+ 2,
33
+ {
34
+ ignores: ['fetch'],
35
+ },
36
+ ],
37
+ },
38
+ settings: {
39
+ ...config.settings,
40
+ n: {
41
+ tryExtensions: [
42
+ '.js',
43
+ '.json',
44
+ '.ts',
45
+ ],
46
+ },
47
+ },
48
+ };
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@bhsd/code-standard",
3
+ "version": "1.0.0",
4
+ "homepage": "https://github.com/bhsd-harry/code-standard#readme",
5
+ "bugs": {
6
+ "url": "https://github.com/bhsd-harry/code-standard/issues"
7
+ },
8
+ "license": "MIT",
9
+ "author": "Bhsd",
10
+ "files": [
11
+ "*.cjs",
12
+ "!.eslintrc.cjs"
13
+ ],
14
+ "scripts": {
15
+ "lint": "eslint --cache ."
16
+ },
17
+ "devDependencies": {
18
+ "@stylistic/eslint-plugin": "^3.1.0",
19
+ "@types/node": "^24.0.10",
20
+ "eslint": "^8.57.1",
21
+ "eslint-plugin-eslint-comments": "^3.2.0",
22
+ "eslint-plugin-jsdoc": "^51.3.3",
23
+ "eslint-plugin-json-es": "^1.6.0",
24
+ "eslint-plugin-n": "^17.20.0",
25
+ "eslint-plugin-promise": "^7.2.1",
26
+ "eslint-plugin-regexp": "^2.9.0",
27
+ "eslint-plugin-unicorn": "^56.0.1"
28
+ }
29
+ }
@@ -0,0 +1,72 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ extends: 'stylelint-config-recommended',
5
+ plugins: ['@stylistic/stylelint-plugin'],
6
+ rules: {
7
+ 'declaration-property-value-no-unknown': true,
8
+ 'no-unknown-animations': true,
9
+ 'no-unknown-custom-media': true,
10
+ 'at-rule-no-vendor-prefix': true,
11
+ 'color-hex-alpha': 'never',
12
+ 'color-named': 'never',
13
+ 'length-zero-no-unit': true,
14
+ 'media-feature-name-no-vendor-prefix': true,
15
+ 'selector-no-vendor-prefix': true,
16
+ 'value-no-vendor-prefix': true,
17
+ 'declaration-block-single-line-max-declarations': 1,
18
+ 'number-max-precision': 2,
19
+ 'alpha-value-notation': 'number',
20
+ 'color-function-alias-notation': 'without-alpha',
21
+ 'color-function-notation': 'legacy',
22
+ 'color-hex-length': 'short',
23
+ 'font-weight-notation': 'named-where-possible',
24
+ 'hue-degree-notation': 'number',
25
+ 'keyframe-selector-notation': 'percentage-unless-within-keyword-only-block',
26
+ 'selector-not-notation': 'complex',
27
+ 'selector-pseudo-element-colon-notation': 'double',
28
+ 'font-family-name-quotes': 'always-where-recommended',
29
+ 'selector-attribute-quotes': 'always',
30
+ 'declaration-block-no-redundant-longhand-properties': true,
31
+ 'shorthand-property-no-redundant-values': true,
32
+ 'comment-whitespace-inside': 'always',
33
+ '@stylistic/color-hex-case': 'lower',
34
+ '@stylistic/function-comma-space-after': 'always',
35
+ '@stylistic/function-comma-space-before': 'never',
36
+ '@stylistic/function-parentheses-space-inside': 'never',
37
+ '@stylistic/function-whitespace-after': 'always',
38
+ '@stylistic/number-leading-zero': 'never',
39
+ '@stylistic/number-no-trailing-zeros': true,
40
+ '@stylistic/string-quotes': 'double',
41
+ '@stylistic/declaration-bang-space-after': 'never',
42
+ '@stylistic/declaration-bang-space-before': 'always',
43
+ '@stylistic/declaration-colon-space-after': 'always',
44
+ '@stylistic/declaration-colon-space-before': 'never',
45
+ '@stylistic/declaration-block-semicolon-newline-after': 'always',
46
+ '@stylistic/declaration-block-trailing-semicolon': 'always',
47
+ '@stylistic/block-closing-brace-newline-after': 'always',
48
+ '@stylistic/block-closing-brace-newline-before': 'always',
49
+ '@stylistic/block-opening-brace-newline-after': 'always',
50
+ '@stylistic/block-opening-brace-space-before': 'always',
51
+ '@stylistic/selector-attribute-brackets-space-inside': 'never',
52
+ '@stylistic/selector-attribute-operator-space-after': 'never',
53
+ '@stylistic/selector-attribute-operator-space-before': 'never',
54
+ '@stylistic/selector-combinator-space-after': 'always',
55
+ '@stylistic/selector-combinator-space-before': 'always',
56
+ '@stylistic/selector-max-empty-lines': 0,
57
+ '@stylistic/selector-pseudo-class-parentheses-space-inside': 'never',
58
+ '@stylistic/media-feature-colon-space-after': 'always',
59
+ '@stylistic/media-feature-colon-space-before': 'never',
60
+ '@stylistic/media-feature-parentheses-space-inside': 'never',
61
+ '@stylistic/at-rule-name-space-after': 'always',
62
+ '@stylistic/indentation': 'tab',
63
+ '@stylistic/linebreaks': 'unix',
64
+ '@stylistic/max-empty-lines': 1,
65
+ '@stylistic/no-empty-first-line': true,
66
+ '@stylistic/no-eol-whitespace': true,
67
+ '@stylistic/no-extra-semicolons': true,
68
+ '@stylistic/no-missing-end-of-source-newline': true,
69
+ },
70
+ reportInvalidScopeDisables: true,
71
+ reportNeedlessDisables: true,
72
+ };