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

Merged
merged 12 commits into from
May 7, 2025
Merged

chore: Refactor codemods #8056

merged 12 commits into from
May 7, 2025

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

@rspbot
Copy link

rspbot commented Apr 29, 2025

@dannify
Copy link
Member

dannify commented May 7, 2025

Let's get this merged and test it next week

@reidbarber reidbarber added this pull request to the merge queue May 7, 2025
Merged via the queue into main with commit 0548d30 May 7, 2025
30 checks passed
@reidbarber reidbarber deleted the codemod-refactor branch May 7, 2025 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants