eslint-config-beslogic 2.2.1 → 2.3.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/.azuredevops/pull_request_template.md +16 -0
- package/CHANGELOG.md +14 -3
- package/README.md +2 -2
- package/angular.js +3 -2
- package/javascript.js +10 -9
- package/jest.js +11 -2
- package/lib/patch-dependencies.js +7 -11
- package/lib/utils.js +8 -1
- package/package.json +1 -1
- package/react.js +6 -0
- package/storybook.js +2 -5
- package/tsconfig.4.3.json +4 -1
- package/typescript.js +6 -5
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Thank you for your contribution to Beslogic's **ESLint-Config-Beslogic** repo.
|
|
2
|
+
Before submitting this PR, please make sure:
|
|
3
|
+
|
|
4
|
+
- [ ] The project is building
|
|
5
|
+
- [ ] There are no linting issues
|
|
6
|
+
- [ ] You updated the projects' README.md and CHANGELOG.md with the new changes
|
|
7
|
+
- [ ] You reviewed your own PR and made sure there's no test/debug code or any obvious mistakes.
|
|
8
|
+
- [ ] You set and configured auto-complete to "Complete associated work items after merging" & "Delete \<branch> after merging".
|
|
9
|
+
- [ ] You cleaned up your commit history or set the PR Merge type to "Squash".
|
|
10
|
+
|
|
11
|
+
Make sure that the code wasn't copied from elsewhere (check one):
|
|
12
|
+
|
|
13
|
+
- [ ] This is your own original code
|
|
14
|
+
- [ ] You have made sure that we have permission to use the copied code and that we follow its licensing
|
|
15
|
+
|
|
16
|
+
_Add a short description_
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
## 2.3.0
|
|
6
|
+
|
|
7
|
+
- Allow single element equality for `@typescript-eslint/prefer-string-starts-ends-with`
|
|
8
|
+
- Disabled `unicorn/prefer-string-raw` for json-like and eslintrc.json
|
|
9
|
+
- Set tsconfig's `angularCompilerOptions.enableI18nLegacyMessageIdFormat` to `false`
|
|
10
|
+
- Set tsconfig's `compilerOptions.target` to `"ES2022"`
|
|
11
|
+
For more details, see [this `@angular/cli` warning](https://github.com/angular/angular-cli/blob/16.2.0/packages/angular_devkit/build_angular/src/tools/webpack/plugins/typescript.ts#L36-L39)
|
|
12
|
+
- Presets for Jest now consider the framework (Angular, React, or DOM)
|
|
13
|
+
- Updated Jest file matching to Jest's default patterns
|
|
14
|
+
- No longer leaving empty strings for eslint extends generated by NX
|
|
15
|
+
- Fixed an invalid syntax for `@nx/js` patching
|
|
16
|
+
|
|
3
17
|
## 2.2.1
|
|
4
18
|
|
|
5
19
|
- Bumped `eslint-plugin-react` to `^7.33`
|
|
@@ -29,7 +43,6 @@
|
|
|
29
43
|
- `jest/prefer-importing-jest-globals` is enabled by default, which removes needing a dependency
|
|
30
44
|
on often outdated `@types/jest` and removes the need for `types: ["jest"]` in `tsconfig.json`
|
|
31
45
|
- Bumped `dprint` to `^0.40.2` to prepare for process plugins
|
|
32
|
-
|
|
33
46
|
- Bumped `@typescript-eslint/eslint-plugin` to `^7.4`
|
|
34
47
|
- Re-enabled `@typescript-eslint/no-import-type-side-effects`
|
|
35
48
|
and set `@typescript-eslint/consistent-type-imports` back to default options
|
|
@@ -38,13 +51,11 @@
|
|
|
38
51
|
- Prefered `@typescript-eslint/prefer-destructuring` over `autofix/prefer-destructuring`
|
|
39
52
|
- Disabled `@typescript-eslint/key-spacing`, `autofix/func-call-spacing`,
|
|
40
53
|
and `lines-around-comment` in `dprint` preset
|
|
41
|
-
|
|
42
54
|
- Patched-out prettier from nx generators
|
|
43
55
|
- Used Search&Replace based package patching:
|
|
44
56
|
- Removes `patch-package` from dependencies
|
|
45
57
|
- Removes bundled git patches
|
|
46
58
|
- Speedup check for `eslint-plugin-total-functions` install
|
|
47
|
-
|
|
48
59
|
- Bumped `eslint-plugin-n` to `>=16.2`. Notably, this:
|
|
49
60
|
- improves support for ts-node
|
|
50
61
|
- Updates documentation links
|
package/README.md
CHANGED
|
@@ -99,7 +99,7 @@ Default preset, extends from `beslogic/javascript` and `beslogic/typescript`.
|
|
|
99
99
|
|
|
100
100
|
### `beslogic/jest`
|
|
101
101
|
|
|
102
|
-
[Jest](https://www.npmjs.com/package/jest) and [Testing Library](https://testing-library.com/) configs. Is already extended by `beslogic/javascript` and `beslogic/typescript` for all `*spec.[jt]s` and `*.test.[jt]sx` files. You should not need to extend from this configuration unless you want to add it to a test file that is not automatically picked up by the naming convention.
|
|
102
|
+
[Jest](https://www.npmjs.com/package/jest) and [Testing Library](https://testing-library.com/) configs. Is already extended by `beslogic/javascript` and `beslogic/typescript` for all `*spec.[jt]s` and `*.test.[jt]sx` files, as well as `*.[jt]s` and `*.[jt]sx` files inside of `__tests__` folders. You should not need to extend from this configuration unless you want to add it to a test file that is not automatically picked up by the naming convention.
|
|
103
103
|
|
|
104
104
|
### `beslogic/javascript`
|
|
105
105
|
|
|
@@ -179,7 +179,7 @@ npm install --save-dev eslint-plugin-mui eslint-plugin-jsx-a11y eslint-plugin-re
|
|
|
179
179
|
Configurations for NGX projects. Comes with `html` template and inline template support. Already extends `beslogic/rxjs` and `beslogic/typescript`. Also extends `beslogic/node-js` for Javascript files.
|
|
180
180
|
|
|
181
181
|
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)).\
|
|
182
|
-
If bundling
|
|
182
|
+
If bundling as an npm package set `"strictMetadataEmit": true` under `angularCompilerOptions`.
|
|
183
183
|
|
|
184
184
|
Add the following `devDependencies` to your `package.json`:
|
|
185
185
|
|
package/angular.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
// Copyright 2024 Beslogic Inc.
|
|
3
3
|
|
|
4
|
-
const { getModuleVersion, jestNoRestrictedSyntax } = require("./lib/utils")
|
|
4
|
+
const { getModuleVersion, jestNoRestrictedSyntax, jestFilePatterns } = require("./lib/utils")
|
|
5
5
|
|
|
6
6
|
const angularEslintVersion = getModuleVersion("@angular-eslint/eslint-plugin", 16.2)
|
|
7
7
|
const typescriptVersion = getModuleVersion("typescript", 4.7)
|
|
@@ -341,7 +341,8 @@ module.exports = {
|
|
|
341
341
|
}
|
|
342
342
|
},
|
|
343
343
|
{
|
|
344
|
-
"files":
|
|
344
|
+
"files": jestFilePatterns,
|
|
345
|
+
"extends": ["plugin:testing-library/angular"],
|
|
345
346
|
"rules": { "no-restricted-syntax": jestNoRestrictedSyntax(noRestrictedSyntax) }
|
|
346
347
|
},
|
|
347
348
|
{
|
package/javascript.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 Beslogic Inc.
|
|
3
3
|
|
|
4
4
|
const restrictedGlobals = require("confusing-browser-globals")
|
|
5
|
-
const { jestNoRestrictedSyntax } = require("./lib/utils")
|
|
5
|
+
const { jestNoRestrictedSyntax, jestFilePatterns } = require("./lib/utils")
|
|
6
6
|
|
|
7
7
|
const commaDangleDefault = "always-multiline"
|
|
8
8
|
const idLenghtConfig = {
|
|
@@ -379,10 +379,7 @@ module.exports = {
|
|
|
379
379
|
}
|
|
380
380
|
},
|
|
381
381
|
{
|
|
382
|
-
"files":
|
|
383
|
-
"*spec.js",
|
|
384
|
-
".test.jsx"
|
|
385
|
-
],
|
|
382
|
+
"files": jestFilePatterns,
|
|
386
383
|
"extends": ["./jest"],
|
|
387
384
|
"rules": { "no-restricted-syntax": jestNoRestrictedSyntax(noRestrictedSyntax) }
|
|
388
385
|
},
|
|
@@ -393,7 +390,11 @@ module.exports = {
|
|
|
393
390
|
],
|
|
394
391
|
// To reconsider, since this would conflict with a simple dprint default
|
|
395
392
|
// "extends": ["./json-like"]
|
|
396
|
-
"globals": { "module": true }
|
|
393
|
+
"globals": { "module": true },
|
|
394
|
+
"rules": {
|
|
395
|
+
// Keep consistent with preset rules
|
|
396
|
+
"unicorn/prefer-string-raw": "off"
|
|
397
|
+
}
|
|
397
398
|
}
|
|
398
399
|
],
|
|
399
400
|
"rules": {
|
|
@@ -576,18 +577,18 @@ module.exports = {
|
|
|
576
577
|
{
|
|
577
578
|
"groups": [
|
|
578
579
|
// Side effect imports.
|
|
579
|
-
[
|
|
580
|
+
["^\\u0000"],
|
|
580
581
|
// Node.js builtins prefixed with `node:`.
|
|
581
582
|
["^node:"],
|
|
582
583
|
// Packages.
|
|
583
584
|
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
|
|
584
|
-
[
|
|
585
|
+
["^@?\\w"],
|
|
585
586
|
// Absolute imports and other imports such as Vue-style `@/foo`.
|
|
586
587
|
// Anything not matched in another group.
|
|
587
588
|
["^"],
|
|
588
589
|
// Relative imports.
|
|
589
590
|
// Anything that starts with a dot or src/
|
|
590
|
-
[
|
|
591
|
+
["^(\\.|src/)"]
|
|
591
592
|
]
|
|
592
593
|
}
|
|
593
594
|
],
|
package/jest.js
CHANGED
|
@@ -9,7 +9,9 @@ module.exports = {
|
|
|
9
9
|
"extends": [
|
|
10
10
|
"plugin:jest/all",
|
|
11
11
|
"plugin:jest-formatting/strict",
|
|
12
|
-
|
|
12
|
+
// Note: The DOM preset includes some rules not in Marko or Vue (eg.: no-await-sync-events).
|
|
13
|
+
// Those must be disabled in their preset if we ever support them.
|
|
14
|
+
"plugin:testing-library/dom"
|
|
13
15
|
],
|
|
14
16
|
"env": {
|
|
15
17
|
"browser": false,
|
|
@@ -87,6 +89,13 @@ module.exports = {
|
|
|
87
89
|
{
|
|
88
90
|
"allow": ["beforeEach"]
|
|
89
91
|
}
|
|
90
|
-
]
|
|
92
|
+
],
|
|
93
|
+
|
|
94
|
+
/*
|
|
95
|
+
* testing-library overrides (https://github.com/testing-library/eslint-plugin-testing-library#supported-rules)
|
|
96
|
+
*/
|
|
97
|
+
"testing-library/no-debugging-utils": "error",
|
|
98
|
+
"testing-library/prefer-user-event": "warn",
|
|
99
|
+
"testing-library/prefer-explicit-assert": "error"
|
|
91
100
|
}
|
|
92
101
|
}
|
|
@@ -67,16 +67,11 @@ const patches = [
|
|
|
67
67
|
join(base, "src", "generators", "add-linting", "lib", "create-eslint-configuration.js"),
|
|
68
68
|
[
|
|
69
69
|
// Remove code that adds preset extensions
|
|
70
|
+
// plugin:@nx/angular-template
|
|
71
|
+
// plugin:@nx/angular
|
|
72
|
+
// plugin:@angular-eslint/template/process-inline-templates
|
|
70
73
|
{
|
|
71
|
-
"from":
|
|
72
|
-
"to": ""
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
"from": "plugin:@angular-eslint/template/process-inline-templates",
|
|
76
|
-
"to": ""
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
"from": "plugin:@nx/angular-template",
|
|
74
|
+
"from": /'plugin:.+?',?/gu,
|
|
80
75
|
"to": ""
|
|
81
76
|
},
|
|
82
77
|
// Remove empty extends
|
|
@@ -146,8 +141,9 @@ const patches = [
|
|
|
146
141
|
"to": "false"
|
|
147
142
|
},
|
|
148
143
|
{
|
|
149
|
-
|
|
150
|
-
"
|
|
144
|
+
// eslint-disable-next-line regexp/no-super-linear-move -- Is it really?
|
|
145
|
+
"from": /.+?devkit_1\.ensurePackage\)\('prettier'.+?[\n;]/gu,
|
|
146
|
+
"to": ""
|
|
151
147
|
}
|
|
152
148
|
]
|
|
153
149
|
)
|
package/lib/utils.js
CHANGED
|
@@ -36,8 +36,15 @@ const jestNoRestrictedSyntax = (
|
|
|
36
36
|
!entry.selector.startsWith("ArrowFunctionExpression")
|
|
37
37
|
)
|
|
38
38
|
|
|
39
|
+
// Matching Jest's own default file patterns: https://jestjs.io/docs/configuration#testmatch-arraystring
|
|
40
|
+
const jestFilePatterns = [
|
|
41
|
+
"**/__tests__/**/*.[jt]s?(x)",
|
|
42
|
+
"**/?(*.)+(spec|test).[jt]s?(x)"
|
|
43
|
+
]
|
|
44
|
+
|
|
39
45
|
module.exports = {
|
|
40
46
|
getModuleVersion,
|
|
41
47
|
jestNoRestrictedSyntax,
|
|
42
|
-
resolveModuleLocation
|
|
48
|
+
resolveModuleLocation,
|
|
49
|
+
jestFilePatterns
|
|
43
50
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-beslogic",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "ESLint rules, plugins and configs used at Beslogic",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"// dependencies": "Run for ourselves when we install dependencies w/o running npm i afterward",
|
package/react.js
CHANGED
|
@@ -17,6 +17,8 @@ preventAbbreviationsConfig.allowList.Props = true
|
|
|
17
17
|
preventAbbreviationsConfig.allowList.ref = true
|
|
18
18
|
preventAbbreviationsConfig.allowList.Ref = true
|
|
19
19
|
|
|
20
|
+
const { jestFilePatterns } = require("./lib/utils")
|
|
21
|
+
|
|
20
22
|
/** @type {import("eslint").Linter.Config} */
|
|
21
23
|
module.exports = {
|
|
22
24
|
"extends": [
|
|
@@ -88,6 +90,10 @@ module.exports = {
|
|
|
88
90
|
]
|
|
89
91
|
}
|
|
90
92
|
},
|
|
93
|
+
{
|
|
94
|
+
"files": jestFilePatterns,
|
|
95
|
+
"extends": ["plugin:testing-library/react"]
|
|
96
|
+
},
|
|
91
97
|
typeDefinitionOverride
|
|
92
98
|
],
|
|
93
99
|
"rules": {
|
package/storybook.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 Beslogic Inc.
|
|
3
3
|
|
|
4
4
|
const angularConfig = require("./angular")
|
|
5
|
-
const { jestNoRestrictedSyntax } = require("./lib/utils")
|
|
5
|
+
const { jestNoRestrictedSyntax, jestFilePatterns } = require("./lib/utils")
|
|
6
6
|
|
|
7
7
|
const noRestrictedSyntax = angularConfig.overrides?.[1].rules?.["no-restricted-syntax"]
|
|
8
8
|
/** @type {import("eslint").Linter.Config} */
|
|
@@ -28,10 +28,7 @@ module.exports = {
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
|
-
"files":
|
|
32
|
-
"*spec.ts",
|
|
33
|
-
".test.tsx"
|
|
34
|
-
],
|
|
31
|
+
"files": jestFilePatterns,
|
|
35
32
|
"rules": { "no-restricted-syntax": jestNoRestrictedSyntax(noRestrictedSyntax) }
|
|
36
33
|
}
|
|
37
34
|
]
|
package/tsconfig.4.3.json
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
// You should probably disable it at least in tests.
|
|
11
11
|
"noUncheckedIndexedAccess": true,
|
|
12
12
|
"module": "ESNext", // ESNext or CommonJS
|
|
13
|
-
|
|
13
|
+
// See: https://github.com/angular/angular-cli/blob/16.2.0/packages/angular_devkit/build_angular/src/tools/webpack/plugins/typescript.ts#L36-L39
|
|
14
|
+
"target": "ES2022", // ES2022 or higher
|
|
14
15
|
"lib": [
|
|
15
16
|
"ES2021", // ES2021 or higher
|
|
16
17
|
"DOM",
|
|
@@ -20,8 +21,10 @@
|
|
|
20
21
|
"emitDecoratorMetadata": true,
|
|
21
22
|
"experimentalDecorators": true
|
|
22
23
|
},
|
|
24
|
+
// https://next.angular.dev/reference/configs/angular-compiler-options
|
|
23
25
|
"angularCompilerOptions": {
|
|
24
26
|
// "strictMetadataEmit": true, // For bundling with an npm package
|
|
27
|
+
"enableI18nLegacyMessageIdFormat": false,
|
|
25
28
|
"strictInjectionParameters": true,
|
|
26
29
|
"strictInputAccessModifiers": true,
|
|
27
30
|
"strictTemplates": true,
|
package/typescript.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 Beslogic Inc.
|
|
3
3
|
|
|
4
4
|
const javascriptConfig = require("./javascript")
|
|
5
|
-
const { jestNoRestrictedSyntax } = require("./lib/utils")
|
|
5
|
+
const { jestNoRestrictedSyntax, jestFilePatterns } = require("./lib/utils")
|
|
6
6
|
const { resolveModuleLocation } = require("./lib/utils")
|
|
7
7
|
|
|
8
8
|
const commaDangleDefault = "always-multiline"
|
|
@@ -396,6 +396,10 @@ module.exports = {
|
|
|
396
396
|
"@typescript-eslint/prefer-enum-initializers": "off",
|
|
397
397
|
// TODO: Would accept this if it had autofixes, otherwise this is too tedious to use. Check again later
|
|
398
398
|
"@typescript-eslint/prefer-readonly-parameter-types": "off",
|
|
399
|
+
"@typescript-eslint/prefer-string-starts-ends-with": [
|
|
400
|
+
"error",
|
|
401
|
+
{ "allowSingleElementEquality": true }
|
|
402
|
+
],
|
|
399
403
|
"@typescript-eslint/promise-function-async": [
|
|
400
404
|
"error",
|
|
401
405
|
{
|
|
@@ -507,10 +511,7 @@ module.exports = {
|
|
|
507
511
|
}
|
|
508
512
|
},
|
|
509
513
|
{
|
|
510
|
-
"files":
|
|
511
|
-
"*spec.ts",
|
|
512
|
-
".test.tsx"
|
|
513
|
-
],
|
|
514
|
+
"files": jestFilePatterns,
|
|
514
515
|
"extends": ["./jest"],
|
|
515
516
|
"rules": {
|
|
516
517
|
"no-restricted-syntax": jestNoRestrictedSyntax(noRestrictedSyntax)
|