Skip to content

Commit 4f28fbb

Browse files
authored
Use .flatMap() instead of .map().flat() (#895)
1 parent 0093a96 commit 4f28fbb

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

.changeset/tidy-moles-join.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"aws-sdk-js-codemod": patch
3+
---
4+
5+
Use `.flatMap()` instead of `.map().flat()`

biome.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"recommended": true,
1515
"complexity": {
1616
"noForEach": "off",
17-
"useFlatMap": "off",
1817
"useOptionalChain": "off"
1918
},
2019
"correctness": {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const DEEP_IMPORT_PATH_REGEXP = new RegExp(`${PACKAGE_NAME}/clients/([\\w]*)`, "
44

55
export const getClientNamesFromDeepImport = (fileSource: string) => {
66
const clientsFromDeepImportPath = new Set(
7-
[...fileSource.matchAll(DEEP_IMPORT_PATH_REGEXP)].map((regExpMatch) => regExpMatch[1]).flat()
7+
[...fileSource.matchAll(DEEP_IMPORT_PATH_REGEXP)].flatMap((regExpMatch) => regExpMatch[1])
88
);
99

1010
return CLIENT_NAMES.filter((clientName) =>

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const getV3ClientTypes = (
3737
const typesFromString = getTypesFromString(clientTypesMap[clientTypeName]);
3838
return typesFromString.some((type) => !nativeTypes.includes(type));
3939
})
40-
.map((clientTypeName) => {
40+
.flatMap((clientTypeName) => {
4141
if (clientTypeName === "ClientConfiguration") {
4242
return clientTypesMap[clientTypeName];
4343
}
@@ -51,6 +51,5 @@ export const getV3ClientTypes = (
5151
}
5252

5353
return clientTypeName;
54-
})
55-
.flat();
54+
});
5655
};

0 commit comments

Comments
 (0)