diff --git a/.changeset/gentle-news-provide.md b/.changeset/gentle-news-provide.md new file mode 100644 index 000000000..5e892279f --- /dev/null +++ b/.changeset/gentle-news-provide.md @@ -0,0 +1,5 @@ +--- +"aws-sdk-js-codemod": patch +--- + +Do not use spread syntax on accumulators diff --git a/biome.json b/biome.json index e81febeb5..9af8d7f22 100644 --- a/biome.json +++ b/biome.json @@ -20,9 +20,6 @@ "noUndeclaredVariables": "error", "noUnusedVariables": "error" }, - "performance": { - "noAccumulatingSpread": "off" - }, "style": { "noNamespace": "error", "noNonNullAssertion": "off", diff --git a/src/transforms/v2-to-v3/client-names/getClientMetadataRecord.ts b/src/transforms/v2-to-v3/client-names/getClientMetadataRecord.ts index df343f3ef..967297f71 100644 --- a/src/transforms/v2-to-v3/client-names/getClientMetadataRecord.ts +++ b/src/transforms/v2-to-v3/client-names/getClientMetadataRecord.ts @@ -7,16 +7,19 @@ export const getClientMetadataRecord = ( ): ClientMetadataRecord => Object.entries( Object.entries(v2ClientNamesRecord).reduce( - (acc, [v2ClientName, v2ClientLocalName]) => ({ - ...acc, - [v2ClientName]: { + (acc: ClientMetadataRecord, [v2ClientName, v2ClientLocalName]) => { + acc[v2ClientName] = { v2ClientLocalName, v3ClientName: getV3ClientName(v2ClientName), v3ClientPackageName: getV3ClientPackageName(v2ClientName), - }, - }), + }; + return acc; + }, {} - ) as ClientMetadataRecord + ) ) .sort(([, { v3ClientPackageName: a }], [, { v3ClientPackageName: b }]) => b.localeCompare(a)) - .reduce((r, [k, v]) => ({ ...r, [k]: v }), {}); + .reduce((acc: ClientMetadataRecord, [key, value]) => { + acc[key] = value; + return acc; + }, {}); diff --git a/src/transforms/v2-to-v3/config/CLIENT_NAMES_MAP.ts b/src/transforms/v2-to-v3/config/CLIENT_NAMES_MAP.ts index 821a61d09..42bdcb1b8 100644 --- a/src/transforms/v2-to-v3/config/CLIENT_NAMES_MAP.ts +++ b/src/transforms/v2-to-v3/config/CLIENT_NAMES_MAP.ts @@ -2,7 +2,10 @@ import { CLIENT_NAMES } from "./CLIENT_NAMES"; // The key is the client name in v2, and value is the client name in v3. export const CLIENT_NAMES_MAP: Record = { - ...CLIENT_NAMES.reduce((acc, name) => ({ ...acc, [name]: name }), {}), + ...CLIENT_NAMES.reduce((acc: Record, name) => { + acc[name] = name; + return acc; + }, {}), AugmentedAIRuntime: "SageMakerA2IRuntime", CUR: "CostAndUsageReportService", CodeArtifact: "Codeartifact", diff --git a/src/transforms/v2-to-v3/config/CLIENT_PACKAGE_NAMES_MAP.ts b/src/transforms/v2-to-v3/config/CLIENT_PACKAGE_NAMES_MAP.ts index e75a1564b..24e190acd 100644 --- a/src/transforms/v2-to-v3/config/CLIENT_PACKAGE_NAMES_MAP.ts +++ b/src/transforms/v2-to-v3/config/CLIENT_PACKAGE_NAMES_MAP.ts @@ -2,37 +2,34 @@ import { CLIENT_NAMES } from "./CLIENT_NAMES"; // The key is the client name in v2, and value is the client package name in v3. export const CLIENT_PACKAGE_NAMES_MAP: Record = { - ...CLIENT_NAMES.reduce( - (acc, name) => ({ - ...acc, - [name]: `client-${name.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase()}` - .replace("-chime-sdk", "-chime-sdk-") - .replace("client-amplify-", "client-amplify") - .replace("client-bcmdata-exports", "client-bcm-data-exports") - .replace("client-control-catalog", "client-controlcatalog") - .replace("client-clean-rooms-ml", "client-cleanroomsml") - .replace("client-cloud-", "client-cloud") - .replace("client-code-", "client-code") - .replace("client-connect-", "client-connect") - .replace("client-data-", "client-data") - .replace("client-free-tier", "client-freetier") - .replace("client-io-t", "client-iot-") - .replace("client-iot-fleet-", "client-iotfleet") - .replace("client-lookout-", "client-lookout") - .replace("client-media-", "client-media") - .replace("client-migration-hub-", "client-migrationhub") - .replace("client-network-monitor", "client-networkmonitor") - .replace("client-pinpoint-sms", "client-pinpoint-sms-") - .replace("client-route53", "client-route53-") - .replace("client-sage-maker", "client-sagemaker") - .replace("client-security-", "client-security") - .replace("client-supply-chain", "client-supplychain") - .replace("client-timestream-influx-db", "client-timestream-influxdb") - .replace("client-trusted-advisor", "client-trustedadvisor") - .replace("client-work-", "client-work"), - }), - {} - ), + ...CLIENT_NAMES.reduce((acc: Record, name) => { + acc[name] = `client-${name.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase()}` + .replace("-chime-sdk", "-chime-sdk-") + .replace("client-amplify-", "client-amplify") + .replace("client-bcmdata-exports", "client-bcm-data-exports") + .replace("client-control-catalog", "client-controlcatalog") + .replace("client-clean-rooms-ml", "client-cleanroomsml") + .replace("client-cloud-", "client-cloud") + .replace("client-code-", "client-code") + .replace("client-connect-", "client-connect") + .replace("client-data-", "client-data") + .replace("client-free-tier", "client-freetier") + .replace("client-io-t", "client-iot-") + .replace("client-iot-fleet-", "client-iotfleet") + .replace("client-lookout-", "client-lookout") + .replace("client-media-", "client-media") + .replace("client-migration-hub-", "client-migrationhub") + .replace("client-network-monitor", "client-networkmonitor") + .replace("client-pinpoint-sms", "client-pinpoint-sms-") + .replace("client-route53", "client-route53-") + .replace("client-sage-maker", "client-sagemaker") + .replace("client-security-", "client-security") + .replace("client-supply-chain", "client-supplychain") + .replace("client-timestream-influx-db", "client-timestream-influxdb") + .replace("client-trusted-advisor", "client-trustedadvisor") + .replace("client-work-", "client-work"); + return acc; + }, {}), AccessAnalyzer: "client-accessanalyzer", ACMPCA: "client-acm-pca", APIGateway: "client-api-gateway",