eslint-config-beslogic 3.2.1 → 3.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/.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/dprint-json-like.json",
6
+ "extends": "https://raw.githubusercontent.com/BesLogic/shared-configs/main/.dprint-json-like.jsonc",
7
7
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.3.0
4
+
5
+ (backport of 4.3.0)
6
+
7
+ - Correctly also disable `compilerOptions.emitDecoratorMetadata` when disabling `compilerOptions.experimentalDecorators` out of the box
8
+ - Added instructions to explicitely enable both on Angular projects using experimental decorators
9
+ - Added a `tsconfig.5.6.json` TSConfig preset with `noUncheckedSideEffectImports` enabled
10
+ - Enabled `compilerOptions.resolveJsonModule` by default
11
+ - Enabled `compilerOptions.checkJS` by default
12
+ - Relaxed `prefer-arrow/prefer-arrow-functions` for `**/*[.-]service.ts` files as we expected `@Injectable` to have lifecycle methods
13
+ - Disabled `@typescript-eslint/prefer-for-of` and `sonarjs/prefer-for-of` in favor of `unicorn/no-for-loop`
14
+ - Allowed `i++` in "loop afterthrought" (`for (i = 0; i < l; i++)`) for rule `autofix/no-plusplus`
15
+ - Set `@typescript-eslint/switch-exhaustiveness-check`'s `considerDefaultExhaustiveForUnions` to `false` in non-extra-strict preset
16
+ - Disabled `unicorn/no-useless-switch-case` in extra-strict preset as it and conflicts with `considerDefaultExhaustiveForUnions`
17
+ - Bumped `@stylistic/eslint-plugin` to `^2.12.0` as it fixed `jsx-wrap-multilines` breaking in the presence of comments
18
+ - Bumped `dprint` to `^0.46` to ensure .gitignore support
19
+
20
+ ## 3.2.2
21
+
22
+ - Disabled `unicorn/no-useless-switch-case` in extra-strict preset as it conflicts with `considerDefaultExhaustiveForUnions`
23
+ - Relaxed `prefer-arrow/prefer-arrow-functions` for `**/*[.-]service.ts` files as we expected `@Injectable` to have lifecycle methods
24
+
3
25
  ## 3.2.1
4
26
 
5
27
  - Disabled `@typescript-eslint/no-misused-spread`:\
@@ -82,7 +104,6 @@
82
104
  }
83
105
  ```
84
106
 
85
- ```
86
107
  `eslint-plugin-sonarjs@2` added a ton of rules, a lot of which duplicates base ESLint rules and other plugins we have. _**Please report those you find**_
87
108
 
88
109
  ### Changes
@@ -293,4 +314,3 @@
293
314
  - Changed the maximum line length from `120` to `100`
294
315
  - Split language-specific `editor.defaultFormatter` to work around
295
316
  <https://github.com/microsoft/vscode/issues/168411>
