Skip to content

chore: Refactor codemods #8056

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

chore: Refactor codemods #8056

wants to merge 11 commits into from

Conversation

reidbarber
Copy link
Member

@reidbarber reidbarber commented Apr 8, 2025

This will make it easier to add and maintain S1 to S2 codemods in the future.

Codemods are now split up by component in src/codemods/components/.

So to add a Button codemod:

  1. Create src/codemods/components/Button/transform.ts if it doesn't exist
  2. Implement the component transform logic in a default exported function and import any shared transform functions needed (i.e. removeProp)
  3. Add tests at __tests__/button.test.ts

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

Unit tests should validate that all the transforms are still correctly applied, but it would be good to build and test that it still works end-to-end:

  1. cd packages/dev/codemods && yarn build

  2. Change directories to an example app

  3. node ../../packages/dev/codemods/dist/index.js s1-to-s2

🧢 Your Project:

]
},
ActionGroup: {
changes: [
Copy link
Member

Choose a reason for hiding this comment

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

just checking, but the declarative approach is going away?

Copy link
Member Author

@reidbarber reidbarber Apr 10, 2025

Choose a reason for hiding this comment

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

Yep, I think there were just too many steps to remember to do when adding a codemod. Also with more single component-specific codemods getting added it made less sense.

@rspbot
Copy link

rspbot commented Apr 15, 2025

* - Change variant="cta" to variant="accent"
* - Change variant="overBackground" to variant="primary" staticColor="white"
* - Change style to fillStyle
* - Comment out isPending (it has not been implemented yet)
Copy link
Member

@snowystinger snowystinger Apr 16, 2025

Choose a reason for hiding this comment

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

we should fix this one https://react-spectrum.adobe.com/s2/index.html?path=/docs/button--docs not in this PR, just tasks we follow up with

Or, I guess it's just deleting the line?

Copy link
Member Author

Choose a reason for hiding this comment

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

I can clean this up in a follow-up, and double check that others are updated as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants