@josundt/eslint-config 5.2.2 → 5.3.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,6 +1,6 @@
1
1
  {
2
2
  "name": "@josundt/eslint-config",
3
- "version": "5.2.2",
3
+ "version": "5.3.1",
4
4
  "description": "ESLint ruleset with required plugins for josundt TypeScript projects",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -27,22 +27,22 @@
27
27
  "utils/**/*.js"
28
28
  ],
29
29
  "peerDependencies": {
30
- "typescript": ">=5.0.4"
30
+ "typescript": ">=5.3.2"
31
31
  },
32
32
  "dependencies": {
33
- "@josundt/prettier-config": "^1.0.0",
34
- "@typescript-eslint/eslint-plugin": "5.59.5",
35
- "@typescript-eslint/parser": "5.59.5",
36
- "eslint": "8.40.0",
37
- "eslint-import-resolver-typescript": "3.5.5",
38
- "eslint-plugin-deprecation": "1.4.1",
33
+ "@josundt/prettier-config": "^3.1.0",
34
+ "@typescript-eslint/eslint-plugin": "6.13.1",
35
+ "@typescript-eslint/parser": "6.13.1",
36
+ "eslint": "8.54.0",
37
+ "eslint-import-resolver-typescript": "3.6.1",
38
+ "eslint-plugin-deprecation": "2.0.0",
39
39
  "eslint-plugin-eslint-comments": "3.2.0",
40
- "eslint-plugin-import": "2.27.5",
40
+ "eslint-plugin-import": "2.29.0",
41
41
  "eslint-plugin-jasmine": "4.1.3",
42
- "eslint-plugin-jest": "27.2.1",
43
- "eslint-plugin-jsdoc": "44.0.2",
44
- "eslint-plugin-no-lookahead-lookbehind-regexp": "0.1.0",
45
- "eslint-plugin-prettier": "4.2.1",
46
- "eslint-plugin-unicorn": "47.0.0"
42
+ "eslint-plugin-jest": "27.6.0",
43
+ "eslint-plugin-jsdoc": "46.9.0",
44
+ "eslint-plugin-no-lookahead-lookbehind-regexp": "0.3.0",
45
+ "eslint-plugin-prettier": "5.0.1",
46
+ "eslint-plugin-unicorn": "49.0.0"
47
47
  }
48
48
  }
