@josundt/eslint-config 4.3.3 → 4.6.1

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/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@josundt/eslint-config",
3
- "version": "4.3.3",
3
+ "version": "4.6.1",
4
4
  "description": "ESLint ruleset with required plugins for josundt TypeScript projects",
5
- "main": ".eslintrc.js",
5
+ "main": "index.js",
6
6
  "scripts": {
7
7
  "lint": "echo \"No linting for this project\"",
8
8
  "build": "echo \"No build for this project\"",
@@ -26,17 +26,17 @@
26
26
  "rules/**/*.js"
27
27
  ],
28
28
  "peerDependencies": {
29
- "typescript": ">=4.3.2"
29
+ "typescript": ">=4.6.2"
30
30
  },
31
31
  "dependencies": {
32
- "@typescript-eslint/eslint-plugin": "4.25.0",
33
- "@typescript-eslint/parser": "4.25.0",
34
- "eslint": "7.27.0",
35
- "eslint-import-resolver-typescript": "2.4.0",
36
- "eslint-plugin-deprecation": "1.2.1",
37
- "eslint-plugin-import": "2.23.3",
38
- "eslint-plugin-jasmine": "4.1.2",
39
- "eslint-plugin-jsdoc": "35.0.0",
40
- "eslint-plugin-unicorn": "32.0.1"
32
+ "@typescript-eslint/eslint-plugin": "5.14.0",
33
+ "@typescript-eslint/parser": "5.14.0",
34
+ "eslint": "8.10.0",
35
+ "eslint-import-resolver-typescript": "2.5.0",
36
+ "eslint-plugin-deprecation": "1.3.2",
37
+ "eslint-plugin-import": "2.25.4",
38
+ "eslint-plugin-jasmine": "4.1.3",
39
+ "eslint-plugin-jsdoc": "37.9.7",
40
+ "eslint-plugin-unicorn": "41.0.0"
41
41
  }
42
42
  }
package/rules/eslint.js CHANGED
@@ -61,7 +61,7 @@ module.exports = {
61
61
  ],
62
62
  "guard-for-in": "error",
63
63
  "handle-callback-err": "error",
