-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add comment to investigate removal of .promise() (#859)
- Loading branch information
Showing
8 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"aws-sdk-js-codemod": patch | ||
--- | ||
|
||
Add comment to investigate removal of .promise() |
4 changes: 4 additions & 0 deletions
4
src/transforms/v2-to-v3/__fixtures__/api-promise/orphan-promise.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// client is AWS SDK JS v2 client here, but jscodeshift can't detect it because of lack of types/import. | ||
export const listTables = (client) => { | ||
return client.listTables().promise(); | ||
} |
8 changes: 8 additions & 0 deletions
8
src/transforms/v2-to-v3/__fixtures__/api-promise/orphan-promise.output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// client is AWS SDK JS v2 client here, but jscodeshift can't detect it because of lack of types/import. | ||
export const listTables = (client) => { | ||
return ( | ||
// The `.promise()` call might be on an JS SDK v2 client API. | ||
// If yes, please remove .promise(). If not, remove this comment. | ||
client.listTables().promise() | ||
); | ||
} |
2 changes: 1 addition & 1 deletion
2
src/transforms/v2-to-v3/__fixtures__/misc/no-formatting.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
const env = {...process.env, ...this.config.env || {}} | ||
const env = {...process.env, ...(this.config.env || {})} |
2 changes: 1 addition & 1 deletion
2
src/transforms/v2-to-v3/__fixtures__/misc/no-formatting.output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
const env = {...process.env, ...this.config.env || {}} | ||
const env = {...process.env, ...(this.config.env || {})} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Collection, JSCodeshift } from "jscodeshift"; | ||
|
||
export const addPromiseRemovalComments = (j: JSCodeshift, source: Collection<unknown>): void => { | ||
// Add comment for .promise() calls which weren't removed. | ||
source | ||
.find(j.CallExpression, { | ||
callee: { | ||
type: "MemberExpression", | ||
property: { type: "Identifier", name: "promise" }, | ||
}, | ||
}) | ||
.forEach(({ node }) => { | ||
const comments = node.comments || []; | ||
comments.push(j.commentLine(" The `.promise()` call might be on an JS SDK v2 client API.")); | ||
comments.push( | ||
j.commentLine(" If yes, please remove .promise(). If not, remove this comment.") | ||
); | ||
node.comments = comments; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters