Skip to content

Commit 7414acc

Browse files
authored
Rename literalValue to sourceValue (#247)
1 parent 49c3da8 commit 7414acc

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

src/transforms/v2-to-v3/utils/get/getImportIdentifierName.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { Collection, Identifier, JSCodeshift } from "jscodeshift";
33
export const getImportIdentifierName = (
44
j: JSCodeshift,
55
source: Collection<unknown>,
6-
literalValue: string
6+
sourceValue: string
77
): string | undefined => {
88
const importSpecifiers = source
99
.find(j.ImportDeclaration, {
1010
type: "ImportDeclaration",
11-
source: { value: literalValue },
11+
source: { value: sourceValue },
1212
})
1313
.nodes()
1414
.map((importDeclaration) => importDeclaration.specifiers)

src/transforms/v2-to-v3/utils/get/getRequireIdentifierName.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Collection, Identifier, JSCodeshift } from "jscodeshift";
33
export const getRequireIdentifierName = (
44
j: JSCodeshift,
55
source: Collection<unknown>,
6-
literalValue: string
6+
sourceValue: string
77
): string | undefined =>
88
(
99
source
@@ -12,7 +12,7 @@ export const getRequireIdentifierName = (
1212
init: {
1313
type: "CallExpression",
1414
callee: { type: "Identifier", name: "require" },
15-
arguments: [{ value: literalValue }],
15+
arguments: [{ value: sourceValue }],
1616
},
1717
})
1818
.nodes()[0]?.id as Identifier

src/transforms/v2-to-v3/utils/get/getRequireVariableDeclaration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import { Collection, JSCodeshift } from "jscodeshift";
33
export const getRequireVariableDeclaration = (
44
j: JSCodeshift,
55
source: Collection<unknown>,
6-
literalValue: string
6+
sourceValue: string
77
) =>
88
source.find(j.VariableDeclaration, {
99
declarations: [
1010
{
1111
init: {
1212
type: "CallExpression",
1313
callee: { type: "Identifier", name: "require" },
14-
arguments: [{ value: literalValue }],
14+
arguments: [{ value: sourceValue }],
1515
},
1616
},
1717
],

src/transforms/v2-to-v3/utils/remove/removeImportIdentifierName.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ import { Collection, JSCodeshift } from "jscodeshift";
33
export interface RemoveImportIdentifierNameOptions {
44
importedName?: string;
55
localName: string;
6-
literalValue: string;
6+
sourceValue: string;
77
}
88

99
export const removeImportIdentifierName = (
1010
j: JSCodeshift,
1111
source: Collection<unknown>,
1212
options: RemoveImportIdentifierNameOptions
1313
) => {
14-
const { localName, literalValue } = options;
14+
const { localName, sourceValue } = options;
1515
const importedName = options.importedName ?? localName;
1616

1717
source
1818
.find(j.ImportDeclaration, {
1919
specifiers: [{ local: { name: localName } }],
20-
source: { value: literalValue },
20+
source: { value: sourceValue },
2121
})
2222
.forEach((declarationPath) => {
2323
// Remove import from ImportDeclaration.

src/transforms/v2-to-v3/utils/remove/removeRequireIdentifierName.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import { getRequireVariableDeclaration } from "../get";
44

55
export interface RemoveRequireIdentifierNameOptions {
66
localName: string;
7-
literalValue: string;
7+
sourceValue: string;
88
}
99

1010
export const removeRequireIdentifierName = (
1111
j: JSCodeshift,
1212
source: Collection<unknown>,
13-
{ localName, literalValue }: RemoveRequireIdentifierNameOptions
13+
{ localName, sourceValue }: RemoveRequireIdentifierNameOptions
1414
) => {
15-
getRequireVariableDeclaration(j, source, literalValue)
15+
getRequireVariableDeclaration(j, source, sourceValue)
1616
.filter(
1717
(nodePath) =>
1818
((nodePath.value.declarations[0] as VariableDeclarator).id as Identifier).name === localName

src/transforms/v2-to-v3/utils/remove/removeV2ClientModule.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ export const removeV2ClientModule = (
1818
options: RemoveV2ClientModuleOptions
1919
) => {
2020
const { v2ClientName, v2ClientLocalName } = options;
21-
const literalValue = getV2ServiceModulePath(v2ClientName);
21+
const sourceValue = getV2ServiceModulePath(v2ClientName);
2222
const removeIdentifierNameOptions = {
2323
localName: v2ClientLocalName,
24-
literalValue,
24+
sourceValue,
2525
};
2626

2727
if (containsRequire(j, source)) {
@@ -34,7 +34,7 @@ export const removeV2ClientModule = (
3434
if (isV2ClientInputOutputType(v2ClientTypeName)) {
3535
removeImportIdentifierName(j, source, {
3636
localName: v2ClientTypeName,
37-
literalValue,
37+
sourceValue,
3838
});
3939
}
4040
}

src/transforms/v2-to-v3/utils/remove/removeV2GlobalModule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const removeV2GlobalModule = (
1616
if (identifierUsages.size() === 1) {
1717
const removeIdentifierNameOptions = {
1818
localName: v2GlobalName,
19-
literalValue: PACKAGE_NAME,
19+
sourceValue: PACKAGE_NAME,
2020
};
2121
if (containsRequire(j, source)) {
2222
removeRequireIdentifierName(j, source, removeIdentifierNameOptions);

0 commit comments

Comments
 (0)