@josundt/eslint-config 4.7.3 → 4.9.6

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,36 @@
1
+ // References:
2
+ // https://medium.com/@jose_82797/how-to-import-eslint-issues-into-sonarqube-overview-analysis-in-a-frontend-application-b8e8946b8104
3
+ // https://eslint.org/docs/latest/developer-guide/working-with-custom-formatters#working-with-custom-formatters
4
+
5
+ module.exports = function(results) {
6
+ var summary = {issues: []};
7
+ results.forEach(function(result) {
8
+ result.messages.forEach(function(msg) {
9
+ var logMessage = {
10
+ engineId: "eslint",
11
+ ruleId: msg.ruleId,
12
+ primaryLocation: {
13
+ message: msg.message,
14
+ filePath: result.filePath,
15
+ textRange: {
16
+ startLine: msg.line,
17
+ endLine: msg.endLine,
18
+ endColumn: msg.endColumn
19
+ }
20
+ }
21
+ };
22
+
23
+ // The log message type and severity is up to you but you need to take in consideration SonarQube properties
24
+ if (msg.severity === 1) {
25
+ logMessage.type = "CODE_SMELL";
26
+ logMessage.severity = "INFO";
27
+ }
28
+ if (msg.severity === 2) {
29
+ logMessage.type = "BUG";
30
+ logMessage.severity="MAJOR";
31
+ }
32
+ summary.issues.push(logMessage);
33
+ });
34
+ });
35
+ return JSON.stringify(summary, null, 2);
36
+ };
package/index.js CHANGED
@@ -1 +1 @@
1
- module.exports = require("./typescript-web-jasmine");
1
+ module.exports = require("./typescript-web-jest");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@josundt/eslint-config",
3
- "version": "4.7.3",
3
+ "version": "4.9.6",
4
4
  "description": "ESLint ruleset with required plugins for josundt TypeScript projects",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -27,17 +27,19 @@
27
27
  "utils/**/*.js"
28
28
  ],
29
29
  "peerDependencies": {
30
- "typescript": ">=4.7.2"
30
+ "typescript": ">=4.9.3"
31
31
  },
32
32
  "dependencies": {
33
- "@typescript-eslint/eslint-plugin": "5.27.0",
34
- "@typescript-eslint/parser": "5.27.0",
35
- "eslint": "8.16.0",
36
- "eslint-import-resolver-typescript": "2.7.1",
37
- "eslint-plugin-deprecation": "1.3.2",
33
+ "@typescript-eslint/eslint-plugin": "5.45.0",
34
+ "@typescript-eslint/parser": "5.45.0",
35
+ "eslint": "8.28.0",
36
+ "eslint-import-resolver-typescript": "3.5.2",
37
+ "eslint-plugin-deprecation": "1.3.3",
38
+ "eslint-plugin-eslint-comments": "3.2.0",
38
39
  "eslint-plugin-import": "2.26.0",
39
40
  "eslint-plugin-jasmine": "4.1.3",
40
- "eslint-plugin-jsdoc": "39.3.2",
41
- "eslint-plugin-unicorn": "42.0.0"
41
+ "eslint-plugin-jest": "27.1.6",
42
+ "eslint-plugin-jsdoc": "39.6.4",
43
+ "eslint-plugin-unicorn": "45.0.1"
42
44
  }
43
45
  }
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ "plugins": [
3
+ "eslint-plugin-eslint-comments"
4
+ ],
5
+ "rules": {
6
+ "eslint-comments/disable-enable-pair": "warn",
7
+ "eslint-comments/no-aggregating-enable": "warn",
8
+ "eslint-comments/no-duplicate-disable": "warn",
9
+ "eslint-comments/no-unlimited-disable": "warn",
10
+ "eslint-comments/no-unused-enable": "warn",
11
+ "eslint-comments/no-unused-disable": "warn"
12
+ }
13
+ };
package/rules/eslint.js CHANGED
@@ -4,62 +4,24 @@ module.exports = {
4
4
  ],
