@josundt/eslint-config 4.8.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.8.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.8.2"
30
+ "typescript": ">=4.9.3"
31
31
  },
32
32
  "dependencies": {
33
- "@typescript-eslint/eslint-plugin": "5.36.1",
34
- "@typescript-eslint/parser": "5.36.1",
35
- "eslint": "8.23.0",
36
- "eslint-import-resolver-typescript": "3.5.0",
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.6",
41
- "eslint-plugin-unicorn": "43.0.2"
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,26 +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",
223
- {
224
- "allowAfterThis": true
225
- }
226
- ],
227
152
  "no-unneeded-ternary": [
228
153
  "error",
229
154
  {
230
155
  "defaultAssignment": true
231
156
  }
232
157
  ],
233
- "no-unsafe-finally": "error",
234
- "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
235
- "no-unused-labels": "error",
158
+ "no-unused-expressions": "error",
159
+ "no-unused-private-class-members": "error",
236
160
  "no-unused-vars": [
237
161
  "error",
238
162
  {
@@ -245,7 +169,10 @@ module.exports = {
245
169
  "no-useless-constructor": "error",
246
170
  "no-var": "error",
247
171
  "no-void": "error",
172
+ "no-warning-comments": ["warn", { "terms": ["todo"] }],
173
+ "object-curly-newline": ["warn", { "consistent": true }],
248
174
  "object-curly-spacing": ["error", "always"],
175
+ "object-property-newline": ["warn", { "allowAllPropertiesOnSameLine": true }],
249
176
  "object-shorthand": [
250
177
  "error",
251
178
  "never"
@@ -269,7 +196,9 @@ module.exports = {
269
196
  ],
270
197
  "prefer-arrow-callback": "error",
271
198
  "prefer-const": "error",
199
+ "prefer-exponentiation-operator": "error",
272
200
  "prefer-object-spread": "error",
201
+ "prefer-promise-reject-errors": "error",
273
202
  "prefer-template": "error",
274
203
  "quotes": [
275
204
  "error",
@@ -281,17 +210,21 @@ module.exports = {
281
210
  ],
282
211
  "radix": "error",
283
212
  "require-await": "error",
213
+ "require-unicode-regexp": "error",
214
+ "rest-spread-spacing": ["error", "never"],
284
215
  "return-await": "error",
285
216
  "semi": [
286
217
  "error",
287
218
  "always"
288
219
  ],
220
+ "semi-spacing": ["error", {"before": false, "after": true}],
221
+ "semi-style": ["error", "last"],
289
222
  "space-before-blocks": [
290
- "error",
223
+ "warn",
291
224
  "always"
292
225
  ],
293
226
  "space-before-function-paren": [
294
- "error",
227
+ "warn",
295
228
  {
296
229
  "anonymous": "always",
297
230
  "asyncArrow": "always",
@@ -299,13 +232,13 @@ module.exports = {
299
232
  }
300
233
  ],
301
234
  "space-in-parens": [
302
- "error",
235
+ "warn",
303
236
  "never"
304
237
  ],
305
- "space-infix-ops": "error",
306
- "spaced-comment": "off",
307
- "use-isnan": "error",
308
- "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"],
309
242
  "yoda": "error"
310
243
  }
311
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
+ };
@@ -364,7 +364,8 @@ module.exports = {
364
364
  "ignoreTernaryTests": true,
365
365
  "ignoreMixedLogicalExpressions": true
366
366
  }
367
- ], "@typescript-eslint/prefer-optional-chain": "error",
367
+ ],
368
+ "@typescript-eslint/prefer-optional-chain": "error",
368
369
  "@typescript-eslint/prefer-readonly": "error",
369
370
  "@typescript-eslint/prefer-readonly-parameter-types": "off", // Could be useful but requires too much work and verbose notation
370
371
  "@typescript-eslint/prefer-reduce-type-parameter": "error",
@@ -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",