@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.
package/README.md CHANGED
@@ -1,15 +1,16 @@
1
1
  # @josundt/eslint-config #
2
2
 
3
- ESLint ruleset including required ESLint plugins for josundt TypeScript projects
3
+ ESLint ruleset including required ESLint plugins for jorundt TypeScript projects
4
4
 
5
5
  ## Usage ##
6
+ 1. Make sure you have installed and configured `@josundt/prettier-config` first
6
7
 
7
- 1. Install this package
8
+ 2. Install this package
8
9
  ```bash
9
10
  npm install @josundt/eslint-config
10
11
  ```
11
12
 
12
- 2. Create an `.eslintrc` file in the root directory of your project with the following content:
13
+ 3. Create an `.eslintrc` file in the root directory of your project with the following content:
13
14
  ```javascript
14
15
  {
15
16
  "extends": ["@josundt"]
@@ -25,7 +26,7 @@ ESLint ruleset including required ESLint plugins for josundt TypeScript projects
25
26
  * `["@josundt/eslint-config/typescript-node"]` (same as default; but without __browser__ environment and __jasmine__ linting support) .
26
27
 
27
28
 
28
- 3. Add `lint:ts` script to your project's package.json file:
29
+ 4. Add `lint:ts` script to your project's package.json file:
29
30
  ```javascript
30
31
  {
31
32
  // ...
@@ -38,12 +39,12 @@ ESLint ruleset including required ESLint plugins for josundt TypeScript projects
38
39
  }
39
40
  ```
40
41
 
41
- 4. Test the script:
42
+ 5. Test the script:
42
43
  ```bash
43
44
  npm run lint:ts
44
45
  ```
45
46
 
46
- 5. Live Code Analysis in Visual Studio Code:
47
+ 6. Live Code Analysis in Visual Studio Code:
47
48
  - Add a `.eslintignore` file in the root directory of your project with the following content:
48
49
  ```text
49
50
  # Ignore js files; only analyze typescript files:
@@ -2,10 +2,10 @@
2
2
  // https://medium.com/@jose_82797/how-to-import-eslint-issues-into-sonarqube-overview-analysis-in-a-frontend-application-b8e8946b8104
3
3
  // https://eslint.org/docs/latest/developer-guide/working-with-custom-formatters#working-with-custom-formatters
4
4
 
