eslint-config-beslogic 4.2.2 → 4.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,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.3.0
4
+
5
+ - Correctly also disable `compilerOptions.emitDecoratorMetadata` when disabling `compilerOptions.experimentalDecorators` out of the box
6
+ - Added instructions to explicitely enable both on Angular projects using experimental decorators
7
+ - Added a `tsconfig.5.6.json` TSConfig preset with `noUncheckedSideEffectImports` enabled
8
+ - Enabled `compilerOptions.resolveJsonModule` by default
9
+ - Enabled `compilerOptions.checkJS` by default
10
+ - Relaxed `prefer-arrow/prefer-arrow-functions` for `**/*[.-]service.ts` files as we expected `@Injectable` to have lifecycle methods
11
+ - Disabled `@typescript-eslint/prefer-for-of` and `sonarjs/prefer-for-of` in favor of `unicorn/no-for-loop`
12
+ - Allowed `i++` in "loop afterthrought" (`for (i = 0; i < l; i++)`) for rule `autofix/no-plusplus`
13
+ - Set `@typescript-eslint/switch-exhaustiveness-check`'s `considerDefaultExhaustiveForUnions` to `false` in non-extra-strict preset
14
+ - Disabled `unicorn/no-useless-switch-case` in extra-strict preset as it and conflicts with `considerDefaultExhaustiveForUnions`
15
+ - Bumped `@stylistic/eslint-plugin` to `^2.12.0` as it fixed `jsx-wrap-multilines` breaking in the presence of comments
16
+ - Bumped `dprint` to `^0.46` to ensure .gitignore support
17
+
3
18
  ## 4.2.2
4
19
 
5
20
  - 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 +73,15 @@
58
73
  - Bumped `eslint-plugin-react` to `^7.37.1`
59
74
  - Added dependency on `@eslint/compat` and `eslint-config-flat-gitignore`
60
75
 
76
+ ## 3.2.1
77
+
78
+ - Disabled `@typescript-eslint/no-misused-spread`:\
79
+ Still a handful of false-positives and I couldn't get the configuration working.\
80
+ Especially annoying with autogenerated API when spreading class instance
81
+ with readonly properties as its contructor object.\
82
+ ie: `new Myclass({...someInstance, overwritten_prop: "foo"})`\
83
+ NOTE: If fixed, we'd still only want this in extra-strict config.
84
+
61
85
  ## 3.2.0
62
86
 
63
87
  - 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 { noAutofixRreferArrowFunctionsConfig, noRestrictedSyntax as noRestrictedSyntaxJS, preferArrowFunctionsConfig, preventAbbreviationsConfig as preventAbbreviationsConfigJS } from "./javascript.mjs"
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"
@@ -282,6 +282,7 @@ export default tseslint.config(
282
282
  "**/*[.-]component.ts",
283
283
  "**/*[.-]directive.ts",
284
284
  "**/*[.-]interceptor.ts",
285
+ "**/*[.-]service.ts", // @Injectable
285
286
  "**/*[.-]pipes.ts"
286
287
  ],
287
288
  "rules": {
@@ -292,7 +293,7 @@ export default tseslint.config(
292
293
  "no-autofix/prefer-arrow/prefer-arrow-functions": [
293
294
  "error",
294
295
  {
295
- ...noAutofixRreferArrowFunctionsConfig,
296
+ ...noAutofixPreferArrowFunctionsConfig,
296
297
  // https://github.com/TristonJ/eslint-plugin-prefer-arrow/issues/17
297
298
  "classPropertiesAllowed": false
298
299
  }
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
@@ -159,7 +159,7 @@ export const noRestrictedImportsConfig = {
159
159
  }
160
160
  ]
161
161
  }
162
- export const noAutofixRreferArrowFunctionsConfig = {
162
+ export const noAutofixPreferArrowFunctionsConfig = {
163
163
  "classPropertiesAllowed": true,
164
164
  "disallowPrototype": true,
165
165
  "singleReturnOnly": false,
@@ -179,6 +179,7 @@ export default tseslint.config(
179
179
  sonarjs.configs.recommended,
180
180
  unicorn.configs["flat/all"],
181
181
  regexp.configs["flat/recommended"],
182
+ // @ts-expect-error: Fixed by https://github.com/un-ts/eslint-plugin-import-x/releases/tag/v4.13.3
182
183
  pluginImportX.flatConfigs.recommended,
183
184
  comments.recommended,
184
185
  {
@@ -234,6 +235,8 @@ export default tseslint.config(
234
235
  "sonarjs/todo-tag": "off",
235
236
  // Duplicates unicorn/prefer-string-starts-ends-with
236
237
  "sonarjs/prefer-string-starts-ends-with": "off",
238
+ // Duplicates unicorn/no-for-loop and typescript-eslint/prefer-for-of
239
+ "sonarjs/prefer-for-of": "off",
237
240
  // Duplicates no-nested-ternary and unicorn/no-nested-ternary
238
241
  "sonarjs/no-nested-conditional": "off",
239
242
 
@@ -452,7 +455,7 @@ export default tseslint.config(
452
455
  // but we still want to check for other cases
453
456
  "no-autofix/prefer-arrow/prefer-arrow-functions": [
454
457
  "error",
455
- noAutofixRreferArrowFunctionsConfig
458
+ noAutofixPreferArrowFunctionsConfig
456
459
  ],
457
460
  "prefer-arrow/prefer-arrow-functions": [
458
461
  "error",
@@ -834,6 +837,10 @@ export default tseslint.config(
834
837
  */
835
838
  "rules": {
836
839
  "autofix/no-caller": "error",
840
+ "autofix/no-plusplus": [
841
+ "error",
842
+ { "allowForLoopAfterthoughts": true }
843
+ ],
837
844
  "autofix/no-proto": "error",
838
845
  "autofix/no-prototype-builtins": "error",
839
846
  "autofix/no-throw-literal": "error",
package/node-js.mjs CHANGED
@@ -21,6 +21,7 @@ export default tseslint.config(
21
21
  n.configs["flat/recommended-script"],
22
22
  {
23
23
  "settings": {
24
+ // This is apparently legacy in a recent update: https://github.com/un-ts/eslint-plugin-import-x/pull/272
24
25
  "import-x/resolver": {
25
26
  "node": true
26
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-beslogic",
3
- "version": "4.2.2",
3
+ "version": "4.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",
@@ -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.8.0",
48
+ "@stylistic/eslint-plugin": "^2.12.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.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": ["input", "select", "textarea"]
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 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
@@ -2,16 +2,14 @@
2
2
  // Copyright 2024 Beslogic Inc.
3
3
 
4
4
  {
5
- "extends": "./tsconfig.4.3.json",
5
+ "extends": "./tsconfig.5.6.json",
6
6
  "compilerOptions": {
7
- "moduleResolution": "Node16",
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
- "checkJs": true,
15
- "noImplicitAny": false
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
- { "requireDefaultForNonUnion": true }
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",