@josundt/eslint-config 4.9.7 → 5.2.0

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": "4.9.7",
3
+ "version": "5.2.0",
4
4
  "description": "ESLint ruleset with required plugins for josundt TypeScript projects",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -27,19 +27,22 @@
27
27
  "utils/**/*.js"
28
28
  ],
29
29
  "peerDependencies": {
30
- "typescript": ">=4.9.3"
30
+ "typescript": ">=5.0.4"
31
31
  },
32
32
  "dependencies": {
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",
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",
38
39
  "eslint-plugin-eslint-comments": "3.2.0",
39
- "eslint-plugin-import": "2.26.0",
40
+ "eslint-plugin-import": "2.27.5",
40
41
  "eslint-plugin-jasmine": "4.1.3",
41
- "eslint-plugin-jest": "27.1.6",
42
- "eslint-plugin-jsdoc": "39.6.4",
43
- "eslint-plugin-unicorn": "45.0.1"
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"
44
47
  }
45
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,25 +1,15 @@
1
1
  module.exports = {
2
- "extends": [
3
- "eslint:recommended"
4
- ],
5
- "rules": {
2
+ extends: ["eslint:recommended"],
3
+ rules: {
6
4
  "arrow-body-style": "error",
7
5
  "arrow-parens": ["error", "as-needed"],
8
- "arrow-spacing": ["error", { "before": true, "after": true }],
9
- "brace-style": ["error", "1tbs"],
10
6
  "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 }],
7
+ "complexity": ["warn", { max: 20 }],
15
8
  "curly": "error",
16
9
  "default-case-last": "error",
17
10
  "default-param-last": "error",
18
11
  "dot-location": ["error", "property"],
19
12
  "eqeqeq": ["error", "always"],
20
- "func-call-spacing": ["error", "never"],
21
- "function-call-argument-newline": ["warn", "consistent"],
22
- "function-paren-newline": ["warn", "multiline-arguments"],
23
13
  "guard-for-in": "error",
24
14
  "grouped-accessor-pairs": "error",
25
15
  "handle-callback-err": "error",
@@ -37,41 +27,12 @@ module.exports = {
37
27
  //"undefined"
38
28
  ],
39
29
  "id-match": "error",
40
- "indent": [
41
- "warn",
42
- 4,
43
- {
44
- "ObjectExpression": "first",
45
- "FunctionDeclaration": {
46
- "parameters": "first"
47
- },
48
- "FunctionExpression": {
49
- "parameters": "first"
50
- },
51
- "SwitchCase": 1,
52
-
53
- // Fix to decorator indentation problem
54
- "ignoredNodes": [
55
- "FunctionExpression > .params[decorators.length > 0]",
56
- "FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
57
- "ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
58
- ]
59
- }
60
- ],
61
- "key-spacing": ["error", { "beforeColon": false, "afterColon": true, "mode": "strict" }],
62
- "keyword-spacing": "error",
63
30
  "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
68
- "max-len": [
69
- "warn",
70
- {
71
- "ignorePattern": "^import |^\\s*\\/\\/ |^\\s*\\/\\*\\*",
72
- "code": 180
73
- }
74
- ],
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",
75
36
  "max-lines": ["off", 2000],
76
37
  "new-parens": "error",
77
38
  "no-array-constructor": "error",
@@ -80,24 +41,32 @@ module.exports = {
80
41
  "no-console": "error",
81
42
  "no-constant-binary-expression": "error",
82
43
  "no-duplicate-imports": "error",
83
- "no-empty-function": ["error", {
84
- //allow: [/*"functions", "arrowFunctions", "generatorFunctions", "methods", "generatorMethods", "getters", "setters", "constructors", "asyncFunctions", "asyncMethods"*/]
85
- }],
44
+ "no-empty-function": [
45
+ "error",
46
+ {
47
+ //allow: [/*"functions", "arrowFunctions", "generatorFunctions", "methods", "generatorMethods", "getters", "setters", "constructors", "asyncFunctions", "asyncMethods"*/]
48
+ }
49
+ ],
86
50
  "no-empty-static-block": "error",
87
51
  "no-eval": "error",
88
52
  "no-extra-bind": "error",
89
- "no-implicit-coercion": ["error", { "allow": ["!!"] }],
53
+ "no-implicit-coercion": ["error", { allow: ["!!"] }],
90
54
  "no-implied-eval": "error",
91
55
  "no-inner-declarations": "off", // Switched off from recommended rules, gave too many issues
92
56
  "no-invalid-this": "error",
93
- "no-multi-spaces": "warn",
94
57
  "no-multi-str": "error",
95
58
  "no-lone-blocks": "error",
96
59
  "no-lonely-if": "error",
97
- "no-multiple-empty-lines": "warn",
98
60
  "no-new-func": "error",
99
61
  "no-new-wrappers": "error",
100
62
  "no-octal-escape": "error",
63
+ "no-redeclare": "error",
64
+ "no-restricted-imports": [
65
+ "off",
66
+ {
67
+ paths: []
68
+ }
69
+ ],
101
70
  "no-restricted-syntax": [
102
71
  "off", // Below - rules to require Async suffix on async methods - not good enough
103
72
  // {
@@ -105,33 +74,37 @@ module.exports = {
105
74
  // "message": "Function ending in 'Async' must be declared async"
106
75
  // },
107
76
  {
108
- "selector": "FunctionDeclaration[async=true][id.name!=/Async$/][id.name!=/^(configure)$/]",
109
- "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'"
110
80
  },
111
81
  // {
112
82
  // "selector": "MethodDefinition[value.async=false][key.name=/Async$/]",
113
83
  // "message": "Method ending in 'Async' must be declared async"
114
84
  // },
115
85
  {
116
- "selector": "MethodDefinition[value.async=true][key.name!=/Async$/][key.name!=/^(activate|deactivate|canActivate|canDeactivate|attached|bind)$/]",
117
- "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'"
118
89
  },
119
90
  // {
120
91
  // "selector": "Property[value.type=/FunctionExpression$/][value.async=false][key.name=/Async$/]",
121
92
  // "message": "Function ending in 'Async' must be declared async"
122
93
  // },
123
94
  {
124
- "selector": "Property[value.type=/FunctionExpression$/][value.async=true][key.name!=/Async$/]",
125
- "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'"
126
98
  },
127
99
  // {
128
100
  // "selector": "VariableDeclarator[init.type=/FunctionExpression$/][init.async=false][id.name=/Async$/]",
129
101
  // "message": "Function ending in 'Async' must be declared async"
130
102
  // },
131
103
  {
132
- "selector": "VariableDeclarator[init.type=/FunctionExpression$/][init.async=true][id.name!=/Async$/]",
133
- "message": "Async function name must end in 'Async'"
134
- },
104
+ selector:
105
+ "VariableDeclarator[init.type=/FunctionExpression$/][init.async=true][id.name!=/Async$/]",
106
+ message: "Async function name must end in 'Async'"
107
+ }
135
108
  // "ForInStatement"
136
109
  ],
137
110
  "no-return-await": "error",
@@ -139,10 +112,10 @@ module.exports = {
139
112
  "no-shadow": [
140
113
  "error",
141
114
  {
142
- "hoist": "all",
143
- "builtinGlobals": false,
144
- "ignoreOnInitialization": false,
145
- "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
146
119
  }
147
120
  ],
148
121
  "no-template-curly-in-string": "error",
@@ -152,7 +125,7 @@ module.exports = {
152
125
  "no-unneeded-ternary": [
153
126
  "error",
154
127
  {
155
- "defaultAssignment": true
128
+ defaultAssignment: true
156
129
  }
157
130
  ],
158
131
  "no-unused-expressions": "error",
@@ -160,84 +133,29 @@ module.exports = {
160
133
  "no-unused-vars": [
161
134
  "error",
162
135
  {
163
- "vars": "all",
164
- "args": "none",
165
- "destructuredArrayIgnorePattern": "^_"
136
+ vars: "all",
137
+ args: "none",
138
+ destructuredArrayIgnorePattern: "^_"
166
139
  }
167
140
  ],
168
141
  "no-use-before-define": "error",
169
142
  "no-useless-constructor": "error",
170
143
  "no-var": "error",
171
144
  "no-void": "error",
172
- "no-warning-comments": ["warn", { "terms": ["todo"] }],
173
- "object-curly-newline": ["warn", { "consistent": true }],
174
- "object-curly-spacing": ["error", "always"],
175
- "object-property-newline": ["warn", { "allowAllPropertiesOnSameLine": true }],
176
- "object-shorthand": [
177
- "error",
178
- "never"
179
- ],
180
- "one-var": [
181
- "error",
182
- "never"
183
- ],
184
- "padding-line-between-statements": [
185
- "error",
186
- { "blankLine": "always", "prev": ["directive", "import"], "next": "*" },
187
- { "blankLine": "any", "prev": ["directive", "import"], "next": ["directive", "import"] },
188
-
189
- { "blankLine": "always", "prev": "*", "next": ["export", "class", "function", "iife"] },
190
- { "blankLine": "always", "prev": ["export", "class", "function", "iife"], "next": "*" },
191
-
192
- // { "blankLine": "always", "prev": "*", "next": "return" }, // Newline before return
193
-
194
- // { "blankLine": "always", "prev": "*", "next": "multiline-block-like" }, // Newline BEFORE multiline block
195
- // { "blankLine": "always", "prev": "multiline-block-like", "next": "*" } // Newline AFTER multiline block
196
- ],
145
+ "no-warning-comments": ["warn", { terms: ["todo"] }],
146
+ "object-shorthand": ["error", "never"],
147
+ "one-var": ["error", "never"],
197
148
  "prefer-arrow-callback": "error",
198
149
  "prefer-const": "error",
199
150
  "prefer-exponentiation-operator": "error",
200
151
  "prefer-object-spread": "error",
201
152
  "prefer-promise-reject-errors": "error",
202
153
  "prefer-template": "error",
203
- "quotes": [
204
- "error",
205
- "double"
206
- ],
207
- "quote-props": [
208
- "error",
209
- "consistent-as-needed"
210
- ],
154
+ "quote-props": ["error", "consistent-as-needed"],
211
155
  "radix": "error",
212
156
  "require-await": "error",
213
157
  "require-unicode-regexp": "error",
214
- "rest-spread-spacing": ["error", "never"],
215
158
  "return-await": "error",
216
- "semi": [
217
- "error",
218
- "always"
219
- ],
220
- "semi-spacing": ["error", {"before": false, "after": true}],
221
- "semi-style": ["error", "last"],
222
- "space-before-blocks": [
223
- "warn",
224
- "always"
225
- ],
226
- "space-before-function-paren": [
227
- "warn",
228
- {
229
- "anonymous": "always",
230
- "asyncArrow": "always",
231
- "named": "never"
232
- }
233
- ],
234
- "space-in-parens": [
235
- "warn",
236
- "never"
237
- ],
238
- "space-infix-ops": "warn",
239
- "switch-colon-spacing": ["error", {"after": true, "before": false}],
240
- "template-curly-spacing": ["error", "never"],
241
159
  "unicode-bom": ["error", "never"],
242
160
  "yoda": "error"
243
161
  }
@@ -1,22 +1,19 @@
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
  ],
13
10
  "import/no-commonjs": "error", // Disallow require() syntax - only esm syntax allowed
14
- "import/no-nodejs-modules": "error", // Disallowed: import * as path from "path"; Allowed: import * as path from "node:path";
15
11
  "import/no-default-export": "off",
16
12
  "import/no-deprecated": "error",
17
13
  "import/no-duplicates": "error",
18
14
  "import/no-extraneous-dependencies": "off",
19
15
  "import/no-internal-modules": "off",
16
+ "import/no-nodejs-modules": "off",
20
17
  "import/no-unassigned-import": "error",
21
18
  "import/order": "off"
22
19
  }
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ extends: ["./import-typescript-node.js"],
3
+ rules: {
4
+ "import/no-nodejs-modules": "error" // Disallowed: import * as path from "path"; Allowed: import * as path from "node:path";
5
+ }
6
+ };
package/rules/jasmine.js CHANGED
@@ -1,22 +1,12 @@
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
- ],
6
+ plugins: ["jasmine"],
7
+ rules: {
8
+ "jasmine/no-suite-dupes": ["error", "branch"],
9
+ "jasmine/no-spec-dupes": ["error", "branch"],
20
10
  "jasmine/no-describe-variables": "error"
21
11
  }
22
12
  };
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",
@@ -0,0 +1,12 @@
1
+ module.exports = {
2
+ plugins: ["no-lookahead-lookbehind-regexp"],
3
+ rules: {
4
+ "no-lookahead-lookbehind-regexp/no-lookahead-lookbehind-regexp": [
5
+ "error",
6
+ "no-lookahead",
7
+ "no-lookbehind",
8
+ "no-negative-lookahead",
9
+ "no-negative-lookbehind"
10
+ ]
11
+ }
12
+ };
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ plugins: ["prettier"],
3
+ rules: {
4
+ "prettier/prettier": "error"
5
+ }
6
+ };