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

fix(codemod): support aliased act() import #1242

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

henryqdineen
Copy link
Contributor

📚 Description

This fixes an edge cast that we found in our codebase where the act named import was being aliased.

-import { ComponentType, ReactNode } from 'react';
-import { act as domAct } from 'react-dom/test-utils';
+import { ComponentType, ReactNode, act } from 'react';

The fix is to copy over all act specifiers instead of assuming that the new specifier is not aliased. I understand that it's impossible to handle all edge cases but this one seems straightforward. As an alternative you could check that local.name == 'act' and skip transforming the import. That would prevent introducing broken code but limit the capabilities of the codemod.

🧪 Test Plan

Added a unit test.

📄 Documentation to Update

N/A

Copy link

vercel bot commented Aug 16, 2024

@henryqdineen is attempting to deploy a commit to the Codemod Team on Vercel.

A member of the Team first needs to authorize it.

@mohab-sameh mohab-sameh added ❤️ community contribution codemod-issue Any issues related to a codemod, FP or FN. labels Aug 19, 2024
@alexbit-codemod
Copy link
Contributor

thank you so much for your contribution @henryqdineen. we will review and merge this soon.

Copy link
Contributor

@mohebifar mohebifar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codemod-issue Any issues related to a codemod, FP or FN. ❤️ community contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants