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 an import in case we find a specific component (add import { SuspenseLoader } from 'src/components/spinner-container';
in case <SuspenseLoader/>
can be found).
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
).