@josundt/eslint-config 4.9.7 → 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.
@@ -1,129 +1,5 @@
1
- const eslintRuleSet = require("./eslint.js");
2
- const { deepMergeObjects } = require("../utils/merge.js");
3
-
4
- const eslintRules = eslintRuleSet.rules;
5
-
6
- // Map of all the typescript-eslint extensions.
7
- // If extension rule has additional properties compared to standard eslint rule:
8
- // If the map value is an object:
9
- // The object will be merged merged with standard rule (rule object 1);
10
- // If the map value is an array:
11
- // The items of the array will be added as a new rule options object.
12
- // If the map value is a function:
13
- // The standard eslint options object will be passed as parameters, the return statement will be added as options.
14
- const extensions = new Map([
15
- ["brace-style", null],
16
- ["comma-dangle", null],
17
- ["comma-spacing", null],
18
- ["default-param-last", null],
19
- ["dot-notation", {
20
- "allowPrivateClassPropertyAccess": false,
21
- "allowProtectedClassPropertyAccess": false,
22
- "allowIndexSignaturePropertyAccess": false
23
- }],
24
- ["func-call-spacing", null],
25
- ["indent", null],
26
- ["init-declarations", null],
27
- ["keyword-spacing", null],
28
- ["lines-between-class-members", {
29
- "exceptAfterOverload": true
30
- }],
31
- ["no-array-constructor", null],
32
- ["no-dupe-class-members", null],
33
- ["no-empty-function", {
34
- allow: ["private-constructors", "protected-constructors" /* "decoratedFunctions", "overrideMethods" */ ]
35
- }],
36
- ["no-extra-parens", null],
37
- ["no-extra-semi", null],
38
- ["no-invalid-this", null],
39
- ["no-loop-func", null],
40
- ["no-loss-of-precision", null],
41
- ["no-magic-numbers", null],
42
- ["no-shadow", v => {
43
- const o = {
44
- ...v,
45
- "ignoreTypeValueShadow": true,
46
- "ignoreFunctionTypeParameterNameValueShadow": true
47
- };
48
- delete o["ignoreOnInitialization"]; // Temporary bug in @typescript/eslint "no-shadow" extension rule - "ignoreOnInitialization" property considered invalid
49
- return o;
50
- }],
51
- ["no-unused-expressions", null],
52
- ["no-unused-vars", null],
53
- ["no-use-before-define", null],
54
- ["no-useless-constructor", null],
55
- ["object-curly-spacing", null],
56
- ["padding-line-between-statements", [
57
- { "blankLine": "always", "prev": "*", "next": ["interface", "type"] },
58
- { "blankLine": "always", "prev": ["interface", "type"], "next": "*" }
59
- ]],
60
- ["quotes", null],
61
- ["require-await", null],
62
- ["return-await", null],
63
- ["semi", null],
64
- ["space-before-blocks", null],
65
- ["space-before-function-paren", null],
66
- // ["space-infix-ops", null] // buggy with typescript (as of 5.27.0) -- switched off below
67
- ]);
68
-
69
- switchOffExtensions = new Set([
70
- "no-unused-vars",
71
- "no-invalid-this",
72
- "no-use-before-define",
73
- "no-useless-constructor",
74
- "space-infix-ops"
75
- ]);
76
-
77
-
78
- // Building eslint-typescript rules for existsing eslint rules and switching off original eslint rule
79
- const extendedEslintRules = Object.entries(eslintRules).reduce((extRules, [key, value]) => {
80
-
81
- // Try to get from known extensions map
82
- const extension = extensions.get(key);
83
-
84
- // If found in known typescript eslint extension rules map
85
- if (extension !== undefined) {
86
-
87
- // Switch off standard eslint rule
88
- extRules[key] = "off";
89
-
90
- // Special handling of certain extension rules that need to be switched off:
91
- if (switchOffExtensions.has(key)) {
92
- extRules[`@typescript-eslint/${key}`] = "off";
93
- } else {
94
- // If extension rule has extended options, merge with standard eslint rule options:
95
- if (extension !== null) {
96
- // Ensure value is array if only severity string:
97
- value = Array.isArray(value) ? [...value] : [value];
98
- if (Array.isArray(extension)) {
99
- value.push(...extension);
100
- } else if (typeof extension === "object") {
101
- // If array only contains severity string, push object
102
- if (value.length === 1) {
103
- value.push(extension);
104
- // Else merge object
105
- } else {
106
- value[value.length - 1] = deepMergeObjects(value[value.length - 1], extension);
107
- }
108
- } else if (typeof extension === "function") {
109
- const [, ...options] = value;
110
- value[value.length - 1] = { ...extension(...options) };
111
- }
112
- }
113
- // Add extension rule value with the @typescript-eslint key prefix
114
- extRules[`@typescript-eslint/${key}`] = value;
115
- }
116
-
117
-
118
- }
119
- // else: if no extension rule exists, the standard eslint rule will be used through the "extends" configuration below
120
-
121
- return extRules;
122
- }, {});
123
-
124
- // console.log(extensionRules);
125
- // console.log(`Converted ${Object.keys(extensionRules).filter(k => !k.startsWith("@typescript")).length} of ${extensions.size} available extension rules`);
126
- // console.log("Not converted:", Array.from(extensions.keys()).filter(k => !Object.keys(extensionRules).filter(k => !k.startsWith("@typescript")).includes(k)));
1
+ const { typescriptEslintRules } = require("./typescript-eslint/rules.js");
2
+ const { typescriptEslintExtensionrules } = require("./typescript-eslint/extensionrules.js");
127
3
 