5
- module.exports = function(results) {
6
- var summary = {issues: []};
7
- results.forEach(function(result) {
8
- result.messages.forEach(function(msg) {
5
+ module.exports = function (results) {
6
+ var summary = { issues: [] };
7
+ results.forEach(function (result) {
8
+ result.messages.forEach(function (msg) {
9
9
  var logMessage = {
10
10
  engineId: "eslint",
11
11
  ruleId: msg.ruleId,
@@ -15,9 +15,9 @@ module.exports = function(results) {
15
15
  textRange: {
16
16
  startLine: msg.line,
17
17
  endLine: msg.endLine,
18
- endColumn: msg.endColumn
19
- }
20
- }
18
+ endColumn: msg.endColumn,
19
+ },
20
+ },
21
21
  };
22
22
 
23
23
  // The log message type and severity is up to you but you need to take in consideration SonarQube properties
@@ -27,7 +27,7 @@ module.exports = function(results) {
27
27
  }
28
28
  if (msg.severity === 2) {
29
29
  logMessage.type = "BUG";
30
- logMessage.severity="MAJOR";
30
+ logMessage.severity = "MAJOR";
31
31
  }
32
32
  summary.issues.push(logMessage);
33
33
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@josundt/eslint-config",
3
- "version": "5.0.4",
3
+ "version": "5.2.1",
4
4
  "description": "ESLint ruleset with required plugins for josundt TypeScript projects",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -30,17 +30,19 @@
30
30
  "typescript": ">=5.0.4"
31
31
  },
32
32
  "dependencies": {
33
- "@typescript-eslint/eslint-plugin": "5.58.0",
34
- "@typescript-eslint/parser": "5.58.0",
35
- "eslint": "8.38.0",
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",
36
37
  "eslint-import-resolver-typescript": "3.5.5",
37
38
  "eslint-plugin-deprecation": "1.4.1",
38
39
  "eslint-plugin-eslint-comments": "3.2.0",
39
40
  "eslint-plugin-import": "2.27.5",
40
41
  "eslint-plugin-jasmine": "4.1.3",
41
42
  "eslint-plugin-jest": "27.2.1",
42
- "eslint-plugin-jsdoc": "40.3.0",
43
+ "eslint-plugin-jsdoc": "44.0.2",
43
44
  "eslint-plugin-no-lookahead-lookbehind-regexp": "0.1.0",
44
- "eslint-plugin-unicorn": "46.0.0"
45
+ "eslint-plugin-prettier": "4.2.1",
46
+ "eslint-plugin-unicorn": "47.0.0"
45
47
  }
46
48
  }
@@ -1,8 +1,6 @@
1
1
  module.exports = {
2
- "plugins": [
3
- "deprecation"
4
- ],
5
- "rules": {
2
+ plugins: ["deprecation"],
3
+ rules: {
6
4
  "deprecation/deprecation": "error"
7
5
  }
8
6
  };
@@ -1,8 +1,6 @@
1
1
  module.exports = {
2
- "plugins": [
3
- "eslint-plugin-eslint-comments"
4
- ],
5
- "rules": {
2
+ plugins: ["eslint-plugin-eslint-comments"],
3
+ rules: {
6
4
  "eslint-comments/disable-enable-pair": "warn",
7
5
  "eslint-comments/no-aggregating-enable": "warn",
8
6
  "eslint-comments/no-duplicate-disable": "warn",
package/rules/eslint.js CHANGED
@@ -1,103 +1,10 @@
1
1
  module.exports = {
2
- "extends": [
3
- "eslint:recommended"
4
- ],
5
- "rules": {
6
-
7
- // ================== Formatting rules ==================
8
-
9
- "arrow-spacing": ["error", { "before": true, "after": true }],
10
- "block-spacing": "off",
11
- "brace-style": ["error", "1tbs"],
12
- "comma-dangle": "off",
13
- "comma-spacing": ["error", {"before": false, "after": true }],
14
- "comma-style": ["error", "last"],
15
- "computed-property-spacing": ["error", "never"],
16
- "func-call-spacing": ["error", "never"],
17
- "function-call-argument-newline": ["warn", "consistent"],
18
- "function-paren-newline": ["warn", "multiline-arguments"],
19
- "indent": [
20
- "warn",
21
- 4,
22
- {
23
- "ObjectExpression": "first",
24
- "FunctionDeclaration": {
25
- "parameters": "first"
26
- },
27
- "FunctionExpression": {
28
- "parameters": "first"
29
- },
30
- "SwitchCase": 1,
31
-
32
- // Fix to decorator indentation problem
33
- "ignoredNodes": [
34
- "FunctionExpression > .params[decorators.length > 0]",
35
- "FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
36
- "ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
37
- ]
38
- }
39
- ],
40
- "key-spacing": ["error", { "beforeColon": false, "afterColon": true, "mode": "strict" }],
41
- "keyword-spacing": "error",
42
- "lines-arround-comment": "off",
43
- "lines-between-class-members": "off",
44
- "member-delimiter-style": "off",
45
- "no-extra-parens": "off",
46
- "no-multi-spaces": "warn",
47
- "no-multiple-empty-lines": "warn",
48
- "object-curly-newline": ["warn", { "consistent": true }],
49
- "object-curly-spacing": ["error", "always"],
50
- "object-property-newline": ["warn", { "allowAllPropertiesOnSameLine": true }],
51
- "padding-line-between-statements": [
52
- "error",
53
- { "blankLine": "always", "prev": ["directive", "import"], "next": "*" },
54
- { "blankLine": "any", "prev": ["directive", "import"], "next": ["directive", "import"] },
55
-
56
- { "blankLine": "always", "prev": "*", "next": ["export", "class", "function", "iife"] },
57
- { "blankLine": "always", "prev": ["export", "class", "function", "iife"], "next": "*" },
58
-
59
- // { "blankLine": "always", "prev": "*", "next": "return" }, // Newline before return
60
-
61
- // { "blankLine": "always", "prev": "*", "next": "multiline-block-like" }, // Newline BEFORE multiline block
62
- // { "blankLine": "always", "prev": "multiline-block-like", "next": "*" } // Newline AFTER multiline block
63
- ],
64
- "quotes": [
65
- "error",
66
- "double"
67
- ],
68
- "rest-spread-spacing": ["error", "never"],
69
- "semi": [
70
- "error",
71
- "always"
72
- ],
73
- "semi-spacing": ["error", {"before": false, "after": true}],
74
- "semi-style": ["error", "last"],
75
- "space-before-blocks": [
76
- "warn",
77
- "always"
78
- ],
79
- "space-before-function-paren": [
80
- "warn",
81
- {
82
- "anonymous": "always",
83
- "asyncArrow": "always",
84
- "named": "never"
85
- }
86
- ],
87
- "space-in-parens": [
88
- "warn",
89
- "never"
90
- ],
91
- "space-infix-ops": "warn",
92
- "switch-colon-spacing": ["error", {"after": true, "before": false}],
93
- "template-curly-spacing": ["error", "never"],
94
-
95
- // =================== Other rules ===================
96
-
2
+ extends: ["eslint:recommended"],
3
+ rules: {
97
4
  "arrow-body-style": "error",
98
5
  "arrow-parens": ["error", "as-needed"],
99
6
  "class-methods-use-this": "off", // Warn when methods could be static
100
- "complexity": ["warn", { "max": 20 }],
7
+ "complexity": ["warn", { max: 20 }],
101
8
  "curly": "error",
102
9
  "default-case-last": "error",
103
10
  "default-param-last": "error",
@@ -121,17 +28,11 @@ module.exports = {
121
28
  ],
122
29
  "id-match": "error",
123
30
  "max-classes-per-file": ["off", 5],
124
- "max-depth": ["warn", { "max": 5 }], // default 4
125
- "max-params": ["off", { "max": 6 }], // default 3 - SWITCHED OFF - does not work well with constructor injection
126
- "max-statements-per-line": ["warn", { "max": 1 }], // default 1
127
- "max-statements": ["warn", { "max": 100 }], // default 50
128
- "max-len": [
129
- "warn",
130
- {
131
- "ignorePattern": "^import |^\\s*\\/\\/ |^\\s*\\/\\*\\*",
132
- "code": 180
133
- }
134
- ],
31
+ "max-depth": ["warn", { max: 5 }], // default 4
32
+ "max-params": ["off", { max: 6 }], // default 3 - SWITCHED OFF - does not work well with constructor injection
33
+ "max-statements-per-line": ["warn", { max: 1 }], // default 1
34
+ "max-statements": ["warn", { max: 100 }], // default 50
35
+ "max-len": "off",
135
36
  "max-lines": ["off", 2000],
136
37
  "new-parens": "error",
137
38
  "no-array-constructor": "error",
@@ -140,13 +41,16 @@ module.exports = {
140
41
  "no-console": "error",
141
42
  "no-constant-binary-expression": "error",
142
43
  "no-duplicate-imports": "error",
143
- "no-empty-function": ["error", {
144
- //allow: [/*"functions", "arrowFunctions", "generatorFunctions", "methods", "generatorMethods", "getters", "setters", "constructors", "asyncFunctions", "asyncMethods"*/]
145
- }],
44
+ "no-empty-function": [
45
+ "error",
46
+ {
47
+ //allow: [/*"functions", "arrowFunctions", "generatorFunctions", "methods", "generatorMethods", "getters", "setters", "constructors", "asyncFunctions", "asyncMethods"*/]
48
+ }
49
+ ],
146
50
  "no-empty-static-block": "error",
147
51
  "no-eval": "error",
148
52
  "no-extra-bind": "error",
149
- "no-implicit-coercion": ["error", { "allow": ["!!"] }],
53
+ "no-implicit-coercion": ["error", { allow: ["!!"] }],
150
54
  "no-implied-eval": "error",
151
55
  "no-inner-declarations": "off", // Switched off from recommended rules, gave too many issues
152
56
  "no-invalid-this": "error",
@@ -157,9 +61,12 @@ module.exports = {
157
61
  "no-new-wrappers": "error",
158
62
  "no-octal-escape": "error",
159
63
  "no-redeclare": "error",
160
- "no-restricted-imports": ["off", {
161
- "paths": []
162
- }],
64
+ "no-restricted-imports": [
65
+ "off",
66
+ {
67
+ paths: []
68
+ }
69
+ ],
163
70
  "no-restricted-syntax": [
164
71
  "off", // Below - rules to require Async suffix on async methods - not good enough
165
72
  // {
@@ -167,33 +74,37 @@ module.exports = {
167
74
  // "message": "Function ending in 'Async' must be declared async"
168
75
  // },
169
76
  {
170
- "selector": "FunctionDeclaration[async=true][id.name!=/Async$/][id.name!=/^(configure)$/]",
171
- "message": "Async function name must end in 'Async'"
77
+ selector:
78
+ "FunctionDeclaration[async=true][id.name!=/Async$/][id.name!=/^(configure)$/]",
79
+ message: "Async function name must end in 'Async'"
172
80
  },
173
81
  // {
174
82
  // "selector": "MethodDefinition[value.async=false][key.name=/Async$/]",
175
83
  // "message": "Method ending in 'Async' must be declared async"
176
84
  // },
177
85
  {
178
- "selector": "MethodDefinition[value.async=true][key.name!=/Async$/][key.name!=/^(activate|deactivate|canActivate|canDeactivate|attached|bind)$/]",
179
- "message": "Async method name must end in 'Async'"
86
+ selector:
87
+ "MethodDefinition[value.async=true][key.name!=/Async$/][key.name!=/^(activate|deactivate|canActivate|canDeactivate|attached|bind)$/]",
88
+ message: "Async method name must end in 'Async'"
180
89
  },
181
90
  // {
182
91
  // "selector": "Property[value.type=/FunctionExpression$/][value.async=false][key.name=/Async$/]",
183
92
  // "message": "Function ending in 'Async' must be declared async"
184
93
  // },
185
94
  {
186
- "selector": "Property[value.type=/FunctionExpression$/][value.async=true][key.name!=/Async$/]",
187
- "message": "Async function name must end in 'Async'"
95
+ selector:
96
+ "Property[value.type=/FunctionExpression$/][value.async=true][key.name!=/Async$/]",
97
+ message: "Async function name must end in 'Async'"
188
98
  },
189
99
  // {
190
100
  // "selector": "VariableDeclarator[init.type=/FunctionExpression$/][init.async=false][id.name=/Async$/]",
191
101
  // "message": "Function ending in 'Async' must be declared async"
192
102
  // },
193
103
  {
194
- "selector": "VariableDeclarator[init.type=/FunctionExpression$/][init.async=true][id.name!=/Async$/]",
195
- "message": "Async function name must end in 'Async'"
196
- },
104
+ selector:
105
+ "VariableDeclarator[init.type=/FunctionExpression$/][init.async=true][id.name!=/Async$/]",
106
+ message: "Async function name must end in 'Async'"
107
+ }
197
108
  // "ForInStatement"
198
109
  ],
199
110
  "no-return-await": "error",
@@ -201,10 +112,10 @@ module.exports = {
201
112
  "no-shadow": [
202
113
  "error",
203
114
  {
204
- "hoist": "all",
205
- "builtinGlobals": false,
206
- "ignoreOnInitialization": false,
207
- "allow": [] // array of identifier names for which shadowing is allowed
115
+ hoist: "all",
116
+ builtinGlobals: false,
117
+ ignoreOnInitialization: false,
118
+ allow: [] // array of identifier names for which shadowing is allowed
208
119
  }
209
120
  ],
210
121
  "no-template-curly-in-string": "error",
@@ -214,7 +125,7 @@ module.exports = {
214
125
  "no-unneeded-ternary": [
215
126
  "error",
216
127
  {
217
- "defaultAssignment": true
128
+ defaultAssignment: true
218
129
  }
219
130
  ],
220
131
  "no-unused-expressions": "error",
@@ -222,34 +133,25 @@ module.exports = {
222
133
  "no-unused-vars": [
223
134
  "error",
224
135
  {
225
- "vars": "all",
226
- "args": "none",
227
- "destructuredArrayIgnorePattern": "^_"
136
+ vars: "all",
137
+ args: "none",
138
+ destructuredArrayIgnorePattern: "^_"
228
139
  }
229
140
  ],
230
141
  "no-use-before-define": "error",
231
142
  "no-useless-constructor": "error",
232
143
  "no-var": "error",
233
144
  "no-void": "error",
234
- "no-warning-comments": ["warn", { "terms": ["todo"] }],
235
- "object-shorthand": [
236
- "error",
237
- "never"
238
- ],
239
- "one-var": [
240
- "error",
241
- "never"
242
- ],
145
+ "no-warning-comments": ["warn", { terms: ["todo"] }],
146
+ "object-shorthand": ["error", "never"],
147
+ "one-var": ["error", "never"],
243
148
  "prefer-arrow-callback": "error",
244
149
  "prefer-const": "error",
245
150
  "prefer-exponentiation-operator": "error",
246
151
  "prefer-object-spread": "error",
247
152
  "prefer-promise-reject-errors": "error",
248
153
  "prefer-template": "error",
249
- "quote-props": [
250
- "error",
251
- "consistent-as-needed"
252
- ],
154
+ "quote-props": ["error", "consistent-as-needed"],
253
155
  "radix": "error",
254
156
  "require-await": "error",
255
157
  "require-unicode-regexp": "error",
@@ -1,12 +1,9 @@
1
1
  module.exports = {
2
- "extends": [
3
- "plugin:import/typescript"
4
- ],
5
- "plugins": [
6
- "import"
7
- ],
8
- "rules": {
9
- "import/extensions": [ // Ensure all local .ts file imports use .js extension
2
+ extends: ["plugin:import/typescript"],
3
+ plugins: ["import"],
4
+ rules: {
5
+ "import/extensions": [
6
+ // Ensure all local .ts file imports use .js extension
10
7
  "error",
11
8
  "ignorePackages"
12
9
  ],
@@ -1,8 +1,6 @@
1
1
  module.exports = {
2
- "extends": [
3
- "./import-typescript-node.js"
4
- ],
5
- "rules": {
2
+ extends: ["./import-typescript-node.js"],
3
+ rules: {
6
4
  "import/no-nodejs-modules": "error" // Disallowed: import * as path from "path"; Allowed: import * as path from "node:path";
7
5
  }
8
6
  };
package/rules/jasmine.js CHANGED
@@ -1,22 +1,14 @@
1
1
  module.exports = {
2
- "extends": [
3
- "plugin:jasmine/recommended"
4
- ],
5
- "env": {
6
- "jasmine": true
2
+ extends: ["plugin:jasmine/recommended"],
3
+ env: {
4
+ jasmine: true
7
5
  },
8
- "plugins": [
9
- "jasmine"
10
- ],
11
- "rules": {
12
- "jasmine/no-suite-dupes": [
13
- "error",
14
- "branch"
15
- ],
16
- "jasmine/no-spec-dupes": [
17
- "error",
18
- "branch"
19
- ],
20
- "jasmine/no-describe-variables": "error"
6
+ plugins: ["jasmine"],
7
+ rules: {
8
+ "jasmine/no-suite-dupes": ["error", "branch"],
9
+ "jasmine/no-spec-dupes": ["error", "branch"],
10
+ "jasmine/no-describe-variables": "error",
11
+ "jasmine/new-line-between-declarations": "off", // formatting rule conflicting with formatters (e.g. prettier)
12
+ "jasmine/new-line-before-expect": "off" // formatting rule conflicting with formatters (e.g. prettier)
21
13
  }
22
14
  };
package/rules/jest.js CHANGED
@@ -1,14 +1,10 @@
1
1
  module.exports = {
2
- "extends": [
3
- "plugin:jest/recommended"
4
- ],
5
- "env": {
2
+ extends: ["plugin:jest/recommended"],
3
+ env: {
6
4
  "jest/globals": true
7
5
  },
8
- "plugins": [
9
- "jest"
10
- ],
11
- "rules": {
6
+ plugins: ["jest"],
7
+ rules: {
12
8
  "jest/unbound-method": "error"
13
9
  }
14
10
  };
@@ -1,22 +1,19 @@
1
1
  module.exports = {
2
- "extends": [
3
- "plugin:jsdoc/recommended"
4
- ],
5
- "plugins": [
6
- "jsdoc"
7
- ],
8
- "settings": {
9
- "jsdoc": {
10
- "mode": "typescript",
11
- "tagNamePreference": {
12
- "augments": {
13
- "message": "@extends is to be used over @augments as it is more evocative of classes than @augments",
14
- "replacement": "extends"
2
+ extends: ["plugin:jsdoc/recommended"],
3
+ plugins: ["jsdoc"],
4
+ settings: {
5
+ jsdoc: {
6
+ mode: "typescript",
7
+ tagNamePreference: {
8
+ augments: {
9
+ message:
10
+ "@extends is to be used over @augments as it is more evocative of classes than @augments",
11
+ replacement: "extends"
15
12
  }
16
13
  }
17
14
  }
18
15
  },
19
- "rules": {
16
+ rules: {
20
17
  "jsdoc/require-jsdoc": "off",
21
18
  "jsdoc/no-types": "error",
22
19
  "jsdoc/require-param-type": "off",
@@ -26,7 +23,7 @@ module.exports = {
26
23
  "jsdoc/check-tag-names": [
27
24
  "warn",
28
25
  {
29
- "definedTags": [
26
+ definedTags: [
30
27
  "internal",
31
28
  "constructor",
32
29
  "export",
@@ -1,8 +1,6 @@
1
1
  module.exports = {
2
- "plugins": [
3
- "no-lookahead-lookbehind-regexp",
4
- ],
5
- "rules": {
2
+ plugins: ["no-lookahead-lookbehind-regexp"],
3
+ rules: {
6
4
  "no-lookahead-lookbehind-regexp/no-lookahead-lookbehind-regexp": [
7
5
  "error",
8
6
  "no-lookahead",
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ plugins: ["prettier"],
3
+ rules: {
4
+ "prettier/prettier": "error"
5
+ }
6
+ };