@blumintinc/eslint-plugin-blumint 1.20.6 → 1.20.7
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/lib/index.js
CHANGED
|
@@ -35,11 +35,23 @@ const createRule_1 = require("../utils/createRule");
|
|
|
35
35
|
* - WriteArrayAsGenericType normalizes arrays to `Array<T>` for consistent output.
|
|
36
36
|
* - UseFullyQualifiedType reduces ambiguity from locally-imported type names.
|
|
37
37
|
* - UseStructuralFallback keeps output meaningful when a nominal name is unavailable.
|
|
38
|
+
*
|
|
39
|
+
* Resolved on first use rather than at module load: the plugin barrel imports
|
|
40
|
+
* every rule eagerly, and the compiler package root does not expose this enum on
|
|
41
|
+
* all installed TypeScript releases (TypeScript 7 exports only a version stub),
|
|
42
|
+
* so dereferencing it at module scope makes the whole plugin fail to load rather
|
|
43
|
+
* than merely disabling this type-aware rule. Every call site sits behind a
|
|
44
|
+
* `parserServices.program` guard, so the enum is present whenever this runs.
|
|
38
45
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
let typeFormatFlagsCache;
|
|
47
|
+
function typeFormatFlags() {
|
|
48
|
+
typeFormatFlagsCache ??=
|
|
49
|
+
ts.TypeFormatFlags.NoTruncation |
|
|
50
|
+
ts.TypeFormatFlags.WriteArrayAsGenericType |
|
|
51
|
+
ts.TypeFormatFlags.UseFullyQualifiedType |
|
|
52
|
+
ts.TypeFormatFlags.UseStructuralFallback;
|
|
53
|
+
return typeFormatFlagsCache;
|
|
54
|
+
}
|
|
43
55
|
function extractAssertionTypeNode(expression) {
|
|
44
56
|
if (!expression)
|
|
45
57
|
return null;
|
|
@@ -137,7 +149,7 @@ function removeTypeAnnotation(fixer, typeAnnotation, sourceCode) {
|
|
|
137
149
|
return fixer.removeRange([removalStart, end]);
|
|
138
150
|
}
|
|
139
151
|
function typeText(type, checker) {
|
|
140
|
-
return checker.typeToString(type, undefined,
|
|
152
|
+
return checker.typeToString(type, undefined, typeFormatFlags());
|
|
141
153
|
}
|
|
142
154
|
function unwrapAlias(type, checker) {
|
|
143
155
|
const aliasSymbol = type
|
|
@@ -179,7 +191,7 @@ function getFormattedTypeProperties(type, checker) {
|
|
|
179
191
|
function getFormattedCallSignatures(type, checker) {
|
|
180
192
|
return checker
|
|
181
193
|
.getSignaturesOfType(type, ts.SignatureKind.Call)
|
|
182
|
-
.map((sig) => checker.signatureToString(sig, undefined,
|
|
194
|
+
.map((sig) => checker.signatureToString(sig, undefined, typeFormatFlags()))
|
|
183
195
|
.sort();
|
|
184
196
|
}
|
|
185
197
|
function structuralKey(type, checker) {
|
|
@@ -208,8 +220,8 @@ function getTypeRepresentations(annotationType, assertionType, checker) {
|
|
|
208
220
|
return {
|
|
209
221
|
annotationText: typeText(annotationType, checker),
|
|
210
222
|
assertionText: typeText(assertionType, checker),
|
|
211
|
-
annotationCanonical: checker.typeToString(annotationType, undefined,
|
|
212
|
-
assertionCanonical: checker.typeToString(assertionType, undefined,
|
|
223
|
+
annotationCanonical: checker.typeToString(annotationType, undefined, typeFormatFlags() | ts.TypeFormatFlags.NoTypeReduction),
|
|
224
|
+
assertionCanonical: checker.typeToString(assertionType, undefined, typeFormatFlags() | ts.TypeFormatFlags.NoTypeReduction),
|
|
213
225
|
annotationStructural: structuralKey(annotationType, checker),
|
|
214
226
|
assertionStructural: structuralKey(assertionType, checker),
|
|
215
227
|
};
|
|
@@ -16,12 +16,25 @@ const DEFAULT_EXPENSIVE_PATTERNS = [
|
|
|
16
16
|
'heavy',
|
|
17
17
|
'hash',
|
|
18
18
|
];
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Resolved on first use rather than at module load: the plugin barrel imports
|
|
21
|
+
* every rule eagerly, and the compiler package root does not expose this enum on
|
|
22
|
+
* all installed TypeScript releases (TypeScript 7 exports only a version stub),
|
|
23
|
+
* so dereferencing it at module scope makes the whole plugin fail to load rather
|
|
24
|
+
* than merely disabling this type-aware rule. The sole call site sits behind a
|
|
25
|
+
* `parserServices.program` guard, so the enum is present whenever this runs.
|
|
26
|
+
*/
|
|
27
|
+
let passByValueFlagsCache;
|
|
28
|
+
function passByValueFlags() {
|
|
29
|
+
passByValueFlagsCache ??=
|
|
30
|
+
typescript_1.default.TypeFlags.StringLike |
|
|
31
|
+
typescript_1.default.TypeFlags.NumberLike |
|
|
32
|
+
typescript_1.default.TypeFlags.BigIntLike |
|
|
33
|
+
typescript_1.default.TypeFlags.BooleanLike |
|
|
34
|
+
typescript_1.default.TypeFlags.Undefined |
|
|
35
|
+
typescript_1.default.TypeFlags.Null;
|
|
36
|
+
return passByValueFlagsCache;
|
|
37
|
+
}
|
|
25
38
|
function isCustomHookName(name) {
|
|
26
39
|
if (!name)
|
|
27
40
|
return false;
|
|
@@ -137,7 +150,7 @@ function isPassByValueType(type, checker) {
|
|
|
137
150
|
// Conservative: arrays with unresolvable element types are indeterminate.
|
|
138
151
|
return { passByValue: false, indeterminate: true, description };
|
|
139
152
|
}
|
|
140
|
-
if (type.flags &
|
|
153
|
+
if (type.flags & passByValueFlags()) {
|
|
141
154
|
return { passByValue: true, indeterminate: false, description };
|
|
142
155
|
}
|
|
143
156
|
return { passByValue: false, indeterminate: false, description };
|
package/package.json
CHANGED
package/release-manifest.json
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "1.20.7",
|
|
4
|
+
"date": "2026-07-28T05:35:51.746Z",
|
|
5
|
+
"rules": [
|
|
6
|
+
{
|
|
7
|
+
"name": "no-redundant-annotation-assertion",
|
|
8
|
+
"changeType": "fix",
|
|
9
|
+
"issues": [
|
|
10
|
+
1354
|
|
11
|
+
],
|
|
12
|
+
"summary": "resolve type format flags lazily (closes #1354)"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "no-usememo-for-pass-by-value",
|
|
16
|
+
"changeType": "fix",
|
|
17
|
+
"issues": [
|
|
18
|
+
1354
|
|
19
|
+
],
|
|
20
|
+
"summary": "resolve compiler type flags lazily (refs #1354)"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
},
|
|
2
24
|
{
|
|
3
25
|
"version": "1.20.6",
|
|
4
26
|
"date": "2026-07-28T05:19:38.242Z",
|