eslint-config-beslogic 2.0.2 → 2.1.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/CHANGELOG.md +18 -1
- package/README.md +15 -11
- package/angular.js +28 -45
- package/lib/utils.js +19 -16
- package/package.json +12 -17
- package/typescript.js +24 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
- Bumped the following minimum versions:
|
|
6
|
+
- `@angular-eslint/eslint-plugin@>=16.2`
|
|
7
|
+
- `@angular-eslint/eslint-plugin-template@>=16.2`
|
|
8
|
+
- `@angular-eslint/template-parser@>=16.2`
|
|
9
|
+
- `@typescript-eslint/eslint-plugin@^6.2`
|
|
10
|
+
- `eslint-plugin-jest@^27.2.3`
|
|
11
|
+
- `eslint-plugin-unused-imports@^3.0`
|
|
12
|
+
- Assuming `node>=16`, `typescript>=4.5` and `@angular/compiler>=16.2.5`
|
|
13
|
+
- This should speedup config parsing that had to check for specific versions
|
|
14
|
+
- Made `eslint-plugin-total-functions` optional due to its extra-strictness and it had to be
|
|
15
|
+
explicitly specified anyway due to version resolution issues.
|
|
16
|
+
- Added link to changelog in README
|
|
17
|
+
- Improved detection of installed peer dependencies' version number to be more accurate and faster
|
|
18
|
+
|
|
3
19
|
## 2.0.2
|
|
4
20
|
|
|
5
21
|
- Disabled the following rules in Storybook stories:
|
|
@@ -12,4 +28,5 @@
|
|
|
12
28
|
|
|
13
29
|
- Created CHANGELOG.md
|
|
14
30
|
- Changed the maximum line length from `120` to `100`
|
|
15
|
-
- Split language-specific `editor.defaultFormatter` to work around
|
|
31
|
+
- Split language-specific `editor.defaultFormatter` to work around
|
|
32
|
+
<https://github.com/microsoft/vscode/issues/168411>
|
package/README.md
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
## Installation and usage
|
|
4
4
|
|
|
5
|
-
Run `npm i --save-dev eslint-config-beslogic
|
|
5
|
+
Run `npm i --save-dev eslint-config-beslogic`\
|
|
6
|
+
For extra strict TypeScript linting, you can also install [eslint-plugin-total-functions](https://www.npmjs.com/package/eslint-plugin-total-functions): `npm i --save-dev eslint-plugin-total-functions`\
|
|
7
|
+
The installation will be automatically detected and configured.
|
|
6
8
|
|
|
7
9
|
Depending on your needs, you will need to also install other peer dependencies for linting.
|
|
8
10
|
|
|
@@ -17,7 +19,7 @@ These are configuration files you'll have to update manually to best work with t
|
|
|
17
19
|
|
|
18
20
|
### `package.json`
|
|
19
21
|
|
|
20
|
-
Add the following `scripts
|
|
22
|
+
Add the following `scripts`:
|
|
21
23
|
|
|
22
24
|
```json
|
|
23
25
|
"scripts": {
|
|
@@ -25,11 +27,6 @@ Add the following `scripts` and `engines`:
|
|
|
25
27
|
"lint": "dprint check && npm run eslint",
|
|
26
28
|
"lint:fix": "dprint fmt && npm run eslint -- --fix"
|
|
27
29
|
},
|
|
28
|
-
"// node 16": "14 won't install peer deps properly + prefer EventTarget (only available node 16)",
|
|
29
|
-
"engines": {
|
|
30
|
-
"node": ">=16",
|
|
31
|
-
"npm": ">=8"
|
|
32
|
-
}
|
|
33
30
|
```
|
|
34
31
|
|
|
35
32
|
### Base `tsconfig.json`
|
|
@@ -110,10 +107,13 @@ Basic javascript configs, is extended by all other configs except `beslogic/type
|
|
|
110
107
|
|
|
111
108
|
### `beslogic/typescript`
|
|
112
109
|
|
|
113
|
-
Basic TypeScript-specific configs and `TSX` support, is extended by all other TypeScript exclusive configs. To avoid rules conflicts, it does **not** already extend from `beslogic/javascript`. So you should extend from both in a pure TypeScript project. You may also need to specify `parserOptions.project`. ie: `"parserOptions": { "project": ["tsconfig.json"] },` and `"parser": "@typescript-eslint/parser"
|
|
110
|
+
Basic TypeScript-specific configs and `TSX` support, is extended by all other TypeScript exclusive configs. To avoid rules conflicts, it does **not** already extend from `beslogic/javascript`. So you should extend from both in a pure TypeScript project. You may also need to specify `parserOptions.project`. ie: `"parserOptions": { "project": ["tsconfig.json"] },` and `"parser": "@typescript-eslint/parser"` if you reconfigure some rules yourself.
|
|
114
111
|
|
|
115
112
|
For the linting to be fully effective, please make sure that your base `tsconfig.json` extends `eslint-config-beslogic/tsconfig.X.X.json` (see [Parallel configurations](#parallel-configurations)).
|
|
116
113
|
|
|
114
|
+
For extra strict TypeScript linting, you can also install [eslint-plugin-total-functions](https://www.npmjs.com/package/eslint-plugin-total-functions): `npm i --save-dev eslint-plugin-total-functions`\
|
|
115
|
+
The installation will be automatically detected and configured.
|
|
116
|
+
|
|
117
117
|
### `beslogic/node-js`
|
|
118
118
|
|
|
119
119
|
Configurations for NodeJS backends.
|
|
@@ -131,7 +131,7 @@ Configurations for projects using RxJs. Already extends and `beslogic/typescript
|
|
|
131
131
|
Add the following `devDependencies` to your `package.json`:
|
|
132
132
|
|
|
133
133
|
```shell
|
|
134
|
-
npm install --save-dev eslint-plugin-rxjs
|
|
134
|
+
npm install --save-dev eslint-plugin-rxjs
|
|
135
135
|
```
|
|
136
136
|
|
|
137
137
|
### `beslogic/react`
|
|
@@ -171,7 +171,7 @@ npm install --save-dev eslint-plugin-react-redux eslint-plugin-jsx-a11y eslint-p
|
|
|
171
171
|
Add the following `devDependencies` to your `package.json`:
|
|
172
172
|
|
|
173
173
|
```shell
|
|
174
|
-
npm install --save-dev eslint-plugin-mui eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-redux eslint-plugin-react-prefer-function-component
|
|
174
|
+
npm install --save-dev eslint-plugin-mui eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-redux eslint-plugin-react-prefer-function-component
|
|
175
175
|
```
|
|
176
176
|
|
|
177
177
|
### `beslogic/angular`
|
|
@@ -184,7 +184,7 @@ If bundling with an npm package set `"strictMetadataEmit": true` under `angularC
|
|
|
184
184
|
Add the following `devDependencies` to your `package.json`:
|
|
185
185
|
|
|
186
186
|
```shell
|
|
187
|
-
npm install --save-dev @angular-eslint/eslint-plugin @angular-eslint/eslint-plugin-template @angular-eslint/template-parser github:BesLogic/eslint-plugin-rxjs-angular#dist eslint-plugin-angular-file-naming
|
|
187
|
+
npm install --save-dev @angular-eslint/eslint-plugin @angular-eslint/eslint-plugin-template @angular-eslint/template-parser github:BesLogic/eslint-plugin-rxjs-angular#dist eslint-plugin-angular-file-naming
|
|
188
188
|
```
|
|
189
189
|
|
|
190
190
|
### `beslogic/storybook`
|
|
@@ -211,3 +211,7 @@ You must also extend the base configuration in a `dprint.json` file (see [Parall
|
|
|
211
211
|
### `beslogic/json-like`
|
|
212
212
|
|
|
213
213
|
Enforces stylistic rules for JS objects to look like valid JSON objects.
|
|
214
|
+
|
|
215
|
+
## Changelog
|
|
216
|
+
|
|
217
|
+
You can view the changelog under the [Code Tab](https://www.npmjs.com/package/eslint-config-beslogic?activeTab=code), or at <https://socket.dev/npm/package/eslint-config-beslogic/files/latest/CHANGELOG.md>
|
package/angular.js
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
// Copyright 2024 Beslogic Inc.
|
|
3
3
|
|
|
4
|
-
const {
|
|
4
|
+
const { getModuleVersion, jestNoRestrictedSyntax } = require("./lib/utils")
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
try {
|
|
8
|
-
angularEslintPluginVersion = getProjectModuleVersion("@angular-eslint/eslint-plugin")
|
|
9
|
-
} catch (error) {
|
|
10
|
-
console.warn(error)
|
|
11
|
-
}
|
|
12
|
-
let typescriptVersion = 4.3
|
|
13
|
-
try {
|
|
14
|
-
typescriptVersion = getProjectModuleVersion("typescript")
|
|
15
|
-
} catch (error) {
|
|
16
|
-
console.warn(error)
|
|
17
|
-
}
|
|
6
|
+
const angularEslintPluginVersion = getModuleVersion("@angular-eslint/eslint-plugin", 16.2)
|
|
18
7
|
|
|
19
8
|
const javascriptConfig = require("./javascript")
|
|
20
9
|
const typescriptConfig = require("./typescript")
|
|
@@ -33,28 +22,22 @@ const noRestrictedSyntax = [
|
|
|
33
22
|
"message": "Don't use imports that ends in \"..\" or \"../\""
|
|
34
23
|
},
|
|
35
24
|
// From typescript configs, but allow on @Input()
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
: {
|
|
45
|
-
"selector":
|
|
46
|
-
"PropertyDefinition[definite=true]:not(:has(Decorator[expression.callee.name=\"Input\"]))",
|
|
47
|
-
"message":
|
|
48
|
-
"Forbidden non-null property assertion. https://typescript-eslint.io/rules/no-non-null-assertion . " +
|
|
49
|
-
"This is only allowed on component @Input() restricted by its selector."
|
|
50
|
-
}
|
|
25
|
+
{
|
|
26
|
+
"selector":
|
|
27
|
+
"PropertyDefinition[definite=true]:not(:has(Decorator[expression.callee.name=\"Input\"] Property[key.name=\"required\"][value.value=true]))",
|
|
28
|
+
"message":
|
|
29
|
+
"Forbidden non-null property assertion. https://typescript-eslint.io/rules/no-non-null-assertion . " +
|
|
30
|
+
"This is only allowed on required component @Input({ required:true }). https://angular.io/api/core/Input#required"
|
|
31
|
+
}
|
|
51
32
|
]
|
|
52
33
|
|
|
53
|
-
const typeDefinitionOverride = typescriptConfig
|
|
54
|
-
|
|
55
|
-
)
|
|
34
|
+
const typeDefinitionOverride = typescriptConfig
|
|
35
|
+
.overrides
|
|
36
|
+
?.find(override => override.files === "*.d.ts")
|
|
56
37
|
|
|
57
|
-
const preferArrowFunctionsConfig = javascriptConfig
|
|
38
|
+
const preferArrowFunctionsConfig = javascriptConfig
|
|
39
|
+
.rules
|
|
40
|
+
?.["prefer-arrow/prefer-arrow-functions"]
|
|
58
41
|
?.[1]
|
|
59
42
|
const preventAbbreviationsConfig = {
|
|
60
43
|
...javascriptConfig.rules?.["unicorn/prevent-abbreviations"]?.[1]
|
|
@@ -158,9 +141,6 @@ module.exports = {
|
|
|
158
141
|
]
|
|
159
142
|
}
|
|
160
143
|
],
|
|
161
|
-
// "@angular-eslint/template/prefer-ngsrc": angularEslintPluginVersion >= 16.2
|
|
162
|
-
// ? "error"
|
|
163
|
-
// : "off",
|
|
164
144
|
// This constantly requires wrapping images in an additional div or knowing the exact display size.
|
|
165
145
|
// Doesn't support relative sizing either, not sure if worth even trying to enforce.
|
|
166
146
|
"@angular-eslint/template/prefer-ngsrc": "off",
|
|
@@ -183,6 +163,12 @@ module.exports = {
|
|
|
183
163
|
"plugin:@angular-eslint/template/process-inline-templates"
|
|
184
164
|
],
|
|
185
165
|
"parserOptions": {
|
|
166
|
+
// TODO: Try "project": true https://typescript-eslint.io/blog/parser-options-project-true/
|
|
167
|
+
// This wouldn't work for tsconfig.spec.ts though
|
|
168
|
+
// https://typescript-eslint.io/blog/parser-options-project-true/#investigating-custom-tsconfig-names
|
|
169
|
+
// https://github.com/typescript-eslint/typescript-eslint/issues/7383#issuecomment-2073032501
|
|
170
|
+
// TODO: even better, try: https://typescript-eslint.io/packages/parser/#experimental_useprojectservice
|
|
171
|
+
// "EXPERIMENTAL_useProjectService": true,
|
|
186
172
|
"project": [
|
|
187
173
|
"tsconfig?(.*).json",
|
|
188
174
|
"projects/*/tsconfig?(.*).json",
|
|
@@ -190,7 +176,7 @@ module.exports = {
|
|
|
190
176
|
],
|
|
191
177
|
// TODO: Consider use a tsconfig.eslint.json instead
|
|
192
178
|
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/README.md#parseroptionscreatedefaultprogram
|
|
193
|
-
"
|
|
179
|
+
"deprecated__createDefaultProgram": true,
|
|
194
180
|
// Needed specifically for @typescript-eslint/consistent-type-imports
|
|
195
181
|
"emitDecoratorMetadata": true
|
|
196
182
|
},
|
|
@@ -289,8 +275,7 @@ module.exports = {
|
|
|
289
275
|
],
|
|
290
276
|
// Incompatible with Angular's dependecy injection
|
|
291
277
|
"@typescript-eslint/no-invalid-this": "off",
|
|
292
|
-
//
|
|
293
|
-
"@typescript-eslint/no-parameter-properties": "off",
|
|
278
|
+
// Redundant with Angular's dependecy injection
|
|
294
279
|
"@typescript-eslint/parameter-properties": "off",
|
|
295
280
|
|
|
296
281
|
/*
|
|
@@ -306,13 +291,11 @@ module.exports = {
|
|
|
306
291
|
"@typescript-eslint/no-import-type-side-effects": "off",
|
|
307
292
|
"@typescript-eslint/consistent-type-imports": [
|
|
308
293
|
"error",
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
"fixStyle": "inline-type-imports" // Only available since typescript 4.5
|
|
315
|
-
}
|
|
294
|
+
{
|
|
295
|
+
// Sets the autofix to use `import { type A } from '...'` which works around the above mentionned issue
|
|
296
|
+
// This only affects autofixing to help devs not aware of this edge case, both styles are always allowed.
|
|
297
|
+
"fixStyle": "inline-type-imports"
|
|
298
|
+
}
|
|
316
299
|
],
|
|
317
300
|
|
|
318
301
|
"unicorn/no-keyword-prefix": [
|
package/lib/utils.js
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
1
|
+
const getModuleVersion = (
|
|
2
|
+
/** @type {string} */ nodeModule,
|
|
3
|
+
/** @type {number} */ fallbackVersion
|
|
4
|
+
) => {
|
|
5
|
+
try {
|
|
6
|
+
// eslint-disable-next-line n/global-require -- Dynamic loading
|
|
7
|
+
return Number.parseFloat(require(`${nodeModule}/package.json`).version)
|
|
8
|
+
} catch (error) {
|
|
9
|
+
console.warn(error)
|
|
3
10
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Number.parseFloat(
|
|
8
|
-
JSON.parse(
|
|
9
|
-
readFileSync(
|
|
10
|
-
join(__dirname, "..", `${nodeModule}/package.json`)
|
|
11
|
-
).toString()
|
|
12
|
-
).version
|
|
13
|
-
)
|
|
11
|
+
return fallbackVersion
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
14
|
|
|
15
|
-
const jestNoRestrictedSyntax =
|
|
15
|
+
const jestNoRestrictedSyntax = (
|
|
16
|
+
/** @type {(string | number | { selector: string; })[]} */ noRestrictedSyntax
|
|
17
|
+
) =>
|
|
16
18
|
noRestrictedSyntax.filter(entry =>
|
|
19
|
+
typeof entry === "number" ||
|
|
17
20
|
typeof entry === "string" ||
|
|
18
|
-
// Exclude from jest tests for compatibility with
|
|
21
|
+
// Exclude from jest tests for compatibility with
|
|
22
|
+
// `jest/valid-describe-callback` and `jest/no-test-return-statement`
|
|
19
23
|
!entry.selector.startsWith("ArrowFunctionExpression")
|
|
20
24
|
)
|
|
21
25
|
|
|
22
26
|
module.exports = {
|
|
23
|
-
|
|
24
|
-
getOwnModuleVersion,
|
|
27
|
+
getModuleVersion,
|
|
25
28
|
jestNoRestrictedSyntax
|
|
26
29
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-beslogic",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "ESLint rules, plugins and configs used at Beslogic",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -36,18 +36,11 @@
|
|
|
36
36
|
],
|
|
37
37
|
"author": "Samuel Therrien <samuel.therrien@beslogic.com>",
|
|
38
38
|
"license": "MIT",
|
|
39
|
-
"//
|
|
40
|
-
"engines": {
|
|
41
|
-
"node": ">=16",
|
|
42
|
-
"npm": ">=8"
|
|
43
|
-
},
|
|
44
|
-
"// @babel/eslint-parser & eslint-plugin-sonarjs": "Bumped json5 to fix prototype Pollution in minimist <1.2.6",
|
|
45
|
-
"// eslint-plugin-total-functions": "Supported version is dictated by TypeScript and ESLint",
|
|
46
|
-
"// ||": "Support new rules in typescript-eslint/eslint-plugin, but eslint-plugin-total-functions is blocking",
|
|
39
|
+
"// @babel/eslint-parser": "Bumped json5 to fix prototype Pollution in minimist <1.2.6",
|
|
47
40
|
"dependencies": {
|
|
48
41
|
"@babel/eslint-parser": "^7.20.12",
|
|
49
42
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.1",
|
|
50
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
43
|
+
"@typescript-eslint/eslint-plugin": "^6.2",
|
|
51
44
|
"confusing-browser-globals": "^1.0",
|
|
52
45
|
"dprint": "^0.39.1",
|
|
53
46
|
"eslint": "^8.28",
|
|
@@ -57,7 +50,7 @@
|
|
|
57
50
|
"eslint-plugin-etc": "^2.0",
|
|
58
51
|
"eslint-plugin-extra-rules": "^0.0.0-development",
|
|
59
52
|
"eslint-plugin-import": "^2.27.3",
|
|
60
|
-
"eslint-plugin-jest": "^
|
|
53
|
+
"eslint-plugin-jest": "^27.2.3",
|
|
61
54
|
"eslint-plugin-jest-formatting": "^3.1",
|
|
62
55
|
"eslint-plugin-no-autofix": "^1.2",
|
|
63
56
|
"eslint-plugin-no-relative-import-paths": "^1.5.3",
|
|
@@ -65,15 +58,16 @@
|
|
|
65
58
|
"eslint-plugin-regexp": "^1.12",
|
|
66
59
|
"eslint-plugin-simple-import-sort": ">=9.0",
|
|
67
60
|
"eslint-plugin-sonarjs": "^0.20",
|
|
68
|
-
"eslint-plugin-total-functions": ">=5.0",
|
|
69
61
|
"eslint-plugin-unicorn": "^46.0",
|
|
70
|
-
"eslint-plugin-unused-imports": "^
|
|
62
|
+
"eslint-plugin-unused-imports": "^3.0",
|
|
71
63
|
"patch-package": "^7.0.0"
|
|
72
64
|
},
|
|
65
|
+
"// eslint-plugin-total-functions": "Supported version is dictated by TypeScript and ESLint",
|
|
66
|
+
"// (cont)": "Also made optional because of extra strictness",
|
|
73
67
|
"optionalDependencies": {
|
|
74
|
-
"@angular-eslint/eslint-plugin": ">=
|
|
75
|
-
"@angular-eslint/eslint-plugin-template": ">=
|
|
76
|
-
"@angular-eslint/template-parser": ">=
|
|
68
|
+
"@angular-eslint/eslint-plugin": ">=16.2",
|
|
69
|
+
"@angular-eslint/eslint-plugin-template": ">=16.2",
|
|
70
|
+
"@angular-eslint/template-parser": ">=16.2",
|
|
77
71
|
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
78
72
|
"eslint-plugin-mui": "^0.1.1",
|
|
79
73
|
"eslint-plugin-n": ">=14.0",
|
|
@@ -84,7 +78,8 @@
|
|
|
84
78
|
"eslint-plugin-rxjs": "^5.0.3",
|
|
85
79
|
"eslint-plugin-rxjs-angular": "github:BesLogic/eslint-plugin-rxjs-angular#dist",
|
|
86
80
|
"eslint-plugin-storybook": "^0.6.10",
|
|
87
|
-
"eslint-plugin-testing-library": "^5.10.2"
|
|
81
|
+
"eslint-plugin-testing-library": "^5.10.2",
|
|
82
|
+
"eslint-plugin-total-functions": ">=5.0"
|
|
88
83
|
},
|
|
89
84
|
"devDependencies": {
|
|
90
85
|
"@types/eslint": "^8.37.0",
|
package/typescript.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
const javascriptConfig = require("./javascript")
|
|
5
5
|
const { jestNoRestrictedSyntax } = require("./lib/utils")
|
|
6
|
-
const {
|
|
6
|
+
const { getModuleVersion } = require("./lib/utils")
|
|
7
7
|
|
|
8
8
|
const commaDangleDefault = "always-multiline"
|
|
9
9
|
const noRestrictedSyntax = [
|
|
@@ -23,12 +23,7 @@ const paddingLineBetweenStatementsConfig = javascriptConfig
|
|
|
23
23
|
?.find(override => override.extends === "plugin:autofix/all")
|
|
24
24
|
?.rules?.["autofix/padding-line-between-statements"]
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
try {
|
|
28
|
-
typescriptEslintVersion = getProjectModuleVersion("@typescript-eslint/eslint-plugin")
|
|
29
|
-
} catch (error) {
|
|
30
|
-
console.warn(error)
|
|
31
|
-
}
|
|
26
|
+
const totalFunctionsVersion = getModuleVersion("eslint-plugin-total-functions", 0)
|
|
32
27
|
|
|
33
28
|
/** @type {import("eslint").Linter.Config} */
|
|
34
29
|
module.exports = {
|
|
@@ -38,10 +33,14 @@ module.exports = {
|
|
|
38
33
|
"*.ts",
|
|
39
34
|
"*.tsx"
|
|
40
35
|
],
|
|
41
|
-
"plugins":
|
|
36
|
+
"plugins": totalFunctionsVersion
|
|
37
|
+
? ["total-functions"]
|
|
38
|
+
: [],
|
|
42
39
|
"extends": [
|
|
43
40
|
"plugin:@typescript-eslint/all",
|
|
44
|
-
|
|
41
|
+
...totalFunctionsVersion
|
|
42
|
+
? ["plugin:total-functions/recommended"]
|
|
43
|
+
: [],
|
|
45
44
|
"plugin:etc/recommended",
|
|
46
45
|
"plugin:import/typescript"
|
|
47
46
|
],
|
|
@@ -76,6 +75,12 @@ module.exports = {
|
|
|
76
75
|
},
|
|
77
76
|
"parser": "@typescript-eslint/parser",
|
|
78
77
|
"parserOptions": {
|
|
78
|
+
// TODO: Try "project": true https://typescript-eslint.io/blog/parser-options-project-true/
|
|
79
|
+
// This wouldn't work for tsconfig.spec.ts though
|
|
80
|
+
// https://typescript-eslint.io/blog/parser-options-project-true/#investigating-custom-tsconfig-names
|
|
81
|
+
// https://github.com/typescript-eslint/typescript-eslint/issues/7383#issuecomment-2073032501
|
|
82
|
+
// TODO: even better, try: https://typescript-eslint.io/packages/parser/#experimental_useprojectservice
|
|
83
|
+
// "EXPERIMENTAL_useProjectService": true,
|
|
79
84
|
"project": ["tsconfig?(.*).json"],
|
|
80
85
|
"sourceType": "module",
|
|
81
86
|
"ecmaFeatures": {
|
|
@@ -118,7 +123,9 @@ module.exports = {
|
|
|
118
123
|
* - `inputEvent.target as Partial<HTMLInputElement>` <-- Oops!
|
|
119
124
|
* - `event.target as Partial<HTMLInputElement> | null` <-- Ok!
|
|
120
125
|
*/
|
|
121
|
-
"total-functions/no-unsafe-type-assertion":
|
|
126
|
+
"total-functions/no-unsafe-type-assertion": totalFunctionsVersion
|
|
127
|
+
? "warn"
|
|
128
|
+
: "off",
|
|
122
129
|
// False positives with external library
|
|
123
130
|
// See https://github.com/microsoft/TypeScript/issues/13347 for a request to fix this at the language level
|
|
124
131
|
"total-functions/no-unsafe-readonly-mutable-assignment": "off",
|
|
@@ -162,15 +169,13 @@ module.exports = {
|
|
|
162
169
|
* Custom rules and @typescript-eslint/all overrides (https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/configs/all.ts)
|
|
163
170
|
* Automatically deactivates ESLint rules (configured below) that are taken care of by TypeScript (https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/configs/eslint-recommended.ts)
|
|
164
171
|
*/
|
|
165
|
-
"@typescript-eslint/class-methods-use-this":
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
]
|
|
173
|
-
: "off",
|
|
172
|
+
"@typescript-eslint/class-methods-use-this": [
|
|
173
|
+
"error",
|
|
174
|
+
{
|
|
175
|
+
"ignoreOverrideMethods": true,
|
|
176
|
+
"ignoreClassesThatImplementAnInterface": true
|
|
177
|
+
}
|
|
178
|
+
],
|
|
174
179
|
"@typescript-eslint/comma-dangle": [
|
|
175
180
|
"error",
|
|
176
181
|
commaDangleDefault
|
|
@@ -237,8 +242,6 @@ module.exports = {
|
|
|
237
242
|
"ignoreArrowShorthand": true
|
|
238
243
|
}
|
|
239
244
|
],
|
|
240
|
-
// Obsoleted by import/no-duplicates
|
|
241
|
-
"@typescript-eslint/no-duplicate-imports": "off",
|
|
242
245
|
"@typescript-eslint/no-empty-interface": [
|
|
243
246
|
"error",
|
|
244
247
|
{
|