Skip to content

Commit

Permalink
Use .flatMap() instead of .map().flat() (#895)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr authored Jul 12, 2024
1 parent 0093a96 commit 4f28fbb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/tidy-moles-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"aws-sdk-js-codemod": patch
---

Use `.flatMap()` instead of `.map().flat()`
1 change: 0 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"recommended": true,
"complexity": {
"noForEach": "off",
"useFlatMap": "off",
"useOptionalChain": "off"
},
"correctness": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const DEEP_IMPORT_PATH_REGEXP = new RegExp(`${PACKAGE_NAME}/clients/([\\w]*)`, "

export const getClientNamesFromDeepImport = (fileSource: string) => {
const clientsFromDeepImportPath = new Set(
[...fileSource.matchAll(DEEP_IMPORT_PATH_REGEXP)].map((regExpMatch) => regExpMatch[1]).flat()
[...fileSource.matchAll(DEEP_IMPORT_PATH_REGEXP)].flatMap((regExpMatch) => regExpMatch[1])
);

return CLIENT_NAMES.filter((clientName) =>
Expand Down
5 changes: 2 additions & 3 deletions src/transforms/v2-to-v3/ts-type/getV3ClientTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const getV3ClientTypes = (
const typesFromString = getTypesFromString(clientTypesMap[clientTypeName]);
return typesFromString.some((type) => !nativeTypes.includes(type));
})
.map((clientTypeName) => {
.flatMap((clientTypeName) => {
if (clientTypeName === "ClientConfiguration") {
return clientTypesMap[clientTypeName];
}
Expand All @@ -51,6 +51,5 @@ export const getV3ClientTypes = (
}

return clientTypeName;
})
.flat();
});
};

0 comments on commit 4f28fbb

Please sign in to comment.