Skip to content

Commit 5b3cdc4

Browse files
authored
Remove v2 and v3 from utility names in utils folder (#456)
1 parent bf79847 commit 5b3cdc4

File tree

10 files changed

+30
-30
lines changed

10 files changed

+30
-30
lines changed

src/transforms/v2-to-v3/apis/getV2ClientIdNamesFromNewExpr.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Collection, Identifier, JSCodeshift, NewExpression } from "jscodeshift";
22

3-
import { getV2ClientNewExpression } from "../utils";
3+
import { getClientNewExpression } from "../utils";
44

55
export interface GetV2ClientIdNamesFromNewExprOptions {
66
v2ClientName: string;
@@ -45,11 +45,11 @@ export const getV2ClientIdNamesFromNewExpr = (
4545
for (const getNames of [getNamesFromVariableDeclarator, getNamesFromAssignmentPattern]) {
4646
if (v2GlobalName) {
4747
namesFromGlobalModule.push(
48-
...getNames(j, source, getV2ClientNewExpression({ v2GlobalName, v2ClientName }))
48+
...getNames(j, source, getClientNewExpression({ v2GlobalName, v2ClientName }))
4949
);
5050
}
5151
namesFromServiceModule.push(
52-
...getNames(j, source, getV2ClientNewExpression({ v2ClientLocalName }))
52+
...getNames(j, source, getClientNewExpression({ v2ClientLocalName }))
5353
);
5454
}
5555

src/transforms/v2-to-v3/client-instances/replaceClientCreation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Collection, JSCodeshift } from "jscodeshift";
22

3-
import { getV2ClientNewExpression } from "../utils";
3+
import { getClientNewExpression } from "../utils";
44

55
export interface ReplaceClientCreationOptions {
66
v2ClientName: string;
@@ -15,7 +15,7 @@ export const replaceClientCreation = (
1515
{ v2ClientName, v2ClientLocalName, v2GlobalName }: ReplaceClientCreationOptions
1616
): void => {
1717
source
18-
.find(j.NewExpression, getV2ClientNewExpression({ v2GlobalName, v2ClientName }))
18+
.find(j.NewExpression, getClientNewExpression({ v2GlobalName, v2ClientName }))
1919
.replaceWith((v2ClientNewExpression) =>
2020
j.newExpression(j.identifier(v2ClientLocalName), v2ClientNewExpression.node.arguments)
2121
);

src/transforms/v2-to-v3/client-names/getNamesFromNewExpr.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { Collection, Identifier, JSCodeshift, MemberExpression } from "jscodeshift";
22

3-
import { getV2ClientNewExpression } from "../utils";
3+
import { getClientNewExpression } from "../utils";
44

55
export const getNamesFromNewExpr = (
66
j: JSCodeshift,
77
source: Collection<unknown>,
88
v2GlobalName: string
99
): string[] =>
1010
source
11-
.find(j.NewExpression, getV2ClientNewExpression({ v2GlobalName }))
11+
.find(j.NewExpression, getClientNewExpression({ v2GlobalName }))
1212
.nodes()
1313
.map(
1414
(newExpression) => ((newExpression.callee as MemberExpression).property as Identifier).name

src/transforms/v2-to-v3/modules/getClientTSTypeRefCount.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Collection, JSCodeshift } from "jscodeshift";
22

3-
import { getV2ClientTSTypeRef } from "../utils";
3+
import { getClientTSTypeRef } from "../utils";
44
import { ClientModulesOptions } from "./types";
55

66
export const getClientTSTypeRefCount = (
@@ -13,14 +13,14 @@ export const getClientTSTypeRefCount = (
1313
if (v2GlobalName) {
1414
const clienTSTypeRefFromGlobalName = source.find(
1515
j.TSTypeReference,
16-
getV2ClientTSTypeRef({ v2ClientName, v2GlobalName })
16+
getClientTSTypeRef({ v2ClientName, v2GlobalName })
1717
);
1818
clientTSTypeRefCount += clienTSTypeRefFromGlobalName.length;
1919
}
2020

2121
const clienTSTypeRefFromClientLocalName = source.find(
2222
j.TSTypeReference,
23-
getV2ClientTSTypeRef({ v2ClientLocalName })
23+
getClientTSTypeRef({ v2ClientLocalName })
2424
);
2525
clientTSTypeRefCount += clienTSTypeRefFromClientLocalName.length;
2626

src/transforms/v2-to-v3/modules/getNewExpressionCount.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Collection, JSCodeshift } from "jscodeshift";
22

3-
import { getV2ClientNewExpression } from "../utils";
3+
import { getClientNewExpression } from "../utils";
44
import { ClientModulesOptions } from "./types";
55

66
export const getNewExpressionCount = (
@@ -13,14 +13,14 @@ export const getNewExpressionCount = (
1313
if (v2GlobalName) {
1414
const newExpressionsFromGlobalName = source.find(
1515
j.NewExpression,
16-
getV2ClientNewExpression({ v2ClientName, v2GlobalName })
16+
getClientNewExpression({ v2ClientName, v2GlobalName })
1717
);
1818
newExpressionCount += newExpressionsFromGlobalName.length;
1919
}
2020

2121
const newExpressionsFromClientLocalName = source.find(
2222
j.NewExpression,
23-
getV2ClientNewExpression({ v2ClientLocalName })
23+
getClientNewExpression({ v2ClientLocalName })
2424
);
2525
newExpressionCount += newExpressionsFromClientLocalName.length;
2626

src/transforms/v2-to-v3/ts-type/getV2ClientTypeNames.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Collection, Identifier, JSCodeshift, TSQualifiedName, TSTypeReference } from "jscodeshift";
22

33
import { getImportSpecifiers } from "../modules";
4-
import { getV2ClientTSTypeRef, getV2ServiceModulePath } from "../utils";
4+
import { getClientTSTypeRef, getV2ServiceModulePath } from "../utils";
55

66
export interface GetV2ClientTypeNamesOptions {
77
v2ClientName: string;
@@ -29,16 +29,16 @@ export const getV2ClientTypeNames = (
2929
const v2ClientTypeNames = [];
3030

3131
if (v2GlobalName) {
32-
const v2GlobalTSTypeRef = getV2ClientTSTypeRef({
32+
const globalTSTypeRef = getClientTSTypeRef({
3333
v2ClientName,
3434
v2GlobalName,
3535
withoutRightSection: true,
3636
});
37-
v2ClientTypeNames.push(...getRightIdentifierName(j, source, v2GlobalTSTypeRef));
37+
v2ClientTypeNames.push(...getRightIdentifierName(j, source, globalTSTypeRef));
3838
}
3939

40-
const v2ClientTSTypeRef = getV2ClientTSTypeRef({ v2ClientLocalName, withoutRightSection: true });
41-
v2ClientTypeNames.push(...getRightIdentifierName(j, source, v2ClientTSTypeRef));
40+
const clientTSTypeRef = getClientTSTypeRef({ v2ClientLocalName, withoutRightSection: true });
41+
v2ClientTypeNames.push(...getRightIdentifierName(j, source, clientTSTypeRef));
4242

4343
v2ClientTypeNames.push(
4444
...getImportSpecifiers(j, source, getV2ServiceModulePath(v2ClientName))

src/transforms/v2-to-v3/ts-type/replaceTSTypeReference.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Collection, Identifier, JSCodeshift, TSQualifiedName, TSTypeReference } from "jscodeshift";
22

3-
import { getV2ClientTSTypeRef } from "../utils";
3+
import { getClientTSTypeRef } from "../utils";
44
import { getV2ClientTypeNames } from "./getV2ClientTypeNames";
55
import { getV3ClientTypeReference } from "./getV3ClientTypeReference";
66

@@ -28,7 +28,7 @@ export const replaceTSTypeReference = (
2828
// Replace type reference to client created with global name.
2929
if (v2GlobalName) {
3030
source
31-
.find(j.TSTypeReference, getV2ClientTSTypeRef({ v2ClientName, v2GlobalName }))
31+
.find(j.TSTypeReference, getClientTSTypeRef({ v2ClientName, v2GlobalName }))
3232
.replaceWith((v2ClientType) =>
3333
j.tsTypeReference(j.identifier(v3ClientName), v2ClientType.node.typeParameters)
3434
);
@@ -37,7 +37,7 @@ export const replaceTSTypeReference = (
3737
source
3838
.find(
3939
j.TSTypeReference,
40-
getV2ClientTSTypeRef({ v2ClientName, v2GlobalName, withoutRightSection: true })
40+
getClientTSTypeRef({ v2ClientName, v2GlobalName, withoutRightSection: true })
4141
)
4242
.filter((v2ClientType) => isRightSectionIdentifier(v2ClientType.node))
4343
.replaceWith((v2ClientType) => {
@@ -48,7 +48,7 @@ export const replaceTSTypeReference = (
4848

4949
// Replace reference to client types created with client module.
5050
source
51-
.find(j.TSTypeReference, getV2ClientTSTypeRef({ v2ClientLocalName, withoutRightSection: true }))
51+
.find(j.TSTypeReference, getClientTSTypeRef({ v2ClientLocalName, withoutRightSection: true }))
5252
.filter((v2ClientType) => isRightSectionIdentifier(v2ClientType.node))
5353
.replaceWith((v2ClientType) => {
5454
const v2ClientTypeName = getRightIdentifierName(v2ClientType.node);

src/transforms/v2-to-v3/utils/getV2ClientNewExpression.ts renamed to src/transforms/v2-to-v3/utils/getClientNewExpression.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { NewExpression } from "jscodeshift";
22

3-
export interface ClientNewExpressionOptions {
3+
export interface GetClientNewExpressionOptions {
44
v2ClientLocalName?: string;
55
v2ClientName?: string;
66
v2GlobalName?: string;
77
}
88

9-
export const getV2ClientNewExpression = ({
9+
export const getClientNewExpression = ({
1010
v2ClientLocalName,
1111
v2ClientName,
1212
v2GlobalName,
13-
}: ClientNewExpressionOptions): NewExpression => {
13+
}: GetClientNewExpressionOptions): NewExpression => {
1414
if (!v2GlobalName && !v2ClientLocalName) {
1515
throw new Error(
1616
`One of the following options must be provided: v2ClientLocalName, v2GlobalName`

src/transforms/v2-to-v3/utils/getV2ClientTSTypeRef.ts renamed to src/transforms/v2-to-v3/utils/getClientTSTypeRef.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { Identifier, TSQualifiedName, TSTypeReference } from "jscodeshift";
22

3-
export interface V2ClientTsTypeRefOptions {
3+
export interface GetClientTsTypeRefOptions {
44
v2ClientLocalName?: string;
55
v2ClientName?: string;
66
v2GlobalName?: string;
77
withoutRightSection?: boolean;
88
}
99

10-
export const getV2ClientTSTypeRef = ({
10+
export const getClientTSTypeRef = ({
1111
v2ClientLocalName,
1212
v2ClientName,
1313
v2GlobalName,
1414
withoutRightSection = false,
15-
}: V2ClientTsTypeRefOptions): TSTypeReference => {
15+
}: GetClientTsTypeRefOptions): TSTypeReference => {
1616
if (!v2GlobalName && !v2ClientLocalName) {
1717
throw new Error(
1818
`One of the following options must be provided: v2ClientLocalName, v2GlobalName`
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export * from "./getV2ClientNewExpression";
2-
export * from "./getV2ClientTSTypeRef";
1+
export * from "./getClientNewExpression";
2+
export * from "./getClientTSTypeRef";
33
export * from "./getV2ServiceModulePath";
44
export * from "./getV3DefaultLocalName";
55
export * from "./isTypeScriptFile";

0 commit comments

Comments
 (0)