5
5
  "rules": {
6
6
  "arrow-body-style": "error",
7
- "arrow-parens": [
8
- "error",
9
- "as-needed"
10
- ],
11
- "arrow-spacing": [
12
- "error",
13
- {
14
- "before": true,
15
- "after": true
16
- }
17
- ],
18
- "brace-style": [
19
- "error",
20
- "1tbs"
21
- ],
22
- "camelcase": "off",
23
- "capitalized-comments": [
24
- "off",
25
- "always"
26
- ],
27
- "class-methods-use-this": "off",
28
- "comma-dangle": "off",
29
- "comma-spacing": [
30
- "error",
31
- {
32
- "before": false,
33
- "after": true
34
- }
35
- ],
36
- "complexity": [
37
- "off",
38
- {
39
- "max": 20
40
- }
41
- ],
42
- "constructor-super": "error",
7
+ "arrow-parens": ["error", "as-needed"],
8
+ "arrow-spacing": ["error", { "before": true, "after": true }],
9
+ "brace-style": ["error", "1tbs"],
10
+ "class-methods-use-this": "off", // Warn when methods could be static
11
+ "comma-spacing": ["error", {"before": false, "after": true }],
12
+ "comma-style": ["error", "last"],
13
+ "computed-property-spacing": ["error", "never"],
14
+ "complexity": ["warn", { "max": 20 }],
43
15
  "curly": "error",
44
- "default-case": "off",
16
+ "default-case-last": "error",
45
17
  "default-param-last": "error",
46
- "dot-notation": [
47
- "off",
48
- {
49
- "before": false,
50
- "after": true
51
- }
52
- ],
53
- "eol-last": "off",
54
- "eqeqeq": [
55
- "error",
56
- "always"
57
- ],
58
- "func-call-spacing": [
59
- "error",
60
- "never"
61
- ],
18
+ "dot-location": ["error", "property"],
19
+ "eqeqeq": ["error", "always"],
20
+ "func-call-spacing": ["error", "never"],
21
+ "function-call-argument-newline": ["warn", "consistent"],
22
+ "function-paren-newline": ["warn", "multiline-arguments"],
62
23
  "guard-for-in": "error",
24
+ "grouped-accessor-pairs": "error",
63
25
  "handle-callback-err": "error",
64
26
  "id-denylist": [
65
27
  "error",
@@ -96,23 +58,13 @@ module.exports = {
96
58
  ]
97
59
  }
98
60
  ],
99
- "init-declarations": "off",
61
+ "key-spacing": ["error", { "beforeColon": false, "afterColon": true, "mode": "strict" }],
100
62
  "keyword-spacing": "error",