296
- ```
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.js CHANGED
@@ -49,7 +49,7 @@ const typeDefinitionOverride = typescriptConfig
49
49
  .overrides
50
50
  ?.find(override => override.files === "*.d.ts")
51
51
 
52
- const noAutofixRreferArrowFunctionsConfig = javascriptConfig
52
+ const noAutofixPreferArrowFunctionsConfig = javascriptConfig
53
53
  .rules
54
54
  ?.["no-autofix/prefer-arrow/prefer-arrow-functions"]
55
55
  ?.[1]
@@ -296,6 +296,7 @@ module.exports = {
296
296
  "*[.-]component.ts",
297
297
  "*[.-]directive.ts",
298
298
  "*[.-]interceptor.ts",
299
+ "*[.-]service.ts", // @Injectable
299
300
  "*[.-]pipes.ts"
300
301
  ],
301
302
  "rules": {
@@ -306,7 +307,7 @@ module.exports = {
306
307
  "no-autofix/prefer-arrow/prefer-arrow-functions": [
307
308
  "error",
308
309
  {
309
- ...noAutofixRreferArrowFunctionsConfig,
310
+ ...noAutofixPreferArrowFunctionsConfig,
310
311
  // https://github.com/TristonJ/eslint-plugin-prefer-arrow/issues/17
311
312
  "classPropertiesAllowed": false
312
313
  }
package/extra-strict.js CHANGED
@@ -70,6 +70,8 @@ module.exports = {
70
70
  "allowNullish": false
71
71
  }
72
72
  ],
73
+ // Unconfigurable and conflicts with `considerDefaultExhaustiveForUnions: true` (set in v4)
74
+ "unicorn/no-useless-switch-case": "off",
73
75
 
74
76
  /*
75
77
  * @typescript-eslint rules that require strictNullChecks
package/javascript.js CHANGED
@@ -76,6 +76,10 @@ module.exports = {
76
76
  */
77
77
  "rules": {
78
78
  "autofix/no-caller": "error",
79
+ "autofix/no-plusplus": [
80
+ "error",
81
+ { "allowForLoopAfterthoughts": true }
82
+ ],
79
83
  "autofix/no-proto": "error",
80
84
  "autofix/no-prototype-builtins": "error",
81
85
  "autofix/no-throw-literal": "error",
@@ -333,6 +337,8 @@ module.exports = {
333
337
  "sonarjs/todo-tag": "off",
334
338
  // Duplicates unicorn/prefer-string-starts-ends-with
335
339
  "sonarjs/prefer-string-starts-ends-with": "off",
340
+ // Duplicates unicorn/no-for-loop and typescript-eslint/prefer-for-of
341
+ "sonarjs/prefer-for-of": "off",
336
342
  // Duplicates no-nested-ternary and unicorn/no-nested-ternary
337
343
  "sonarjs/no-nested-conditional": "off",
338
344
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-beslogic",
3
- "version": "3.2.1",
3
+ "version": "3.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",
@@ -43,12 +43,12 @@
43
43
  "// eslint-plugin-sonarjs": "Exact version pin. Check for new presets and typescript-eslint@8 support as we",
44
44
  "dependencies": {
45
45
  "@eslint-community/eslint-plugin-eslint-comments": "^4.1",
46
- "@stylistic/eslint-plugin": "^2.8.0",
46
+ "@stylistic/eslint-plugin": "^2.12.0",
47
47
  "@typescript-eslint/eslint-plugin": "^8.15.0",
48
48
  "@typescript-eslint/parser": "^8.15.0",
49
49
  "@types/eslint": "^8.56",
50
50
  "confusing-browser-globals": "^1.0",
51
- "dprint": "^0.40.2",
51
+ "dprint": "^0.46.0",
52
52
  "eslint": "^8.57",
53
53
  "eslint-import-resolver-typescript": "^3.2.6",
54
54
  "eslint-plugin-autofix": "^1.1 || ^2.0",
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 this is no longer needed for Angular with TypeScript 5, let's
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
@@ -1,14 +1,16 @@
1
1
  {
2
- "extends": "./tsconfig.4.3.json",
2
+ "extends": "./tsconfig.5.6.json",
3
3
  "compilerOptions": {
4
- "moduleResolution": "Node16",
5
- "module": "Node16",
4
+ "module": "nodenext", // Set to node18 once we update to typescript 5.8
6
5
  "allowSyntheticDefaultImports": true,
7
6
  "noUncheckedIndexedAccess": false,
8
7
  "noEmit": true,
9
8
  "jsx": "react",
10
9
  "allowJs": true,
11
- "checkJs": true,
12
10
  "noImplicitAny": false,
11
+ // For Angular tests
12
+ "verbatimModuleSyntax": false,
13
+ "emitDecoratorMetadata": true,
14
+ "experimentalDecorators": true,
13
15
  },
14
16
  }
package/typescript.js CHANGED
@@ -299,6 +299,11 @@ module.exports = {
299
299
  ],
300
300
  "@typescript-eslint/prefer-enum-initializers": "off",
301
301
 
302
+ // Very similar to `unicorn/no-for-loop` but doesn't have autofixes.
303
+ // TODO: If autofixes or suggestion is added, prefer over unicorn's
304
+ // https://github.com/typescript-eslint/typescript-eslint/issues/11336
305
+ "@typescript-eslint/prefer-for-of": "off",
306
+
302
307
  // TODO: Would accept this if it had autofixes, otherwise this is too tedious to use. Check again later
303
308
  "@typescript-eslint/prefer-readonly-parameter-types": "off",
304
309
  "@typescript-eslint/prefer-string-starts-ends-with": [