Codemods are programmatic transformations that are run on a codebase to make wide-sweeping changes. Rather than [[refactoring]] manually, a codemod can trawl through all files like a super-powered find and replace.
Uses [[20211130062748-ast]] under the hood to 'read' the code and act upon it. Popular examples include [[jscodeshift and ts-morph]].
Broadly, codemods:
Note that codemods should be idempotent. They're often re-run on the same area of code and need to support that. Often the reason is to support newer code that's added in a PR, or after resolving merge conflicts or similar.
[[codemods]] [[migrations]] [[refactoring]] [[staticcodeanalysis]]