eslint-config-beslogic 4.2.2 → 4.3.2
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/.dprint.jsonc +1 -1
- package/CHANGELOG.md +29 -0
- package/README.md +15 -0
- package/TODO-SONARJS_CHECK_IF_DUPLICATED.json +0 -1
- package/angular.mjs +7 -2
- package/extra-strict.mjs +9 -0
- package/javascript.mjs +12 -3
- package/node-js.mjs +1 -0
- package/package.json +3 -3
- package/react.mjs +5 -1
- package/tsconfig.4.3.json +2 -0
- package/tsconfig.5.0.json +5 -1
- package/tsconfig.5.6.json +15 -0
- package/tsconfig.json +4 -6
- package/typescript.mjs +13 -1
package/.dprint.jsonc
CHANGED
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
|
|
4
4
|
{
|
|
5
5
|
// https://dprint.dev/config/#extending-a-different-configuration-file
|
|
6
|
-
"extends": "https://raw.githubusercontent.com/BesLogic/shared-configs/main
|
|
6
|
+
"extends": "https://raw.githubusercontent.com/BesLogic/shared-configs/main/.dprint-json-like.jsonc",
|
|
7
7
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.3.2
|
|
4
|
+
|
|
5
|
+
- Disabled `@angular-eslint/no-host-metadata-property` as it is now the recommendation for signals. See <https://github.com/angular-eslint/angular-eslint/discussions/2303>
|
|
6
|
+
- Allowed `0n` as a magic value by default
|
|
7
|
+
|
|
8
|
+
## 4.3.0
|
|
9
|
+
|
|
10
|
+
- Correctly also disable `compilerOptions.emitDecoratorMetadata` when disabling `compilerOptions.experimentalDecorators` out of the box
|
|
11
|
+
- Added instructions to explicitely enable both on Angular projects using experimental decorators
|
|
12
|
+
- Added a `tsconfig.5.6.json` TSConfig preset with `noUncheckedSideEffectImports` enabled
|
|
13
|
+
- Enabled `compilerOptions.resolveJsonModule` by default
|
|
14
|
+
- Enabled `compilerOptions.checkJS` by default
|
|
15
|
+
- Relaxed `prefer-arrow/prefer-arrow-functions` for `**/*[.-]service.ts` files as we expected `@Injectable` to have lifecycle methods
|
|
16
|
+
- Disabled `@typescript-eslint/prefer-for-of` and `sonarjs/prefer-for-of` in favor of `unicorn/no-for-loop`
|
|
17
|
+
- Allowed `i++` in "loop afterthrought" (`for (i = 0; i < l; i++)`) for rule `autofix/no-plusplus`
|
|
18
|
+
- Set `@typescript-eslint/switch-exhaustiveness-check`'s `considerDefaultExhaustiveForUnions` to `false` in non-extra-strict preset
|
|
19
|
+
- Disabled `unicorn/no-useless-switch-case` in extra-strict preset as it and conflicts with `considerDefaultExhaustiveForUnions`
|
|
20
|
+
- Bumped `@stylistic/eslint-plugin` to `^2.12.0` as it fixed `jsx-wrap-multilines` breaking in the presence of comments
|
|
21
|
+
- Bumped `dprint` to `^0.46` to ensure .gitignore support
|
|
22
|
+
|
|
3
23
|
## 4.2.2
|
|
4
24
|
|
|
5
25
|
- Exclude `<select>` and `<textarea>` from `react/jsx-props-no-spreading` as it is very often needed for custom inputs and validation using Higher Order Components
|
|
@@ -58,6 +78,15 @@
|
|
|
58
78
|
- Bumped `eslint-plugin-react` to `^7.37.1`
|
|
59
79
|
- Added dependency on `@eslint/compat` and `eslint-config-flat-gitignore`
|
|
60
80
|
|
|
81
|
+
## 3.2.1
|
|
82
|
+
|
|
83
|
+
- Disabled `@typescript-eslint/no-misused-spread`:\
|
|
84
|
+
Still a handful of false-positives and I couldn't get the configuration working.\
|
|
85
|
+
Especially annoying with autogenerated API when spreading class instance
|
|
86
|
+
with readonly properties as its contructor object.\
|
|
87
|
+
ie: `new Myclass({...someInstance, overwritten_prop: "foo"})`\
|
|
88
|
+
NOTE: If fixed, we'd still only want this in extra-strict config.
|
|
89
|
+
|
|
61
90
|
## 3.2.0
|
|
62
91
|
|
|
63
92
|
- Migrated from `eslint-plugin-import` to `eslint-plugin-import-x@^4.2.1` for performance and better support.
|
package/README.md
CHANGED
|
@@ -23,6 +23,12 @@ Read the [`package.json`](https://github.com/BesLogic/shared-configs/blob/main/R
|
|
|
23
23
|
|
|
24
24
|
Extend the following in your base `tsconfig.json` (follow link for more details):
|
|
25
25
|
|
|
26
|
+
[`typescript@>=5.6`](https://socket.dev/npm/package/eslint-config-beslogic/files/latest/tsconfig.5.6.json):
|
|
27
|
+
|
|
28
|
+
```jsonc
|
|
29
|
+
"extends": ["eslint-config-beslogic/tsconfig.5.6.json"],
|
|
30
|
+
```
|
|
31
|
+
|
|
26
32
|
[`typescript@>=5.0`](https://socket.dev/npm/package/eslint-config-beslogic/files/latest/tsconfig.5.0.json):
|
|
27
33
|
|
|
28
34
|
```jsonc
|
|
@@ -37,6 +43,15 @@ Extend the following in your base `tsconfig.json` (follow link for more details)
|
|
|
37
43
|
|
|
38
44
|
"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 }`.
|
|
39
45
|
|
|
46
|
+
If using experimental decorators (likely for an Angular project), you still need to set
|
|
47
|
+
|
|
48
|
+
```jsonc
|
|
49
|
+
"compilerOptions": {
|
|
50
|
+
"emitDecoratorMetadata": true,
|
|
51
|
+
"experimentalDecorators": true,
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
40
55
|
If deploying / bundling with an Angular npm package, also set `angularCompilerOptions": { "strictMetadataEmit": true }`.
|
|
41
56
|
|
|
42
57
|
### `.vscode/settings.json` and `.vscode/extensions.json`
|
|
@@ -136,7 +136,6 @@
|
|
|
136
136
|
"sonarjs/os-command": "error",
|
|
137
137
|
"sonarjs/post-message": "error",
|
|
138
138
|
"sonarjs/prefer-default-last": "error",
|
|
139
|
-
"sonarjs/prefer-for-of": "error",
|
|
140
139
|
"sonarjs/prefer-function-type": "error",
|
|
141
140
|
"sonarjs/prefer-namespace-keyword": "error",
|
|
142
141
|
"sonarjs/prefer-promise-shorthand": "error",
|
package/angular.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import rxjsAngular from "eslint-plugin-rxjs-angular"
|
|
|
7
7
|
import testingLibrary from "eslint-plugin-testing-library"
|
|
8
8
|
import tseslint from "typescript-eslint"
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { noAutofixPreferArrowFunctionsConfig, noRestrictedSyntax as noRestrictedSyntaxJS, preferArrowFunctionsConfig, preventAbbreviationsConfig as preventAbbreviationsConfigJS } from "./javascript.mjs"
|
|
11
11
|
import { getModuleVersion, jestFilePatterns, jestNoRestrictedSyntax } from "./lib/utils.mjs"
|
|
12
12
|
import beslogicNodeJS from "./node-js.mjs"
|
|
13
13
|
import beslogicRXJS from "./rxjs.mjs"
|
|
@@ -202,6 +202,10 @@ export default tseslint.config(
|
|
|
202
202
|
"style": "camelCase"
|
|
203
203
|
}
|
|
204
204
|
],
|
|
205
|
+
// Deprecated in v18, removed in v19.
|
|
206
|
+
// TODO: Adopt the inverse rule once it's been created. This is the recommendation for signals
|
|
207
|
+
// See https://github.com/angular-eslint/angular-eslint/discussions/2303
|
|
208
|
+
"@angular-eslint/no-host-metadata-property": "off",
|
|
205
209
|
"@angular-eslint/prefer-on-push-component-change-detection": "off",
|
|
206
210
|
// We need to disable the autofix because some of the "new" standalone components
|
|
207
211
|
// would still be declared in their module. This breaks Angular and requires manual changes.
|
|
@@ -282,6 +286,7 @@ export default tseslint.config(
|
|
|
282
286
|
"**/*[.-]component.ts",
|
|
283
287
|
"**/*[.-]directive.ts",
|
|
284
288
|
"**/*[.-]interceptor.ts",
|
|
289
|
+
"**/*[.-]service.ts", // @Injectable
|
|
285
290
|
"**/*[.-]pipes.ts"
|
|
286
291
|
],
|
|
287
292
|
"rules": {
|
|
@@ -292,7 +297,7 @@ export default tseslint.config(
|
|
|
292
297
|
"no-autofix/prefer-arrow/prefer-arrow-functions": [
|
|
293
298
|
"error",
|
|
294
299
|
{
|
|
295
|
-
...
|
|
300
|
+
...noAutofixPreferArrowFunctionsConfig,
|
|
296
301
|
// https://github.com/TristonJ/eslint-plugin-prefer-arrow/issues/17
|
|
297
302
|
"classPropertiesAllowed": false
|
|
298
303
|
}
|
package/extra-strict.mjs
CHANGED
|
@@ -76,6 +76,15 @@ export default tseslint.config(
|
|
|
76
76
|
"allowNullish": false
|
|
77
77
|
}
|
|
78
78
|
],
|
|
79
|
+
"@typescript-eslint/switch-exhaustiveness-check": [
|
|
80
|
+
"error",
|
|
81
|
+
{
|
|
82
|
+
"requireDefaultForNonUnion": true,
|
|
83
|
+
"considerDefaultExhaustiveForUnions": true
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
// Unconfigurable and conflicts with `considerDefaultExhaustiveForUnions: true`
|
|
87
|
+
"unicorn/no-useless-switch-case": "off",
|
|
79
88
|
|
|
80
89
|
/*
|
|
81
90
|
* @typescript-eslint rules that require strictNullChecks
|
package/javascript.mjs
CHANGED
|
@@ -46,6 +46,8 @@ export const noMagicNumbersConfig = {
|
|
|
46
46
|
// "detectObjects": true,
|
|
47
47
|
"enforceConst": true,
|
|
48
48
|
"ignore": [
|
|
49
|
+
// Used in Falsy type definition
|
|
50
|
+
"0n",
|
|
49
51
|
// Access first element
|
|
50
52
|
0,
|
|
51
53
|
// Off by one indexes & comparisons
|
|
@@ -159,7 +161,7 @@ export const noRestrictedImportsConfig = {
|
|
|
159
161
|
}
|
|
160
162
|
]
|
|
161
163
|
}
|
|
162
|
-
export const
|
|
164
|
+
export const noAutofixPreferArrowFunctionsConfig = {
|
|
163
165
|
"classPropertiesAllowed": true,
|
|
164
166
|
"disallowPrototype": true,
|
|
165
167
|
"singleReturnOnly": false,
|
|
@@ -179,6 +181,7 @@ export default tseslint.config(
|
|
|
179
181
|
sonarjs.configs.recommended,
|
|
180
182
|
unicorn.configs["flat/all"],
|
|
181
183
|
regexp.configs["flat/recommended"],
|
|
184
|
+
// @ts-expect-error: Fixed by https://github.com/un-ts/eslint-plugin-import-x/releases/tag/v4.13.3
|
|
182
185
|
pluginImportX.flatConfigs.recommended,
|
|
183
186
|
comments.recommended,
|
|
184
187
|
{
|
|
@@ -234,6 +237,8 @@ export default tseslint.config(
|
|
|
234
237
|
"sonarjs/todo-tag": "off",
|
|
235
238
|
// Duplicates unicorn/prefer-string-starts-ends-with
|
|
236
239
|
"sonarjs/prefer-string-starts-ends-with": "off",
|
|
240
|
+
// Duplicates unicorn/no-for-loop and typescript-eslint/prefer-for-of
|
|
241
|
+
"sonarjs/prefer-for-of": "off",
|
|
237
242
|
// Duplicates no-nested-ternary and unicorn/no-nested-ternary
|
|
238
243
|
"sonarjs/no-nested-conditional": "off",
|
|
239
244
|
|
|
@@ -434,7 +439,7 @@ export default tseslint.config(
|
|
|
434
439
|
// Packages.
|
|
435
440
|
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
|
|
436
441
|
["^@?\\w"],
|
|
437
|
-
// Absolute imports and other imports such as Vue
|
|
442
|
+
// Absolute imports and other imports such as Vue or Next style `@/foo`.
|
|
438
443
|
// Anything not matched in another group.
|
|
439
444
|
["^"],
|
|
440
445
|
// Relative imports.
|
|
@@ -452,7 +457,7 @@ export default tseslint.config(
|
|
|
452
457
|
// but we still want to check for other cases
|
|
453
458
|
"no-autofix/prefer-arrow/prefer-arrow-functions": [
|
|
454
459
|
"error",
|
|
455
|
-
|
|
460
|
+
noAutofixPreferArrowFunctionsConfig
|
|
456
461
|
],
|
|
457
462
|
"prefer-arrow/prefer-arrow-functions": [
|
|
458
463
|
"error",
|
|
@@ -834,6 +839,10 @@ export default tseslint.config(
|
|
|
834
839
|
*/
|
|
835
840
|
"rules": {
|
|
836
841
|
"autofix/no-caller": "error",
|
|
842
|
+
"autofix/no-plusplus": [
|
|
843
|
+
"error",
|
|
844
|
+
{ "allowForLoopAfterthoughts": true }
|
|
845
|
+
],
|
|
837
846
|
"autofix/no-proto": "error",
|
|
838
847
|
"autofix/no-prototype-builtins": "error",
|
|
839
848
|
"autofix/no-throw-literal": "error",
|
package/node-js.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-beslogic",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.2",
|
|
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",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.1",
|
|
47
47
|
"@eslint/compat": "^1.2.4",
|
|
48
|
-
"@stylistic/eslint-plugin": "^2.
|
|
48
|
+
"@stylistic/eslint-plugin": "^2.12.0",
|
|
49
49
|
"@types/eslint": "^8.56",
|
|
50
50
|
"confusing-browser-globals": "^1.0",
|
|
51
|
-
"dprint": "^0.
|
|
51
|
+
"dprint": "^0.46.0",
|
|
52
52
|
"eslint": "^8.56 || ^9.12",
|
|
53
53
|
"eslint-config-flat-gitignore": "^1.0.0",
|
|
54
54
|
"eslint-import-resolver-typescript": "^3.2.6",
|
package/react.mjs
CHANGED
|
@@ -147,7 +147,11 @@ export default tseslint.config(
|
|
|
147
147
|
"explicitSpread": "ignore",
|
|
148
148
|
"custom": "ignore",
|
|
149
149
|
// Very often needed for custom inputs and validation using Higher Order Components
|
|
150
|
-
"exceptions": [
|
|
150
|
+
"exceptions": [
|
|
151
|
+
"input",
|
|
152
|
+
"select",
|
|
153
|
+
"textarea"
|
|
154
|
+
]
|
|
151
155
|
}
|
|
152
156
|
],
|
|
153
157
|
"react/prop-types": "off",
|
package/tsconfig.4.3.json
CHANGED
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
{
|
|
5
5
|
"compilerOptions": {
|
|
6
6
|
"strict": true,
|
|
7
|
+
"checkJs": true,
|
|
7
8
|
"newLine": "LF", // Now default in TypeScript 5.0
|
|
8
9
|
"forceConsistentCasingInFileNames": true, // Now default in TypeScript 5.0
|
|
10
|
+
"resolveJsonModule": true,
|
|
9
11
|
"noFallthroughCasesInSwitch": true,
|
|
10
12
|
"noImplicitOverride": true,
|
|
11
13
|
"noImplicitReturns": true,
|
package/tsconfig.5.0.json
CHANGED
|
@@ -5,10 +5,14 @@
|
|
|
5
5
|
"extends": "./tsconfig.4.3.json",
|
|
6
6
|
"compilerOptions": {
|
|
7
7
|
"verbatimModuleSyntax": true,
|
|
8
|
-
// Since
|
|
8
|
+
// Since these are no longer needed for most projects with TypeScript 5, let's
|
|
9
9
|
// disable it so @typescript-eslint/consistent-type-imports doesn't turn
|
|
10
10
|
// itself off in files using decorators.
|
|
11
|
+
// Likely still needed in Angular, if you wanna try without,
|
|
12
|
+
// see https://angular.dev/reference/migrations/inject-function for migrating @Inject
|
|
13
|
+
//
|
|
11
14
|
// https://typescript-eslint.io/rules/consistent-type-imports/#caveat-decorators--experimentaldecorators-true--emitdecoratormetadata-true
|
|
15
|
+
"emitDecoratorMetadata": false,
|
|
12
16
|
"experimentalDecorators": false
|
|
13
17
|
}
|
|
14
18
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Copyright 2025 Beslogic Inc.
|
|
3
|
+
|
|
4
|
+
{
|
|
5
|
+
"extends": "./tsconfig.5.0.json",
|
|
6
|
+
"compilerOptions": {
|
|
7
|
+
"noUncheckedSideEffectImports": true
|
|
8
|
+
// Likely still needed in Angular, if you wanna try without,
|
|
9
|
+
// see https://angular.dev/reference/migrations/inject-function for migrating @Inject
|
|
10
|
+
//
|
|
11
|
+
// https://typescript-eslint.io/rules/consistent-type-imports/#caveat-decorators--experimentaldecorators-true--emitdecoratormetadata-true
|
|
12
|
+
// "emitDecoratorMetadata": true,
|
|
13
|
+
// "experimentalDecorators": true,
|
|
14
|
+
}
|
|
15
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -2,16 +2,14 @@
|
|
|
2
2
|
// Copyright 2024 Beslogic Inc.
|
|
3
3
|
|
|
4
4
|
{
|
|
5
|
-
"extends": "./tsconfig.
|
|
5
|
+
"extends": "./tsconfig.5.6.json",
|
|
6
6
|
"compilerOptions": {
|
|
7
|
-
"
|
|
8
|
-
"module": "Node16",
|
|
7
|
+
"module": "nodenext", // Set to node18 once we update to typescript 5.8
|
|
9
8
|
"allowSyntheticDefaultImports": true,
|
|
10
9
|
"noUncheckedIndexedAccess": false,
|
|
11
10
|
"noEmit": true,
|
|
12
11
|
"jsx": "react-jsx",
|
|
13
12
|
"allowJs": true,
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
}
|
|
13
|
+
"noImplicitAny": false,
|
|
14
|
+
},
|
|
17
15
|
}
|
package/typescript.mjs
CHANGED
|
@@ -79,6 +79,7 @@ export default tseslint.config(
|
|
|
79
79
|
...tseslint.configs.all,
|
|
80
80
|
// https://github.com/cartant/eslint-plugin-etc/issues/74
|
|
81
81
|
fixupConfigRules(compat.extends("plugin:etc/recommended")),
|
|
82
|
+
// @ts-expect-error: Fixed by https://github.com/un-ts/eslint-plugin-import-x/releases/tag/v4.13.3
|
|
82
83
|
pluginImportX.flatConfigs.typescript
|
|
83
84
|
],
|
|
84
85
|
"languageOptions": {
|
|
@@ -102,6 +103,7 @@ export default tseslint.config(
|
|
|
102
103
|
}
|
|
103
104
|
},
|
|
104
105
|
"settings": {
|
|
106
|
+
// This is apparently legacy in a recent update: https://github.com/un-ts/eslint-plugin-import-x/pull/272
|
|
105
107
|
"import-x/resolver": {
|
|
106
108
|
"typescript": {
|
|
107
109
|
// Recommended by eslint-import-resolver-typescript
|
|
@@ -334,6 +336,11 @@ export default tseslint.config(
|
|
|
334
336
|
],
|
|
335
337
|
"@typescript-eslint/prefer-enum-initializers": "off",
|
|
336
338
|
|
|
339
|
+
// Very similar to `unicorn/no-for-loop` but doesn't have autofixes.
|
|
340
|
+
// TODO: If autofixes or suggestion is added, prefer over unicorn's
|
|
341
|
+
// https://github.com/typescript-eslint/typescript-eslint/issues/11336
|
|
342
|
+
"@typescript-eslint/prefer-for-of": "off",
|
|
343
|
+
|
|
337
344
|
// TODO: Would accept this if it had autofixes, otherwise this is too tedious to use. Check again later
|
|
338
345
|
"@typescript-eslint/prefer-readonly-parameter-types": "off",
|
|
339
346
|
"@typescript-eslint/prefer-string-starts-ends-with": [
|
|
@@ -356,7 +363,12 @@ export default tseslint.config(
|
|
|
356
363
|
],
|
|
357
364
|
"@typescript-eslint/switch-exhaustiveness-check": [
|
|
358
365
|
"error",
|
|
359
|
-
{
|
|
366
|
+
{
|
|
367
|
+
"requireDefaultForNonUnion": true,
|
|
368
|
+
// Set to true in extra-strict configs
|
|
369
|
+
// Helps prevent conflicts with unicorn/no-useless-switch-case
|
|
370
|
+
"considerDefaultExhaustiveForUnions": false
|
|
371
|
+
}
|
|
360
372
|
],
|
|
361
373
|
"@typescript-eslint/unbound-method": [
|
|
362
374
|
"error",
|