@josundt/eslint-config 5.0.4 → 5.2.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.
@@ -15,53 +15,34 @@ const eslintRules = eslintRuleSet.rules;
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
- // ================== Formatting rules ==================
20
-
21
- ["block-spacing", true],
22
- ["brace-style", true],
23
- ["camelcase", false],
24
- ["comma-dangle", true],
25
- ["comma-spacing", true],
26
- ["func-call-spacing", true],
27
- ["indent", true],
28
- ["key-spacing", true],
29
- ["keyword-spacing", true],
30
- ["lines-arround-comment", true],
31
- ["lines-between-class-members", true],
32
- ["member-delimiter-style", true],
33
- ["no-extra-parens", true],
34
- ["object-curly-spacing", true],
35
- ["padding-line-between-statements", [
36
- { "blankLine": "always", "prev": "*", "next": ["interface", "type"] },
37
- { "blankLine": "always", "prev": ["interface", "type"], "next": "*" }
38
- ]],
39
- ["quotes", true],
40
- ["semi", true],
41
- ["space-before-blocks", true],
42
- ["space-before-function-paren", true],
43
- ["space-infix-ops", false],
44
- // ["space-infix-ops", true] // buggy with typescript (as of 5.27.0) -- switched off below
45
-
46
-
47
- // =================== Other rules ===================
48
-
49
18
  ["default-param-last", true],
50
- ["dot-notation", {
51
- "allowPrivateClassPropertyAccess": false,
52
- "allowProtectedClassPropertyAccess": false,
53
- "allowIndexSignaturePropertyAccess": false
54
- }],
19
+ [
20
+ "dot-notation",
21
+ {
22
+ allowPrivateClassPropertyAccess: false,
23
+ allowProtectedClassPropertyAccess: false,
24
+ allowIndexSignaturePropertyAccess: false
25
+ }
26
+ ],
55
27
  ["init-declarations", true],
56
- ["lines-between-class-members", {
57
- "exceptAfterOverload": true
58
- }],
28
+ [
29
+ "lines-between-class-members",
30
+ {
31
+ exceptAfterOverload: true
32
+ }
33
+ ],
59
34
  ["no-array-constructor", true],
60
35
  ["no-dupe-class-members", true],
61
36
  ["no-duplicate-imports", true],
62
- ["no-empty-function", {
63
- allow: ["private-constructors", "protected-constructors" /* "decoratedFunctions", "overrideMethods" */ ]
64
- }],
37
+ [
38
+ "no-empty-function",
39
+ {
40
+ allow: [
41
+ "private-constructors",
42
+ "protected-constructors" /* "decoratedFunctions", "overrideMethods" */
43
+ ]
44
+ }
45
+ ],
65
46
  ["no-extra-semi", true],
66
47
  ["no-implied-eval", true],
67
48
  ["no-invalid-this", false],
@@ -70,22 +51,25 @@ const extensions = new Map([
70
51
  ["no-magic-numbers", true],
71
52
  ["no-redeclare", true],
72
53
  ["no-restricted-imports", true],
73
- ["no-shadow", v => {
74
- const o = {
75
- ...v,
76
- "ignoreTypeValueShadow": true,
77
- "ignoreFunctionTypeParameterNameValueShadow": true
78
- };
79
- delete o["ignoreOnInitialization"]; // Temporary bug in @typescript/eslint "no-shadow" extension rule - "ignoreOnInitialization" property considered invalid
80
- return o;
81
- }],
54
+ [
55
+ "no-shadow",
56
+ v => {
57
+ const o = {
58
+ ...v,
59
+ ignoreTypeValueShadow: true,
60
+ ignoreFunctionTypeParameterNameValueShadow: true
61
+ };
62
+ delete o["ignoreOnInitialization"]; // Temporary bug in @typescript/eslint "no-shadow" extension rule - "ignoreOnInitialization" property considered invalid
63
+ return o;
64
+ }
65
+ ],
82
66
  ["no-throw-literal", true],
83
67
  ["no-unused-expressions", true],
84
68
  ["no-unused-vars", false],
85
69
  ["no-use-before-define", false],
86
70
  ["no-useless-constructor", false],
87
71
  ["require-await", true],
88
- ["return-await", true],
72
+ ["return-await", true]
89
73
  ]);
