Skip to content

Commit

Permalink
Remove newlines from ObjectPattern requires with multiple keys (#717)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr authored Nov 12, 2023
1 parent c18f8be commit 56a5979
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .changeset/eight-shrimps-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"aws-sdk-js-codemod": patch
---

Remove newlines from ObjectPattern requires with multiple keys
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
const {
DynamoDB,
DynamoDBClient
} = require("@aws-sdk/client-dynamodb");
const { DynamoDB, DynamoDBClient } = require("@aws-sdk/client-dynamodb");

const client1 = new DynamoDB();
const client2 = new DynamoDBClient();
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
const {
DynamoDB,
DynamoDBClient
} = require("@aws-sdk/client-dynamodb");
const { DynamoDB, DynamoDBClient } = require("@aws-sdk/client-dynamodb");

const client1 = new DynamoDB();
const client2 = new DynamoDBClient();
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
const { getSignedUrl } = require("@aws-sdk/s3-request-presigner");

const {
GetObjectCommand,
S3
} = require("@aws-sdk/client-s3");
const { GetObjectCommand, S3 } = require("@aws-sdk/client-s3");

const s3 = new S3();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
const {
S3,
waitUntilBucketExists
} = require("@aws-sdk/client-s3");
const { S3, waitUntilBucketExists } = require("@aws-sdk/client-s3");

const Bucket = "BUCKET_NAME";
const client = new S3();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
const {
S3,
waitUntilBucketExists
} = require("@aws-sdk/client-s3");
const { S3, waitUntilBucketExists } = require("@aws-sdk/client-s3");

const Bucket = "BUCKET_NAME";
const client = new S3();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
const {
S3,
waitUntilBucketExists
} = require("@aws-sdk/client-s3");
const { S3, waitUntilBucketExists } = require("@aws-sdk/client-s3");

const Bucket = "BUCKET_NAME";
const client = new S3();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
const {
S3,
waitUntilBucketExists
} = require("@aws-sdk/client-s3");
const { S3, waitUntilBucketExists } = require("@aws-sdk/client-s3");

const Bucket = "BUCKET_NAME";
const client = new S3();
Expand Down
5 changes: 3 additions & 2 deletions src/transforms/v2-to-v3/utils/getFormattedSourceString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const getFormattedSourceString = (source: string) =>
source
// Remove newlines from ObjectPattern requires.
.replace(
/\{\n {2}([\w]*)\n\} = require\((['"])@aws-sdk/g,
(_, identifier, quote) => `{ ${identifier} } = require(${quote}@aws-sdk`
/\{\n {2}([\w,\n ]+)\n\} = require\((['"])@aws-sdk/g,
(_, identifiers, quote) =>
`{ ${identifiers.split(",\n ").join(", ")} } = require(${quote}@aws-sdk`
);

0 comments on commit 56a5979

Please sign in to comment.