react-codemod icon indicating copy to clipboard operation
react-codemod copied to clipboard

Exposing utils / helpers in some way

Open cbranch101 opened this issue 3 years ago • 2 comments

We're considering creating our own React codemods, and it seems like a lot of the legwork you've done in this repo would be useful to build off of, would it be possible to bundle up and export the contents of the utils file and maybe a few other useful functions in an index file and add a main.js to the package.json?

cbranch101 avatar Jul 06 '21 17:07 cbranch101

Of course copypasta is an option, but it seems like it might be cool if there was a core api for creating react code mods

cbranch101 avatar Jul 06 '21 17:07 cbranch101

react-codemod is two things now:

  • A bunch of jscodeshift transforms
  • A CLI to run the transforms

The CLI has some nice features like checking git status, dry run, etc. which is relevant regardless of the transform. Letting the CLI be used with custom transforms allows others to leverage those features without redoing the same, in a custom CLI tool. This seems feasible with a minor change in react-codemod cli, to let transform be a name of a predefined transform (as is now), or path to a transform file.

npx react-codemod <transformNameOrPath> <path> [...options]

UPDATE: I see now that dry-run for example is supported by the original jscodeshift cli, so maybe one could use jscodeshift cli directly for custom transform, but still it might be relevant to have the CLI of react-codemod reusable for custom transforms.

alirezamirian avatar Aug 24 '22 11:08 alirezamirian