@josundt/eslint-config 4.9.6 → 5.0.4

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.
@@ -0,0 +1,309 @@
1
+ /* Main @typescript-eslint rules */
2
+ const rules = {
3
+ "adjacent-overload-signatures": "error",
4
+ "array-type": [
5
+ "error",
6
+ {
7
+ "default": "array-simple",
8
+ "readonly": "array-simple"
9
+ }
10
+ ],
11
+ "await-thenable": "error",
12
+ "ban-ts-comment": [
13
+ "error",
14
+ {
15
+ "ts-expect-error": "allow-with-description",
16
+ "ts-ignore": true,
17
+ "ts-nocheck": true,
18
+ "ts-check": false,
19
+ "minimumDescriptionLength": 10,
20
+ //"descriptionFormat": "someformathere"
21
+ }
22
+ ],
23
+ "ban-tslint-comment": "error", // No longer use tslint - remove rules
24
+ "ban-types": "off", // Can be used to ban certain types
25
+ "class-literal-property-style": "off",
26
+ "consistent-generic-constructors": ["off", "constructor"],
27
+ "consistent-indexed-object-style": ["error", "record"],
28
+ "consistent-type-assertions": [
29
+ "error",
30
+ {
31
+ "assertionStyle": "as",
32
+ "objectLiteralTypeAssertions": "allow"
33
+ }
34
+ ],
35
+ "consistent-type-definitions": [
36
+ "error",
37
+ "interface"
38
+ ],
39
+ "consistent-type-exports": [
40
+ "error",
41
+ {
42
+ "fixMixedExportsWithInlineTypeSpecifier": true
43
+ }
44
+ ],
45
+ "consistent-type-imports": [
46
+ "error",
47
+ {
48
+ "prefer": "type-imports",
49
+ "fixStyle": "inline-type-imports",
50
+ "disallowTypeAnnotations": false
51
+ }
52
+ ],
53
+ "explicit-function-return-type": [
54
+ "error",
55
+ {
56
+ "allowConciseArrowFunctionExpressionsStartingWithVoid": true,
57
+ "allowExpressions": true,
58
+ "allowFunctionsWithoutTypeParameters": false,
59
+ "allowHigherOrderFunctions": true,
60
+ "allowIIFEs": false,
61
+ "allowTypedFunctionExpressions": true,
62
+ "allowedNames": []
63
+ }
64
+ ],
65
+ "explicit-member-accessibility": [
66
+ "error",
67
+ {
68
+ "accessibility": "no-public"
69
+ }
70
+ ],
71
+ "explicit-module-boundary-types": [ // same as "recommended" except error instead of warning
72
+ "error",
73
+ {
74
+ "allowArgumentsExplicitlyTypedAsAny": false,
75
+ "allowDirectConstAssertionInArrowFunctions": true,
76
+ "allowHigherOrderFunctions": true,
77
+ "allowTypedFunctionExpressions": true,
78
+ "allowedNames": []
79
+ }
80
+ ],
81
+ "member-delimiter-style": [
82
+ "error",
83
+ {
84
+ "multiline": {
85
+ "delimiter": "semi",
86
+ "requireLast": true
87
+ },
88
+ "singleline": {
89
+ "delimiter": "semi",
90
+ "requireLast": true
91
+ }
92
+ }
93
+ ],
94
+ "member-ordering": "off",
95
+ "method-signature-style": "off", // useful rule since lambda method notation enforces stricter type checking, but has somme inconveniences for ovelaoads, "implement interface" refactoring, and general code complexity
96
+ "naming-convention": [
97
+ "error",
98
+ {
99
+ "selector": "default",
100
+ "format": [
101
+ "camelCase"
102
+ ],
103
+ "leadingUnderscore": "forbid",
104
+ "trailingUnderscore": "forbid"
105
+ },
106
+ {
107
+ "selector": "typeLike",
108
+ "format": [
109
+ "PascalCase"
110
+ ]
111
+ },
112
+ {
113
+ "selector": "method",
114
+ "modifiers": [
115
+ // "#private", // Did not work even if it was added in 5.49.0
116
+ "private"
117
+ ],
118
+ "format": [
119
+ "camelCase"
120
+ ],
121
+ "leadingUnderscore": "allow",
122
+ "trailingUnderscore": "forbid"
123
+ },
124
+ {
125
+ "selector": "property",
126
+ "modifiers": [
127
+ // "#private", // Did not work even if it was added in 5.49.0
128
+ "private"
129
+ ],
130
+ "format": [
131
+ "camelCase"
132
+ ],
133
+ "leadingUnderscore": "allow",
134
+ "trailingUnderscore": "forbid"
135
+ },
136
+ {
137
+ "selector": "enumMember",
138
+ "format": [
139
+ "camelCase",
140
+ "PascalCase"
141
+ ]
142
+ }
143
+ ],
144
+ "no-base-to-string": "error",
145
+ "no-confusing-non-null-assertion": "error",
146
+ "no-confusing-void-expression": [
147
+ "error",
148
+ {
149
+ "ignoreArrowShorthand": true
150
+ }
151
+ ],
152
+ "no-duplicate-enum-values": "error",
153
+ "no-duplicate-type-constituents": "error",
154
+ "no-dynamic-delete": "error",
155
+ "no-empty-interface": "off",
156
+ "no-explicit-any": [
157
+ "off",
158
+ {
159
+ "ignoreRestArgs": "false"
160
+ }
161
+ ],
162
+ "no-extra-non-null-assertion": "error",
163
+ "no-extraneous-class": "error",
164
+ "no-floating-promises": "error", // Must be switched on to prevent promises not awaited
165
+ "no-for-in-array": "error",
166
+ "no-import-type-side-effects": "error",
167
+ "no-inferrable-types": "off",
168
+ "no-invalid-void-type": [
169
+ "error",
170
+ {
171
+ "allowInGenericTypeArguments": true,
172
+ "allowAsThisParameter": true
173
+ }
174
+ ],
175
+ "no-meaningless-void-operator": "error",
176
+ "no-misused-new": "error",
177
+ "no-misused-promises": [
178
+ "error",
179
+ {
180
+ "checksConditionals": true,
181
+ "checksSpreads": true,
182
+ "checksVoidReturn": true // {
183
+ // arguments: true, //Disables checking an asynchronous function passed as argument where the parameter type expects a function that returns void
184
+ // attributes: true, //Disables checking an asynchronous function passed as a JSX attribute expected to be a function that returns void
185
+ // properties: true, //Disables checking an asynchronous function passed as an object property expected to be a function that returns void
186
+ // returns: true, //Disables checking an asynchronous function returned in a function whose return type is a function that returns void
187
+ // variables: true //Disables checking an asynchronous function used as a variable whose return type is a function that returns void
188
+ // }
189
+ }
190
+ ],
191
+ "no-mixed-enums": "error",
192
+ "no-namespace": "off",
193
+ "no-non-null-asserted-nullish-coalescing": "error",
194
+ "no-non-null-asserted-optional-chain": "error",
195
+ "no-non-null-assertion": "off",
196
+ "no-redundant-type-constituents": "error",
197
+ "no-require-imports": "error",
198
+ "no-unsafe-enum-comparison": "error",
199
+ "no-this-alias": "error",
200
+ "no-throw-literal": [
201
+ "error",
202
+ {
203
+ "allowThrowingAny": false, // Default is to allow throwing values of type any
204
+ "allowThrowingUnknown": true // Default is to allow throwing values of type unknown
205
+ }
206
+ ],
207
+ "no-type-alias": "off",
208
+ "no-unnecessary-boolean-literal-compare": "error",
209
+ "no-unnecessary-condition": "off", // allow runtime null checks etc even if reported not necessary by type system
210
+ "no-unnecessary-qualifier": "error",
211
+ "no-unnecessary-type-arguments": "off",
212
+ "no-unnecessary-type-assertion": "off",
213
+ "no-unnecessary-type-constraint": "error",
214
+ "no-unsafe-argument": "error",
215
+ "no-unsafe-assignment": "error",
216
+ "no-unsafe-call": "error",
217
+ "no-unsafe-member-access": "error",
218
+ "no-unsafe-return": "error",
219
+ "no-unused-vars-experimental": "off", // to strict with method params...
220
+ "no-useless-empty-export": "error",
221
+ "no-var-requires": "error",
222
+ "non-nullable-type-assertion-style": "error",
223
+ "parameter-properties": [
224
+ "error",
225
+ {
226
+ "prefer": "class-property", // or "parameter-property"
227
+ "allow": ["private readonly", "private", "protected readonly"]
228
+ }
229
+ ],
230
+ "prefer-as-const": "off",
231
+ "prefer-enum-initializers": "error",
232
+ "prefer-for-of": "error",
233
+ "prefer-function-type": "error",
234
+ "prefer-includes": "error",
235
+ "prefer-literal-enum-member": "error",
236
+ "prefer-namespace-keyword": "error",
237
+ "prefer-nullish-coalescing": [
238
+ "error",
239
+ {
240
+ "ignoreConditionalTests": true,
241
+ "ignoreTernaryTests": true,
242
+ "ignoreMixedLogicalExpressions": true
243
+ }
244
+ ],
245
+ "prefer-optional-chain": "error",
246
+ "prefer-readonly": "error",
247
+ "prefer-readonly-parameter-types": "off", // Could be useful but requires too much work and verbose notation
248
+ "prefer-reduce-type-parameter": "error",
249
+ "prefer-regexp-exec": "error",
250
+ "prefer-return-this-type": "error",
251
+ "prefer-string-starts-ends-with": "error",
252
+ "prefer-ts-expect-error": "error",
253
+ "promise-function-async": "off",
254
+ "require-array-sort-compare": "error",
255
+ "restrict-plus-operands": [
256
+ "error",
257
+ {
258
+ "checkCompoundAssignments": true,
259
+ "allowAny": false
260
+ }
261
+ ],
262
+ "restrict-template-expressions": [
263
+ "error",
264
+ {
265
+ "allowAny": false,
266
+ "allowBoolean": false,
267
+ "allowNever": false,
268
+ "allowNullish": false,
269
+ "allowNumber": true,
270
+ "allowRegExp": false
271
+ }
272
+ ],
273
+ "sort-type-constituents": "off",
274
+ "strict-boolean-expressions": [
275
+ "off",
276
+ {
277
+ "allowString": true,
278
+ "allowNumber": true,
279
+ "allowNullableObject": true,
280
+ "allowNullableString": true,
281
+ "allowNullableNumber": true,
282
+ "allowNullableBoolean": true,
283
+ "allowAny": false
284
+ }
285
+ ],
286
+ "switch-exhaustiveness-check": "error",
287
+ "triple-slash-reference": "error",
288
+ "type-annotation-spacing": "error", // This is a formatting rule
289
+ "typedef": [
290
+ "error",
291
+ {
292
+ "arrayDestructuring": false,
293
+ "arrowParameter": false,
294
+ "memberVariableDeclaration": true,
295
+ "objectDestructuring": false,
296
+ "parameter": true,
297
+ "propertyDeclaration": true,
298
+ "variableDeclaration": false
299
+ }
300
+ ],
301
+ "unbound-method": "error",
302
+ "unified-signatures": "off",
303
+ };
304
+
305
+ // Rules - append "@typescript-eslint/" to rule names
306
+ module.exports.typescriptEslintRules = Object.entries(rules).reduce((aggr, [key, value]) => ({
307
+ ...aggr,
308
+ [`@typescript-eslint/${key}`]: value
309
+ }), {});