Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task
trivikr opened this issue Nov 8, 2023 · 0 comments
Labels
enhancement New feature or request p3 This is a minor priority issue

Comments

@trivikr
Copy link
Member

trivikr commented Nov 8, 2023

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:

import AWS from "aws-sdk";

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

Output:

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:

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

@trivikr trivikr added the enhancement New feature or request label Nov 8, 2023
@trivikr trivikr added the p3 This is a minor priority issue label Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request p3 This is a minor priority issue
Projects
None yet
Development

No branches or pull requests

1 participant