@enormora/eslint-config-typescript 0.0.39 → 0.0.40

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/package.json CHANGED
@@ -4,10 +4,10 @@
4
4
  "Christian Rackerseder <github@echooff.de>"
5
5
  ],
6
6
  "dependencies": {
7
- "@typescript-eslint/eslint-plugin": "8.59.4",
8
- "@typescript-eslint/parser": "8.59.4",
9
- "eslint-import-resolver-typescript": "4.4.4",
10
- "eslint-plugin-functional": "9.0.4",
7
+ "@typescript-eslint/eslint-plugin": "8.60.1",
8
+ "@typescript-eslint/parser": "8.60.1",
9
+ "eslint-import-resolver-typescript": "4.4.5",
10
+ "eslint-plugin-functional": "9.0.5",
11
11
  "eslint-plugin-import-x": "4.16.2",
12
12
  "eslint-plugin-perfectionist": "5.9.0"
13
13
  },
@@ -20,12 +20,12 @@
20
20
  "license": "MIT",
21
21
  "name": "@enormora/eslint-config-typescript",
22
22
  "peerDependencies": {
23
- "@enormora/eslint-config-base": "0.0.34"
23
+ "@enormora/eslint-config-base": "0.0.35"
24
24
  },
25
25
  "repository": {
26
26
  "type": "git",
27
27
  "url": "git://github.com/enormora/eslint-config.git"
28
28
  },
29
29
  "type": "module",
30
- "version": "0.0.39"
30
+ "version": "0.0.40"
31
31
  }
@@ -13,6 +13,10 @@ export const noTsEnumDeclarationRestriction = {
13
13
  message: 'Use a string union type instead'
14
14
  };
15
15
 
16
+ const namedReferenceIgnorePattern =
17
+ String.raw`^(?!(?:Array|ReadonlyArray|Map|ReadonlyMap|Set|ReadonlySet|Record|Readonly)\b)` +
18
+ String.raw`[A-Z][\w$]*(?:\.[A-Z][\w$]*)*(?:<.*>)?$`;
19
+
16
20
  const functionLikeNodes = [
17
21
  'FunctionDeclaration',
18
22
  'FunctionExpression',
@@ -82,7 +86,26 @@ export const typescriptConfig = {
82
86
  extensions: [ ...javascriptExtensions, ...typescriptExtensions ]
83
87
  }),
84
88
  createTypeScriptImportResolver()
85
- ]
89
+ ],
90
+ // The upstream defaults in `is-immutable-type` classify Date, URL,
91
+ // and URLSearchParams as Mutable, which poisons any union, record,
92
+ // or recursive value type that mentions them. We promote them — and
93
+ // a few more value-like built-ins — to ReadonlyShallow so consumers
94
+ // can use them without a Readonly<T> wrapper. Map and Set stay
95
+ // Mutable (via the upstream defaults) so the autofixer keeps
96
+ // rewriting them to ReadonlyMap/ReadonlySet.
97
+ immutability: {
98
+ overrides: [
99
+ { type: { from: 'lib', name: 'Date' }, to: 'ReadonlyShallow' },
100
+ { type: { from: 'lib', name: 'RegExp' }, to: 'ReadonlyShallow' },
101
+ { type: { from: 'lib', name: 'URL' }, to: 'ReadonlyShallow' },
102
+ { type: { from: 'lib', name: 'URLSearchParams' }, to: 'ReadonlyShallow' },
103
+ { type: { from: 'lib', name: 'WeakMap' }, to: 'ReadonlyShallow' },
104
+ { type: { from: 'lib', name: 'WeakSet' }, to: 'ReadonlyShallow' },
105
+ { type: { from: 'lib', name: 'Promise' }, to: 'ReadonlyShallow' },
106
+ { type: { from: 'lib', name: 'Error' }, to: 'ReadonlyShallow' }
107
+ ]
108
+ }
86
109
  },
87
110
  plugins: {
88
111
  '@typescript-eslint': typescriptPlugin,
@@ -165,6 +188,10 @@ export const typescriptConfig = {
165
188
  allowTypedFunctionExpressions: true
166
189
  }
167
190
  ],
191
+ // TS already validates return types, and the SonarJS heuristic
192
+ // misfires on intentional tagged-union returns (e.g. `Value | Sentinel`)
193
+ // even when expressed as a single named alias.
194
+ 'sonarjs/function-return-type': 'off',
168
195
  ...configureWrappedCoreRule('max-params'),
169
196
  '@typescript-eslint/member-ordering': 'error',
170
197
  ...configureWrappedCoreRule('no-array-constructor'),
