4 ms·
I find the idea of https://github.com/facebook/jscodeshift https://github.com/facebook/jscodeshift to be really useful. I've started writing small scripts usin
by stringham 9y ago
I find the idea of https://github.com/facebook/jscodeshift https://github.com/facebook/jscodeshift to be really useful.
I've started writing small scripts using the TypeScript parser as a library to make meaningful improvements in our codebase. Since JavaScript is valid TypeScript syntax the scripts work on both.
For example, I wrote a small script to change var to let or const when possible. It uses the AST to check scoping rules and to check if a variable is ever reassigned.
Writing scripts like this is way more effective than doing it by hand.