-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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: support parsing files with macros in codemod #7114
Conversation
@@ -225,6 +225,12 @@ import { style } from "@react-spectrum/s2/style" with { type: "macro" }; | |||
})}>Test</RSPButton>" | |||
`; | |||
|
|||
exports[`Should leave existing style macros unaffected 1`] = ` | |||
"import { style } from "@react-spectrum/s2/style" with { type: "macro" }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where'd the import of TextField go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Looks like that was an unrelated issue that came up when we renamed the package, but we didn't have any tests to catch it. Just needed to update:
- if (path.node.source.value === '@adobe/react-spectrum' || path.node.source.value.startsWith('@react-spectrum/')) {
+ if (path.node.source.value === '@adobe/react-spectrum' || (path.node.source.value.startsWith('@react-spectrum/') && path.node.source.value !== '@react-spectrum/s2')) {
2cccdf3
to
27e65b4
Compare
By updating the parser, we can now run codemods on files with the style macro already imported.
Also fixes an issue where existing s2 imports were being removed.
✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project: