forked from stdlib-js/stdlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypescript.js
More file actions
2729 lines (2562 loc) · 60.5 KB
/
typescript.js
File metadata and controls
2729 lines (2562 loc) · 60.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* @license Apache-2.0
*
* Copyright (c) 2023 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable stdlib/jsdoc-doctest-marker, stdlib/jsdoc-doctest-quote-props */
'use strict';
// MODULES //
var merge = require( './../../../lib/node_modules/@stdlib/utils/merge' );
var mapValues = require( './../../../lib/node_modules/@stdlib/utils/map-values' );
var constantFunction = require( './../../../lib/node_modules/@stdlib/utils/constant-function' );
var defaults = require( './../.eslintrc.js' );
// MAIN //
/**
* ESLint rules.
*
* @namespace rules
*/
var rules = merge( {}, mapValues( defaults.rules, constantFunction( 'off' ) ) );
/**
* Requires that function overload signatures be consecutive.
*
* @name adjacent-overload-signatures
* @memberof rules
* @type {string}
* @default 'error'
* @see [adjacent-overload-signatures]{@link https://typescript-eslint.io/rules/adjacent-overload-signatures}
*
* @example
* // Bad...
* interface Foo {
* foo( s: string ): void;
* foo( n: number ): void;
* bar(): void;
* foo( sn: string | number ): void;
* }
*
* // Good...
* interface Foo {
* foo( s: string ): void;
* foo( n: number ): void;
* foo( sn: string | number ): void;
* bar(): void;
* }
*/
rules[ '@typescript-eslint/adjacent-overload-signatures' ] = 'error';
/**
* Enforces the use of `Array<type>` for generic array type annotations.
*
* @name array-type
* @memberof rules
* @type {Array}
* @default [ 'error', { 'default': 'generic' } ]
* @see [array-type]{@link https://typescript-eslint.io/rules/array-type}
*
* @example
* // Bad...
* const bad: string[] = [];
*
* // Good...
* const good: Array<string> = [];
*/
rules[ '@typescript-eslint/array-type' ] = [ 'error', {
'default': 'generic'
}];
/**
* Enforces that `await` is used with a Promise.
*
* @name await-thenable
* @memberof rules
* @type {string}
* @default 'error'
* @see [await-thenable]{@link https://typescript-eslint.io/rules/await-thenable}
*
* @example
* // Bad...
* function test() {
* await 123;
* }
*
* // Good...
* async function test() {
* await Promise.resolve();
* }
*/
rules[ '@typescript-eslint/await-thenable' ] = 'error';
/**
* Disables the prohibition against TypeScript `@ts-` comments.
*
* @name ban-ts-comment
* @memberof rules
* @type {string}
* @default 'off'
* @see [ban-ts-comment]{@link https://typescript-eslint.io/rules/ban-ts-comment}
*
* @example
* // Okay...
* // @ts-ignore
* console.log( someVarThatDoesNotExist );
*/
rules[ '@typescript-eslint/ban-ts-comment' ] = 'off';
/**
* Disables the ban on certain TypeScript types like `{}` or `object`.
*
* @name ban-types
* @memberof rules
* @type {string}
* @default 'off'
* @see [ban-types]{@link https://typescript-eslint.io/rules/ban-types}
*
* @example
* // Okay...
* type foo = {};
* type bar = object;
*/
rules[ '@typescript-eslint/ban-types' ] = 'off';
/**
* Enforces the use of consistent type assertions.
*
* @name consistent-type-assertions
* @memberof rules
* @type {string}
* @default 'error'
* @see [consistent-type-assertions]{@link https://typescript-eslint.io/rules/consistent-type-assertions}
*
* @example
* // Bad...
* let x = <number>someValue;
*
* // Good...
* let x = someValue as number;
*/
rules[ '@typescript-eslint/consistent-type-assertions' ] = 'error';
/**
* Enforces consistent usage of type definitions either with `interface` or `type`.
*
* @name consistent-type-definitions
* @memberof rules
* @type {string}
* @default 'error'
* @see [consistent-type-definitions]{@link https://typescript-eslint.io/rules/consistent-type-definitions}
*
* @example
* // Bad...
* type T = {};
*
* // Good...
* interface T {}
*/
rules[ '@typescript-eslint/consistent-type-definitions' ] = 'error';
/**
* Disables the rule that requires dot notation when accessing properties.
*
* @name dot-notation
* @memberof rules
* @type {string}
* @default 'off'
* @see [dot-notation]{@link https://typescript-eslint.io/rules/dot-notation}
*
* @example
* // Okay...
* let x = foo[ 'bar' ];
* let y = foo.bar;
*/
rules[ '@typescript-eslint/dot-notation' ] = 'off';
/**
* Requires that functions have an explicit return type.
*
* @name explicit-function-return-type
* @memberof rules
* @type {string}
* @default 'error'
* @see [explicit-function-return-type]{@link https://typescript-eslint.io/rules/explicit-function-return-type}
*
* @example
* // Bad...
* function test() {
* return 42;
* }
*
* // Good...
* function test(): number {
* return 42;
* }
*/
rules[ '@typescript-eslint/explicit-function-return-type' ] = 'error';
/**
* Enforces explicit visibility declarations for class members.
*
* ## Notes
*
* - The 'no-public' option requires explicit visibility except for public members.
*
* @name explicit-member-accessibility
* @memberof rules
* @type {Array}
* @default [ 'error', { 'accessibility': 'no-public' } ]
* @see [explicit-member-accessibility]{@link https://typescript-eslint.io/rules/explicit-member-accessibility}
*
* @example
* // Bad...
* class MyClass {
* memberWithoutVisibility = 'no explicit visibility';
* }
*
* // Good...
* class MyClass {
* private memberWithVisibility = 'has explicit visibility';
* }
*/
rules[ '@typescript-eslint/explicit-member-accessibility' ] = [
'error',
{
'accessibility': 'no-public'
}
];
/**
* Requires explicit return and argument types on exported functions' and classes' public class methods.
*
* @name explicit-module-boundary-types
* @memberof rules
* @type {string}
* @default 'error'
* @see [explicit-module-boundary-types]{@link https://typescript-eslint.io/rules/explicit-module-boundary-types}
*
* @example
* // Bad...
* export function badFunction( a ) {
* return a;
* }
*
* // Good...
* export function goodFunction( a: string ): string {
* return a;
* }
*/
rules[ '@typescript-eslint/explicit-module-boundary-types' ] = 'error';
/**
* Enforces indentation with tabs.
*
* @name indent
* @memberof rules
* @type {Array}
* @default [ 'error', 'tab' ]
* @see [indent]{@link https://typescript-eslint.io/rules/indent}
*
* @example
* // Bad...
* function bad() {
* return true;
* }
*
* // Good...
* function good() {
* return true;
* }
*/
rules[ '@typescript-eslint/indent' ] = [ 'error', 'tab' ];
/**
* Enforces a specific member delimiter style in interfaces and type literals.
*
* @name member-delimiter-style
* @memberof rules
* @type {Array}
* @default [ 'error', { 'multiline': { 'delimiter': 'semi', 'requireLast': true }, 'singleline': { 'delimiter': 'semi', 'requireLast': false } } ]
* @see [member-delimiter-style]{@link https://typescript-eslint.io/rules/member-delimiter-style}
*
* @example
* // Bad...
* interface Bad {
* name: string,
* age: number
* }
*
* // Good...
* interface Good {
* name: string;
* age: number;
* }
*/
rules[ '@typescript-eslint/member-delimiter-style' ] = [
'error',
{
'multiline': {
'delimiter': 'semi',
'requireLast': true
},
'singleline': {
'delimiter': 'semi',
'requireLast': false
}
}
];
/**
* Disables TypeScript's no-shadow rule.
*
* @name no-shadow
* @memberof rules
* @type {Array}
* @default [ 'off', { 'hoist': 'all' } ]
* @see [no-shadow]{@link https://typescript-eslint.io/rules/no-shadow}
*
* @example
* // Okay...
* const x = 1;
* function example() {
* const x = 2;
* }
*/
rules[ '@typescript-eslint/no-shadow' ] = [ 'off', {
'hoist': 'all'
}];
/**
* Disables the rule against the delete operator with computed key expressions.
*
* @name no-dynamic-delete
* @memberof rules
* @type {string}
* @default 'off'
* @see [no-dynamic-delete]{@link https://typescript-eslint.io/rules/no-dynamic-delete}
*
* @example
* // Okay...
* delete object[ dynamicKey ];
*/
rules[ '@typescript-eslint/no-dynamic-delete' ] = 'off';
/**
* Disallows empty functions. Functions with a comment inside are not considered empty.
*
* @name no-empty-function
* @memberof rules
* @type {string}
* @default 'error'
* @see [no-empty-function]{@link https://typescript-eslint.io/rules/no-empty-function}
*
* @example
* // Bad...
* function noOp() {}
*
* // Good...
* function noOp() {
* // intentional no-op
* }
*/
rules[ '@typescript-eslint/no-empty-function' ] = 'error';
/**
* Disallows the declaration of empty interfaces.
*
* @name no-empty-interface
* @memberof rules
* @type {string}
* @default 'error'
* @see [no-empty-interface]{@link https://typescript-eslint.io/rules/no-empty-interface}
*
* @example
* // Bad...
* interface Empty {}
*
* // Good...
* interface NotEmpty {
* data: string;
* }
*/
rules[ '@typescript-eslint/no-empty-interface' ] = 'error';
/**
* Warns on usage of the `any` type.
*
* @name no-explicit-any
* @memberof rules
* @type {string}
* @default 'warn'
* @see [no-explicit-any]{@link https://typescript-eslint.io/rules/no-explicit-any}
*
* @example
* // Bad...
* function unsafe( arg: any ): any { return arg; }
*
* // Good...
* function safe( arg: unknown ): unknown { return arg; }
*/
rules[ '@typescript-eslint/no-explicit-any' ] = 'warn';
/**
* Disallows classes that only have static members and don't need to be instantiated.
*
* @name no-extraneous-class
* @memberof rules
* @type {string}
* @default 'error'
* @see [no-extraneous-class]{@link https://typescript-eslint.io/rules/no-extraneous-class}
*
* @example
* // Bad...
* class StaticOnly {
* static doSomething() {}
* }
*
* // Good...
* namespace StaticOnly {
* export function doSomething() {}
* }
*/
rules[ '@typescript-eslint/no-extraneous-class' ] = 'error';
/**
* Requires Promises to be handled appropriately. Unhandled Promises can cause unexpected behavior.
*
* @name no-floating-promises
* @memberof rules
* @type {string}
* @default 'error'
* @see [no-floating-promises]{@link https://typescript-eslint.io/rules/no-floating-promises}
*
* @example
* // Bad...
* new Promise( resolve => resolve() );
*
* // Good...
* new Promise( resolve => resolve() ).catch( handleError );
*/
rules[ '@typescript-eslint/no-floating-promises' ] = 'error';
/**
* Disallows iterating over an array with a for-in loop. A for-of loop should be used instead.
*
* @name no-for-in-array
* @memberof rules
* @type {string}
* @default 'error'
* @see [no-for-in-array]{@link https://typescript-eslint.io/rules/no-for-in-array}
*
* @example
* // Bad...
* const arr = [ 1, 2, 3 ];
* for ( const i in arr ) {
* console.log( arr[ i ] );
* }
*
* // Good...
* for ( const i of arr ) {
* console.log( i );
* }
*/
rules[ '@typescript-eslint/no-for-in-array' ] = 'error';
/**
* Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean.
*
* @name no-inferrable-types
* @memberof rules
* @type {string}
* @default 'error'
* @see [no-inferrable-types]{@link https://typescript-eslint.io/rules/no-inferrable-types}
*
* @example
* // Bad...
* let x: number = 1;
*
* // Good...
* let x = 1;
*/
rules[ '@typescript-eslint/no-inferrable-types' ] = 'error';
/**
* Disallows the incorrect use of `new` with interfaces or `new` for defining a constructor.
*
* @name no-misused-new
* @memberof rules
* @type {string}
* @default 'error'
* @see [no-misused-new]{@link https://typescript-eslint.io/rules/no-misused-new}
*
* @example
* // Bad...
* interface I {
* new (): I;
* }
*
* // Good...
* class C implements I {
* constructor() {}
* }
*/
rules[ '@typescript-eslint/no-misused-new' ] = 'error';
/**
* Disallows the use of custom TypeScript modules and namespaces.
*
* @name no-namespace
* @memberof rules
* @type {string}
* @default 'error'
* @see [no-namespace]{@link https://typescript-eslint.io/rules/no-namespace}
*
* @example
* // Bad...
* module M {
* export const x = 1;
* }
*
* // Good...
* namespace N {
* export const x = 1;
* }
*/
rules[ '@typescript-eslint/no-namespace' ] = 'error';
/**
* Disallows non-null assertions using the `!` postfix operator.
*
* @name no-non-null-assertion
* @memberof rules
* @type {string}
* @default 'error'
* @see [no-non-null-assertion]{@link https://typescript-eslint.io/rules/no-non-null-assertion}
*
* @example
* // Bad...
* const x: number | null = null;
* const y: number = x!;
*
* // Good...
* if ( x !== null ) {
* const y: number = x;
* }
*/
rules[ '@typescript-eslint/no-non-null-assertion' ] = 'error';
/**
* Disables the rule against using `require` statements instead of import declarations.
*
* @name no-require-imports
* @memberof rules
* @type {string}
* @default 'off'
* @see [no-require-imports]{@link https://typescript-eslint.io/rules/no-require-imports}
*
* @example
* // Okay...
* const module = require( 'module' );
*/
rules[ '@typescript-eslint/no-require-imports' ] = 'off';
/**
* Disallows aliases for `this`.
*
* @name no-this-alias
* @memberof rules
* @type {string}
* @default 'error'
* @see [no-this-alias]{@link https://typescript-eslint.io/rules/no-this-alias}
*
* @example
* // Bad...
* const self = this;
* const that = this;
*
* // Good...
* function example() {
* console.log( this );
* }
*/
rules[ '@typescript-eslint/no-this-alias' ] = 'error';
/**
* Disables the rule against unnecessary boolean literal comparisons.
*
* @name no-unnecessary-boolean-literal-compare
* @memberof rules
* @type {string}
* @default 'off'
* @see [no-unnecessary-boolean-literal-compare]{@link https://typescript-eslint.io/rules/no-unnecessary-boolean-literal-compare}
*
* @example
* // Okay...
* const x = true;
* if ( x === true ) {
* // ...
* }
*/
rules[ '@typescript-eslint/no-unnecessary-boolean-literal-compare' ] = 'off';
/**
* Disallows unnecessary qualifiers (like namespaces or enum names) when the referenced item is accessible without them.
*
* @name no-unnecessary-qualifier
* @memberof rules
* @type {string}
* @default 'error'
* @see [no-unnecessary-qualifier]{@link https://typescript-eslint.io/rules/no-unnecessary-qualifier}
*
* @example
* // Bad...
* namespace A {
* export const B = 1;
* }
* const x = A.B;
*
* // Good...
* const B = 1;
* const x = B;
*/
rules[ '@typescript-eslint/no-unnecessary-qualifier' ] = 'error';
/**
* Disallows unnecessary type arguments in generics where the argument is the default.
*
* @name no-unnecessary-type-arguments
* @memberof rules
* @type {string}
* @default 'error'
* @see [no-unnecessary-type-arguments]{@link https://typescript-eslint.io/rules/no-unnecessary-type-arguments}
*
* @example
* // Bad...
* function f<T = number>( x: T ) {
* return x + x
* }
* f<number>();
*
* // Good...
* function f<T>( x: T ) {
* return x + x
* }
* f( 1 );
* f<string>( 'a' );
*/
rules[ '@typescript-eslint/no-unnecessary-type-arguments' ] = 'error';
/**
* Disallows unnecessary type assertions that do not change the type of an expression.
*
* @name no-unnecessary-type-assertion
* @memberof rules
* @type {string}
* @default 'error'
* @see [no-unnecessary-type-assertion]{@link https://typescript-eslint.io/rules/no-unnecessary-type-assertion}
*
* @example
* // Bad...
* const x: number = 10;
* const y = x as number;
*
* // Good...
* const x: number = 10;
* const y = x;
*/
rules[ '@typescript-eslint/no-unnecessary-type-assertion' ] = 'error';
/**
* Disallows unused expressions which have no effect on the state of the program.
*
* @name no-unused-expressions
* @memberof rules
* @type {string}
* @default 'error'
* @see [no-unused-expressions]{@link https://typescript-eslint.io/rules/no-unused-expressions}
*
* @example
* // Bad...
* 0;
* if ( false ) {}
*
* // Good...
* (() => {
* const a = 0;
* })();
*/
rules[ '@typescript-eslint/no-unused-expressions' ] = 'error';
/**
* Disables the rule against unused variables.
*
* @name no-unused-vars
* @memberof rules
* @type {string}
* @default [ 'error', { 'args': 'after-used' } ]
* @see [no-unused-vars]{@link https://typescript-eslint.io/rules/no-unused-vars}
*
* @example
* // Bad...
* function foo( x, y, z ) {
* return x + y;
* }
*
* // Okay...
* function bar( x, y, z ) {
* return y + z;
* }
*/
rules[ '@typescript-eslint/no-unused-vars' ] = [ 'error', {
'args': 'after-used'
}];
/**
* Disallows the use of variables before they are defined.
*
* @name no-use-before-define
* @memberof rules
* @type {string}
* @default 'error'
* @see [no-use-before-define]{@link https://typescript-eslint.io/rules/no-use-before-define}
*
* @example
* // Bad...
* console.log( a );
* let a = 10;
*
* // Good...
* let b = 10;
* console.log( b );
*/
rules[ '@typescript-eslint/no-use-before-define' ] = 'error';
/**
* Disallows the use of `require` statements except in import statements.
*
* @name no-var-requires
* @memberof rules
* @type {string}
* @default 'error'
* @see [no-var-requires]{@link https://typescript-eslint.io/rules/no-var-requires}
*
* @example
* // Bad...
* const moduleA = require( 'moduleA' );
*
* // Good...
* import moduleA from 'moduleA';
*
* import moduleA = require( 'moduleA' );
*/
rules[ '@typescript-eslint/no-var-requires' ] = 'error';
/**
* Disables the preference for `for-of` loops over standard `for` loops with index variables.
*
* @name prefer-for-of
* @memberof rules
* @type {string}
* @default 'off'
* @see [prefer-for-of]{@link https://typescript-eslint.io/rules/prefer-for-of}
*
* @example
* // Okay...
* for ( let i = 0; i < myArray.length; i++ ) {
* console.log( myArray[ i ] );
* }
*/
rules[ '@typescript-eslint/prefer-for-of' ] = 'off';
/**
* Prefers function types instead of interfaces with call signatures.
*
* @name prefer-function-type
* @memberof rules
* @type {string}
* @default 'error'
* @see [prefer-function-type]{@link https://typescript-eslint.io/rules/prefer-function-type}
*
* @example
* // Bad...
* interface Callable {
* (): void;
* }
*
* // Good...
* type Callable = () => void;
*/
rules[ '@typescript-eslint/prefer-function-type' ] = 'error';
/**
* Prefers the use of the `namespace` keyword instead of `module` to declare custom TypeScript modules.
*
* @name prefer-namespace-keyword
* @memberof rules
* @type {string}
* @default 'error'
* @see [prefer-namespace-keyword]{@link https://typescript-eslint.io/rules/prefer-namespace-keyword}
*
* @example
* // Bad...
* module M {
* export const x = 1;
* }
*
* // Good...
* namespace M {
* export const x = 1;
* }
*/
rules[ '@typescript-eslint/prefer-namespace-keyword' ] = 'error';
/**
* Disables the rule that private members are marked as `readonly` if they're never modified outside of the constructor.
*
* @name prefer-readonly
* @memberof rules
* @type {string}
* @default 'off'
* @see [prefer-readonly]{@link https://typescript-eslint.io/rules/prefer-readonly}
*
* @example
* // Okay...
* class MyClass {
* private name: string;
* constructor( name: string ) {
* this.name = name;
* }
* }
*/
rules[ '@typescript-eslint/prefer-readonly' ] = 'off';
/**
* Disables the rule that functions which return promises must be async.
*
* @name promise-function-async
* @memberof rules
* @type {string}
* @default 'off'
* @see [promise-function-async]{@link https://typescript-eslint.io/rules/promise-function-async}
*
* @example
* // Okay...
* function fetchWithoutAsync() {
* return fetch( 'url' ).then( response => response.json() );
* }
*/
rules[ '@typescript-eslint/promise-function-async' ] = 'off';
/**
* Enforces the consistent use of single quotes for string literals and allows avoiding escape for quotes.
*
* @name quotes
* @memberof rules
* @type {Array}
* @default [ 'error', 'single', { 'avoidEscape': true } ]
* @see [quotes]{@link https://typescript-eslint.io/rules/quotes}
*
* @example
* // Bad...
* const bad = "bad";
*
* // Good...
* const good = 'good';
* const goodEscape = "good's";
*/
rules[ '@typescript-eslint/quotes' ] = [
'error',
'single',
{
'avoidEscape': true
}
];
/**
* Requires that `async` functions have an `await` expression.
*
* @name require-await
* @memberof rules
* @type {string}
* @default 'error'
* @see [require-await]{@link https://typescript-eslint.io/rules/require-await}
*
* @example
* // Bad...
* async function bad() {
* return 42;
* }
*
* // Good...
* async function good() {
* return await someAsyncFunction();
* }
*/
rules[ '@typescript-eslint/require-await' ] = 'error';
/**
* When adding two variables, operands must both be of type number or of type string.
*
* @name restrict-plus-operands
* @memberof rules
* @type {string}
* @default 'error'
* @see [restrict-plus-operands]{@link https://typescript-eslint.io/rules/restrict-plus-operands}
*
* @example
* // Bad...
* const bad = 'The total is: ' + 42;
*
* // Good...
* const good = 'The total is: ' + String(42);
*/
rules[ '@typescript-eslint/restrict-plus-operands' ] = 'error';
/**
* Enforces the use of semicolons after statements.
*
* @name semi
* @memberof rules
* @type {Array}
* @default [ 'error', 'always' ]
* @see [semi]{@link https://typescript-eslint.io/rules/semi}
*
* @example
* // Bad...
* const bad = 'no semi'
*
* // Good...
* const good = 'semi';
*/
rules[ '@typescript-eslint/semi' ] = [ 'error', 'always' ];
/**
* Disables the rule for strict boolean expressions.
*
* @name strict-boolean-expressions
* @memberof rules
* @type {string}
* @default 'off'
* @see [strict-boolean-expressions]{@link https://typescript-eslint.io/rules/strict-boolean-expressions}
*
* @example
* // Okay...
* if ( someValue ) {}
*/
rules[ '@typescript-eslint/strict-boolean-expressions' ] = 'off';
/**
* Enforces triple slash references (`/// <reference path="" />`) usage.
*
* @name triple-slash-reference
* @memberof rules
* @type {Array}
* @default [ 'error', { 'path': 'always', 'types': 'prefer-import', 'lib': 'always' } ]
* @see [triple-slash-reference]{@link https://typescript-eslint.io/rules/triple-slash-reference}
*
* @example
* // Bad...
* /// <reference lib="libname" />
*
* // Okay...
* /// <reference types="@stdlib/types" />
*/
rules[ '@typescript-eslint/triple-slash-reference' ] = [
'error',
{
'path': 'always',
'types': 'prefer-import',
'lib': 'always'
}
];
/**
* Requires consistent spacing around type annotations.
*
* @name type-annotation-spacing
* @memberof rules
* @type {string}
* @default 'error'
* @see [type-annotation-spacing]{@link https://typescript-eslint.io/rules/type-annotation-spacing}
*
* @example