101
- "linebreak-style": [
102
- "off",
103
- "windows"
104
- ],
105
- "lines-between-class-members": [
106
- "off",
107
- "always",
108
- {
109
- "exceptAfterSingleLine": true
110
- }
111
- ],
112
- "max-classes-per-file": [
113
- "off",
114
- 5
115
- ],
63
+ "max-classes-per-file": ["off", 5],
64
+ "max-depth": ["warn", { "max": 5 }], // default 4
65
+ "max-params": ["off", { "max": 6 }], // default 3 - SWITCHED OFF - does not work well with constructor injection
66
+ "max-statements-per-line": ["warn", { "max": 1 }], // default 1
67
+ "max-statements": ["warn", { "max": 100 }], // default 50
116
68
  "max-len": [
117
69
  "warn",
118
70
  {
@@ -120,52 +72,32 @@ module.exports = {
120
72
  "code": 180
121
73
  }
122
74
  ],
123
- "max-lines": [
124
- "off",
125
- 2000
126
- ],
75
+ "max-lines": ["off", 2000],
127
76
  "new-parens": "error",
128
- "newline-per-chained-call": "off",
129
77
  "no-array-constructor": "error",
130
78
  "no-bitwise": "error",
131
79
  "no-caller": "error",
132
- "no-cond-assign": [
133
- "error"
134
- ],
135
80
  "no-console": "error",
136
- "no-constant-condition": "error",
137
- "no-control-regex": "error",
138
- "no-debugger": "error",
139
- "no-dupe-class-members": "error",
140
- "no-duplicate-case": "error",
81
+ "no-constant-binary-expression": "error",
141
82
  "no-duplicate-imports": "error",
142
- "no-empty": "error",
143
- "no-empty-character-class": "error",
144
83
  "no-empty-function": ["error", {
145
84
  //allow: [/*"functions", "arrowFunctions", "generatorFunctions", "methods", "generatorMethods", "getters", "setters", "constructors", "asyncFunctions", "asyncMethods"*/]
146
85
  }],
86
+ "no-empty-static-block": "error",
147
87
  "no-eval": "error",
148
- "no-ex-assign": "error",
149
88
  "no-extra-bind": "error",
150
- "no-extra-boolean-cast": "error",
151
- "no-extra-parens": "off",
152
- "no-extra-semi": "error",
153
- "no-fallthrough": "off",
89
+ "no-implicit-coercion": ["error", { "allow": ["!!"] }],
154
90
  "no-implied-eval": "error",
155
- "no-inner-declarations": "off",
156
- "no-invalid-regexp": "error",
91
+ "no-inner-declarations": "off", // Switched off from recommended rules, gave too many issues
157
92
  "no-invalid-this": "error",
158
- "no-irregular-whitespace": "error",
159
- "no-loss-of-precision": "error",
160
- "no-magic-numbers": "off",
93
+ "no-multi-spaces": "warn",
161
94
  "no-multi-str": "error",
95
+ "no-lone-blocks": "error",
96
+ "no-lonely-if": "error",
162
97
  "no-multiple-empty-lines": "warn",
163
98
  "no-new-func": "error",
164
99
  "no-new-wrappers": "error",
165
- "no-octal": "error",
166
100
  "no-octal-escape": "error",
167
- "no-redeclare": "error",
168
- "no-regex-spaces": "error",
169
101
  "no-restricted-syntax": [
170
102
  "off", // Below - rules to require Async suffix on async methods - not good enough
171
103
  // {
@@ -213,20 +145,18 @@ module.exports = {
213
145
  "allow": [] // array of identifier names for which shadowing is allowed
214
146
  }
215
147
  ],
216
- "no-sparse-arrays": "error",
217
148
  "no-template-curly-in-string": "error",
218
149
  "no-throw-literal": "error",
219
150
  "no-trailing-spaces": "warn",
220
151
  "no-undef-init": "error",
221
- "no-underscore-dangle": [
222
- "off",
152
+ "no-unneeded-ternary": [
153
+ "error",
223
154
  {
224
- "allowAfterThis": true
155
+ "defaultAssignment": true
225
156
  }
226
157
  ],
227
- "no-unsafe-finally": "error",
228
- "no-unused-expressions": "error", // Switched off since it breaks support for null coalescing and optional chaining in TypeScript: https://github.com/typescript-eslint/typescript-eslint/issues/1051 - https://github.com/typescript-eslint/typescript-eslint/issues/1052
229
- "no-unused-labels": "error",
158
+ "no-unused-expressions": "error",
159
+ "no-unused-private-class-members": "error",
230
160
  "no-unused-vars": [
231
161
  "error",
232
162
  {
@@ -239,7 +169,10 @@ module.exports = {
239
169
  "no-useless-constructor": "error",
240
170
  "no-var": "error",
241
171
  "no-void": "error",
172
+ "no-warning-comments": ["warn", { "terms": ["todo"] }],
173
+ "object-curly-newline": ["warn", { "consistent": true }],
242
174
  "object-curly-spacing": ["error", "always"],
175
+ "object-property-newline": ["warn", { "allowAllPropertiesOnSameLine": true }],
243
176
  "object-shorthand": [
244
177
  "error",
245
178
  "never"
@@ -263,7 +196,9 @@ module.exports = {
263
196
  ],
264
197
  "prefer-arrow-callback": "error",
265
198
  "prefer-const": "error",
199
+ "prefer-exponentiation-operator": "error",
266
200
  "prefer-object-spread": "error",
201
+ "prefer-promise-reject-errors": "error",
267
202
  "prefer-template": "error",
268
203
  "quotes": [
269
204
  "error",
@@ -275,17 +210,21 @@ module.exports = {
275
210
  ],
276
211
  "radix": "error",
277
212
  "require-await": "error",
213
+ "require-unicode-regexp": "error",
214
+ "rest-spread-spacing": ["error", "never"],
278
215
  "return-await": "error",
279
216
  "semi": [
280
217
  "error",
281
218
  "always"
282
219
  ],
220
+ "semi-spacing": ["error", {"before": false, "after": true}],
221
+ "semi-style": ["error", "last"],
283
222
  "space-before-blocks": [
284
- "error",
223
+ "warn",
285
224
  "always"
286
225
  ],
287
226
  "space-before-function-paren": [
288
- "error",
227
+ "warn",
289
228
  {
290
229
  "anonymous": "always",
291
230
  "asyncArrow": "always",
@@ -293,13 +232,13 @@ module.exports = {
293
232
  }
294
233
  ],
295
234
  "space-in-parens": [
296
- "error",
235
+ "warn",
297
236
  "never"
298
237
  ],
299
- "space-infix-ops": "error",
300
- "spaced-comment": "off",
301
- "use-isnan": "error",
302
- "valid-typeof": "error",
238
+ "space-infix-ops": "warn",
239
+ "switch-colon-spacing": ["error", {"after": true, "before": false}],
240
+ "template-curly-spacing": ["error", "never"],
241
+ "unicode-bom": ["error", "never"],
303
242
  "yoda": "error"
304
243
  }
305
244
  };
package/rules/jest.js ADDED
@@ -0,0 +1,14 @@
1
+ module.exports = {
2
+ "extends": [
3
+ "plugin:jest/recommended"
4
+ ],
5
+ "env": {
6
+ "jest/globals": true
7
+ },
8
+ "plugins": [
9
+ "jest"
10
+ ],
11
+ "rules": {
12
+ "jest/unbound-method": "error"
13
+ }
14
+ };
@@ -164,6 +164,7 @@ module.exports = {
164
164
  ],
165
165
  "@typescript-eslint/ban-tslint-comment": "error", // No longer use tslint - remove rules
166
166
  "@typescript-eslint/ban-types": "off", // Can be used to ban certain types
167
+ "@typescript-eslint/consistent-generic-constructors": ["off", "constructor"],
167
168
  "@typescript-eslint/consistent-indexed-object-style": ["error", "record"],
168
169
  "@typescript-eslint/consistent-type-assertions": [
169
170
  "error",
@@ -349,14 +350,21 @@ module.exports = {
349
350
  "allow": ["private readonly", "private", "protected readonly"]
350
351
  }
351
352
  ],
352
- "@typescript-eslint/prefer-as-const": "error",
353
+ "@typescript-eslint/prefer-as-const": "off",
353
354
  "@typescript-eslint/prefer-enum-initializers": "error",
354
355
  "@typescript-eslint/prefer-for-of": "error",
355
356
  "@typescript-eslint/prefer-function-type": "error",
356
357
  "@typescript-eslint/prefer-includes": "error",
357
358
  "@typescript-eslint/prefer-literal-enum-member": "error",
358
359
  "@typescript-eslint/prefer-namespace-keyword": "error",
359
- "@typescript-eslint/prefer-nullish-coalescing": "error",
360
+ "@typescript-eslint/prefer-nullish-coalescing": [
361
+ "error",
362
+ {
363
+ "ignoreConditionalTests": true,
364
+ "ignoreTernaryTests": true,
365
+ "ignoreMixedLogicalExpressions": true
366
+ }
367
+ ],
360
368
  "@typescript-eslint/prefer-optional-chain": "error",
361
369
  "@typescript-eslint/prefer-readonly": "error",
362
370
  "@typescript-eslint/prefer-readonly-parameter-types": "off", // Could be useful but requires too much work and verbose notation
@@ -10,11 +10,23 @@ module.exports = {
10
10
  "extends": [
11
11
  "./rules/deprecation.js",
12
12
  // "./rules/eslint.js", -> commented out since "typescript-eslint" rules inherit from this
13
+ "./rules/eslint-comments.js",
13
14
  "./rules/import-typescript.js",
14
- "./rules/jasmine.js",
15
15
  "./rules/jsdoc-typescript.js",
16
16
  "./rules/typescript-eslint.js",
17
17
  "./rules/unicorn.js",
18
18
  ].map(require.resolve),
19
- "rules": {}
19
+ "rules": {},
20
+ "overrides": [ // Overrides for test files
21
+ {
22
+ "files": ["**/?(*.)+(spec).[jt]s?(x)"],
23
+ "extends": [
24
+ "./rules/jasmine.js",
25
+ "./rules/jest.js"
26
+ ].map(require.resolve),
27
+ "rules": {
28
+ "@typescript-eslint/unbound-method": "off",
29
+ }
30
+ }
31
+ ],
20
32
  };
@@ -10,6 +10,7 @@ module.exports = {
10
10
  "extends": [
11
11
  "./rules/deprecation.js",
12
12
  // "./rules/eslint.js", -> commented out since "typescript-eslint" rules inherit from this
13
+ "./rules/eslint-comments.js",
13
14
  "./rules/import-typescript.js",
14
15
  "./rules/jsdoc-typescript.js",
15
16
  "./rules/typescript-eslint.js",
@@ -11,11 +11,23 @@ module.exports = {
11
11
  "extends": [
12
12
  "./rules/deprecation.js",
13
13
  // "./rules/eslint.js", -> commented out since "typescript-eslint" rules inherit from this
14
+ "./rules/eslint-comments.js",
14
15
  "./rules/import-typescript.js",
15
- "./rules/jasmine.js",
16
16
  "./rules/jsdoc-typescript.js",
17
17
  "./rules/typescript-eslint.js",
18
18
  "./rules/unicorn.js",
19
19
  ].map(require.resolve),
20
- "rules": {}
20
+ "rules": {},
21
+ "overrides": [ // Overrides for test files
22
+ {
23
+ "files": ["**/?(*.)+(spec).[jt]s?(x)"],
24
+ "extends": [
25
+ "./rules/jasmine.js",
26
+ "./rules/jest.js"
27
+ ].map(require.resolve),
28
+ "rules": {
29
+ "@typescript-eslint/unbound-method": "off",
30
+ }
31
+ }
32
+ ],
21
33
  };
package/typescript-web.js CHANGED
@@ -11,6 +11,7 @@ module.exports = {
11
11
  "extends": [
12
12
  "./rules/deprecation.js",
13
13
  // "./rules/eslint.js", -> commented out since "typescript-eslint" rules inherit from this
14
+ "./rules/eslint-comments.js",
14
15
  "./rules/import-typescript.js",
15
16
  "./rules/jsdoc-typescript.js",
16
17
  "./rules/typescript-eslint.js",