@@ -365,6 +392,11 @@ export const typescriptConfig = {
365
392
  enforcement: 'ReadonlyShallow',
366
393
  ignoreClasses: false,
367
394
  ignoreInferredTypes: true,
395
+ // Mimics the deprecated functional/prefer-readonly-type: skip
396
+ // named class/interface/type-alias references whose upstream
397
+ // members are not declared readonly, so structural shallow
398
+ // checks cannot be satisfied by any annotation.
399
+ ignoreTypePattern: [ namedReferenceIgnorePattern ],
368
400
  fixer: {
369
401
  ReadonlyShallow: [
370
402
  {
@@ -378,6 +410,24 @@ export const typescriptConfig = {
378
410
  {
379
411
  pattern: '^(Map|Set)<(.+)>$',
380
412
  replace: 'Readonly$1<$2>'
413
+ },
414
+ {
415
+ pattern: '^Record<(.+)>$',
416
+ replace: 'Readonly<Record<$1>>'
417
+ },
418
+ {
419
+ pattern: '^\\{ \\[([^\\]]+)\\]: (.+?);? \\}$',
420
+ replace: '{ readonly [$1]: $2; }'
421
+ },
422
+ // Iterative one-property-per-pass prefix for object
423
+ // literal types. ESLint --fix runs the rule repeatedly
424
+ // until stable, so this prefixes one property each
425
+ // pass. Anchoring at "^{ " or "; " means only property
426
+ // boundaries inside an object type match; function
427
+ // parameters are inside "(" and never matched.
428
+ {
429
+ pattern: '(^\\{ |; )(?!readonly )([\\w$]+\\??: )',
430
+ replace: '$1readonly $2'
381
431
  }
382
432
  ]
383
433
  },
@@ -415,6 +465,18 @@ export const typescriptConfig = {
415
465
  {
416
466
  pattern: '^(Map|Set)<(.+)>$',
417
467
  replace: 'Readonly$1<$2>'
468
+ },
469
+ {
470
+ pattern: '^Record<(.+)>$',
471
+ replace: 'Readonly<Record<$1>>'
472
+ },
473
+ {
474
+ pattern: '^\\{ \\[([^\\]]+)\\]: (.+?);? \\}$',
475
+ replace: '{ readonly [$1]: $2; }'
476
+ },
477
+ {
478
+ pattern: '(^\\{ |; )(?!readonly )([\\w$]+\\??: )',
479
+ replace: '$1readonly $2'
418
480
  }
419
481
  ]
420
482
  }
package/readme.md CHANGED
@@ -15,17 +15,17 @@ npm install --save-dev @enormora/eslint-config-base @enormora/eslint-config-type
15
15
  Create an ESLint configuration file (e.g., `eslint.config.js`) in your project and add the base and node config to the configuration array:
16
16
 
17
17
  ```javascript
18
- import { baseConfig } from "@enormora/eslint-config-base";
19
- import { typescriptConfig } from "@enormora/eslint-config-typescript";
18
+ import { baseConfig } from '@enormora/eslint-config-base';
19
+ import { typescriptConfig } from '@enormora/eslint-config-typescript';
20
20
 
21
21
  export default [
22
- {
23
- ignores: ["dist/**/*"],
24
- },
25
- ...baseConfig,
26
- {
27
- ...typescriptConfig,
28
- files: ["**/*.ts"],
29
- },
22
+ {
23
+ ignores: [ 'dist/**/*' ]
24
+ },
25
+ ...baseConfig,
26
+ {
27
+ ...typescriptConfig,
28
+ files: [ '**/*.ts' ]
29
+ }
30
30
  ];
31
31
  ```
package/sbom.cdx.json CHANGED
@@ -9,83 +9,83 @@
9
9
  {
10
10
  "type": "application",
11
11
  "name": "packtory",
12
- "version": "0.0.15"
12
+ "version": "0.0.32"
13
13
  }
14
14
  ]
15
15
  },
16
16
  "component": {
17
17
  "type": "library",
18
18
  "name": "@enormora/eslint-config-typescript",
19
- "version": "0.0.39",
20
- "bom-ref": "pkg:npm/@enormora/eslint-config-typescript@0.0.39",
21
- "purl": "pkg:npm/@enormora/eslint-config-typescript@0.0.39"
19
+ "version": "0.0.40",
20
+ "bom-ref": "pkg:npm/@enormora/eslint-config-typescript@0.0.40",
21
+ "purl": "pkg:npm/@enormora/eslint-config-typescript@0.0.40"
22
22
  }
23
23
  },
