Skip to content

Commit

Permalink
Support removal of .promise() with parentPath ObjectProperty (#392)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Feb 22, 2023
1 parent 387473f commit ec4577c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/stale-tigers-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"aws-sdk-js-codemod": patch
---

Support removal of .promise() with parentPath ObjectProperty
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import AWS from "aws-sdk";

export const listTablesObjectProperty = async (client: AWS.DynamoDB) => ({
promise: client.listTables().promise(),
});

export const listTables = async (client: AWS.DynamoDB) => client.listTables().promise();
export const listTagsOfResource = async (client: AWS.DynamoDB) =>
client.listTagsOfResource({ ResourceArn: "STRING_VALUE" }).promise();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { DynamoDB } from "@aws-sdk/client-dynamodb";

export const listTablesObjectProperty = async (client: DynamoDB) => ({
promise: client.listTables(),
});

export const listTables = async (client: DynamoDB) => client.listTables();
export const listTagsOfResource = async (client: DynamoDB) =>
client.listTagsOfResource({ ResourceArn: "STRING_VALUE" });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import DynamoDB from "aws-sdk/clients/dynamodb";

export const listTablesObjectProperty = async (client: DynamoDB) => ({
promise: client.listTables().promise(),
});

export const listTables = async (client: DynamoDB) => client.listTables().promise();
export const listTagsOfResource = async (client: DynamoDB) =>
client.listTagsOfResource({ ResourceArn: "STRING_VALUE" }).promise();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { DynamoDB } from "@aws-sdk/client-dynamodb";

export const listTablesObjectProperty = async (client: DynamoDB) => ({
promise: client.listTables(),
});

export const listTables = async (client: DynamoDB) => client.listTables();
export const listTagsOfResource = async (client: DynamoDB) =>
client.listTagsOfResource({ ResourceArn: "STRING_VALUE" });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const removePromiseForCallExpression = (callExpression: ASTPath<CallExpre
break;
}
case "ArrowFunctionExpression":
case "ObjectProperty":
case "ReturnStatement": {
const currentCalleeObject = (callExpression.value.callee as MemberExpression)
.object as CallExpression;
Expand Down

0 comments on commit ec4577c

Please sign in to comment.