90
74
 
91
75
  // console.log(extensionRules);
@@ -93,14 +77,14 @@ const extensions = new Map([
93
77
  // console.log("Not converted:", Array.from(extensions.keys()).filter(k => !Object.keys(extensionRules).filter(k => !k.startsWith("@typescript")).includes(k)));
94
78
 
95
79
  // Building eslint-typescript rules for existsing eslint rules and switching off original eslint rule
96
- module.exports.typescriptEslintExtensionrules = Object.entries(eslintRules).reduce((extRules, [key, value]) => {
97
-
80
+ module.exports.typescriptEslintExtensionrules = Object.entries(
81
+ eslintRules
82
+ ).reduce((extRules, [key, value]) => {
98
83
  // Try to get from known extensions map
99
84
  const extension = extensions.get(key);
100
85
 
101
86
  // If found in known typescript eslint extension rules map
102
87
  if (extension !== undefined) {
103
-
104
88
  // Switch off standard eslint rule
105
89
  extRules[key] = "off";
106
90
 
@@ -118,9 +102,12 @@ module.exports.typescriptEslintExtensionrules = Object.entries(eslintRules).redu
118
102
  // If array only contains severity string, push object
119
103
  if (value.length === 1) {
120
104
  value.push(extension);
121
- // Else merge object
105
+ // Else merge object
122
106
  } else {
123
- value[value.length - 1] = deepMergeObjects(value[value.length - 1], extension);
107
+ value[value.length - 1] = deepMergeObjects(
108
+ value[value.length - 1],
109
+ extension
110
+ );
124
111
  }
125
112
  } else if (typeof extension === "function") {
126
113
  const [, ...options] = value;
@@ -130,8 +117,6 @@ module.exports.typescriptEslintExtensionrules = Object.entries(eslintRules).redu
130
117
  // Add extension rule value with the @typescript-eslint key prefix
131
118
  extRules[`@typescript-eslint/${key}`] = value;
132
119
  }
133
-
134
-
135
120
  }
136
121
  // else: if no extension rule exists, the standard eslint rule will be used through the "extends" configuration below
137
122
 
@@ -4,8 +4,8 @@ const rules = {
4
4
  "array-type": [
5
5
  "error",
6
6
  {
7
- "default": "array-simple",
8
- "readonly": "array-simple"
7
+ default: "array-simple",
8
+ readonly: "array-simple"
9
9
  }
10
10
  ],
11
11
  "await-thenable": "error",
@@ -16,7 +16,7 @@ const rules = {
16
16
  "ts-ignore": true,
17
17
  "ts-nocheck": true,
18
18
  "ts-check": false,
19
- "minimumDescriptionLength": 10,
19
+ "minimumDescriptionLength": 10
20
20
  //"descriptionFormat": "someformathere"
21
21
  }
22
22
  ],
@@ -28,66 +28,64 @@ const rules = {
28
28
  "consistent-type-assertions": [
29
29
  "error",
30
30
  {
31
- "assertionStyle": "as",
32
- "objectLiteralTypeAssertions": "allow"
31
+ assertionStyle: "as",
32
+ objectLiteralTypeAssertions: "allow"
33
33
  }
34
34
  ],
35
- "consistent-type-definitions": [
36
- "error",
37
- "interface"
38
- ],
35
+ "consistent-type-definitions": ["error", "interface"],
39
36
  "consistent-type-exports": [
40
37
  "error",
41
38
  {
42
- "fixMixedExportsWithInlineTypeSpecifier": true
39
+ fixMixedExportsWithInlineTypeSpecifier: true
43
40
  }
44
41
  ],
45
42
  "consistent-type-imports": [
46
43
  "error",
47
44
  {
48
- "prefer": "type-imports",
49
- "fixStyle": "inline-type-imports",
50
- "disallowTypeAnnotations": false
45
+ prefer: "type-imports",
46
+ fixStyle: "inline-type-imports",
47
+ disallowTypeAnnotations: false
51
48
  }
52
49
  ],
53
50
  "explicit-function-return-type": [
54
51
  "error",
55
52
  {
56
- "allowConciseArrowFunctionExpressionsStartingWithVoid": true,
57
- "allowExpressions": true,
58
- "allowFunctionsWithoutTypeParameters": false,
59
- "allowHigherOrderFunctions": true,
60
- "allowIIFEs": false,
61
- "allowTypedFunctionExpressions": true,
62
- "allowedNames": []
53
+ allowConciseArrowFunctionExpressionsStartingWithVoid: true,
54
+ allowExpressions: true,
55
+ allowFunctionsWithoutTypeParameters: false,
56
+ allowHigherOrderFunctions: true,
57
+ allowIIFEs: false,
58
+ allowTypedFunctionExpressions: true,
59
+ allowedNames: []
63
60
  }
64
61
  ],
65
62
  "explicit-member-accessibility": [
66
63
  "error",
67
64
  {
68
- "accessibility": "no-public"
65
+ accessibility: "no-public"
69
66
  }
70
67
  ],
71
- "explicit-module-boundary-types": [ // same as "recommended" except error instead of warning
68
+ "explicit-module-boundary-types": [
69
+ // same as "recommended" except error instead of warning
72
70
  "error",
73
71
  {
74
- "allowArgumentsExplicitlyTypedAsAny": false,
75
- "allowDirectConstAssertionInArrowFunctions": true,
76
- "allowHigherOrderFunctions": true,
77
- "allowTypedFunctionExpressions": true,
78
- "allowedNames": []
72
+ allowArgumentsExplicitlyTypedAsAny: false,
73
+ allowDirectConstAssertionInArrowFunctions: true,
74
+ allowHigherOrderFunctions: true,
75
+ allowTypedFunctionExpressions: true,
76
+ allowedNames: []
79
77
  }
80
78
  ],
81
79
  "member-delimiter-style": [
82
80
  "error",
83
81
  {
84
- "multiline": {
85
- "delimiter": "semi",
86
- "requireLast": true
82
+ multiline: {
83
+ delimiter: "semi",
84
+ requireLast: true
87
85
  },
88
- "singleline": {
89
- "delimiter": "semi",
90
- "requireLast": true
86
+ singleline: {
87
+ delimiter: "semi",
88
+ requireLast: false
91
89
  }
92
90
  }
93
91
  ],
@@ -96,49 +94,38 @@ const rules = {
96
94
  "naming-convention": [
97
95
  "error",
98
96
  {
99
- "selector": "default",
100
- "format": [
101
- "camelCase"
102
- ],
103
- "leadingUnderscore": "forbid",
104
- "trailingUnderscore": "forbid"
97
+ selector: "default",
98
+ format: ["camelCase"],
99
+ leadingUnderscore: "forbid",
100
+ trailingUnderscore: "forbid"
105
101
  },
106
102
  {
107
- "selector": "typeLike",
108
- "format": [
109
- "PascalCase"
110
- ]
103
+ selector: "typeLike",
104
+ format: ["PascalCase"]
111
105
  },
112
106
  {
113
- "selector": "method",
114
- "modifiers": [
107
+ selector: "method",
108
+ modifiers: [
115
109
  // "#private", // Did not work even if it was added in 5.49.0
116
110
  "private"
117
111
  ],
118
- "format": [
119
- "camelCase"
120
- ],
121
- "leadingUnderscore": "allow",
122
- "trailingUnderscore": "forbid"
112
+ format: ["camelCase"],
113
+ leadingUnderscore: "allow",
114
+ trailingUnderscore: "forbid"
123
115
  },
124
116
  {
125
- "selector": "property",
126
- "modifiers": [
117
+ selector: "property",
118
+ modifiers: [
127
119
  // "#private", // Did not work even if it was added in 5.49.0
128
120
  "private"
129
121
  ],
130
- "format": [
131
- "camelCase"
132
- ],
133
- "leadingUnderscore": "allow",
134
- "trailingUnderscore": "forbid"
122
+ format: ["camelCase"],
123
+ leadingUnderscore: "allow",
124
+ trailingUnderscore: "forbid"
135
125
  },
136
126
  {
137
- "selector": "enumMember",
138
- "format": [
139
- "camelCase",
140
- "PascalCase"
141
- ]
127
+ selector: "enumMember",
128
+ format: ["camelCase", "PascalCase"]
142
129
  }
143
130
  ],
144
131
  "no-base-to-string": "error",
@@ -146,7 +133,7 @@ const rules = {
146
133
  "no-confusing-void-expression": [
147
134
  "error",
148
135
  {
149
- "ignoreArrowShorthand": true
136
+ ignoreArrowShorthand: true
150
137
  }
151
138
  ],
152
139
  "no-duplicate-enum-values": "error",
@@ -156,7 +143,7 @@ const rules = {
156
143
  "no-explicit-any": [
157
144
  "off",
158
145
  {
159
- "ignoreRestArgs": "false"
146
+ ignoreRestArgs: "false"
160
147
  }
161
148
  ],
162
149
  "no-extra-non-null-assertion": "error",
@@ -168,8 +155,8 @@ const rules = {
168
155
  "no-invalid-void-type": [
169
156
  "error",
170
157
  {
171
- "allowInGenericTypeArguments": true,
172
- "allowAsThisParameter": true
158
+ allowInGenericTypeArguments: true,
159
+ allowAsThisParameter: true
173
160
  }
174
161
  ],
175
162
  "no-meaningless-void-operator": "error",
@@ -177,9 +164,9 @@ const rules = {
177
164
  "no-misused-promises": [
178
165
  "error",
179
166
  {
180
- "checksConditionals": true,
181
- "checksSpreads": true,
182
- "checksVoidReturn": true // {
167
+ checksConditionals: true,
168
+ checksSpreads: true,
169
+ checksVoidReturn: true // {
183
170
  // arguments: true, //Disables checking an asynchronous function passed as argument where the parameter type expects a function that returns void
184
171
  // attributes: true, //Disables checking an asynchronous function passed as a JSX attribute expected to be a function that returns void
185
172
  // properties: true, //Disables checking an asynchronous function passed as an object property expected to be a function that returns void
@@ -200,8 +187,8 @@ const rules = {
200
187
  "no-throw-literal": [
201
188
  "error",
202
189
  {
203
- "allowThrowingAny": false, // Default is to allow throwing values of type any
204
- "allowThrowingUnknown": true // Default is to allow throwing values of type unknown
190
+ allowThrowingAny: false, // Default is to allow throwing values of type any
191
+ allowThrowingUnknown: true // Default is to allow throwing values of type unknown
205
192
  }
206
193
  ],
207
194
  "no-type-alias": "off",
@@ -223,8 +210,8 @@ const rules = {
223
210
  "parameter-properties": [
224
211
  "error",
225
212
  {
226
- "prefer": "class-property", // or "parameter-property"
227
- "allow": ["private readonly", "private", "protected readonly"]
213
+ prefer: "class-property", // or "parameter-property"
214
+ allow: ["private readonly", "private", "protected readonly"]
228
215
  }
229
216
  ],
230
217
  "prefer-as-const": "off",
@@ -237,9 +224,9 @@ const rules = {
237
224
  "prefer-nullish-coalescing": [
238
225
  "error",
239
226
  {
240
- "ignoreConditionalTests": true,
241
- "ignoreTernaryTests": true,
242
- "ignoreMixedLogicalExpressions": true
227
+ ignoreConditionalTests: true,
228
+ ignoreTernaryTests: true,
229
+ ignoreMixedLogicalExpressions: true
243
230
  }
244
231
  ],
245
232
  "prefer-optional-chain": "error",
@@ -255,32 +242,32 @@ const rules = {
255
242
  "restrict-plus-operands": [
256
243
  "error",
257
244
  {
258
- "checkCompoundAssignments": true,
259
- "allowAny": false
245
+ checkCompoundAssignments: true,
246
+ allowAny: false
260
247
  }
261
248
  ],
262
249
  "restrict-template-expressions": [
263
250
  "error",
264
251
  {
265
- "allowAny": false,
266
- "allowBoolean": false,
267
- "allowNever": false,
268
- "allowNullish": false,
269
- "allowNumber": true,
270
- "allowRegExp": false
252
+ allowAny: false,
253
+ allowBoolean: false,
254
+ allowNever: false,
255
+ allowNullish: false,
256
+ allowNumber: true,
257
+ allowRegExp: false
271
258
  }
272
259
  ],
273
260
  "sort-type-constituents": "off",
274
261
  "strict-boolean-expressions": [
275
262
  "off",
276
263
  {
277
- "allowString": true,
278
- "allowNumber": true,
279
- "allowNullableObject": true,
280
- "allowNullableString": true,
281
- "allowNullableNumber": true,
282
- "allowNullableBoolean": true,
283
- "allowAny": false
264
+ allowString: true,
265
+ allowNumber: true,
266
+ allowNullableObject: true,
267
+ allowNullableString: true,
268
+ allowNullableNumber: true,
269
+ allowNullableBoolean: true,
270
+ allowAny: false
284
271
  }
285
272
  ],
286
273
  "switch-exhaustiveness-check": "error",
@@ -289,21 +276,24 @@ const rules = {
289
276
  "typedef": [
290
277
  "error",
291
278
  {
292
- "arrayDestructuring": false,
293
- "arrowParameter": false,
294
- "memberVariableDeclaration": true,
295
- "objectDestructuring": false,
296
- "parameter": true,
297
- "propertyDeclaration": true,
298
- "variableDeclaration": false
279
+ arrayDestructuring: false,
280
+ arrowParameter: false,
281
+ memberVariableDeclaration: true,
282
+ objectDestructuring: false,
283
+ parameter: true,
284
+ propertyDeclaration: true,
285
+ variableDeclaration: false
299
286
  }
300
287
  ],
301
288
  "unbound-method": "error",
302
- "unified-signatures": "off",
289
+ "unified-signatures": "off"
303
290
  };
304
291
 
305
292
  // 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
- }), {});
293
+ module.exports.typescriptEslintRules = Object.entries(rules).reduce(
294
+ (aggr, [key, value]) => ({
295
+ ...aggr,
296
+ [`@typescript-eslint/${key}`]: value
297
+ }),
298
+ {}
299
+ );
@@ -1,16 +1,16 @@
1
1
  const { typescriptEslintRules } = require("./typescript-eslint/rules.js");
2
- const { typescriptEslintExtensionrules } = require("./typescript-eslint/extensionrules.js");
2
+ const {
3
+ typescriptEslintExtensionrules
4
+ } = require("./typescript-eslint/extensionrules.js");
3
5
 
4
6
  module.exports = {
5
- "extends": [
7
+ extends: [
6
8
  "./eslint",
7
9
  "plugin:@typescript-eslint/recommended",
8
10
  "plugin:@typescript-eslint/recommended-requiring-type-checking"
9
11
  ],
10
- "plugins": [
11
- "@typescript-eslint/eslint-plugin"
12
- ],
13
- "rules": {
12
+ plugins: ["@typescript-eslint/eslint-plugin"],
13
+ rules: {
14
14
  ...typescriptEslintRules,
15
15
  ...typescriptEslintExtensionrules
16
16
  }
package/rules/unicorn.js CHANGED
@@ -1,12 +1,10 @@
1
1
  module.exports = {
2
- "plugins": [
3
- "unicorn"
4
- ],
5
- "rules": {
2
+ plugins: ["unicorn"],
3
+ rules: {
6
4
  "unicorn/filename-case": [
7
5
  "error",
8
6
  {
9
- "case": "kebabCase"
7
+ case: "kebabCase"
10
8
  }
11
9
  ]
12
10
  }
@@ -1,36 +1,37 @@
1
1
  module.exports = {
2
- "env": {
3
- "node": true,
4
- "es6": true,
5
- "jest": true,
6
- "jasmine": true
2
+ env: {
3
+ node: true,
4
+ es6: true,
5
+ jest: true,
6
+ jasmine: true
7
7
  },
8
- "parser": "@typescript-eslint/parser",
9
- "parserOptions": {
10
- "ecmaVersion": 2021,
11
- "project": "tsconfig.json",
12
- "sourceType": "module"
8
+ parser: "@typescript-eslint/parser",
9
+ parserOptions: {
10
+ ecmaVersion: 2021,
11
+ project: "tsconfig.json",
12
+ sourceType: "module"
13
13
  },
14
- "extends": [
14
+ extends: [
15
15
  "./rules/deprecation.js",
16
16
  // "./rules/eslint.js", -> commented out since "typescript-eslint" rules inherit from this
17
17
  "./rules/eslint-comments.js",
18
18
  "./rules/import-typescript-node.js",
19
19
  "./rules/jsdoc-typescript.js",
20
+ "./rules/prettier.js",
20
21
  "./rules/typescript-eslint.js",
21
- "./rules/unicorn.js",
22
+ "./rules/unicorn.js"
22
23
  ].map(require.resolve),
23
- "rules": {},
24
- "overrides": [ // Overrides for test files
24
+ rules: {},
25
+ overrides: [
26
+ // Overrides for test files
25
27
  {
26
- "files": ["**/?(*.)+(spec).[jt]s?(x)"],
27
- "extends": [
28
- "./rules/jasmine.js",
29
- "./rules/jest.js"
30
- ].map(require.resolve),
31
- "rules": {
32
- "@typescript-eslint/unbound-method": "off",
28
+ files: ["**/?(*.)+(spec).[jt]s?(x)"],
29
+ extends: ["./rules/jasmine.js", "./rules/jest.js"].map(
30
+ require.resolve
31
+ ),
32
+ rules: {
33
+ "@typescript-eslint/unbound-method": "off"
33
34
  }
34
35
  }
35
- ],
36
+ ]
36
37
  };
@@ -1,22 +1,23 @@
1
1
  module.exports = {
2
- "env": {
3
- "node": true,
4
- "es6": true
2
+ env: {
3
+ node: true,
4
+ es6: true
5
5
  },
6
- "parser": "@typescript-eslint/parser",
7
- "parserOptions": {
8
- "ecmaVersion": 2021,
9
- "project": "tsconfig.json",
10
- "sourceType": "module"
6
+ parser: "@typescript-eslint/parser",
7
+ parserOptions: {
8
+ ecmaVersion: 2021,
9
+ project: "tsconfig.json",
10
+ sourceType: "module"
11
11
  },
12
- "extends": [
12
+ extends: [
13
13
  "./rules/deprecation.js",
14
14
  // "./rules/eslint.js", -> commented out since "typescript-eslint" rules inherit from this
15
15
  "./rules/eslint-comments.js",
16
16
  "./rules/import-typescript-node.js",
17
17
  "./rules/jsdoc-typescript.js",
18
+ "./rules/prettier.js",
18
19
  "./rules/typescript-eslint.js",
19
- "./rules/unicorn.js",
20
+ "./rules/unicorn.js"
20
21
  ].map(require.resolve),
21
- "rules": {}
22
+ rules: {}
22
23
  };