24
24
  "components": [
25
25
  {
26
26
  "type": "library",
27
27
  "name": "@enormora/eslint-config-base",
28
- "version": "0.0.34",
29
- "bom-ref": "pkg:npm/@enormora/eslint-config-base@0.0.34",
28
+ "version": "0.0.35",
29
+ "bom-ref": "pkg:npm/@enormora/eslint-config-base@0.0.35",
30
30
  "scope": "optional",
31
31
  "licenses": [
32
32
  {
33
33
  "expression": "MIT"
34
34
  }
35
35
  ],
36
- "purl": "pkg:npm/@enormora/eslint-config-base@0.0.34"
36
+ "purl": "pkg:npm/@enormora/eslint-config-base@0.0.35"
37
37
  },
38
38
  {
39
39
  "type": "library",
40
40
  "name": "@typescript-eslint/eslint-plugin",
41
- "version": "8.59.4",
42
- "bom-ref": "pkg:npm/@typescript-eslint/eslint-plugin@8.59.4",
41
+ "version": "8.60.1",
42
+ "bom-ref": "pkg:npm/@typescript-eslint/eslint-plugin@8.60.1",
43
43
  "scope": "required",
44
44
  "licenses": [
45
45
  {
46
46
  "expression": "MIT"
47
47
  }
48
48
  ],
49
- "purl": "pkg:npm/@typescript-eslint/eslint-plugin@8.59.4"
49
+ "purl": "pkg:npm/@typescript-eslint/eslint-plugin@8.60.1"
50
50
  },
51
51
  {
52
52
  "type": "library",
53
53
  "name": "@typescript-eslint/parser",
54
- "version": "8.59.4",
55
- "bom-ref": "pkg:npm/@typescript-eslint/parser@8.59.4",
54
+ "version": "8.60.1",
55
+ "bom-ref": "pkg:npm/@typescript-eslint/parser@8.60.1",
56
56
  "scope": "required",
57
57
  "licenses": [
58
58
  {
59
59
  "expression": "MIT"
60
60
  }
61
61
  ],
62
- "purl": "pkg:npm/@typescript-eslint/parser@8.59.4"
62
+ "purl": "pkg:npm/@typescript-eslint/parser@8.60.1"
63
63
  },
64
64
  {
65
65
  "type": "library",
66
66
  "name": "eslint-import-resolver-typescript",
67
- "version": "4.4.4",
68
- "bom-ref": "pkg:npm/eslint-import-resolver-typescript@4.4.4",
67
+ "version": "4.4.5",
68
+ "bom-ref": "pkg:npm/eslint-import-resolver-typescript@4.4.5",
69
69
  "scope": "required",
70
70
  "licenses": [
71
71
  {
72
72
  "expression": "ISC"
73
73
  }
74
74
  ],
75
- "purl": "pkg:npm/eslint-import-resolver-typescript@4.4.4"
75
+ "purl": "pkg:npm/eslint-import-resolver-typescript@4.4.5"
76
76
  },
77
77
  {
78
78
  "type": "library",
79
79
  "name": "eslint-plugin-functional",
80
- "version": "9.0.4",
81
- "bom-ref": "pkg:npm/eslint-plugin-functional@9.0.4",
80
+ "version": "9.0.5",
81
+ "bom-ref": "pkg:npm/eslint-plugin-functional@9.0.5",
82
82
  "scope": "required",
83
83
  "licenses": [
84
84
  {
85
85
  "expression": "MIT"
86
86
  }
87
87
  ],
88
- "purl": "pkg:npm/eslint-plugin-functional@9.0.4"
88
+ "purl": "pkg:npm/eslint-plugin-functional@9.0.5"
89
89
  },
90
90
  {
91
91
  "type": "library",
@@ -116,31 +116,31 @@
116
116
  ],
117
117
  "dependencies": [
118
118
  {
119
- "ref": "pkg:npm/@enormora/eslint-config-base@0.0.34"
119
+ "ref": "pkg:npm/@enormora/eslint-config-base@0.0.35"
120
120
  },
121
121
  {
122
- "ref": "pkg:npm/@enormora/eslint-config-typescript@0.0.39",
122
+ "ref": "pkg:npm/@enormora/eslint-config-typescript@0.0.40",
123
123
  "dependsOn": [
124
- "pkg:npm/@enormora/eslint-config-base@0.0.34",
125
- "pkg:npm/@typescript-eslint/eslint-plugin@8.59.4",
126
- "pkg:npm/@typescript-eslint/parser@8.59.4",
127
- "pkg:npm/eslint-import-resolver-typescript@4.4.4",
128
- "pkg:npm/eslint-plugin-functional@9.0.4",
124
+ "pkg:npm/@enormora/eslint-config-base@0.0.35",
125
+ "pkg:npm/@typescript-eslint/eslint-plugin@8.60.1",
126
+ "pkg:npm/@typescript-eslint/parser@8.60.1",
127
+ "pkg:npm/eslint-import-resolver-typescript@4.4.5",
128
+ "pkg:npm/eslint-plugin-functional@9.0.5",
129
129
  "pkg:npm/eslint-plugin-import-x@4.16.2",
130
130
  "pkg:npm/eslint-plugin-perfectionist@5.9.0"
131
131
  ]
132
132
  },
133
133
  {
134
- "ref": "pkg:npm/@typescript-eslint/eslint-plugin@8.59.4"
134
+ "ref": "pkg:npm/@typescript-eslint/eslint-plugin@8.60.1"
135
135
  },
136
136
  {
137
- "ref": "pkg:npm/@typescript-eslint/parser@8.59.4"
137
+ "ref": "pkg:npm/@typescript-eslint/parser@8.60.1"
138
138
  },
139
139
  {
140
- "ref": "pkg:npm/eslint-import-resolver-typescript@4.4.4"
140
+ "ref": "pkg:npm/eslint-import-resolver-typescript@4.4.5"
141
141
  },
142
142
  {
143
- "ref": "pkg:npm/eslint-plugin-functional@9.0.4"
143
+ "ref": "pkg:npm/eslint-plugin-functional@9.0.5"
144
144
  },
145
145
  {
146
146
  "ref": "pkg:npm/eslint-plugin-import-x@4.16.2"