Skip to content

Commit 304ae20

Browse files
authored
Remove trailing comma from ObjectProperty require (#719)
1 parent 0ac2c98 commit 304ae20

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

.changeset/pretty-tips-cry.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 trailing comma from ObjectProperty require
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const AWS = require("aws-sdk");
2+
3+
const client = new AWS.DynamoDB({
4+
region: "us-west-2",
5+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const { DynamoDB } = require("@aws-sdk/client-dynamodb");
2+
3+
const client = new DynamoDB({
4+
region: "us-west-2",
5+
});

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ export const getFormattedSourceString = (source: string) =>
77
.replace(
88
/\{\n {2}([\w,\n ]+)\n\} = require\((['"])@aws-sdk/g,
99
(_, identifiers, quote) =>
10-
`{ ${identifiers.split(",\n ").join(", ")} } = require(${quote}@aws-sdk`
10+
`{ ${identifiers
11+
.split(",")
12+
.map((str: string) => str.trimLeft())
13+
.filter((str: string) => str !== "")
14+
.join(", ")} } = require(${quote}@aws-sdk`
1115
)
1216
// Remove extra newlines between require declarations.
1317
.replace(

0 commit comments

Comments
 (0)