package/rules/eslint.js CHANGED
@@ -3,7 +3,7 @@ module.exports = {
3
3
  rules: {
4
4
  "arrow-body-style": "error",
5
5
  "arrow-parens": ["error", "as-needed"],
6
- "class-methods-use-this": "off", // Warn when methods could be static
6
+ "class-methods-use-this": ["off", { enforceForClassFields: true }], // Warn when methods could be static
7
7
  "complexity": ["warn", { max: 20 }],
8
8
  "curly": "error",
9
9
  "default-case-last": "error",
@@ -150,6 +150,16 @@ module.exports = {
150
150
  "error",
151
151
  { destructuring: "all", ignoreReadBeforeAssign: false }
152
152
  ],
153
+ "prefer-destructuring": [
154
+ "warn",
155
+ {
156
+ array: true,
157
+ object: true
158
+ },
159
+ {
160
+ enforceForRenamedProperties: false
161
+ }
162
+ ],
153
163
  "prefer-exponentiation-operator": "error",
154
164
  "prefer-object-spread": "error",
155
165
  "prefer-promise-reject-errors": "error",
@@ -5,16 +5,24 @@ const eslintRules = eslintRuleSet.rules;
5
5
 
6
6
  // Map of all the typescript-eslint extensions.
7
7
  // If extension rule has additional properties compared to standard eslint rule:
8
- // If the map value is null:
9
- // The options from the standard rule will be used as is.
8
+ // If the map value is a boolean:
9
+ // If true the options from the standard rule will be used as is; if false the rule will be switched off.
10
10
  // If the map value is an object:
11
11
  // The object will be merged merged with standard rule (rule object 1).
12
12
  // If the map value is an array:
13
- // The items of the array will be added as a new rule options object.
13
+ // The options items of the array (expected to be object literals or undefined) will be merged with the options items of the standard rule (expected to be object literals or undefined).
14
14
  // If the map value is a function:
15
15
  // The standard eslint options object will be passed as parameters, the return statement will be added as options.
16
16
 
17
17
  const extensions = new Map([
18
+ [
19
+ "class-methods-use-this",
20
+ false
21
+ // {
22
+ // ignoreOverrideMethods: false,
23
+ // ignoreClassesThatImplementAnInterface: false
24
+ // }
25
+ ],
18
26
  ["default-param-last", true],
19
27
  [
20
28
  "dot-notation",
@@ -33,7 +41,7 @@ const extensions = new Map([
33
41
  ],
34
42
  ["no-array-constructor", true],
35
43
  ["no-dupe-class-members", true],
36
- ["no-duplicate-imports", true],
44
+ ["no-duplicate-imports", false], // typescript-eslint 5.25.0: deprecated in favour of import/no-duplicates
37
45
  [
38
46
  "no-empty-function",
39
47
  {
@@ -68,6 +76,10 @@ const extensions = new Map([
68
76
  ["no-unused-vars", false],
69
77
  ["no-use-before-define", false],
70
78
  ["no-useless-constructor", false],
79
+ [
80
+ "prefer-destructuring",
81
+ [{}, { enforceForDeclarationWithTypeAnnotation: false }]
82
+ ],
71
83
  ["require-await", true],
72
84
  ["return-await", true]
73
85
  ]);
@@ -97,7 +109,19 @@ module.exports.typescriptEslintExtensionrules = Object.entries(
97
109
  // Ensure value is array if only severity string:
98
110
  value = Array.isArray(value) ? [...value] : [value];
99
111
  if (Array.isArray(extension)) {
100
- value.push(...extension);
112
+ const [severity, ...orgOpts] = value;
113
+ const extOpts = extension;
114
+ value = [severity];
115
+ for (
116
+ let i = 0;
117
+ i < Math.max(orgOpts.length, extOpts.length);
118
+ i++
119
+ ) {
120
+ value.push({
121
+ ...(orgOpts[i] ?? {}),
122
+ ...(extOpts[i] ?? {})
123
+ });
124
+ }
101
125
  } else if (typeof extension === "object") {
102
126
  // If array only contains severity string, push object
103
127
  if (value.length === 1) {
@@ -21,7 +21,12 @@ const rules = {
21
21
  }
22
22
  ],
23
23
  "ban-tslint-comment": "error", // No longer use tslint - remove rules
24
- "ban-types": "off", // Can be used to ban certain types
24
+ "ban-types": [
25
+ "error",
26
+ {
27
+ // Enable additional/disable default disabled types here
28
+ }
29
+ ],
25
30
  "class-literal-property-style": "off",
26
31
  "consistent-generic-constructors": ["off", "constructor"],
27
32
  "consistent-indexed-object-style": ["error", "record"],
@@ -183,6 +188,7 @@ const rules = {
183
188
  "no-redundant-type-constituents": "error",
184
189
  "no-require-imports": "error",
185
190
  "no-unsafe-enum-comparison": "error",
191
+ "no-unsafe-unary-minus": "error",
186
192
  "no-this-alias": "error",
187
193
  "no-throw-literal": [
188
194
  "error",
@@ -191,7 +197,6 @@ const rules = {
191
197
  allowThrowingUnknown: true // Default is to allow throwing values of type unknown
192
198
  }
193
199
  ],
194
- "no-type-alias": "off",
195
200
  "no-unnecessary-boolean-literal-compare": "error",
196
201
  "no-unnecessary-condition": "off", // allow runtime null checks etc even if reported not necessary by type system
197
202
  "no-unnecessary-qualifier": "error",
@@ -226,7 +231,13 @@ const rules = {
226
231
  {
227
232
  ignoreConditionalTests: true,
228
233
  ignoreTernaryTests: true,
229
- ignoreMixedLogicalExpressions: true
234
+ ignoreMixedLogicalExpressions: true,
235
+ ignorePrimitives: {
236
+ string: false,
237
+ number: false,
238
+ bigint: false,
239
+ boolean: false
240
+ }
230
241
  }
231
242
  ],
232
243
  "prefer-optional-chain": "error",
@@ -238,11 +249,16 @@ const rules = {
238
249
  "prefer-string-starts-ends-with": "error",
239
250
  "prefer-ts-expect-error": "error",
240
251
  "promise-function-async": "off",
241
- "require-array-sort-compare": "error",
252
+ "require-array-sort-compare": [
253
+ "error",
254
+ {
255
+ ignoreStringArrays: false
256
+ }
257
+ ],
242
258
  "restrict-plus-operands": [
243
259
  "error",
244
260
  {
245
- checkCompoundAssignments: true,
261
+ skipCompoundAssignments: false,
246
262
  allowAny: false
247
263
  }
248
264
  ],