eslint-config-beslogic 2.1.0 → 2.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/CHANGELOG.md +56 -3
- package/README.md +5 -5
- package/angular.js +6 -26
- package/dprint.js +5 -3
- package/javascript.js +29 -16
- package/jest.js +9 -0
- package/json-like.js +2 -1
- package/lib/patch-dependencies.js +165 -0
- package/lib/utils.js +16 -2
- package/node-js.js +18 -13
- package/package.json +21 -21
- package/react.js +8 -1
- package/tsconfig.4.3.json +4 -2
- package/tsconfig.5.0.json +6 -1
- package/typescript.js +36 -8
- package/lib/apply-patches.js +0 -76
- package/lib/patches/@angular+material/@angular+material+14.2.7.patch +0 -13
- package/lib/patches/@angular+material/@angular+material+15.1.2.patch +0 -14
- package/lib/patches/@angular+material/@angular+material+16.2.10.patch +0 -13
- package/lib/patches/@angular+material/@angular+material+17.2.0.patch +0 -13
- package/lib/patches/@nx+angular/@nx+angular+16.3.2.patch +0 -56
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 2.2.1
|
|
4
|
+
|
|
5
|
+
- Bumped `eslint-plugin-react` to `^7.33`
|
|
6
|
+
- Check context objects with `react/display-name`
|
|
7
|
+
- Added React 18 deprecations
|
|
8
|
+
- Remove accidental recommendation to install `eslint-plugn-react-redux` from non-redux presets in `README.md`
|
|
9
|
+
- Now enforce at least 1 newline after imports even with dprint preset.
|
|
10
|
+
- Turn on `allowImplicit`, `checkForEach`, and `allowVoid` for rule `array-callback-return`
|
|
11
|
+
- Bumped `eslint-plugin-total-functions` to `>=6.0`
|
|
12
|
+
- which bumps `typescript` dependency to `4.7.3`
|
|
13
|
+
- Bumped `eslint-plugin-testing-library` to `^6.0` which enables a lot more rules by default
|
|
14
|
+
- Bumped `eslint-plugin-unicorn` to `>=49.0`
|
|
15
|
+
- Re-enabled `prefer-event-target` in Angular preset
|
|
16
|
+
- Disabled deprecated `unicorn/no-unsafe-regex`
|
|
17
|
+
- Start checking arguments again for `unicorn/no-useless-undefined`
|
|
18
|
+
now that it can also autofix `undefined` defaults to optional parameters
|
|
19
|
+
- Re-enabled `unicorn/no-nested-ternary`, which allows a single nested level if parenthesised
|
|
20
|
+
- Bumped `eslint-plugin-sonarjs` to `^1.0`
|
|
21
|
+
- Updated vulnerable dependencies
|
|
22
|
+
- They updated their license
|
|
23
|
+
- Bumped `eslint-plugin-simple-import-sort` to `>=12.0`
|
|
24
|
+
- Bumped `eslint-plugin-regexp` to `^2.0`
|
|
25
|
+
- Reduced dependencies
|
|
26
|
+
- Removal of deprecated rules: <https://github.com/ota-meshi/eslint-plugin-regexp#removed>
|
|
27
|
+
- Bumped `eslint-plugin-jest` to `^28.0.0`
|
|
28
|
+
- `jest/no-if` has been replaced by `jest/no-conditional-in-test`
|
|
29
|
+
- `jest/prefer-importing-jest-globals` is enabled by default, which removes needing a dependency
|
|
30
|
+
on often outdated `@types/jest` and removes the need for `types: ["jest"]` in `tsconfig.json`
|
|
31
|
+
- Bumped `dprint` to `^0.40.2` to prepare for process plugins
|
|
32
|
+
|
|
33
|
+
- Bumped `@typescript-eslint/eslint-plugin` to `^7.4`
|
|
34
|
+
- Re-enabled `@typescript-eslint/no-import-type-side-effects`
|
|
35
|
+
and set `@typescript-eslint/consistent-type-imports` back to default options
|
|
36
|
+
- Bumped `eslint` to `^8.56`
|
|
37
|
+
- which bumps `typescript` dependency to `4.7.5`
|
|
38
|
+
- Prefered `@typescript-eslint/prefer-destructuring` over `autofix/prefer-destructuring`
|
|
39
|
+
- Disabled `@typescript-eslint/key-spacing`, `autofix/func-call-spacing`,
|
|
40
|
+
and `lines-around-comment` in `dprint` preset
|
|
41
|
+
|
|
42
|
+
- Patched-out prettier from nx generators
|
|
43
|
+
- Used Search&Replace based package patching:
|
|
44
|
+
- Removes `patch-package` from dependencies
|
|
45
|
+
- Removes bundled git patches
|
|
46
|
+
- Speedup check for `eslint-plugin-total-functions` install
|
|
47
|
+
|
|
48
|
+
- Bumped `eslint-plugin-n` to `>=16.2`. Notably, this:
|
|
49
|
+
- improves support for ts-node
|
|
50
|
+
- Updates documentation links
|
|
51
|
+
- Sets Node 16 as the minimal default w/o having to configure `engines` in `package.json`
|
|
52
|
+
- Allow for automatic ts mapping detection
|
|
53
|
+
- Re-enabled `n/no-unpublished-*` rules by default as it's now based on package being public/private
|
|
54
|
+
- Set `ignoreTypeImport: true` by default for `n/no-unpublished-import`
|
|
55
|
+
|
|
56
|
+
## 2.1.0
|
|
4
57
|
|
|
5
58
|
- Bumped the following minimum versions:
|
|
6
59
|
- `@angular-eslint/eslint-plugin@>=16.2`
|
|
@@ -12,7 +65,7 @@
|
|
|
12
65
|
- Assuming `node>=16`, `typescript>=4.5` and `@angular/compiler>=16.2.5`
|
|
13
66
|
- This should speedup config parsing that had to check for specific versions
|
|
14
67
|
- 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
|
|
68
|
+
explicitly specified anyway due to version resolution issues
|
|
16
69
|
- Added link to changelog in README
|
|
17
70
|
- Improved detection of installed peer dependencies' version number to be more accurate and faster
|
|
18
71
|
|
|
@@ -26,7 +79,7 @@
|
|
|
26
79
|
|
|
27
80
|
## 2.0.0
|
|
28
81
|
|
|
29
|
-
- Created CHANGELOG.md
|
|
82
|
+
- Created `CHANGELOG.md`
|
|
30
83
|
- Changed the maximum line length from `120` to `100`
|
|
31
84
|
- Split language-specific `editor.defaultFormatter` to work around
|
|
32
85
|
<https://github.com/microsoft/vscode/issues/168411>
|
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ Extend the following in your base `tsconfig.json` (follow link for more details)
|
|
|
45
45
|
"extends": "eslint-config-beslogic/tsconfig.4.3.json",
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
"No Unchecked Indexed Access" makes index accesses even stricter. You may not want it in your project. You can disable it with `"compilerOptions": { "noUncheckedIndexedAccess": false }`.
|
|
48
|
+
"No Unchecked Indexed Access" makes index accesses even stricter. You may not want it in your project or in your tests. You can disable it with `"compilerOptions": { "noUncheckedIndexedAccess": false }`.
|
|
49
49
|
|
|
50
50
|
If deploying / bundling with an Angular npm package, also set `angularCompilerOptions": { "strictMetadataEmit": true }`
|
|
51
51
|
|
|
@@ -141,7 +141,7 @@ Configurations for React projects. Comes with `JSX` support.
|
|
|
141
141
|
Add the following `devDependencies` to your `package.json`:
|
|
142
142
|
|
|
143
143
|
```shell
|
|
144
|
-
npm install --save-dev eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-
|
|
144
|
+
npm install --save-dev eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-prefer-function-component
|
|
145
145
|
```
|
|
146
146
|
|
|
147
147
|
### `beslogic/react-native`
|
|
@@ -151,7 +151,7 @@ Configurations for [React Native](https://reactnative.dev/) projects, including
|
|
|
151
151
|
Add the following `devDependencies` to your `package.json`:
|
|
152
152
|
|
|
153
153
|
```shell
|
|
154
|
-
npm install --save-dev eslint-plugin-react-native eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-
|
|
154
|
+
npm install --save-dev eslint-plugin-react-native eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-prefer-function-component
|
|
155
155
|
```
|
|
156
156
|
|
|
157
157
|
### `beslogic/react-redux`
|
|
@@ -161,7 +161,7 @@ Configurations for React projects using the Redux bindings. Already extends `bes
|
|
|
161
161
|
Add the following `devDependencies` to your `package.json`:
|
|
162
162
|
|
|
163
163
|
```shell
|
|
164
|
-
npm install --save-dev eslint-plugin-react-redux eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-
|
|
164
|
+
npm install --save-dev eslint-plugin-react-redux eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-prefer-function-component
|
|
165
165
|
```
|
|
166
166
|
|
|
167
167
|
### `beslogic/mui`
|
|
@@ -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-
|
|
174
|
+
npm install --save-dev eslint-plugin-mui eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-prefer-function-component
|
|
175
175
|
```
|
|
176
176
|
|
|
177
177
|
### `beslogic/angular`
|
package/angular.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
const { getModuleVersion, jestNoRestrictedSyntax } = require("./lib/utils")
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const angularEslintVersion = getModuleVersion("@angular-eslint/eslint-plugin", 16.2)
|
|
7
|
+
const typescriptVersion = getModuleVersion("typescript", 4.7)
|
|
7
8
|
|
|
8
9
|
const javascriptConfig = require("./javascript")
|
|
9
10
|
const typescriptConfig = require("./typescript")
|
|
@@ -17,6 +18,8 @@ const noRestrictedSyntax = [
|
|
|
17
18
|
"message":
|
|
18
19
|
"Angular hooks need to be functions defined on the prototype: https://github.com/angular/angular/issues/7270#issuecomment-201137617"
|
|
19
20
|
},
|
|
21
|
+
// TODO: Possibly implement that ourselves?
|
|
22
|
+
// Upstream request: https://github.com/MelvinVermeer/eslint-plugin-no-relative-import-paths/issues/30
|
|
20
23
|
{
|
|
21
24
|
"selector": "ImportDeclaration[source.value=/\\.\\.\\u002F?$/]",
|
|
22
25
|
"message": "Don't use imports that ends in \"..\" or \"../\""
|
|
@@ -90,7 +93,7 @@ module.exports = {
|
|
|
90
93
|
],
|
|
91
94
|
// Autofix for this rule was broken: https://github.com/angular-eslint/angular-eslint/pull/1602
|
|
92
95
|
// somewhat fixed in 16.1, but not proper: https://github.com/angular-eslint/angular-eslint/issues/1197
|
|
93
|
-
"@angular-eslint/template/attributes-order":
|
|
96
|
+
"@angular-eslint/template/attributes-order": angularEslintVersion >= 17.1
|
|
94
97
|
? "error"
|
|
95
98
|
: "off",
|
|
96
99
|
// and it was added in 14.2.0. Not enforcing it for now allows a wider range of versions.
|
|
@@ -178,7 +181,7 @@ module.exports = {
|
|
|
178
181
|
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/README.md#parseroptionscreatedefaultprogram
|
|
179
182
|
"deprecated__createDefaultProgram": true,
|
|
180
183
|
// Needed specifically for @typescript-eslint/consistent-type-imports
|
|
181
|
-
"emitDecoratorMetadata":
|
|
184
|
+
"emitDecoratorMetadata": typescriptVersion >= 5
|
|
182
185
|
},
|
|
183
186
|
"rules": {
|
|
184
187
|
/*
|
|
@@ -277,27 +280,6 @@ module.exports = {
|
|
|
277
280
|
"@typescript-eslint/no-invalid-this": "off",
|
|
278
281
|
// Redundant with Angular's dependecy injection
|
|
279
282
|
"@typescript-eslint/parameter-properties": "off",
|
|
280
|
-
|
|
281
|
-
/*
|
|
282
|
-
* These two configs are meant to work around the following issue wit Decorators:
|
|
283
|
-
* https://github.com/typescript-eslint/typescript-eslint/issues/5468#issuecomment-1906180432
|
|
284
|
-
* Once the following PR is merged, we can check for that specific @typescript-eslint version
|
|
285
|
-
* to only apply the workaround before it.
|
|
286
|
-
* https://github.com/typescript-eslint/typescript-eslint/pull/8335
|
|
287
|
-
*/
|
|
288
|
-
// This only relates to TypeScript 5.0's --verbatimModuleSyntax,
|
|
289
|
-
// by not enforcing this rule yet, we are not loosing much compared to what we had before.
|
|
290
|
-
// We have to disable it for the "fixStyle: 'inline-type-imports'" workaround to be allowed at all time
|
|
291
|
-
"@typescript-eslint/no-import-type-side-effects": "off",
|
|
292
|
-
"@typescript-eslint/consistent-type-imports": [
|
|
293
|
-
"error",
|
|
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
|
-
}
|
|
299
|
-
],
|
|
300
|
-
|
|
301
283
|
"unicorn/no-keyword-prefix": [
|
|
302
284
|
"error",
|
|
303
285
|
{
|
|
@@ -308,8 +290,6 @@ module.exports = {
|
|
|
308
290
|
]
|
|
309
291
|
}
|
|
310
292
|
],
|
|
311
|
-
// False positives with Angular's EventEmitter: https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1853
|
|
312
|
-
"unicorn/prefer-event-target": "off",
|
|
313
293
|
// Angular is ESM
|
|
314
294
|
"unicorn/prefer-module": "error",
|
|
315
295
|
// This is not supported in Angular's Vite builder https://github.com/angular/angular-cli/issues/26507
|
package/dprint.js
CHANGED
|
@@ -177,11 +177,13 @@ module.exports = {
|
|
|
177
177
|
"computed-property-spacing": "off",
|
|
178
178
|
"autofix/computed-property-spacing": "off",
|
|
179
179
|
"func-call-spacing": "off",
|
|
180
|
+
"autofix/func-call-spacing": "off",
|
|
180
181
|
"@typescript-eslint/func-call-spacing": "off",
|
|
181
182
|
"generator-star-spacing": "off",
|
|
182
183
|
"autofix/generator-star-spacing": "off",
|
|
183
184
|
"key-spacing": "off",
|
|
184
185
|
"autofix/key-spacing": "off",
|
|
186
|
+
"@typescript-eslint/key-spacing": "off",
|
|
185
187
|
"keyword-spacing": "off",
|
|
186
188
|
"autofix/keyword-spacing": "off",
|
|
187
189
|
"@typescript-eslint/keyword-spacing": "off",
|
|
@@ -224,8 +226,9 @@ module.exports = {
|
|
|
224
226
|
/*
|
|
225
227
|
* Unconfigurable or unknown linked configuration
|
|
226
228
|
*/
|
|
227
|
-
"
|
|
229
|
+
"lines-around-comment": "off",
|
|
228
230
|
"autofix/lines-around-comment": "off",
|
|
231
|
+
"@typescript-eslint/lines-around-comment": "off",
|
|
229
232
|
"no-extra-parens": "off",
|
|
230
233
|
"autofix/no-extra-parens": "off",
|
|
231
234
|
"@typescript-eslint/no-extra-parens": "off",
|
|
@@ -236,8 +239,7 @@ module.exports = {
|
|
|
236
239
|
"new-parens": "off",
|
|
237
240
|
"autofix/new-parens": "off",
|
|
238
241
|
"no-floating-decimal": "off",
|
|
239
|
-
"autofix/no-floating-decimal": "off"
|
|
240
|
-
"import/newline-after-import": "off"
|
|
242
|
+
"autofix/no-floating-decimal": "off"
|
|
241
243
|
}
|
|
242
244
|
}
|
|
243
245
|
]
|
package/javascript.js
CHANGED
|
@@ -69,7 +69,7 @@ module.exports = {
|
|
|
69
69
|
],
|
|
70
70
|
"extends": [
|
|
71
71
|
"eslint:recommended",
|
|
72
|
-
"plugin:sonarjs/recommended",
|
|
72
|
+
"plugin:sonarjs/recommended-legacy",
|
|
73
73
|
"plugin:unicorn/all",
|
|
74
74
|
"plugin:regexp/all",
|
|
75
75
|
"plugin:import/recommended",
|
|
@@ -90,6 +90,7 @@ module.exports = {
|
|
|
90
90
|
"ignorePatterns": ["node_modules/"],
|
|
91
91
|
// Useful when using experimental features and code transpiled by Babel
|
|
92
92
|
"parser": "@babel/eslint-parser",
|
|
93
|
+
"reportUnusedDisableDirectives": true,
|
|
93
94
|
"overrides": [
|
|
94
95
|
{
|
|
95
96
|
"files": [
|
|
@@ -430,9 +431,18 @@ module.exports = {
|
|
|
430
431
|
{ "considerQueryString": true }
|
|
431
432
|
],
|
|
432
433
|
"import/no-empty-named-blocks": "error",
|
|
434
|
+
// exactCount has issues with require, at least that's taken care of by dprint:
|
|
435
|
+
// https://github.com/import-js/eslint-plugin-import/issues/2905
|
|
436
|
+
// With https://github.com/dprint/dprint-plugin-typescript/issues/394 we could disable this
|
|
437
|
+
// rule entirely in dprint preset.
|
|
433
438
|
"import/newline-after-import": [
|
|
434
439
|
"error",
|
|
435
|
-
{
|
|
440
|
+
{
|
|
441
|
+
/* eslint-disable-next-line etc/no-commented-out-code
|
|
442
|
+
-- see above comment, bump minimal eslint-plugin-import when this is fixed and enforced */
|
|
443
|
+
// "exactCount": false,
|
|
444
|
+
"considerComments": true
|
|
445
|
+
}
|
|
436
446
|
],
|
|
437
447
|
"import/no-named-as-default": "error",
|
|
438
448
|
"import/no-named-as-default-member": "error",
|
|
@@ -469,6 +479,9 @@ module.exports = {
|
|
|
469
479
|
"case": "camelCase"
|
|
470
480
|
}
|
|
471
481
|
],
|
|
482
|
+
// Only works on 3 node imports by default, and can't configure a default for all imports.
|
|
483
|
+
// Leave it up to the programmer.
|
|
484
|
+
"unicorn/import-style": "off",
|
|
472
485
|
"unicorn/no-array-reduce": [
|
|
473
486
|
"error",
|
|
474
487
|
{
|
|
@@ -486,16 +499,10 @@ module.exports = {
|
|
|
486
499
|
]
|
|
487
500
|
}
|
|
488
501
|
],
|
|
489
|
-
"unicorn/no-nested-ternary": "off",
|
|
490
502
|
"unicorn/no-null": "off",
|
|
491
|
-
//
|
|
492
|
-
"unicorn/no-unsafe-regex": "
|
|
493
|
-
"unicorn/no-useless-undefined":
|
|
494
|
-
"error",
|
|
495
|
-
{
|
|
496
|
-
"checkArguments": false
|
|
497
|
-
}
|
|
498
|
-
],
|
|
503
|
+
// This rule has been deprecated in favor of eslint-plugin-regexp
|
|
504
|
+
"unicorn/no-unsafe-regex": "off",
|
|
505
|
+
"unicorn/no-useless-undefined": "error",
|
|
499
506
|
"unicorn/numeric-separators-style": "error",
|
|
500
507
|
"unicorn/prefer-add-event-listener": "error",
|
|
501
508
|
"unicorn/prefer-array-find": [
|
|
@@ -569,18 +576,18 @@ module.exports = {
|
|
|
569
576
|
{
|
|
570
577
|
"groups": [
|
|
571
578
|
// Side effect imports.
|
|
572
|
-
[
|
|
579
|
+
[String.raw`^\u0000`],
|
|
573
580
|
// Node.js builtins prefixed with `node:`.
|
|
574
581
|
["^node:"],
|
|
575
582
|
// Packages.
|
|
576
583
|
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
|
|
577
|
-
[
|
|
584
|
+
[String.raw`^@?\w`],
|
|
578
585
|
// Absolute imports and other imports such as Vue-style `@/foo`.
|
|
579
586
|
// Anything not matched in another group.
|
|
580
587
|
["^"],
|
|
581
588
|
// Relative imports.
|
|
582
589
|
// Anything that starts with a dot or src/
|
|
583
|
-
[
|
|
590
|
+
[String.raw`^(\.|src/)`]
|
|
584
591
|
]
|
|
585
592
|
}
|
|
586
593
|
],
|
|
@@ -623,6 +630,8 @@ module.exports = {
|
|
|
623
630
|
],
|
|
624
631
|
// I don't think this is that much more readable imo. Especially for regexp beginners
|
|
625
632
|
"regexp/prefer-named-capture-group": "off",
|
|
633
|
+
// TODO: Re-enable once VSCode has syntax highlighting for the v flag
|
|
634
|
+
"regexp/require-unicode-sets-regexp": "off",
|
|
626
635
|
// Obsoleted by eslint-plugin-regexp
|
|
627
636
|
"no-invalid-regexp": "off",
|
|
628
637
|
"prefer-named-capture-group": "off",
|
|
@@ -633,7 +642,10 @@ module.exports = {
|
|
|
633
642
|
* Excludes rules taken care of by eslint-plugin-autofix
|
|
634
643
|
*/
|
|
635
644
|
"accessor-pairs": "error",
|
|
636
|
-
"array-callback-return":
|
|
645
|
+
"array-callback-return": [
|
|
646
|
+
"error",
|
|
647
|
+
{ "allowImplicit": true, "checkForEach": true, "allowVoid": true }
|
|
648
|
+
],
|
|
637
649
|
"block-scoped-var": "error",
|
|
638
650
|
"camelcase": "error",
|
|
639
651
|
"class-methods-use-this": "error",
|
|
@@ -828,7 +840,8 @@ module.exports = {
|
|
|
828
840
|
],
|
|
829
841
|
"patterns": [
|
|
830
842
|
{
|
|
831
|
-
// no-
|
|
843
|
+
// no-relative-import paths doesn't catch ./..
|
|
844
|
+
// TODO: Consider fixing ourselves
|
|
832
845
|
// https://github.com/MelvinVermeer/eslint-plugin-no-relative-import-paths/issues/30
|
|
833
846
|
"group": ["./../"],
|
|
834
847
|
"message": "Relative parent imports are not allowed."
|
package/jest.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
// Copyright 2024 Beslogic Inc.
|
|
3
|
+
const { getModuleVersion } = require("./lib/utils")
|
|
4
|
+
|
|
5
|
+
const jestGlobalsVersion = getModuleVersion("@jest/globals", 29)
|
|
3
6
|
|
|
4
7
|
/** @type {import("eslint").Linter.Config} */
|
|
5
8
|
module.exports = {
|
|
@@ -67,6 +70,12 @@ module.exports = {
|
|
|
67
70
|
"onlyFunctionsWithExpectInLoop": true
|
|
68
71
|
}
|
|
69
72
|
],
|
|
73
|
+
// https://github.com/jestjs/jest/issues/15084
|
|
74
|
+
// Since this will require a major jest version bump anyway,
|
|
75
|
+
// I feel confortable not waiting for our own major version bump to add this
|
|
76
|
+
...(jestGlobalsVersion < 30
|
|
77
|
+
? { "jest/prefer-importing-jest-globals": "off" }
|
|
78
|
+
: {}),
|
|
70
79
|
// Top-level describe is often used for component name, which is capitalized
|
|
71
80
|
"jest/prefer-lowercase-title": [
|
|
72
81
|
"error",
|
package/json-like.js
CHANGED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
const { readFileSync, writeFileSync } = require("node:fs")
|
|
2
|
+
const { join, dirname } = require("node:path")
|
|
3
|
+
const { resolveModuleLocation } = require("./utils")
|
|
4
|
+
|
|
5
|
+
// ANSI color chart: https://en.m.wikipedia.org/wiki/ANSI_escape_code#Colors
|
|
6
|
+
|
|
7
|
+
const searchAndReplace = async (
|
|
8
|
+
/** @type {string} */ file,
|
|
9
|
+
/** @type {{from: string | RegExp, to: string}[]} */ replacements
|
|
10
|
+
) => {
|
|
11
|
+
try {
|
|
12
|
+
/* eslint-disable n/no-sync -- We're a script running in async methods */
|
|
13
|
+
let data = readFileSync(file, "utf8")
|
|
14
|
+
for (const replacement of replacements) {
|
|
15
|
+
data = data.replaceAll(replacement.from, replacement.to)
|
|
16
|
+
}
|
|
17
|
+
writeFileSync(file, data, "utf8")
|
|
18
|
+
/* eslint-enable n/no-sync */
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error(
|
|
21
|
+
"\n\u001B[31m" +
|
|
22
|
+
`The following error happenned while patching ${file} with eslint-config-beslogic. ` +
|
|
23
|
+
"Please contact samuel.therrien@beslogic.com with the package version and the full error to get it fixed." +
|
|
24
|
+
"\u001B[0m"
|
|
25
|
+
)
|
|
26
|
+
throw error
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const getPackageBase = (/** @type {string} */ packageName) => {
|
|
31
|
+
const location = resolveModuleLocation(`${packageName}/package.json`)
|
|
32
|
+
if (!location) {
|
|
33
|
+
console.info(
|
|
34
|
+
`\n\u001B[32m${packageName} not found in node_modules, no need to patch.\u001B[0m`
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return dirname(location)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const patches = [
|
|
44
|
+
async () => {
|
|
45
|
+
const packageName = "@angular/material"
|
|
46
|
+
const base = getPackageBase(packageName)
|
|
47
|
+
if (!base) return
|
|
48
|
+
await searchAndReplace(
|
|
49
|
+
join(base, "dialog", "index.d.ts"),
|
|
50
|
+
[
|
|
51
|
+
{
|
|
52
|
+
"from": "MatDialogRef<T, R = any>",
|
|
53
|
+
"to": "MatDialogRef<T, R = void>"
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
return packageName
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
async () => {
|
|
62
|
+
const packageName = "@nx/angular"
|
|
63
|
+
const base = getPackageBase(packageName)
|
|
64
|
+
if (!base) return
|
|
65
|
+
await Promise.all([
|
|
66
|
+
searchAndReplace(
|
|
67
|
+
join(base, "src", "generators", "add-linting", "lib", "create-eslint-configuration.js"),
|
|
68
|
+
[
|
|
69
|
+
// Remove code that adds preset extensions
|
|
70
|
+
{
|
|
71
|
+
"from": "plugin:@nx/angular",
|
|
72
|
+
"to": ""
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"from": "plugin:@angular-eslint/template/process-inline-templates",
|
|
76
|
+
"to": ""
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"from": "plugin:@nx/angular-template",
|
|
80
|
+
"to": ""
|
|
81
|
+
},
|
|
82
|
+
// Remove empty extends
|
|
83
|
+
{
|
|
84
|
+
"from": /extends: \[\s*\],?/gu,
|
|
85
|
+
"to": ""
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
),
|
|
89
|
+
// Patch out prettier
|
|
90
|
+
searchAndReplace(
|
|
91
|
+
join(base, "src", "generators", "ng-add", "utilities", "workspace.js"),
|
|
92
|
+
[
|
|
93
|
+
{
|
|
94
|
+
"from": "!packageJson.devDependencies['prettier']",
|
|
95
|
+
"to": "false"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"from": "esbenp.prettier-vscode",
|
|
99
|
+
"to": ""
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
)
|
|
103
|
+
])
|
|
104
|
+
|
|
105
|
+
return packageName
|
|
106
|
+
},
|
|
107
|
+
async () => {
|
|
108
|
+
const packageName = "@nx/eslint"
|
|
109
|
+
const base = getPackageBase(packageName)
|
|
110
|
+
if (!base) return
|
|
111
|
+
// Patch out prettier
|
|
112
|
+
await searchAndReplace(
|
|
113
|
+
join(base, "src", "generators", "lint-project", "setup-root-eslint.js"),
|
|
114
|
+
[
|
|
115
|
+
{
|
|
116
|
+
"from": /'eslint-config-prettier':.+?,/gu,
|
|
117
|
+
"to": ""
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
return packageName
|
|
123
|
+
},
|
|
124
|
+
async () => {
|
|
125
|
+
const packageName = "@nx/js"
|
|
126
|
+
const base = getPackageBase(packageName)
|
|
127
|
+
if (!base) return
|
|
128
|
+
// Patch out prettier
|
|
129
|
+
await searchAndReplace(
|
|
130
|
+
join(base, "src", "generators", "init", "init.js"),
|
|
131
|
+
[
|
|
132
|
+
{
|
|
133
|
+
"from": /prettier:.+?,/gu,
|
|
134
|
+
"to": ""
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"from": "if (prettierrcNameOptions",
|
|
138
|
+
"to": "if (false && prettierrcNameOptions"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"from": "!tree.exists(`.prettierignore`)",
|
|
142
|
+
"to": "false"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"from": "!json.recommendations.includes(extension)",
|
|
146
|
+
"to": "false"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"from": "devkit_1.ensurePackage)('prettier'",
|
|
150
|
+
"to": "//"
|
|
151
|
+
}
|
|
152
|
+
]
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
return packageName
|
|
156
|
+
}
|
|
157
|
+
].map(patch =>
|
|
158
|
+
patch().then(packageName =>
|
|
159
|
+
packageName && console.info(
|
|
160
|
+
`\n\u001B[32m${packageName} patched successfully! Now go write great code!\u001B[0m`
|
|
161
|
+
)
|
|
162
|
+
)
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
Promise.all(patches)
|
package/lib/utils.js
CHANGED
|
@@ -6,12 +6,25 @@ const getModuleVersion = (
|
|
|
6
6
|
// eslint-disable-next-line n/global-require -- Dynamic loading
|
|
7
7
|
return Number.parseFloat(require(`${nodeModule}/package.json`).version)
|
|
8
8
|
} catch (error) {
|
|
9
|
-
|
|
9
|
+
if (
|
|
10
|
+
!(error instanceof Error &&
|
|
11
|
+
error.message.startsWith(`Cannot find module '${nodeModule}/package.json'`))
|
|
12
|
+
) {
|
|
13
|
+
console.warn(error)
|
|
14
|
+
}
|
|
10
15
|
|
|
11
16
|
return fallbackVersion
|
|
12
17
|
}
|
|
13
18
|
}
|
|
14
19
|
|
|
20
|
+
const resolveModuleLocation = (/** @type {string} */ nodeModule) => {
|
|
21
|
+
try {
|
|
22
|
+
return require.resolve(nodeModule)
|
|
23
|
+
} catch {
|
|
24
|
+
return false
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
15
28
|
const jestNoRestrictedSyntax = (
|
|
16
29
|
/** @type {(string | number | { selector: string; })[]} */ noRestrictedSyntax
|
|
17
30
|
) =>
|
|
@@ -25,5 +38,6 @@ const jestNoRestrictedSyntax = (
|
|
|
25
38
|
|
|
26
39
|
module.exports = {
|
|
27
40
|
getModuleVersion,
|
|
28
|
-
jestNoRestrictedSyntax
|
|
41
|
+
jestNoRestrictedSyntax,
|
|
42
|
+
resolveModuleLocation
|
|
29
43
|
}
|
package/node-js.js
CHANGED
|
@@ -32,20 +32,22 @@ module.exports = {
|
|
|
32
32
|
},
|
|
33
33
|
"rules": {
|
|
34
34
|
// Node settings (https://github.com/eslint-community/eslint-plugin-n#readme)
|
|
35
|
-
"n/handle-callback-err": "error",
|
|
36
|
-
"n/no-callback-literal": "error",
|
|
37
|
-
"n/no-new-require": "error",
|
|
38
|
-
"n/no-path-concat": "error",
|
|
39
|
-
"n/no-process-exit": "error",
|
|
40
35
|
"n/callback-return": "error",
|
|
41
36
|
"n/exports-style": "error",
|
|
37
|
+
"n/global-require": "error",
|
|
38
|
+
"n/handle-callback-err": "error",
|
|
39
|
+
"n/no-callback-literal": "error",
|
|
42
40
|
"n/no-extraneous-import": [
|
|
43
41
|
"error",
|
|
44
42
|
{
|
|
45
43
|
"allowModules": ["ws"]
|
|
46
44
|
}
|
|
47
45
|
],
|
|
48
|
-
"n/
|
|
46
|
+
"n/no-new-require": "error",
|
|
47
|
+
"n/no-path-concat": "error",
|
|
48
|
+
"n/no-process-exit": "error",
|
|
49
|
+
// Doesn't really work
|
|
50
|
+
"n/no-missing-import": "off",
|
|
49
51
|
"n/no-mixed-requires": "error",
|
|
50
52
|
"n/no-restricted-import": "error",
|
|
51
53
|
"n/no-restricted-require": "error",
|
|
@@ -53,6 +55,12 @@ module.exports = {
|
|
|
53
55
|
"error",
|
|
54
56
|
{ "allowAtRootLevel": true }
|
|
55
57
|
],
|
|
58
|
+
"n/no-unpublished-import": [
|
|
59
|
+
"error",
|
|
60
|
+
{
|
|
61
|
+
"ignoreTypeImport": true
|
|
62
|
+
}
|
|
63
|
+
],
|
|
56
64
|
"n/prefer-global/buffer": "error",
|
|
57
65
|
"n/prefer-global/console": "error",
|
|
58
66
|
"n/prefer-global/process": "error",
|
|
@@ -60,21 +68,18 @@ module.exports = {
|
|
|
60
68
|
"n/prefer-global/text-encoder": "error",
|
|
61
69
|
"n/prefer-global/url-search-params": "error",
|
|
62
70
|
"n/prefer-global/url": "error",
|
|
71
|
+
// Only available in eslint-plugin-n@17
|
|
72
|
+
// No need to support as long as unicorn/prefer-node-protocol isn't deprecated
|
|
73
|
+
// "n/prefer-node-protocol": "error",
|
|
63
74
|
"n/prefer-promises/dns": "error",
|
|
64
75
|
"n/prefer-promises/fs": "error",
|
|
65
|
-
|
|
66
|
-
"n/no-missing-import": "off",
|
|
67
|
-
// no-unpublished-* only matters for published packages
|
|
68
|
-
"n/no-unpublished-import": "off",
|
|
69
|
-
"n/no-unpublished-require": "off",
|
|
76
|
+
|
|
70
77
|
// Is CommonJS, not ESM
|
|
71
78
|
"unicorn/prefer-module": "off",
|
|
72
79
|
"unicorn/prevent-abbreviations": [
|
|
73
80
|
"error",
|
|
74
81
|
preventAbbreviationsConfig
|
|
75
82
|
],
|
|
76
|
-
// Actually important in backend apps
|
|
77
|
-
"unicorn/no-unsafe-regex": "error",
|
|
78
83
|
// Use some logging instead
|
|
79
84
|
"no-console": "error",
|
|
80
85
|
"no-restricted-globals": [
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-beslogic",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "ESLint rules, plugins and configs used at Beslogic",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"// dependencies": "Run for ourselves when we install dependencies w/o running npm i afterward",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"eslint": "eslint ./ --ignore-path .gitignore",
|
|
8
9
|
"lint": "node ./node_modules/dprint/bin check && npm run eslint",
|
|
9
10
|
"lint:fix": "node ./node_modules/dprint/bin fmt && npm run eslint -- --fix",
|
|
10
11
|
"upgrade": "npx npm-check-updates -u & npm i",
|
|
11
12
|
"yalc": "yalc publish",
|
|
12
|
-
"postinstall": "node ./lib/
|
|
13
|
-
"dependencies": "node ./lib/
|
|
13
|
+
"postinstall": "node ./lib/patch-dependencies.js",
|
|
14
|
+
"dependencies": "node ./lib/patch-dependencies.js"
|
|
14
15
|
},
|
|
15
16
|
"keywords": [
|
|
16
17
|
"eslint",
|
|
@@ -40,27 +41,26 @@
|
|
|
40
41
|
"dependencies": {
|
|
41
42
|
"@babel/eslint-parser": "^7.20.12",
|
|
42
43
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.1",
|
|
43
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^7.4",
|
|
44
45
|
"confusing-browser-globals": "^1.0",
|
|
45
|
-
"dprint": "^0.
|
|
46
|
-
"eslint": "^8.
|
|
47
|
-
"eslint-import-resolver-typescript": "^3.
|
|
46
|
+
"dprint": "^0.40.2",
|
|
47
|
+
"eslint": "^8.56",
|
|
48
|
+
"eslint-import-resolver-typescript": "^3.2.6",
|
|
48
49
|
"eslint-plugin-angular-file-naming": "^1.0.6",
|
|
49
|
-
"eslint-plugin-autofix": "^1.1.0",
|
|
50
|
+
"eslint-plugin-autofix": "^1.1 || ^2.0",
|
|
50
51
|
"eslint-plugin-etc": "^2.0",
|
|
51
52
|
"eslint-plugin-extra-rules": "^0.0.0-development",
|
|
52
53
|
"eslint-plugin-import": "^2.27.3",
|
|
53
|
-
"eslint-plugin-jest": "^
|
|
54
|
+
"eslint-plugin-jest": "^28.0",
|
|
54
55
|
"eslint-plugin-jest-formatting": "^3.1",
|
|
55
|
-
"eslint-plugin-no-autofix": "^1.2",
|
|
56
|
+
"eslint-plugin-no-autofix": "^1.2 || ^2.0",
|
|
56
57
|
"eslint-plugin-no-relative-import-paths": "^1.5.3",
|
|
57
58
|
"eslint-plugin-prefer-arrow": "^1.2",
|
|
58
|
-
"eslint-plugin-regexp": "^
|
|
59
|
-
"eslint-plugin-simple-import-sort": ">=
|
|
60
|
-
"eslint-plugin-sonarjs": "^0
|
|
61
|
-
"eslint-plugin-unicorn": "
|
|
62
|
-
"eslint-plugin-unused-imports": "^3.0"
|
|
63
|
-
"patch-package": "^7.0.0"
|
|
59
|
+
"eslint-plugin-regexp": "^2.0",
|
|
60
|
+
"eslint-plugin-simple-import-sort": ">=12.0",
|
|
61
|
+
"eslint-plugin-sonarjs": "^1.0",
|
|
62
|
+
"eslint-plugin-unicorn": ">=49.0",
|
|
63
|
+
"eslint-plugin-unused-imports": "^3.0"
|
|
64
64
|
},
|
|
65
65
|
"// eslint-plugin-total-functions": "Supported version is dictated by TypeScript and ESLint",
|
|
66
66
|
"// (cont)": "Also made optional because of extra strictness",
|
|
@@ -70,16 +70,16 @@
|
|
|
70
70
|
"@angular-eslint/template-parser": ">=16.2",
|
|
71
71
|
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
72
72
|
"eslint-plugin-mui": "^0.1.1",
|
|
73
|
-
"eslint-plugin-n": ">=
|
|
74
|
-
"eslint-plugin-react": "^7.
|
|
75
|
-
"eslint-plugin-react-hooks": "^4.3",
|
|
73
|
+
"eslint-plugin-n": ">=17.0",
|
|
74
|
+
"eslint-plugin-react": "^7.33",
|
|
75
|
+
"eslint-plugin-react-hooks": "^4.3 || ^5.0",
|
|
76
76
|
"eslint-plugin-react-prefer-function-component": "^3.2.0",
|
|
77
77
|
"eslint-plugin-react-redux": "^4.0",
|
|
78
78
|
"eslint-plugin-rxjs": "^5.0.3",
|
|
79
79
|
"eslint-plugin-rxjs-angular": "github:BesLogic/eslint-plugin-rxjs-angular#dist",
|
|
80
80
|
"eslint-plugin-storybook": "^0.6.10",
|
|
81
|
-
"eslint-plugin-testing-library": "^
|
|
82
|
-
"eslint-plugin-total-functions": ">=
|
|
81
|
+
"eslint-plugin-testing-library": "^6.0",
|
|
82
|
+
"eslint-plugin-total-functions": ">=6.0"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@types/eslint": "^8.37.0",
|
package/react.js
CHANGED
|
@@ -114,7 +114,14 @@ module.exports = {
|
|
|
114
114
|
*/
|
|
115
115
|
// Using only max-lines and not max-lines-per-function as most of the react code lives in functions.
|
|
116
116
|
"max-lines-per-function": "off",
|
|
117
|
-
|
|
117
|
+
|
|
118
|
+
/*
|
|
119
|
+
* react overrides (https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules)
|
|
120
|
+
*/
|
|
121
|
+
"react/display-name": [
|
|
122
|
+
"error",
|
|
123
|
+
{ "checkContextObjects": true }
|
|
124
|
+
],
|
|
118
125
|
"react/forbid-component-props": [
|
|
119
126
|
"error",
|
|
120
127
|
// With most styling solutions, style can be fine
|
package/tsconfig.4.3.json
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
"newLine": "LF", // Now default in TypeScript 5.0
|
|
5
5
|
"forceConsistentCasingInFileNames": true, // Now default in TypeScript 5.0
|
|
6
6
|
"noFallthroughCasesInSwitch": true,
|
|
7
|
-
"noImplicitOverride": true,
|
|
7
|
+
"noImplicitOverride": true,
|
|
8
8
|
"noImplicitReturns": true,
|
|
9
|
-
|
|
9
|
+
// This makes index accesses even stricter. You may not want it in your project.
|
|
10
|
+
// You should probably disable it at least in tests.
|
|
11
|
+
"noUncheckedIndexedAccess": true,
|
|
10
12
|
"module": "ESNext", // ESNext or CommonJS
|
|
11
13
|
"target": "ES2017", // ES2017 or higher
|
|
12
14
|
"lib": [
|
package/tsconfig.5.0.json
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "./tsconfig.4.3.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"verbatimModuleSyntax": true
|
|
4
|
+
"verbatimModuleSyntax": true,
|
|
5
|
+
// Since this is no longer needed for Angular with TypeScript 5, let's
|
|
6
|
+
// disable it so @typescript-eslint/consistent-type-imports doesn't turn
|
|
7
|
+
// itself off in files using decorators.
|
|
8
|
+
// https://typescript-eslint.io/rules/consistent-type-imports/#caveat-decorators--experimentaldecorators-true--emitdecoratormetadata-true
|
|
9
|
+
"experimentalDecorators": false
|
|
5
10
|
}
|
|
6
11
|
}
|
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 { resolveModuleLocation } = require("./lib/utils")
|
|
7
7
|
|
|
8
8
|
const commaDangleDefault = "always-multiline"
|
|
9
9
|
const noRestrictedSyntax = [
|
|
@@ -23,7 +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
|
-
const
|
|
26
|
+
const hasTotalFunctions = !!resolveModuleLocation("eslint-plugin-total-functions")
|
|
27
27
|
|
|
28
28
|
/** @type {import("eslint").Linter.Config} */
|
|
29
29
|
module.exports = {
|
|
@@ -33,12 +33,12 @@ module.exports = {
|
|
|
33
33
|
"*.ts",
|
|
34
34
|
"*.tsx"
|
|
35
35
|
],
|
|
36
|
-
"plugins":
|
|
36
|
+
"plugins": hasTotalFunctions
|
|
37
37
|
? ["total-functions"]
|
|
38
38
|
: [],
|
|
39
39
|
"extends": [
|
|
40
40
|
"plugin:@typescript-eslint/all",
|
|
41
|
-
...
|
|
41
|
+
...hasTotalFunctions
|
|
42
42
|
? ["plugin:total-functions/recommended"]
|
|
43
43
|
: [],
|
|
44
44
|
"plugin:etc/recommended",
|
|
@@ -123,7 +123,7 @@ module.exports = {
|
|
|
123
123
|
* - `inputEvent.target as Partial<HTMLInputElement>` <-- Oops!
|
|
124
124
|
* - `event.target as Partial<HTMLInputElement> | null` <-- Ok!
|
|
125
125
|
*/
|
|
126
|
-
"total-functions/no-unsafe-type-assertion":
|
|
126
|
+
"total-functions/no-unsafe-type-assertion": hasTotalFunctions
|
|
127
127
|
? "warn"
|
|
128
128
|
: "off",
|
|
129
129
|
// False positives with external library
|
|
@@ -153,9 +153,6 @@ module.exports = {
|
|
|
153
153
|
// TypeScript already ensures no options are missing
|
|
154
154
|
"unicorn/no-object-as-default-parameter": "off",
|
|
155
155
|
|
|
156
|
-
// Note: not useable with interfaces https://github.com/typescript-eslint/typescript-eslint/issues/1103
|
|
157
|
-
// @typescript-eslint/class-methods-use-this only exists since 6.2
|
|
158
|
-
"class-methods-use-this": "off",
|
|
159
156
|
// Using simple-import-sort instead
|
|
160
157
|
"sort-imports": "off",
|
|
161
158
|
// Not usable with typescript anyway
|
|
@@ -180,6 +177,10 @@ module.exports = {
|
|
|
180
177
|
"error",
|
|
181
178
|
commaDangleDefault
|
|
182
179
|
],
|
|
180
|
+
// @typescript-eslint v7.1.0 will disable this automatically as it added its own version
|
|
181
|
+
"consistent-return": "off",
|
|
182
|
+
// Prefer "noImplicitReturns": true in tsconfig.json
|
|
183
|
+
"@typescript-eslint/consistent-return": "off",
|
|
183
184
|
// Explicit types rules complicates things uselessly and are redundant
|
|
184
185
|
"@typescript-eslint/explicit-function-return-type": "off",
|
|
185
186
|
"@typescript-eslint/explicit-member-accessibility": [
|
|
@@ -375,6 +376,23 @@ module.exports = {
|
|
|
375
376
|
]
|
|
376
377
|
}
|
|
377
378
|
],
|
|
379
|
+
// Favor safer @typescript-eslint/prefer-destructuring
|
|
380
|
+
"autofix/prefer-destructuring": "off",
|
|
381
|
+
"@typescript-eslint/prefer-destructuring": [
|
|
382
|
+
"error",
|
|
383
|
+
{
|
|
384
|
+
// Same as default, needed to configure the second object
|
|
385
|
+
"array": true,
|
|
386
|
+
"object": true
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
// Destructuring w/o assignement keyword (const/let) requires wrapping in parentheses,
|
|
390
|
+
// which can be confusing for example when destructuring into `this`.
|
|
391
|
+
// https://github.com/eslint/eslint/issues/18460
|
|
392
|
+
"enforceForRenamedProperties": false,
|
|
393
|
+
"enforceForDeclarationWithTypeAnnotation": true
|
|
394
|
+
}
|
|
395
|
+
],
|
|
378
396
|
"@typescript-eslint/prefer-enum-initializers": "off",
|
|
379
397
|
// TODO: Would accept this if it had autofixes, otherwise this is too tedious to use. Check again later
|
|
380
398
|
"@typescript-eslint/prefer-readonly-parameter-types": "off",
|
|
@@ -402,6 +420,9 @@ module.exports = {
|
|
|
402
420
|
{
|
|
403
421
|
"allowBoolean": true,
|
|
404
422
|
"allowNullish": true
|
|
423
|
+
// Purposefully keeping allowArray: false (v7.4)
|
|
424
|
+
// as the best way to format arrays is to use Intl.ListFormat
|
|
425
|
+
// and array's default .join() risks producing "[object Object]"
|
|
405
426
|
}
|
|
406
427
|
],
|
|
407
428
|
"@typescript-eslint/semi": [
|
|
@@ -421,7 +442,14 @@ module.exports = {
|
|
|
421
442
|
"int32Hint": true
|
|
422
443
|
}
|
|
423
444
|
],
|
|
445
|
+
// We accept nullish as falsy
|
|
424
446
|
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
447
|
+
"@typescript-eslint/switch-exhaustiveness-check": [
|
|
448
|
+
"error",
|
|
449
|
+
{
|
|
450
|
+
"requireDefaultForNonUnion": true
|
|
451
|
+
}
|
|
452
|
+
],
|
|
425
453
|
"@typescript-eslint/unbound-method": [
|
|
426
454
|
"error",
|
|
427
455
|
{
|
package/lib/apply-patches.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
const { exec } = require("node:child_process")
|
|
2
|
-
const { readdirSync, existsSync } = require("node:fs")
|
|
3
|
-
const { join } = require("node:path")
|
|
4
|
-
|
|
5
|
-
// ANSI color chart: https://en.m.wikipedia.org/wiki/ANSI_escape_code#Colors
|
|
6
|
-
|
|
7
|
-
const appRootPath = join(__dirname, "..", "..", "..")
|
|
8
|
-
if (!existsSync(join(appRootPath, "package.json"))) {
|
|
9
|
-
/* eslint-disable-next-line n/no-process-exit, unicorn/no-process-exit --
|
|
10
|
-
Probably ran in eslint-config-beslogic, just early exit. patch-package would fail anyway */
|
|
11
|
-
process.exit(0)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const execCallback = (/** @type {string} */ packageName) =>
|
|
15
|
-
(
|
|
16
|
-
/** @type {import('node:child_process').ExecException | null} */
|
|
17
|
-
error,
|
|
18
|
-
/** @type {string} */
|
|
19
|
-
stdout,
|
|
20
|
-
/** @type {string} */
|
|
21
|
-
stderr
|
|
22
|
-
) => {
|
|
23
|
-
// NOTE: Can't use `.startsWith` because if "--force" is used, the message will start with
|
|
24
|
-
// "npm WARN using --force Recommended protections disabled."
|
|
25
|
-
if (stdout) console.info(stdout)
|
|
26
|
-
if (stderr.includes("Error: Patch file found for package")) {
|
|
27
|
-
console.info(`\u001B[32m${packageName} not found in node_modules, no need to patch.\u001B[0m`)
|
|
28
|
-
|
|
29
|
-
return
|
|
30
|
-
}
|
|
31
|
-
if (stderr.includes("\nWarning: ")) {
|
|
32
|
-
const reworded = stderr.replace(
|
|
33
|
-
"run\n\n patch-package @nx/angular",
|
|
34
|
-
"contact\n\n samuel.therrien@beslogic.com"
|
|
35
|
-
)
|
|
36
|
-
console.warn(`\u001B[33m${reworded}\u001B[0m`)
|
|
37
|
-
|
|
38
|
-
return
|
|
39
|
-
}
|
|
40
|
-
if (stderr.includes("\n**ERROR** Failed to apply patch for package") && stdout.includes("✔")) {
|
|
41
|
-
console.info(
|
|
42
|
-
`\u001B[32m${packageName} has patches for multiple versions, at least one was applied successfully!\u001B[0m`
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
if (error) {
|
|
48
|
-
console.error(
|
|
49
|
-
"\u001B[31m" +
|
|
50
|
-
`The following error happenned while patching ${packageName} with eslint-config-beslogic. ` +
|
|
51
|
-
"Please contact samuel.therrien@beslogic.com with the package version and the full error to get it fixed." +
|
|
52
|
-
"\u001B[0m"
|
|
53
|
-
)
|
|
54
|
-
throw error
|
|
55
|
-
}
|
|
56
|
-
if (stderr) console.error(`\u001B[31m${stderr}\u001B[0m`)
|
|
57
|
-
console.info(`\u001B[32m${packageName} patched successfully! Now go write great code!\u001B[0m`)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const folders = readdirSync("lib/patches")
|
|
61
|
-
for (const folder of folders) {
|
|
62
|
-
const packageName = folder.replaceAll("+", "/")
|
|
63
|
-
console.info(`\u001B[93mPatching ${packageName}\u001B[0m`)
|
|
64
|
-
// We cannot apply individual patches with patch-package, ang using git is more cumbersome / less safe.
|
|
65
|
-
// So instead we apply individual patch folders.
|
|
66
|
-
// This is necessary if we have multiple patches for optional dependencies.
|
|
67
|
-
// https://www.npmjs.com/package/patch-package#user-content-notes
|
|
68
|
-
exec(
|
|
69
|
-
"npx patch-package" +
|
|
70
|
-
` --patch-dir=node_modules/eslint-config-beslogic/lib/patches/${folder}` +
|
|
71
|
-
" --ignore-whitespace" +
|
|
72
|
-
" --error-on-fail",
|
|
73
|
-
{ "cwd": appRootPath },
|
|
74
|
-
execCallback(packageName)
|
|
75
|
-
)
|
|
76
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
diff --git a/node_modules/@angular/material/dialog/index.d.ts b/node_modules/@angular/material/dialog/index.d.ts
|
|
2
|
-
index 6dc3eab..c9fa899 100644
|
|
3
|
-
--- a/node_modules/@angular/material/dialog/index.d.ts
|
|
4
|
-
+++ b/node_modules/@angular/material/dialog/index.d.ts
|
|
5
|
-
@@ -397,7 +397,7 @@ export declare class MatDialogModule {
|
|
6
|
-
/**
|
|
7
|
-
* Reference to a dialog opened via the MatDialog service.
|
|
8
|
-
*/
|
|
9
|
-
-export declare class MatDialogRef<T, R = any> {
|
|
10
|
-
+export declare class MatDialogRef<T, R = void> {
|
|
11
|
-
private _ref;
|
|
12
|
-
_containerInstance: _MatDialogContainerBase;
|
|
13
|
-
/** The instance of component opened into the dialog. */
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# https://github.com/angular/components/issues/12898
|
|
2
|
-
diff --git a/node_modules/@angular/material/dialog/index.d.ts b/node_modules/@angular/material/dialog/index.d.ts
|
|
3
|
-
index 914c287..80caedb 100644
|
|
4
|
-
--- a/node_modules/@angular/material/dialog/index.d.ts
|
|
5
|
-
+++ b/node_modules/@angular/material/dialog/index.d.ts
|
|
6
|
-
@@ -425,7 +425,7 @@ export declare class MatDialogModule {
|
|
7
|
-
/**
|
|
8
|
-
* Reference to a dialog opened via the MatDialog service.
|
|
9
|
-
*/
|
|
10
|
-
-export declare class MatDialogRef<T, R = any> {
|
|
11
|
-
+export declare class MatDialogRef<T, R = void> {
|
|
12
|
-
private _ref;
|
|
13
|
-
_containerInstance: _MatDialogContainerBase;
|
|
14
|
-
/** The instance of component opened into the dialog. */
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
diff --git a/node_modules/@angular/material/dialog/index.d.ts b/node_modules/@angular/material/dialog/index.d.ts
|
|
2
|
-
index 7d4f965..cd6bdcf 100644
|
|
3
|
-
--- a/node_modules/@angular/material/dialog/index.d.ts
|
|
4
|
-
+++ b/node_modules/@angular/material/dialog/index.d.ts
|
|
5
|
-
@@ -428,7 +428,7 @@ export declare class MatDialogModule {
|
|
6
|
-
/**
|
|
7
|
-
* Reference to a dialog opened via the MatDialog service.
|
|
8
|
-
*/
|
|
9
|
-
-export declare class MatDialogRef<T, R = any> {
|
|
10
|
-
+export declare class MatDialogRef<T, R = void> {
|
|
11
|
-
private _ref;
|
|
12
|
-
_containerInstance: _MatDialogContainerBase;
|
|
13
|
-
/** The instance of component opened into the dialog. */
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
diff --git a/node_modules/@angular/material/dialog/index.d.ts b/node_modules/@angular/material/dialog/index.d.ts
|
|
2
|
-
index e1a0275..efecaab 100644
|
|
3
|
-
--- a/node_modules/@angular/material/dialog/index.d.ts
|
|
4
|
-
+++ b/node_modules/@angular/material/dialog/index.d.ts
|
|
5
|
-
@@ -420,7 +420,7 @@ export declare class MatDialogModule {
|
|
6
|
-
/**
|
|
7
|
-
* Reference to a dialog opened via the MatDialog service.
|
|
8
|
-
*/
|
|
9
|
-
-export declare class MatDialogRef<T, R = any> {
|
|
10
|
-
+export declare class MatDialogRef<T, R = void> {
|
|
11
|
-
private _ref;
|
|
12
|
-
_containerInstance: MatDialogContainer;
|
|
13
|
-
/** The instance of component opened into the dialog. */
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
diff --git a/node_modules/@nx/angular/src/generators/add-linting/lib/create-eslint-configuration.js b/node_modules/@nx/angular/src/generators/add-linting/lib/create-eslint-configuration.js
|
|
2
|
-
index 7acd7d3..dde125a 100644
|
|
3
|
-
--- a/node_modules/@nx/angular/src/generators/add-linting/lib/create-eslint-configuration.js
|
|
4
|
-
+++ b/node_modules/@nx/angular/src/generators/add-linting/lib/create-eslint-configuration.js
|
|
5
|
-
@@ -7,8 +7,6 @@ const extendAngularEslintJson = (json, options) => {
|
|
6
|
-
const overrides = [
|
|
7
|
-
Object.assign(Object.assign({}, json.overrides[0]), { files: ['*.ts'], extends: [
|
|
8
|
-
...(json.overrides[0].extends || []),
|
|
9
|
-
- 'plugin:@nx/angular',
|
|
10
|
-
- 'plugin:@angular-eslint/template/process-inline-templates',
|
|
11
|
-
], rules: {
|
|
12
|
-
'@angular-eslint/directive-selector': [
|
|
13
|
-
'error',
|
|
14
|
-
@@ -27,15 +25,6 @@ const extendAngularEslintJson = (json, options) => {
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
} }),
|
|
18
|
-
- {
|
|
19
|
-
- files: ['*.html'],
|
|
20
|
-
- extends: ['plugin:@nx/angular-template'],
|
|
21
|
-
- /**
|
|
22
|
-
- * Having an empty rules object present makes it more obvious to the user where they would
|
|
23
|
-
- * extend things from if they needed to
|
|
24
|
-
- */
|
|
25
|
-
- rules: {},
|
|
26
|
-
- },
|
|
27
|
-
];
|
|
28
|
-
return Object.assign(Object.assign({}, json), { overrides });
|
|
29
|
-
};
|
|
30
|
-
@@ -53,10 +42,6 @@ function createEsLintConfiguration(tree, options) {
|
|
31
|
-
overrides: [
|
|
32
|
-
{
|
|
33
|
-
files: ['*.ts'],
|
|
34
|
-
- extends: [
|
|
35
|
-
- 'plugin:@nx/angular',
|
|
36
|
-
- 'plugin:@angular-eslint/template/process-inline-templates',
|
|
37
|
-
- ],
|
|
38
|
-
/**
|
|
39
|
-
* NOTE: We no longer set parserOptions.project by default when creating new projects.
|
|
40
|
-
*
|
|
41
|
-
@@ -94,15 +79,6 @@ function createEsLintConfiguration(tree, options) {
|
|
42
|
-
],
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
- {
|
|
46
|
-
- files: ['*.html'],
|
|
47
|
-
- extends: ['plugin:@nx/angular-template'],
|
|
48
|
-
- /**
|
|
49
|
-
- * Having an empty rules object present makes it more obvious to the user where they would
|
|
50
|
-
- * extend things from if they needed to
|
|
51
|
-
- */
|
|
52
|
-
- rules: {},
|
|
53
|
-
- },
|
|
54
|
-
],
|
|
55
|
-
};
|
|
56
|
-
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.projectRoot, '.eslintrc.json'), configJson);
|