miniread 1.111.0 → 1.112.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/dist/transforms/_generated/catalog.js +21 -7
- package/dist/transforms-by-id/rename-collection-constructor-variables/manifest.json +3 -3
- package/dist/transforms-by-id/rename-command-result-variables/manifest.json +13 -0
- package/dist/transforms-by-id/rename-command-result-variables/rename-command-result-variables-transform.d.ts +2 -0
- package/dist/transforms-by-id/rename-command-result-variables/rename-command-result-variables-transform.js +89 -0
- package/dist/transforms-by-id/rename-constructor-variables/get-constructor-base-name-from-expression.d.ts +3 -0
- package/dist/transforms-by-id/rename-constructor-variables/get-constructor-base-name-from-expression.js +30 -0
- package/dist/transforms-by-id/rename-constructor-variables/manifest.json +14 -0
- package/dist/transforms-by-id/rename-constructor-variables/rename-constructor-variables-transform.d.ts +2 -0
- package/dist/transforms-by-id/rename-constructor-variables/rename-constructor-variables-transform.js +74 -0
- package/dist/transforms-by-id/rename-constructor-variables/resolve-constructor-name-from-expression.d.ts +3 -0
- package/dist/transforms-by-id/rename-constructor-variables/resolve-constructor-name-from-expression.js +77 -0
- package/dist/transforms-by-id/rename-constructor-variables/unwrap-transparent-expression.d.ts +3 -0
- package/dist/transforms-by-id/rename-constructor-variables/unwrap-transparent-expression.js +29 -0
- package/dist/transforms-by-id/rename-file-reader-variables/manifest.json +6 -5
- package/dist/transforms-by-id/rename-file-reader-variables/rename-file-reader-variables-transform.js +53 -35
- package/dist/transforms-by-id/rename-stream-data-chunks/manifest.json +14 -0
- package/dist/transforms-by-id/rename-stream-data-chunks/rename-stream-data-chunks-transform.d.ts +2 -0
- package/dist/transforms-by-id/rename-stream-data-chunks/rename-stream-data-chunks-transform.js +130 -0
- package/package.json +1 -1
- package/dist/transforms-by-id/rename-file-reader-variables/is-file-reader-constructor.d.ts +0 -3
- package/dist/transforms-by-id/rename-file-reader-variables/is-file-reader-constructor.js +0 -90
- package/dist/transforms-by-id/rename-file-reader-variables/queue-file-reader-rename.d.ts +0 -12
- package/dist/transforms-by-id/rename-file-reader-variables/queue-file-reader-rename.js +0 -25
- package/dist/transforms-by-id/rename-search-parameters-variables/get-member-expression-property-name.d.ts +0 -2
- package/dist/transforms-by-id/rename-search-parameters-variables/get-member-expression-property-name.js +0 -20
- package/dist/transforms-by-id/rename-search-parameters-variables/get-search-parameters-member-expression.d.ts +0 -3
- package/dist/transforms-by-id/rename-search-parameters-variables/get-search-parameters-member-expression.js +0 -26
- package/dist/transforms-by-id/rename-search-parameters-variables/is-search-parameters-destructure-usage.d.ts +0 -2
- package/dist/transforms-by-id/rename-search-parameters-variables/is-search-parameters-destructure-usage.js +0 -74
- package/dist/transforms-by-id/rename-search-parameters-variables/is-search-parameters-for-of-usage.d.ts +0 -2
- package/dist/transforms-by-id/rename-search-parameters-variables/is-search-parameters-for-of-usage.js +0 -18
- package/dist/transforms-by-id/rename-search-parameters-variables/is-search-parameters-property-access.d.ts +0 -2
- package/dist/transforms-by-id/rename-search-parameters-variables/is-search-parameters-property-access.js +0 -30
- package/dist/transforms-by-id/rename-search-parameters-variables/is-search-parameters-spread-usage.d.ts +0 -2
- package/dist/transforms-by-id/rename-search-parameters-variables/is-search-parameters-spread-usage.js +0 -34
- package/dist/transforms-by-id/rename-search-parameters-variables/manifest.json +0 -14
- package/dist/transforms-by-id/rename-search-parameters-variables/rename-search-parameters-variables-transform.d.ts +0 -2
- package/dist/transforms-by-id/rename-search-parameters-variables/rename-search-parameters-variables-transform.js +0 -89
- package/dist/transforms-by-id/rename-search-parameters-variables/search-parameters-property-names.d.ts +0 -1
- package/dist/transforms-by-id/rename-search-parameters-variables/search-parameters-property-names.js +0 -15
|
@@ -38,10 +38,14 @@ import { renameClientAliasesTransform } from "../../transforms-by-id/rename-clie
|
|
|
38
38
|
import renameClientAliasesManifest from "../../transforms-by-id/rename-client-aliases/manifest.json" with { type: "json" };
|
|
39
39
|
import { renameCollectionConstructorVariablesTransform } from "../../transforms-by-id/rename-collection-constructor-variables/rename-collection-constructor-variables-transform.js";
|
|
40
40
|
import renameCollectionConstructorVariablesManifest from "../../transforms-by-id/rename-collection-constructor-variables/manifest.json" with { type: "json" };
|
|
41
|
+
import { renameCommandResultVariablesTransform } from "../../transforms-by-id/rename-command-result-variables/rename-command-result-variables-transform.js";
|
|
42
|
+
import renameCommandResultVariablesManifest from "../../transforms-by-id/rename-command-result-variables/manifest.json" with { type: "json" };
|
|
41
43
|
import { renameComparisonFlagsTransform } from "../../transforms-by-id/rename-comparison-flags/rename-comparison-flags-transform.js";
|
|
42
44
|
import renameComparisonFlagsManifest from "../../transforms-by-id/rename-comparison-flags/manifest.json" with { type: "json" };
|
|
43
45
|
import { renameComparisonFlagsV2Transform } from "../../transforms-by-id/rename-comparison-flags-v2/rename-comparison-flags-v2-transform.js";
|
|
44
46
|
import renameComparisonFlagsV2Manifest from "../../transforms-by-id/rename-comparison-flags-v2/manifest.json" with { type: "json" };
|
|
47
|
+
import { renameConstructorVariablesTransform } from "../../transforms-by-id/rename-constructor-variables/rename-constructor-variables-transform.js";
|
|
48
|
+
import renameConstructorVariablesManifest from "../../transforms-by-id/rename-constructor-variables/manifest.json" with { type: "json" };
|
|
45
49
|
import { renameDateNowStartTimesTransform } from "../../transforms-by-id/rename-date-now-start-times/rename-date-now-start-times-transform.js";
|
|
46
50
|
import renameDateNowStartTimesManifest from "../../transforms-by-id/rename-date-now-start-times/manifest.json" with { type: "json" };
|
|
47
51
|
import { renameDefaultOptionsParametersV3Transform } from "../../transforms-by-id/rename-default-options-parameters-v3/rename-default-options-parameters-v3-transform.js";
|
|
@@ -132,10 +136,10 @@ import { renameReturnObjectBindingsTransform } from "../../transforms-by-id/rena
|
|
|
132
136
|
import renameReturnObjectBindingsManifest from "../../transforms-by-id/rename-return-object-bindings/manifest.json" with { type: "json" };
|
|
133
137
|
import { renameSanitizedStringVariablesTransform } from "../../transforms-by-id/rename-sanitized-string-variables/rename-sanitized-string-variables-transform.js";
|
|
134
138
|
import renameSanitizedStringVariablesManifest from "../../transforms-by-id/rename-sanitized-string-variables/manifest.json" with { type: "json" };
|
|
135
|
-
import { renameSearchParametersVariablesTransform } from "../../transforms-by-id/rename-search-parameters-variables/rename-search-parameters-variables-transform.js";
|
|
136
|
-
import renameSearchParametersVariablesManifest from "../../transforms-by-id/rename-search-parameters-variables/manifest.json" with { type: "json" };
|
|
137
139
|
import { renameSetstateUpdaterParametersTransform } from "../../transforms-by-id/rename-setstate-updater-parameters/rename-setstate-updater-parameters-transform.js";
|
|
138
140
|
import renameSetstateUpdaterParametersManifest from "../../transforms-by-id/rename-setstate-updater-parameters/manifest.json" with { type: "json" };
|
|
141
|
+
import { renameStreamDataChunksTransform } from "../../transforms-by-id/rename-stream-data-chunks/rename-stream-data-chunks-transform.js";
|
|
142
|
+
import renameStreamDataChunksManifest from "../../transforms-by-id/rename-stream-data-chunks/manifest.json" with { type: "json" };
|
|
139
143
|
import { renameStringSplitVariablesV2Transform } from "../../transforms-by-id/rename-string-split-variables-v2/rename-string-split-variables-v2-transform.js";
|
|
140
144
|
import renameStringSplitVariablesV2Manifest from "../../transforms-by-id/rename-string-split-variables-v2/manifest.json" with { type: "json" };
|
|
141
145
|
import { renameThisAliasesTransform } from "../../transforms-by-id/rename-this-aliases/rename-this-aliases-transform.js";
|
|
@@ -286,6 +290,11 @@ export const generatedTransformCatalog = [
|
|
|
286
290
|
transform: renameCollectionConstructorVariablesTransform,
|
|
287
291
|
manifest: renameCollectionConstructorVariablesManifest,
|
|
288
292
|
},
|
|
293
|
+
{
|
|
294
|
+
id: renameCommandResultVariablesTransform.id,
|
|
295
|
+
transform: renameCommandResultVariablesTransform,
|
|
296
|
+
manifest: renameCommandResultVariablesManifest,
|
|
297
|
+
},
|
|
289
298
|
{
|
|
290
299
|
id: renameComparisonFlagsTransform.id,
|
|
291
300
|
transform: renameComparisonFlagsTransform,
|
|
@@ -296,6 +305,11 @@ export const generatedTransformCatalog = [
|
|
|
296
305
|
transform: renameComparisonFlagsV2Transform,
|
|
297
306
|
manifest: renameComparisonFlagsV2Manifest,
|
|
298
307
|
},
|
|
308
|
+
{
|
|
309
|
+
id: renameConstructorVariablesTransform.id,
|
|
310
|
+
transform: renameConstructorVariablesTransform,
|
|
311
|
+
manifest: renameConstructorVariablesManifest,
|
|
312
|
+
},
|
|
299
313
|
{
|
|
300
314
|
id: renameDateNowStartTimesTransform.id,
|
|
301
315
|
transform: renameDateNowStartTimesTransform,
|
|
@@ -521,16 +535,16 @@ export const generatedTransformCatalog = [
|
|
|
521
535
|
transform: renameSanitizedStringVariablesTransform,
|
|
522
536
|
manifest: renameSanitizedStringVariablesManifest,
|
|
523
537
|
},
|
|
524
|
-
{
|
|
525
|
-
id: renameSearchParametersVariablesTransform.id,
|
|
526
|
-
transform: renameSearchParametersVariablesTransform,
|
|
527
|
-
manifest: renameSearchParametersVariablesManifest,
|
|
528
|
-
},
|
|
529
538
|
{
|
|
530
539
|
id: renameSetstateUpdaterParametersTransform.id,
|
|
531
540
|
transform: renameSetstateUpdaterParametersTransform,
|
|
532
541
|
manifest: renameSetstateUpdaterParametersManifest,
|
|
533
542
|
},
|
|
543
|
+
{
|
|
544
|
+
id: renameStreamDataChunksTransform.id,
|
|
545
|
+
transform: renameStreamDataChunksTransform,
|
|
546
|
+
manifest: renameStreamDataChunksManifest,
|
|
547
|
+
},
|
|
534
548
|
{
|
|
535
549
|
id: renameStringSplitVariablesV2Transform.id,
|
|
536
550
|
transform: renameStringSplitVariablesV2Transform,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"notes": "
|
|
2
|
+
"notes": "Superseded by rename-constructor-variables for constructor-derived variable naming coverage.",
|
|
3
|
+
"supersededBy": "rename-constructor-variables",
|
|
3
4
|
"evaluations": {
|
|
4
5
|
"claude-code-2.1.10:claude-code-2.1.11": {
|
|
5
6
|
"diffSizePercent": 99.96976225573572,
|
|
@@ -9,6 +10,5 @@
|
|
|
9
10
|
"stableNames": 1364
|
|
10
11
|
}
|
|
11
12
|
},
|
|
12
|
-
"recommended":
|
|
13
|
-
"recommendedOrder": 101
|
|
13
|
+
"recommended": false
|
|
14
14
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"evaluations": {
|
|
3
|
+
"claude-code-2.1.10:claude-code-2.1.11": {
|
|
4
|
+
"diffSizePercent": 100,
|
|
5
|
+
"evaluatedAt": "2026-02-13T08:14:27.481Z",
|
|
6
|
+
"changedLines": 338,
|
|
7
|
+
"durationSeconds": 39.400678667,
|
|
8
|
+
"stableNames": 1359
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"recommended": true,
|
|
12
|
+
"recommendedOrder": 100
|
|
13
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { isStableRenamed, RenameGroup } from "../../core/stable-naming.js";
|
|
3
|
+
import { getFilesToProcess, } from "../../core/types.js";
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
6
|
+
const traverse = require("@babel/traverse").default;
|
|
7
|
+
const BASE_NAME = "commandResult";
|
|
8
|
+
const isCommandResultProperty = (path) => {
|
|
9
|
+
const memberExpressionPath = path.parentPath;
|
|
10
|
+
if (!memberExpressionPath.isMemberExpression())
|
|
11
|
+
return false;
|
|
12
|
+
const memberExpression = memberExpressionPath.node;
|
|
13
|
+
if (memberExpression.object !== path.node)
|
|
14
|
+
return false;
|
|
15
|
+
if (memberExpression.computed)
|
|
16
|
+
return false;
|
|
17
|
+
if (memberExpression.property.type !== "Identifier")
|
|
18
|
+
return false;
|
|
19
|
+
return (memberExpression.property.name === "code" ||
|
|
20
|
+
memberExpression.property.name === "stdout" ||
|
|
21
|
+
memberExpression.property.name === "stderr");
|
|
22
|
+
};
|
|
23
|
+
const hasCommandResultPattern = (binding) => {
|
|
24
|
+
let hasCodeProperty = false;
|
|
25
|
+
let hasOutputProperty = false;
|
|
26
|
+
for (const referencePath of binding.referencePaths) {
|
|
27
|
+
if (!referencePath.isIdentifier())
|
|
28
|
+
continue;
|
|
29
|
+
if (!isCommandResultProperty(referencePath))
|
|
30
|
+
continue;
|
|
31
|
+
const property = referencePath.parentPath.node
|
|
32
|
+
.property;
|
|
33
|
+
if (property.type !== "Identifier")
|
|
34
|
+
continue;
|
|
35
|
+
if (property.name === "code")
|
|
36
|
+
hasCodeProperty = true;
|
|
37
|
+
if (property.name === "stdout" || property.name === "stderr") {
|
|
38
|
+
hasOutputProperty = true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return hasCodeProperty && hasOutputProperty;
|
|
42
|
+
};
|
|
43
|
+
export const renameCommandResultVariablesTransform = {
|
|
44
|
+
id: "rename-command-result-variables",
|
|
45
|
+
description: "Renames variables used as command result objects when code/stdout/stderr members are accessed",
|
|
46
|
+
scope: "file",
|
|
47
|
+
parallelizable: true,
|
|
48
|
+
transform(context) {
|
|
49
|
+
let nodesVisited = 0;
|
|
50
|
+
let transformationsApplied = 0;
|
|
51
|
+
for (const fileInfo of getFilesToProcess(context)) {
|
|
52
|
+
const renameGroup = new RenameGroup();
|
|
53
|
+
traverse(fileInfo.ast, {
|
|
54
|
+
VariableDeclarator(path) {
|
|
55
|
+
nodesVisited++;
|
|
56
|
+
const id = path.node.id;
|
|
57
|
+
if (id.type !== "Identifier")
|
|
58
|
+
return;
|
|
59
|
+
const currentName = id.name;
|
|
60
|
+
if (isStableRenamed(currentName))
|
|
61
|
+
return;
|
|
62
|
+
if (currentName === BASE_NAME)
|
|
63
|
+
return;
|
|
64
|
+
const binding = path.scope.getBinding(currentName);
|
|
65
|
+
if (!binding)
|
|
66
|
+
return;
|
|
67
|
+
if (!binding.constant)
|
|
68
|
+
return;
|
|
69
|
+
if (binding.identifier !== id)
|
|
70
|
+
return;
|
|
71
|
+
if (binding.referencePaths.length === 0)
|
|
72
|
+
return;
|
|
73
|
+
if (!hasCommandResultPattern(binding))
|
|
74
|
+
return;
|
|
75
|
+
renameGroup.add({
|
|
76
|
+
scope: binding.scope,
|
|
77
|
+
currentName,
|
|
78
|
+
baseName: BASE_NAME,
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
transformationsApplied += renameGroup.apply();
|
|
83
|
+
}
|
|
84
|
+
return Promise.resolve({
|
|
85
|
+
nodesVisited,
|
|
86
|
+
transformationsApplied,
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as t from "@babel/types";
|
|
2
|
+
import { isValidBindingIdentifier } from "../../transforms/shared/is-valid-binding-identifier.js";
|
|
3
|
+
import { resolveConstructorNameFromExpression } from "./resolve-constructor-name-from-expression.js";
|
|
4
|
+
import { unwrapTransparentExpression } from "./unwrap-transparent-expression.js";
|
|
5
|
+
const toCamelCaseBaseName = (constructorName) => {
|
|
6
|
+
const uppercasePrefixMatch = constructorName.match(/^[A-Z]+(?=[A-Z][a-z]|[0-9]|$)/u);
|
|
7
|
+
if (!uppercasePrefixMatch) {
|
|
8
|
+
const [firstCharacter = "", ...rest] = constructorName;
|
|
9
|
+
return `${firstCharacter.toLowerCase()}${rest.join("")}`;
|
|
10
|
+
}
|
|
11
|
+
const uppercasePrefix = uppercasePrefixMatch[0];
|
|
12
|
+
return (uppercasePrefix.toLowerCase() +
|
|
13
|
+
constructorName.slice(uppercasePrefix.length));
|
|
14
|
+
};
|
|
15
|
+
export const getConstructorBaseNameFromExpression = (scope, expression) => {
|
|
16
|
+
if (!expression)
|
|
17
|
+
return undefined;
|
|
18
|
+
const unwrappedExpression = unwrapTransparentExpression(expression);
|
|
19
|
+
if (!t.isNewExpression(unwrappedExpression))
|
|
20
|
+
return undefined;
|
|
21
|
+
if (!t.isExpression(unwrappedExpression.callee))
|
|
22
|
+
return undefined;
|
|
23
|
+
const constructorName = resolveConstructorNameFromExpression(scope, unwrappedExpression.callee);
|
|
24
|
+
if (!constructorName)
|
|
25
|
+
return undefined;
|
|
26
|
+
const baseName = toCamelCaseBaseName(constructorName);
|
|
27
|
+
if (!isValidBindingIdentifier(baseName))
|
|
28
|
+
return undefined;
|
|
29
|
+
return baseName;
|
|
30
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"notes": "Renames constructor-initialized or constructor-assigned variables by deriving camelCase names from constructor identifiers, member constructors, and local constructor aliases.",
|
|
3
|
+
"evaluations": {
|
|
4
|
+
"claude-code-2.1.10:claude-code-2.1.11": {
|
|
5
|
+
"diffSizePercent": 100.3269456098575,
|
|
6
|
+
"evaluatedAt": "2026-02-13T08:51:30.726Z",
|
|
7
|
+
"changedLines": 15609,
|
|
8
|
+
"durationSeconds": 367.642214666,
|
|
9
|
+
"stableNames": 1804
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"recommended": true,
|
|
13
|
+
"recommendedOrder": 201
|
|
14
|
+
}
|
package/dist/transforms-by-id/rename-constructor-variables/rename-constructor-variables-transform.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { isStableRenamed, RenameGroup } from "../../core/stable-naming.js";
|
|
3
|
+
import { getFilesToProcess, } from "../../core/types.js";
|
|
4
|
+
import { getConstructorBaseNameFromExpression } from "./get-constructor-base-name-from-expression.js";
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
7
|
+
const traverse = require("@babel/traverse").default;
|
|
8
|
+
const queueConstructorRename = (options) => {
|
|
9
|
+
const { scope, currentName, baseName, group, queuedBindings } = options;
|
|
10
|
+
if (isStableRenamed(currentName))
|
|
11
|
+
return;
|
|
12
|
+
const binding = scope.getBinding(currentName);
|
|
13
|
+
if (!binding)
|
|
14
|
+
return;
|
|
15
|
+
if (queuedBindings.has(binding))
|
|
16
|
+
return;
|
|
17
|
+
queuedBindings.add(binding);
|
|
18
|
+
group.add({
|
|
19
|
+
scope: binding.scope,
|
|
20
|
+
currentName,
|
|
21
|
+
baseName,
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
export const renameConstructorVariablesTransform = {
|
|
25
|
+
id: "rename-constructor-variables",
|
|
26
|
+
description: "Renames variables initialized or assigned from constructor calls to constructor-derived names like $dataView and $fooBar",
|
|
27
|
+
scope: "file",
|
|
28
|
+
parallelizable: true,
|
|
29
|
+
transform(context) {
|
|
30
|
+
let nodesVisited = 0;
|
|
31
|
+
let transformationsApplied = 0;
|
|
32
|
+
for (const fileInfo of getFilesToProcess(context)) {
|
|
33
|
+
const group = new RenameGroup();
|
|
34
|
+
const queuedBindings = new Set();
|
|
35
|
+
traverse(fileInfo.ast, {
|
|
36
|
+
VariableDeclarator(path) {
|
|
37
|
+
nodesVisited++;
|
|
38
|
+
const { id } = path.node;
|
|
39
|
+
if (id.type !== "Identifier")
|
|
40
|
+
return;
|
|
41
|
+
const baseName = getConstructorBaseNameFromExpression(path.scope, path.node.init);
|
|
42
|
+
if (!baseName)
|
|
43
|
+
return;
|
|
44
|
+
queueConstructorRename({
|
|
45
|
+
scope: path.scope,
|
|
46
|
+
currentName: id.name,
|
|
47
|
+
baseName,
|
|
48
|
+
group,
|
|
49
|
+
queuedBindings,
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
AssignmentExpression(path) {
|
|
53
|
+
nodesVisited++;
|
|
54
|
+
if (path.node.operator !== "=")
|
|
55
|
+
return;
|
|
56
|
+
if (path.node.left.type !== "Identifier")
|
|
57
|
+
return;
|
|
58
|
+
const baseName = getConstructorBaseNameFromExpression(path.scope, path.node.right);
|
|
59
|
+
if (!baseName)
|
|
60
|
+
return;
|
|
61
|
+
queueConstructorRename({
|
|
62
|
+
scope: path.scope,
|
|
63
|
+
currentName: path.node.left.name,
|
|
64
|
+
baseName,
|
|
65
|
+
group,
|
|
66
|
+
queuedBindings,
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
transformationsApplied += group.apply();
|
|
71
|
+
}
|
|
72
|
+
return Promise.resolve({ nodesVisited, transformationsApplied });
|
|
73
|
+
},
|
|
74
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as t from "@babel/types";
|
|
2
|
+
import { MAX_ALIAS_RESOLUTION_DEPTH, unwrapTransparentExpression, } from "./unwrap-transparent-expression.js";
|
|
3
|
+
const UPPERCASE_CONSTRUCTOR_PATTERN = /^[A-Z][A-Za-z0-9_$]*$/u;
|
|
4
|
+
const getMemberPropertyName = (memberExpression) => {
|
|
5
|
+
if (!memberExpression.computed) {
|
|
6
|
+
if (!t.isIdentifier(memberExpression.property))
|
|
7
|
+
return undefined;
|
|
8
|
+
return memberExpression.property.name;
|
|
9
|
+
}
|
|
10
|
+
if (t.isStringLiteral(memberExpression.property)) {
|
|
11
|
+
return memberExpression.property.value;
|
|
12
|
+
}
|
|
13
|
+
if (t.isTemplateLiteral(memberExpression.property) &&
|
|
14
|
+
memberExpression.property.expressions.length === 0 &&
|
|
15
|
+
memberExpression.property.quasis.length === 1) {
|
|
16
|
+
return memberExpression.property.quasis[0]?.value.cooked ?? undefined;
|
|
17
|
+
}
|
|
18
|
+
return undefined;
|
|
19
|
+
};
|
|
20
|
+
const resolveFromBinding = (binding, visitedBindings, depth) => {
|
|
21
|
+
if (depth > MAX_ALIAS_RESOLUTION_DEPTH)
|
|
22
|
+
return undefined;
|
|
23
|
+
const bindingPath = binding.path;
|
|
24
|
+
if (bindingPath.isClassDeclaration() || bindingPath.isFunctionDeclaration()) {
|
|
25
|
+
return binding.identifier.name;
|
|
26
|
+
}
|
|
27
|
+
if (!bindingPath.isVariableDeclarator() || !binding.constant) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
const { init, id } = bindingPath.node;
|
|
31
|
+
if (!init)
|
|
32
|
+
return undefined;
|
|
33
|
+
const unwrappedInit = unwrapTransparentExpression(init);
|
|
34
|
+
if (t.isClassExpression(unwrappedInit) ||
|
|
35
|
+
t.isFunctionExpression(unwrappedInit)) {
|
|
36
|
+
if (unwrappedInit.id?.name)
|
|
37
|
+
return unwrappedInit.id.name;
|
|
38
|
+
return t.isIdentifier(id) ? id.name : undefined;
|
|
39
|
+
}
|
|
40
|
+
return resolveFromExpression(bindingPath.scope, unwrappedInit, visitedBindings, depth + 1);
|
|
41
|
+
};
|
|
42
|
+
const resolveFromIdentifier = (scope, identifierName, visitedBindings, depth) => {
|
|
43
|
+
if (depth > MAX_ALIAS_RESOLUTION_DEPTH)
|
|
44
|
+
return undefined;
|
|
45
|
+
const binding = scope.getBinding(identifierName);
|
|
46
|
+
if (binding) {
|
|
47
|
+
if (visitedBindings.has(binding))
|
|
48
|
+
return undefined;
|
|
49
|
+
visitedBindings.add(binding);
|
|
50
|
+
const resolvedFromBinding = resolveFromBinding(binding, visitedBindings, depth + 1);
|
|
51
|
+
if (resolvedFromBinding)
|
|
52
|
+
return resolvedFromBinding;
|
|
53
|
+
}
|
|
54
|
+
return UPPERCASE_CONSTRUCTOR_PATTERN.test(identifierName)
|
|
55
|
+
? identifierName
|
|
56
|
+
: undefined;
|
|
57
|
+
};
|
|
58
|
+
const resolveFromExpression = (scope, expression, visitedBindings, depth) => {
|
|
59
|
+
if (depth > MAX_ALIAS_RESOLUTION_DEPTH)
|
|
60
|
+
return undefined;
|
|
61
|
+
const unwrappedExpression = unwrapTransparentExpression(expression);
|
|
62
|
+
if (t.isIdentifier(unwrappedExpression)) {
|
|
63
|
+
return resolveFromIdentifier(scope, unwrappedExpression.name, visitedBindings, depth + 1);
|
|
64
|
+
}
|
|
65
|
+
if (t.isMemberExpression(unwrappedExpression) ||
|
|
66
|
+
t.isOptionalMemberExpression(unwrappedExpression)) {
|
|
67
|
+
return getMemberPropertyName(unwrappedExpression);
|
|
68
|
+
}
|
|
69
|
+
if (t.isClassExpression(unwrappedExpression) ||
|
|
70
|
+
t.isFunctionExpression(unwrappedExpression)) {
|
|
71
|
+
return unwrappedExpression.id?.name;
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
};
|
|
75
|
+
export const resolveConstructorNameFromExpression = (scope, expression) => {
|
|
76
|
+
return resolveFromExpression(scope, expression, new Set(), 0);
|
|
77
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as t from "@babel/types";
|
|
2
|
+
export const MAX_ALIAS_RESOLUTION_DEPTH = 8;
|
|
3
|
+
const unwrapSingleTransparentExpression = (expression) => {
|
|
4
|
+
if (t.isParenthesizedExpression(expression))
|
|
5
|
+
return expression.expression;
|
|
6
|
+
if (t.isTSAsExpression(expression))
|
|
7
|
+
return expression.expression;
|
|
8
|
+
if (t.isTSSatisfiesExpression(expression))
|
|
9
|
+
return expression.expression;
|
|
10
|
+
if (t.isTSTypeAssertion(expression))
|
|
11
|
+
return expression.expression;
|
|
12
|
+
if (t.isTSNonNullExpression(expression))
|
|
13
|
+
return expression.expression;
|
|
14
|
+
if (t.isTypeCastExpression(expression))
|
|
15
|
+
return expression.expression;
|
|
16
|
+
if (t.isSequenceExpression(expression))
|
|
17
|
+
return expression.expressions.at(-1);
|
|
18
|
+
return undefined;
|
|
19
|
+
};
|
|
20
|
+
export const unwrapTransparentExpression = (expression) => {
|
|
21
|
+
let currentExpression = expression;
|
|
22
|
+
for (let depth = 0; depth < MAX_ALIAS_RESOLUTION_DEPTH; depth += 1) {
|
|
23
|
+
const nextExpression = unwrapSingleTransparentExpression(currentExpression);
|
|
24
|
+
if (!nextExpression)
|
|
25
|
+
return currentExpression;
|
|
26
|
+
currentExpression = nextExpression;
|
|
27
|
+
}
|
|
28
|
+
return currentExpression;
|
|
29
|
+
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
+
"notes": "Post-pass behavior after rename-constructor-variables: focuses on FileReader event-handler parameter naming for fileReader-like bindings.",
|
|
2
3
|
"evaluations": {
|
|
3
4
|
"claude-code-2.1.10:claude-code-2.1.11": {
|
|
4
5
|
"diffSizePercent": 100,
|
|
5
|
-
"evaluatedAt": "2026-02-
|
|
6
|
-
"changedLines":
|
|
7
|
-
"durationSeconds":
|
|
8
|
-
"stableNames":
|
|
6
|
+
"evaluatedAt": "2026-02-14T07:23:12.948Z",
|
|
7
|
+
"changedLines": 0,
|
|
8
|
+
"durationSeconds": 25.987191208,
|
|
9
|
+
"stableNames": 1357
|
|
9
10
|
}
|
|
10
11
|
},
|
|
11
12
|
"recommended": true,
|
|
12
|
-
"recommendedOrder":
|
|
13
|
+
"recommendedOrder": 211
|
|
13
14
|
}
|
package/dist/transforms-by-id/rename-file-reader-variables/rename-file-reader-variables-transform.js
CHANGED
|
@@ -1,16 +1,51 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import
|
|
2
|
+
import * as t from "@babel/types";
|
|
3
3
|
import { RenameGroup } from "../../core/stable-naming.js";
|
|
4
4
|
import { getFilesToProcess, } from "../../core/types.js";
|
|
5
|
-
import { isFileReaderConstructor } from "./is-file-reader-constructor.js";
|
|
6
5
|
import { queueFileReaderEventRename } from "./queue-file-reader-event-rename.js";
|
|
7
|
-
import { queueFileReaderRename } from "./queue-file-reader-rename.js";
|
|
8
6
|
const require = createRequire(import.meta.url);
|
|
9
7
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
10
8
|
const traverse = require("@babel/traverse").default;
|
|
9
|
+
const FILE_READER_BINDING_PATTERN = /^\$?fileReader(?:Instance)?\d*$/u;
|
|
10
|
+
const isTrackedFileReaderBindingName = (name) => FILE_READER_BINDING_PATTERN.test(name);
|
|
11
|
+
const getMemberPropertyName = (memberExpression) => {
|
|
12
|
+
if (!memberExpression.computed) {
|
|
13
|
+
if (!t.isIdentifier(memberExpression.property))
|
|
14
|
+
return undefined;
|
|
15
|
+
return memberExpression.property.name;
|
|
16
|
+
}
|
|
17
|
+
if (t.isStringLiteral(memberExpression.property)) {
|
|
18
|
+
return memberExpression.property.value;
|
|
19
|
+
}
|
|
20
|
+
if (t.isTemplateLiteral(memberExpression.property) &&
|
|
21
|
+
memberExpression.property.expressions.length === 0 &&
|
|
22
|
+
memberExpression.property.quasis.length === 1) {
|
|
23
|
+
return memberExpression.property.quasis[0]?.value.cooked ?? undefined;
|
|
24
|
+
}
|
|
25
|
+
return undefined;
|
|
26
|
+
};
|
|
27
|
+
const isFileReaderConstructorExpression = (expression) => {
|
|
28
|
+
if (!t.isNewExpression(expression))
|
|
29
|
+
return false;
|
|
30
|
+
const callee = expression.callee;
|
|
31
|
+
if (t.isIdentifier(callee)) {
|
|
32
|
+
return callee.name === "FileReader";
|
|
33
|
+
}
|
|
34
|
+
if (!t.isMemberExpression(callee) && !t.isOptionalMemberExpression(callee)) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const propertyName = getMemberPropertyName(callee);
|
|
38
|
+
if (propertyName !== "FileReader")
|
|
39
|
+
return false;
|
|
40
|
+
if (!t.isIdentifier(callee.object))
|
|
41
|
+
return false;
|
|
42
|
+
return (callee.object.name === "globalThis" ||
|
|
43
|
+
callee.object.name === "window" ||
|
|
44
|
+
callee.object.name === "self");
|
|
45
|
+
};
|
|
11
46
|
export const renameFileReaderVariablesTransform = {
|
|
12
47
|
id: "rename-file-reader-variables",
|
|
13
|
-
description: "
|
|
48
|
+
description: "Post-pass: renames FileReader event-handler parameters for fileReader-like bindings",
|
|
14
49
|
scope: "file",
|
|
15
50
|
parallelizable: true,
|
|
16
51
|
transform(context) {
|
|
@@ -18,33 +53,20 @@ export const renameFileReaderVariablesTransform = {
|
|
|
18
53
|
let transformationsApplied = 0;
|
|
19
54
|
for (const fileInfo of getFilesToProcess(context)) {
|
|
20
55
|
const renameGroup = new RenameGroup();
|
|
21
|
-
const exportedNames = collectExportedNames(fileInfo.ast.program);
|
|
22
|
-
const queuedBindings = new Set();
|
|
23
56
|
const queuedEventBindings = new Set();
|
|
24
57
|
const fileReaderBindings = new Set();
|
|
25
58
|
let directTransformationsApplied = 0;
|
|
26
59
|
traverse(fileInfo.ast, {
|
|
27
60
|
VariableDeclarator(path) {
|
|
28
61
|
nodesVisited++;
|
|
29
|
-
|
|
30
|
-
if (id.type !== "Identifier") {
|
|
62
|
+
if (path.node.id.type !== "Identifier")
|
|
31
63
|
return;
|
|
32
|
-
|
|
33
|
-
const initPath = path.get("init");
|
|
34
|
-
if (Array.isArray(initPath) || !initPath.isNewExpression()) {
|
|
64
|
+
if (!isTrackedFileReaderBindingName(path.node.id.name))
|
|
35
65
|
return;
|
|
36
|
-
|
|
37
|
-
if (!
|
|
66
|
+
const binding = path.scope.getBinding(path.node.id.name);
|
|
67
|
+
if (!binding)
|
|
38
68
|
return;
|
|
39
|
-
|
|
40
|
-
queueFileReaderRename({
|
|
41
|
-
scope: path.scope,
|
|
42
|
-
currentName: id.name,
|
|
43
|
-
renameGroup,
|
|
44
|
-
exportedNames,
|
|
45
|
-
queuedBindings,
|
|
46
|
-
fileReaderBindings,
|
|
47
|
-
});
|
|
69
|
+
fileReaderBindings.add(binding);
|
|
48
70
|
},
|
|
49
71
|
AssignmentExpression(path) {
|
|
50
72
|
nodesVisited++;
|
|
@@ -54,22 +76,18 @@ export const renameFileReaderVariablesTransform = {
|
|
|
54
76
|
if (!binding) {
|
|
55
77
|
return;
|
|
56
78
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
!isFileReaderConstructor(rightPath)) {
|
|
79
|
+
if (!isTrackedFileReaderBindingName(binding.identifier.name)) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (operator !== "=") {
|
|
62
83
|
fileReaderBindings.delete(binding);
|
|
63
84
|
return;
|
|
64
85
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
queuedBindings,
|
|
71
|
-
fileReaderBindings,
|
|
72
|
-
});
|
|
86
|
+
if (isFileReaderConstructorExpression(path.node.right)) {
|
|
87
|
+
fileReaderBindings.add(binding);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
fileReaderBindings.delete(binding);
|
|
73
91
|
return;
|
|
74
92
|
}
|
|
75
93
|
directTransformationsApplied += queueFileReaderEventRename({
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"notes": "Renames stream data callback chunks converted via toString() for stable semantic naming.",
|
|
3
|
+
"evaluations": {
|
|
4
|
+
"claude-code-2.1.10:claude-code-2.1.11": {
|
|
5
|
+
"diffSizePercent": 100,
|
|
6
|
+
"evaluatedAt": "2026-02-13T08:13:50.155Z",
|
|
7
|
+
"changedLines": 46,
|
|
8
|
+
"durationSeconds": 30.382711458000003,
|
|
9
|
+
"stableNames": 1358
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"recommended": true,
|
|
13
|
+
"recommendedOrder": 115
|
|
14
|
+
}
|