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:

@rspbot
Copy link

rspbot commented Apr 15, 2025

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