I have a small helper file called prettiermod.js
which I use to run codemods. You need to copy'n'paste the prettiermod.js
file and install the dependencies ($ pnpm add globby@^11.0.0 @babel/traverse prettier
).
After this you can create new codemods which use prettiermod.js
. The following codemod adds a property with a default value to a specific component in case it is not there (flow="column"
will be added to the <Stack />
component).
Just call $ node run-codemod.js
to execute the codemod.
I use AST explorer for debugging (@babel/parser
with flow
disabled and typescript
enabled and babelv7
).