Skip to content

Commit 56a5979

Browse files
authored
Remove newlines from ObjectPattern requires with multiple keys (#717)
1 parent c18f8be commit 56a5979

File tree

9 files changed

+15
-30
lines changed

9 files changed

+15
-30
lines changed

.changeset/eight-shrimps-admire.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+
Remove newlines from ObjectPattern requires with multiple keys
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
const {
2-
DynamoDB,
3-
DynamoDBClient
4-
} = require("@aws-sdk/client-dynamodb");
1+
const { DynamoDB, DynamoDBClient } = require("@aws-sdk/client-dynamodb");
52

63
const client1 = new DynamoDB();
74
const client2 = new DynamoDBClient();
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
const {
2-
DynamoDB,
3-
DynamoDBClient
4-
} = require("@aws-sdk/client-dynamodb");
1+
const { DynamoDB, DynamoDBClient } = require("@aws-sdk/client-dynamodb");
52

63
const client1 = new DynamoDB();
74
const client2 = new DynamoDBClient();

src/transforms/v2-to-v3/__fixtures__/s3-get-signed-url/getObject.require.output.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
const { getSignedUrl } = require("@aws-sdk/s3-request-presigner");
22

3-
const {
4-
GetObjectCommand,
5-
S3
6-
} = require("@aws-sdk/client-s3");
3+
const { GetObjectCommand, S3 } = require("@aws-sdk/client-s3");
74

85
const s3 = new S3();
96

src/transforms/v2-to-v3/__fixtures__/waiters/global-require-property.output.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
const {
2-
S3,
3-
waitUntilBucketExists
4-
} = require("@aws-sdk/client-s3");
1+
const { S3, waitUntilBucketExists } = require("@aws-sdk/client-s3");
52

63
const Bucket = "BUCKET_NAME";
74
const client = new S3();

src/transforms/v2-to-v3/__fixtures__/waiters/global-require.output.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
const {
2-
S3,
3-
waitUntilBucketExists
4-
} = require("@aws-sdk/client-s3");
1+
const { S3, waitUntilBucketExists } = require("@aws-sdk/client-s3");
52

63
const Bucket = "BUCKET_NAME";
74
const client = new S3();

src/transforms/v2-to-v3/__fixtures__/waiters/service-require-deep.output.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
const {
2-
S3,
3-
waitUntilBucketExists
4-
} = require("@aws-sdk/client-s3");
1+
const { S3, waitUntilBucketExists } = require("@aws-sdk/client-s3");
52

63
const Bucket = "BUCKET_NAME";
74
const client = new S3();

src/transforms/v2-to-v3/__fixtures__/waiters/service-require.output.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
const {
2-
S3,
3-
waitUntilBucketExists
4-
} = require("@aws-sdk/client-s3");
1+
const { S3, waitUntilBucketExists } = require("@aws-sdk/client-s3");
52

63
const Bucket = "BUCKET_NAME";
74
const client = new S3();

src/transforms/v2-to-v3/utils/getFormattedSourceString.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const getFormattedSourceString = (source: string) =>
55
source
66
// Remove newlines from ObjectPattern requires.
77
.replace(
8-
/\{\n {2}([\w]*)\n\} = require\((['"])@aws-sdk/g,
9-
(_, identifier, quote) => `{ ${identifier} } = require(${quote}@aws-sdk`
8+
/\{\n {2}([\w,\n ]+)\n\} = require\((['"])@aws-sdk/g,
9+
(_, identifiers, quote) =>
10+
`{ ${identifiers.split(",\n ").join(", ")} } = require(${quote}@aws-sdk`
1011
);

0 commit comments

Comments
 (0)