128
4
  module.exports = {
129
5
  "extends": [
@@ -135,294 +11,7 @@ module.exports = {
135
11
  "@typescript-eslint/eslint-plugin"
136
12
  ],
137
13
  "rules": {
138
-
139
- /* Disabling certain eslint rules: */
140
-
141
- "camelCase": "off",
142
-
143
- /* Main @typescript-eslint rules */
144
-
145
- "@typescript-eslint/adjacent-overload-signatures": "error",
146
- "@typescript-eslint/array-type": [
147
- "error",
148
- {
149
- "default": "array-simple",
150
- "readonly": "array-simple"
151
- }
152
- ],
153
- "@typescript-eslint/await-thenable": "error",
154
- "@typescript-eslint/ban-ts-comment": [
155
- "error",
156
- {
157
- "ts-expect-error": "allow-with-description",
158
- "ts-ignore": true,
159
- "ts-nocheck": true,
160
- "ts-check": false,
161
- "minimumDescriptionLength": 10,
162
- //"descriptionFormat": "someformathere"
163
- }
164
- ],
165
- "@typescript-eslint/ban-tslint-comment": "error", // No longer use tslint - remove rules
166
- "@typescript-eslint/ban-types": "off", // Can be used to ban certain types
167
- "@typescript-eslint/consistent-generic-constructors": ["off", "constructor"],
168
- "@typescript-eslint/consistent-indexed-object-style": ["error", "record"],
169
- "@typescript-eslint/consistent-type-assertions": [
170
- "error",
171
- {
172
- "assertionStyle": "as",
173
- "objectLiteralTypeAssertions": "allow"
174
- }
175
- ],
176
- "@typescript-eslint/consistent-type-definitions": [
177
- "error",
178
- "interface"
179
- ],
180
- "@typescript-eslint/consistent-type-exports": "error",
181
- "@typescript-eslint/consistent-type-imports": [
182
- "off",
183
- {
184
- "prefer": "type-imports",
185
- "disallowTypeAnnotations": true
186
- }
187
- ],
188
- "@typescript-eslint/explicit-function-return-type": [
189
- "error",
190
- {
191
- "allowExpressions": true,
192
- "allowTypedFunctionExpressions": true,
193
- "allowHigherOrderFunctions": true,
194
- "allowConciseArrowFunctionExpressionsStartingWithVoid": true,
195
- "allowedNames": []
196
- }
197
- ],
198
- "@typescript-eslint/explicit-member-accessibility": [
199
- "error",
200
- {
201
- "accessibility": "no-public"
202
- }
203
- ],
204
- "@typescript-eslint/explicit-module-boundary-types": [ // same as "recommended" except error instead of warning
205
- "error",
206
- {
207
- "allowArgumentsExplicitlyTypedAsAny": false,
208
- "allowDirectConstAssertionInArrowFunctions": true,
209
- "allowHigherOrderFunctions": true,
210
- "allowTypedFunctionExpressions": true,
211
- "allowedNames": []
212
- }
213
- ],
214
- "@typescript-eslint/member-delimiter-style": [
215
- "error",
216
- {
217
- "multiline": {
218
- "delimiter": "semi",
219
- "requireLast": true
220
- },
221
- "singleline": {
222
- "delimiter": "semi",
223
- "requireLast": true
224
- }
225
- }
226
- ],
227
- "@typescript-eslint/member-ordering": "off",
228
- "@typescript-eslint/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
229
- "@typescript-eslint/naming-convention": [
230
- "error",
231
- {
232
- "selector": "default",
233
- "format": [
234
- "camelCase"
235
- ],
236
- "leadingUnderscore": "forbid",
237
- "trailingUnderscore": "forbid"
238
- },
239
- {
240
- "selector": "typeLike",
241
- "format": [
242
- "PascalCase"
243
- ]
244
- },
245
- {
246
- "selector": "method",
247
- "modifiers": [
248
- "private"
249
- ],
250
- "format": [
251
- "camelCase"
252
- ],
253
- "leadingUnderscore": "allow",
254
- "trailingUnderscore": "forbid"
255
- },
256
- {
257
- "selector": "property",
258
- "modifiers": [
259
- "private"
260
- ],
261
- "format": [
262
- "camelCase"
263
- ],
264
- "leadingUnderscore": "allow",
265
- "trailingUnderscore": "forbid"
266
- },
267
- {
268
- "selector": "enumMember",
269
- "format": [
270
- "camelCase",
271
- "PascalCase"
272
- ]
273
- }
274
- ],
275
- "@typescript-eslint/no-base-to-string": "error",
276
- "@typescript-eslint/no-confusing-non-null-assertion": "error",
277
- "@typescript-eslint/no-confusing-void-expression": [
278
- "error",
279
- {
280
- "ignoreArrowShorthand": true
281
- }
282
- ],
283
- "@typescript-eslint/no-duplicate-enum-values": "error",
284
- "@typescript-eslint/no-dynamic-delete": "error",
285
- "@typescript-eslint/no-empty-interface": "off",
286
- "@typescript-eslint/no-explicit-any": "off",
287
- "@typescript-eslint/no-extra-non-null-assertion": "error",
288
- "@typescript-eslint/no-extraneous-class": "error",
289
- "@typescript-eslint/no-floating-promises": "error", // Must be switched on to prevent promises not awaited
290
- "@typescript-eslint/no-for-in-array": "error",
291
- "@typescript-eslint/no-implied-eval": "error",
292
- "@typescript-eslint/no-inferrable-types": "off",
293
- "@typescript-eslint/no-invalid-void-type": [
294
- "error",
295
- {
296
- "allowInGenericTypeArguments": true,
297
- "allowAsThisParameter": true
298
- }
299
- ],
300
- "@typescript-eslint/no-meaningless-void-operator": "error",
301
- "@typescript-eslint/no-misused-new": "error",
302
- "@typescript-eslint/no-misused-promises": [
303
- "error",
304
- {
305
- checksConditionals: true,
306
- checksSpreads: true,
307
- checksVoidReturn: true // {
308
- // arguments: true, //Disables checking an asynchronous function passed as argument where the parameter type expects a function that returns void
309
- // attributes: true, //Disables checking an asynchronous function passed as a JSX attribute expected to be a function that returns void
310
- // properties: true, //Disables checking an asynchronous function passed as an object property expected to be a function that returns void
311
- // returns: true, //Disables checking an asynchronous function returned in a function whose return type is a function that returns void
312
- // variables: true //Disables checking an asynchronous function used as a variable whose return type is a function that returns void
313
- // }
314
- }
315
- ],
316
- "@typescript-eslint/no-namespace": "off",
317
- "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
318
- "@typescript-eslint/no-non-null-asserted-optional-chain": "error",
319
- "@typescript-eslint/no-non-null-assertion": "off",
320
- "@typescript-eslint/no-redundant-type-constituents": "error",
321
- "@typescript-eslint/no-require-imports": "error",
322
- "@typescript-eslint/no-this-alias": "error",
323
- "@typescript-eslint/no-throw-literal": [
324
- "error",
325
- {
326
- "allowThrowingAny": false, // Default is to allow throwing values of type any
327
- "allowThrowingUnknown": true // Default is to allow throwing values of type unknown
328
- }
329
- ],
330
- "@typescript-eslint/no-type-alias": "off",
331
- "@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
332
- "@typescript-eslint/no-unnecessary-condition": "off", // allow runtime null checks etc even if reported not necessary by type system
333
- "@typescript-eslint/no-unnecessary-qualifier": "error",
334
- "@typescript-eslint/no-unnecessary-type-arguments": "off",
335
- "@typescript-eslint/no-unnecessary-type-assertion": "off",
336
- "@typescript-eslint/no-unnecessary-type-constraint": "error",
337
- "@typescript-eslint/no-unsafe-argument": "error",
338
- "@typescript-eslint/no-unsafe-assignment": "error",
339
- "@typescript-eslint/no-unsafe-call": "error",
340
- "@typescript-eslint/no-unsafe-member-access": "error",
341
- "@typescript-eslint/no-unsafe-return": "error",
342
- "@typescript-eslint/no-unused-vars-experimental": "off", // to strict with method params...
343
- "@typescript-eslint/no-useless-empty-export": "error",
344
- "@typescript-eslint/no-var-requires": "error",
345
- "@typescript-eslint/non-nullable-type-assertion-style": "error",
346
- "@typescript-eslint/parameter-properties": [
347
- "error",
348
- {
349
- "prefer": "class-property", // or "parameter-property"
350
- "allow": ["private readonly", "private", "protected readonly"]
351
- }
352
- ],
353
- "@typescript-eslint/prefer-as-const": "off",
354
- "@typescript-eslint/prefer-enum-initializers": "error",
355
- "@typescript-eslint/prefer-for-of": "error",
356
- "@typescript-eslint/prefer-function-type": "error",
357
- "@typescript-eslint/prefer-includes": "error",
358
- "@typescript-eslint/prefer-literal-enum-member": "error",
359
- "@typescript-eslint/prefer-namespace-keyword": "error",
360
- "@typescript-eslint/prefer-nullish-coalescing": [
361
- "error",
362
- {
363
- "ignoreConditionalTests": true,
364
- "ignoreTernaryTests": true,
365
- "ignoreMixedLogicalExpressions": true
366
- }
367
- ],
368
- "@typescript-eslint/prefer-optional-chain": "error",
369
- "@typescript-eslint/prefer-readonly": "error",
370
- "@typescript-eslint/prefer-readonly-parameter-types": "off", // Could be useful but requires too much work and verbose notation
371
- "@typescript-eslint/prefer-reduce-type-parameter": "error",
372
- "@typescript-eslint/prefer-regexp-exec": "error",
373
- "@typescript-eslint/prefer-return-this-type": "error",
374
- "@typescript-eslint/prefer-string-starts-ends-with": "error",
375
- "@typescript-eslint/prefer-ts-expect-error": "error",
376
- "@typescript-eslint/promise-function-async": "off",
377
- "@typescript-eslint/require-array-sort-compare": "error",
378
- "@typescript-eslint/restrict-plus-operands": [
379
- "error",
380
- {
381
- "checkCompoundAssignments": true,
382
- "allowAny": false
383
- }
384
- ],
385
- "@typescript-eslint/restrict-template-expressions": [
386
- "error",
387
- {
388
- "allowNumber": true,
389
- "allowBoolean": false,
390
- "allowAny": false,
391
- "allowNullish": false,
392
- "allowRegExp": false
393
- }
394
- ],
395
- "@typescript-eslint/sort-type-union-intersection-members": "off",
396
- "@typescript-eslint/strict-boolean-expressions": [
397
- "off",
398
- {
399
- "allowString": true,
400
- "allowNumber": true,
401
- "allowNullableObject": true,
402
- "allowNullableString": true,
403
- "allowNullableNumber": true,
404
- "allowNullableBoolean": true,
405
- "allowAny": false
406
- }
407
- ],
408
- "@typescript-eslint/switch-exhaustiveness-check": "error",
409
- "@typescript-eslint/triple-slash-reference": "error",
410
- "@typescript-eslint/type-annotation-spacing": "error",
411
- "@typescript-eslint/typedef": [
412
- "error",
413
- {
414
- "arrayDestructuring": false,
415
- "arrowParameter": false,
416
- "memberVariableDeclaration": true,
417
- "objectDestructuring": false,
418
- "parameter": true,
419
- "propertyDeclaration": true,
420
- "variableDeclaration": false
421
- }
422
- ],
423
- "@typescript-eslint/unbound-method": "error",
424
- "@typescript-eslint/unified-signatures": "off",
425
-
426
- ...extendedEslintRules
14
+ ...typescriptEslintRules,
15
+ ...typescriptEslintExtensionrules
427
16
  }
428
17
  };
@@ -1,9 +1,13 @@
1
1
  module.exports = {
2
2
  "env": {
3
- "es6": true
3
+ "node": true,
4
+ "es6": true,
5
+ "jest": true,
6
+ "jasmine": true
4
7
  },
5
8
  "parser": "@typescript-eslint/parser",
6
9
  "parserOptions": {
10
+ "ecmaVersion": 2021,
7
11
  "project": "tsconfig.json",
8
12
  "sourceType": "module"
9
13
  },
@@ -11,7 +15,7 @@ module.exports = {
11
15
  "./rules/deprecation.js",
12
16
  // "./rules/eslint.js", -> commented out since "typescript-eslint" rules inherit from this
13
17
  "./rules/eslint-comments.js",
14
- "./rules/import-typescript.js",
18
+ "./rules/import-typescript-node.js",
15
19
  "./rules/jsdoc-typescript.js",
16
20
  "./rules/typescript-eslint.js",
17
21
  "./rules/unicorn.js",
@@ -1,9 +1,11 @@
1
1
  module.exports = {
2
2
  "env": {
3
+ "node": true,
3
4
  "es6": true
4
5
  },
5
6
  "parser": "@typescript-eslint/parser",
6
7
  "parserOptions": {
8
+ "ecmaVersion": 2021,
7
9
  "project": "tsconfig.json",
8
10
  "sourceType": "module"
9
11
  },
@@ -11,7 +13,7 @@ module.exports = {
11
13
  "./rules/deprecation.js",
12
14
  // "./rules/eslint.js", -> commented out since "typescript-eslint" rules inherit from this
13
15
  "./rules/eslint-comments.js",
14
- "./rules/import-typescript.js",
16
+ "./rules/import-typescript-node.js",
15
17
  "./rules/jsdoc-typescript.js",
16
18
  "./rules/typescript-eslint.js",
17
19
  "./rules/unicorn.js",
@@ -1,10 +1,13 @@
1
1
  module.exports = {
2
2
  "env": {
3
3
  "browser": true,
4
- "es6": true
4
+ "es6": true,
5
+ "jest": true,
6
+ "jasmine": true
5
7
  },
6
8
  "parser": "@typescript-eslint/parser",
7
9
  "parserOptions": {
10
+ "ecmaVersion": 2019,
8
11
  "project": "tsconfig.json",
9
12
  "sourceType": "module"
10
13
  },
@@ -12,8 +15,9 @@ module.exports = {
12
15
  "./rules/deprecation.js",
13
16
  // "./rules/eslint.js", -> commented out since "typescript-eslint" rules inherit from this
14
17
  "./rules/eslint-comments.js",
15
- "./rules/import-typescript.js",
18
+ "./rules/import-typescript-web.js",
16
19
  "./rules/jsdoc-typescript.js",
20
+ "./rules/no-lookahead-lookbehind-regexp.js",
17
21
  "./rules/typescript-eslint.js",
18
22
  "./rules/unicorn.js",
19
23
  ].map(require.resolve),
package/typescript-web.js CHANGED
@@ -5,6 +5,7 @@ module.exports = {
5
5
  },
6
6
  "parser": "@typescript-eslint/parser",
7
7
  "parserOptions": {
8
+ "ecmaVersion": 2019,
8
9
  "project": "tsconfig.json",
9
10
  "sourceType": "module"
10
11
  },
@@ -12,8 +13,9 @@ module.exports = {
12
13
  "./rules/deprecation.js",
13
14
  // "./rules/eslint.js", -> commented out since "typescript-eslint" rules inherit from this
14
15
  "./rules/eslint-comments.js",
15
- "./rules/import-typescript.js",
16
+ "./rules/import-typescript-web.js",
16
17
  "./rules/jsdoc-typescript.js",
18
+ "./rules/no-lookahead-lookbehind-regexp.js",
17
19
  "./rules/typescript-eslint.js",
18
20
  "./rules/unicorn.js"
19
21
  ].map(require.resolve),
@@ -1,85 +0,0 @@
1
- // module.exports = {
2
- // "plugins": [
3
- // "@typescript-eslint/tslint",
4
- // ],
5
- // "rules": {
6
- // "@typescript-eslint/tslint/config": [
7
- // "error",
8
- // {
9
- // "rules": {
10
- // "ban": [
11
- // true,
12
- // "I18N"
13
- // ],
14
- // "insecure-random": true, // https://github.com/j-f1/eslint-plugin-desktop/blob/master/docs/rules/no-insecure-random.md
15
- // "max-func-body-length": [
16
- // true,
17
- // 1000,
18
- // {
19
- // "ignore-parameters-to-function-regex": "describe"
20
- // }
21
- // ],
22
- // "mocha-avoid-only": true,
23
- // "mocha-no-side-effect-code": true,
24
- // "mocha-unneeded-done": true,
25
- // "no-cookies": true,
26
- // "no-delete-expression": true,
27
- // "no-disable-auto-sanitization": true,
28
- // "no-document-domain": true,
29
- // "no-document-write": true,
30
- // "no-exec-script": true,
31
- // "no-http-string": [
32
- // true,
33
- // "http://www.example.com/?.*",
34
- // "http://www.examples.com/?.*"
35
- // ],
36
- // "no-inferred-empty-object-type": true,
37
- // "no-inner-html": true,
38
- // "no-jquery-raw-elements": true,
39
- // "no-mergeable-namespace": true,
40
- // "no-reference-import": true,
41
- // "no-string-based-set-immediate": true,
42
- // "no-string-based-set-interval": true,
43
- // "no-string-based-set-timeout": true,
44
- // "no-typeof-undefined": true,
45
- // "no-unnecessary-callback-wrapper": true, // keep
46
- // "no-unsupported-browser-code": true,
47
- // "no-with-statement": true,
48
- // "number-literal-format": true,
49
- // "possible-timing-attack": true,
50
- // "prefer-method-signature": true,
51
- // "prefer-switch": [
52
- // true,
53
- // {
54
- // "min-cases": 3
55
- // }
56
- // ],
57
- // "promise-must-complete": true,
58
- // "return-undefined": true,
59
- // "switch-final-break": [
60
- // true,
61
- // "always"
62
- // ],
63
- // "typedef": [
64
- // true,
65
- // "call-signature",
66
- // "parameter",
67
- // "property-declaration",
68
- // "member-variable-declaration"
69
- // ],
70
- // "use-named-parameter": true,
71
- // "whitespace": [
72
- // true,
73
- // "check-branch",
74
- // "check-decl",
75
- // "check-operator",
76
- // "check-module",
77
- // "check-separator",
78
- // "check-type",
79
- // "check-preblock"
80
- // ]
81
- // }
82
- // }
83
- // ]
84
- // }
85
- // };