react-hook-form / codemod

Migrate React Hook Form V6 to V7 made simple.
MIT License
26 stars 7 forks source link

update-register codemod #2

Closed jorisre closed 3 years ago

jorisre commented 3 years ago
bluebill1049 commented 3 years ago

This is pretty amazing, I did this before... so i just need to run this at the project?

npx @hookform/codemod v7/update-register

jorisre commented 3 years ago

This is pretty amazing, I did this before... so i just need to run this at the project?

npx @hookform/codemod v7/update-register

To give a test before the first NPM publish, you can do the following:

Checkout this branch and execute codemod with npx:

npx ~/path-to-codemod-repo

For me it's npx ~/w/@hookform/codemod

And the cli will ask you info, just reply and let me know if you've issue or new case to migrate ;)

KubaJastrz commented 3 years ago

Hi @jorisre, I've run the codemod on one of my projects (38 uses of register) which resulted in following diff:

Results: 
1 errors
621 unmodified
0 skipped
18 ok
Time elapsed: 5.244seconds

Everything seems to be changed perfectly fine, really awesome tool 💪

That one error comes from being unable to parse one .d.ts file, but it's probably unrelated to the codemod itself and has to do something with jscodeshift.

Also using prettier after doing the codemod is probably recommended cause it did change some of the unrelated formatting ;D

And here's a git diff 🎉

$ git diff --stat
18 files changed, 183 insertions(+), 259 deletions(-)
jorisre commented 3 years ago

@KubaJastrz Thanks for your feedback !