aws / aws/aws-sdk-js-codemod

[Feature]: Add comment when client constructor input is not an ObjectExpression (like an Identifier)

Open
#695 0 comments 0 reactions 0 assignees View on GitHub
enhancement p3
Dominant language
TypeScript
Stars
89
Forks
13
Avg merge
9h 59m
Merged PRs (30d)
1

Description

### Self-service

- [ ] I'd be willing to implement this feature

### Problem

The config keys are not transformed when client constructor input is not an ObjectExpression (like an Identifier).

Example input:
```js
import AWS from "aws-sdk";

const config = { sslEnabled: true };
const s3 = new AWS.S3(config);
```

Output:
```js
import { S3 } from "@aws-sdk/client-s3";

const config = { tls: true };
const s3 = new S3(config);
```

### Solution

When an identifier is passed in client constructor, it might have been intialized and updated at several places or called from different file. The transformer does not have access to this data.

However, the transformer can add a comment on any action developer can take, as follows:

```js
import { S3 } from "@aws-sdk/client-s3";

const config = { sslEnabled: true };
// Codemod only supports transformation of config passed as ObjectExpression.
// Please re-run codemod by converting Identifier to ObjectExpression.
const s3 = new S3(config);
```

### Alternatives

Add detection of Identifier creation in the file, and transform it.

### Additional context

https://github.com/workadventure/workadventure/blob/596886c66383404a642a333ed8c37e9643b313de/uploader/tests/utils/LocalStackContainer.ts#L13-L14

Contributor guide

Open the contributing guide

Research direction

Start at the transformer handling AWS client constructor inputs and compare its behavior for ObjectExpression and Identifier arguments. Use the S3 example and the referenced LocalStackContainer.ts context to verify the warning comment appears for unsupported non-object input while preserving the constructor transformation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.