3 ms·
It's more common than you think! Tools like https://github.com/facebook/jscodeshift https://github.com/facebook/jscodeshift, https://ts-morph.com/ https://ts-mo
by striking 2y ago
It's more common than you think! Tools like https://github.com/facebook/jscodeshift https://github.com/facebook/jscodeshift, https://ts-morph.com/ https://ts-morph.com/, and https://ast-grep.github.io/ https://ast-grep.github.io/ are the ones I'm more familiar with (since my day-to-day is TypeScript).
When I led the conversion of a decently-sized codebase from Flow-typed JS to TypeScript, I ensured that a code formatting tool that we were already using on pre-commit and CI called `prettier` was executed after each step. We took a git snapshot of each step of our automated conversion pipeline, and the diff was much clearer with `prettier` in place at each of those steps.
We've since used codemods frequently to make huge changes to the codebase in an automatic, reproducible, iterable way. They're very comfortable, very fun, and (thanks to the use of a formatter on all code) rarely produce incomprehensible diffs.