diff --git a/.changeset/tidy-moles-join.md b/.changeset/tidy-moles-join.md new file mode 100644 index 000000000..bb90b0ec9 --- /dev/null +++ b/.changeset/tidy-moles-join.md @@ -0,0 +1,5 @@ +--- +"aws-sdk-js-codemod": patch +--- + +Use `.flatMap()` instead of `.map().flat()` diff --git a/biome.json b/biome.json index afa54869a..37fb6f363 100644 --- a/biome.json +++ b/biome.json @@ -14,7 +14,6 @@ "recommended": true, "complexity": { "noForEach": "off", - "useFlatMap": "off", "useOptionalChain": "off" }, "correctness": { diff --git a/src/transforms/v2-to-v3/client-names/getClientNamesFromDeepImport.ts b/src/transforms/v2-to-v3/client-names/getClientNamesFromDeepImport.ts index 98ffd4e12..2f6e45197 100644 --- a/src/transforms/v2-to-v3/client-names/getClientNamesFromDeepImport.ts +++ b/src/transforms/v2-to-v3/client-names/getClientNamesFromDeepImport.ts @@ -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) => diff --git a/src/transforms/v2-to-v3/ts-type/getV3ClientTypes.ts b/src/transforms/v2-to-v3/ts-type/getV3ClientTypes.ts index 3cd68a487..dfc3b5c39 100644 --- a/src/transforms/v2-to-v3/ts-type/getV3ClientTypes.ts +++ b/src/transforms/v2-to-v3/ts-type/getV3ClientTypes.ts @@ -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]; } @@ -51,6 +51,5 @@ export const getV3ClientTypes = ( } return clientTypeName; - }) - .flat(); + }); };