Skip to content

Commit 81a8495

Browse files
authored
Rename containsRequire to hasRequire (#248)
1 parent 7414acc commit 81a8495

File tree

7 files changed

+12
-11
lines changed

7 files changed

+12
-11
lines changed

src/transforms/v2-to-v3/utils/add/addV3ClientModules.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 { containsRequire } from "../containsRequire";
3+
import { hasRequire } from "../has";
44
import { addV3ClientImports } from "./addV3ClientImports";
55
import { addV3ClientRequires } from "./addV3ClientRequires";
66

@@ -17,6 +17,6 @@ export const addV3ClientModules = (
1717
source: Collection<unknown>,
1818
options: AddV3ClientModulesOptions
1919
): void =>
20-
containsRequire(j, source)
20+
hasRequire(j, source)
2121
? addV3ClientRequires(j, source, options)
2222
: addV3ClientImports(j, source, options);

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

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

33
import { CLIENT_NAMES } from "../config";
4-
import { containsRequire } from "../containsRequire";
4+
import { hasRequire } from "../has";
55
import { getImportIdentifierName } from "./getImportIdentifierName";
66
import { getRequireIdentifierName } from "./getRequireIdentifierName";
77
import { getV2ServiceModulePath } from "./getV2ServiceModulePath";
@@ -10,7 +10,7 @@ export const getV2ClientNamesRecord = (
1010
j: JSCodeshift,
1111
source: Collection<unknown>
1212
): Record<string, string> => {
13-
const getIdentifierNameFn = containsRequire(j, source)
13+
const getIdentifierNameFn = hasRequire(j, source)
1414
? getRequireIdentifierName
1515
: getImportIdentifierName;
1616

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

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

33
import { PACKAGE_NAME } from "../config";
4-
import { containsRequire } from "../containsRequire";
4+
import { hasRequire } from "../has";
55
import { getImportIdentifierName } from "./getImportIdentifierName";
66
import { getRequireIdentifierName } from "./getRequireIdentifierName";
77

88
export const getV2GlobalName = (
99
j: JSCodeshift,
1010
source: Collection<unknown>
1111
): string | undefined => {
12-
if (containsRequire(j, source)) {
12+
if (hasRequire(j, source)) {
1313
return getRequireIdentifierName(j, source, PACKAGE_NAME);
1414
}
1515
return getImportIdentifierName(j, source, PACKAGE_NAME);

src/transforms/v2-to-v3/utils/containsRequire.ts renamed to src/transforms/v2-to-v3/utils/has/hasRequire.ts

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

3-
export const containsRequire = (j: JSCodeshift, source: Collection<unknown>) =>
3+
export const hasRequire = (j: JSCodeshift, source: Collection<unknown>) =>
44
source
55
.find(j.CallExpression, {
66
callee: { type: "Identifier", name: "require" },
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./hasRequire";

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

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

3-
import { containsRequire } from "../containsRequire";
43
import { getV2ClientTypeNames, getV2ServiceModulePath } from "../get";
4+
import { hasRequire } from "../has";
55
import { isV2ClientInputOutputType } from "../isV2ClientInputOutputType";
66
import { removeImportIdentifierName } from "./removeImportIdentifierName";
77
import { removeRequireIdentifierName } from "./removeRequireIdentifierName";
@@ -24,7 +24,7 @@ export const removeV2ClientModule = (
2424
sourceValue,
2525
};
2626

27-
if (containsRequire(j, source)) {
27+
if (hasRequire(j, source)) {
2828
removeRequireIdentifierName(j, source, removeIdentifierNameOptions);
2929
} else {
3030
removeImportIdentifierName(j, source, removeIdentifierNameOptions);

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

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

33
import { PACKAGE_NAME } from "../config";
4-
import { containsRequire } from "../containsRequire";
4+
import { hasRequire } from "../has";
55
import { removeImportIdentifierName } from "./removeImportIdentifierName";
66
import { removeRequireIdentifierName } from "./removeRequireIdentifierName";
77

@@ -18,7 +18,7 @@ export const removeV2GlobalModule = (
1818
localName: v2GlobalName,
1919
sourceValue: PACKAGE_NAME,
2020
};
21-
if (containsRequire(j, source)) {
21+
if (hasRequire(j, source)) {
2222
removeRequireIdentifierName(j, source, removeIdentifierNameOptions);
2323
} else {
2424
removeImportIdentifierName(j, source, removeIdentifierNameOptions);

0 commit comments

Comments
 (0)