64
- "id-blacklist": [
64
+ "id-denylist": [
65
65
  "error",
66
66
  "any",
67
67
  "Number",
@@ -86,7 +86,14 @@ module.exports = {
86
86
  "FunctionExpression": {
87
87
  "parameters": "first"
88
88
  },
89
- "SwitchCase": 1
89
+ "SwitchCase": 1,
90
+
91
+ // Fix to decorator indentation problem
92
+ "ignoredNodes": [
93
+ "FunctionExpression > .params[decorators.length > 0]",
94
+ "FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
95
+ "ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
96
+ ]
90
97
  }
91
98
  ],
92
99
  "init-declarations": "off",
@@ -236,12 +243,17 @@ module.exports = {
236
243
  "never"
237
244
  ],
238
245
  "padding-line-between-statements": [
239
- "off",
240
- {
241
- "blankLine": "always",
242
- "prev": "*",
243
- "next": "return"
244
- }
246
+ "error",
247
+ { "blankLine": "always", "prev": ["directive", "import"], "next": "*" },
248
+ { "blankLine": "any", "prev": ["directive", "import"], "next": ["directive", "import"] },
249
+
250
+ { "blankLine": "always", "prev": "*", "next": ["export", "class", "function", "iife"] },
251
+ { "blankLine": "always", "prev": ["export", "class", "function", "iife"], "next": "*" },
252
+
253
+ // { "blankLine": "always", "prev": "*", "next": "return" }, // Newline before return
254
+
255
+ // { "blankLine": "always", "prev": "*", "next": "multiline-block-like" }, // Newline BEFORE multiline block
256
+ // { "blankLine": "always", "prev": "multiline-block-like", "next": "*" } // Newline AFTER multiline block
245
257
  ],
246
258
  "prefer-arrow-callback": "error",
247
259
  "prefer-const": "error",
@@ -262,8 +274,12 @@ module.exports = {
262
274
  "error",
263
275
  "always"
264
276
  ],
277
+ "space-before-blocks": [
278
+ "error",
279
+ "always"
280
+ ],
265
281
  "space-before-function-paren": [
266
- "warn",
282
+ "error",
267
283
  {
268
284
  "anonymous": "always",
269
285
  "asyncArrow": "always",
@@ -2,8 +2,13 @@ const eslintRuleSet = require("./eslint");
2
2
  const eslintRules = eslintRuleSet.rules;
3
3
 
4
4
  // Map of all the typescript-eslint extensions.
5
- // If extension rule has additional properties compared to standard eslint rule,
6
- // the value of the map item has an object that will be merged with standard rule; otherwise null.
5
+ // If extension rule has additional properties compared to standard eslint rule:
6
+ // If the map value is an object:
7
+ // The object will be merged merged with standard rule (rule object 1);
8
+ // If the map value is an array:
9
+ // The items of the array will be added as a new rule options object.
10
+ // If the map value is a function:
11
+ // The standard eslint options object will be passed as parameters, the return statement will be added as options.
7
12
  const extensions = new Map([
8
13
  ["brace-style", null],
9
14
  ["comma-dangle", null],
@@ -31,19 +36,29 @@ const extensions = new Map([
31
36
  ["no-loop-func", null],
32
37
  ["no-loss-of-precision", null],
33
38
  ["no-magic-numbers", null],
34
- ["no-shadow", {
35
- "ignoreTypeValueShadow": true,
36
- "ignoreFunctionTypeParameterNameValueShadow": true
39
+ ["no-shadow", v => {
40
+ const o = {
41
+ ...v,
42
+ "ignoreTypeValueShadow": true,
43
+ "ignoreFunctionTypeParameterNameValueShadow": true
44
+ };
45
+ delete o["ignoreOnInitialization"]; // Temporary bug in @typescript/eslint "no-shadow" extension rule - "ignoreOnInitialization" property considered invalid
46
+ return o;
37
47
  }],
38
48
  ["no-unused-expressions", null],
39
49
  ["no-unused-vars", null],
40
50
  ["no-use-before-define", null],
41
51
  ["no-useless-constructor", null],
42
52
  ["object-curly-spacing", null],
53
+ ["padding-line-between-statements", [
54
+ { "blankLine": "always", "prev": "*", "next": ["interface", "type"] },
55
+ { "blankLine": "always", "prev": ["interface", "type"], "next": "*" }
56
+ ]],
43
57
  ["quotes", null],
44
58
  ["require-await", null],
45
59
  ["return-await", null],
46
60
  ["semi", null],
61
+ ["space-before-blocks", null],
47
62
  ["space-before-function-paren", null],
48
63
  ["space-infix-ops", null]
49
64
  ]);
@@ -74,7 +89,13 @@ const extendedEslintRules = Object.entries(eslintRules).reduce((extRules, [key,
74
89
  // If extension rule has extended options, merge with standard eslint rule options:
75
90
  if (extension !== null) {
76
91
  value = [...value];
77
- value[value.length - 1] = { ...value[value.length - 1], ...extension }
92
+ if (Array.isArray(extension)) {
93
+ value.push(...extension);
94
+ } else if (typeof extension === "object") {
95
+ value[value.length - 1] = { ...value[value.length - 1], ...extension }
96
+ } else if (typeof extension === "function") {
97
+ value[value.length - 1] = { ...extension(value[value.length - 1]) };
98
+ }
78
99
  }
79
100
  // Add extension rule value with the @typescript-eslint key prefix
80
101
  extRules[`@typescript-eslint/${key}`] = value;
@@ -132,6 +153,7 @@ module.exports = {
132
153
  "error",
133
154
  "interface"
134
155
  ],
156
+ "@typescript-eslint/consistent-type-exports": "error",
135
157
  "@typescript-eslint/consistent-type-imports": [
136
158
  "off",
137
159
  {
@@ -145,7 +167,8 @@ module.exports = {
145
167
  "allowExpressions": true,
146
168
  "allowTypedFunctionExpressions": true,
147
169
  "allowHigherOrderFunctions": true,
148
- "allowConciseArrowFunctionExpressionsStartingWithVoid": true
170
+ "allowConciseArrowFunctionExpressionsStartingWithVoid": true,
171
+ "allowedNames": []
149
172
  }
150
173
  ],
151
174
  "@typescript-eslint/explicit-member-accessibility": [
@@ -159,9 +182,9 @@ module.exports = {
159
182
  {
160
183
  "allowArgumentsExplicitlyTypedAsAny": false,
161
184
  "allowDirectConstAssertionInArrowFunctions": true,
162
- "allowedNames": [],
163
185
  "allowHigherOrderFunctions": true,
164
186
  "allowTypedFunctionExpressions": true,
187
+ "allowedNames": []
165
188
  }
166
189
  ],
167
190
  "@typescript-eslint/member-delimiter-style": [
@@ -249,9 +272,23 @@ module.exports = {
249
272
  "allowAsThisParameter": true
250
273
  }
251
274
  ],
275
+ "@typescript-eslint/no-meaningless-void-operator": "error",
252
276
  "@typescript-eslint/no-misused-new": "error",
253
- "@typescript-eslint/no-misused-promises": "error",
277
+ "@typescript-eslint/no-misused-promises": [
278
+ "error",
279
+ {
280
+ checksConditionals: true,
281
+ checksVoidReturn: true // {
282
+ // arguments: true, //Disables checking an asynchronous function passed as argument where the parameter type expects a function that returns void
283
+ // attributes: true, //Disables checking an asynchronous function passed as a JSX attribute expected to be a function that returns void
284
+ // properties: true, //Disables checking an asynchronous function passed as an object property expected to be a function that returns void
285
+ // returns: true, //Disables checking an asynchronous function returned in a function whose return type is a function that returns void
286
+ // variables: true //Disables checking an asynchronous function used as a variable whose return type is a function that returns void
287
+ // }
288
+ }
289
+ ],
254
290
  "@typescript-eslint/no-namespace": "off",
291
+ "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
255
292
  "@typescript-eslint/no-non-null-asserted-optional-chain": "error",
256
293
  "@typescript-eslint/no-non-null-assertion": "off",
257
294
  "@typescript-eslint/no-parameter-properties": [
@@ -260,9 +297,16 @@ module.exports = {
260
297
  "allows": ["private readonly", "private", "protected readonly"]
261
298
  }
262
299
  ],
300
+ "@typescript-eslint/no-redundant-type-constituents": "error",
263
301
  "@typescript-eslint/no-require-imports": "error",
264
302
  "@typescript-eslint/no-this-alias": "error",
265
- "@typescript-eslint/no-throw-literal": "error",
303
+ "@typescript-eslint/no-throw-literal": [
304
+ "error",
305
+ {
306
+ "allowThrowingAny": false, // Default is to allow throwing values of type any
307
+ "allowThrowingUnknown": true // Default is to allow throwing values of type unknown
308
+ }
309
+ ],
266
310
  "@typescript-eslint/no-type-alias": "off",
267
311
  "@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
268
312
  "@typescript-eslint/no-unnecessary-condition": "off", // allow runtime null checks etc even if reported not necessary by type system
@@ -276,6 +320,7 @@ module.exports = {
276
320
  "@typescript-eslint/no-unsafe-member-access": "error",
277
321
  "@typescript-eslint/no-unsafe-return": "error",
278
322
  "@typescript-eslint/no-unused-vars-experimental": "off", // to strict with method params...
323
+ "@typescript-eslint/no-useless-empty-export": "error",
279
324
  "@typescript-eslint/no-var-requires": "error",
280
325
  "@typescript-eslint/non-nullable-type-assertion-style": "error",
281
326
  "@typescript-eslint/prefer-as-const": "error",
@@ -291,6 +336,7 @@ module.exports = {
291
336
  "@typescript-eslint/prefer-readonly-parameter-types": "off", // Could be useful but requires too much work and verbose notation
292
337
  "@typescript-eslint/prefer-reduce-type-parameter": "error",
293
338
  "@typescript-eslint/prefer-regexp-exec": "error",
339
+ "@typescript-eslint/prefer-return-this-type": "error",
294
340
  "@typescript-eslint/prefer-string-starts-ends-with": "error",
295
341
  "@typescript-eslint/prefer-ts-expect-error": "error",
296
342
  "@typescript-eslint/promise-function-async": "off",
@@ -298,10 +344,20 @@ module.exports = {
298
344
  "@typescript-eslint/restrict-plus-operands": [
299
345
  "error",
300
346
  {
301
- "checkCompoundAssignments": true
347
+ "checkCompoundAssignments": true,
348
+ "allowAny": false
349
+ }
350
+ ],
351
+ "@typescript-eslint/restrict-template-expressions": [
352
+ "error",
353
+ {
354
+ "allowNumber": true,
355
+ "allowBoolean": false,
356
+ "allowAny": false,
357
+ "allowNullish": false,
358
+ "allowRegExp": false
302
359
  }
303
360
  ],
304
- "@typescript-eslint/restrict-template-expressions": "error",
305
361
  "@typescript-eslint/sort-type-union-intersection-members": "off",
306
362
  "@typescript-eslint/strict-boolean-expressions": [
307
363
  "off",