1.0.1 • Published 1 year ago
@cambly/syntax-codemods v1.0.1
Syntax Codemods
Codemods (short for "code modifications") are tools that assist in large-scale, partially automated codebase refactors. They are especially useful for migrating codebases between different versions of a library, or migrating codebases to a different library entirely.
Example
Let's say you want to convert all instances of the color prop on <Box /> to backgroundColor:
You could write a codemod that does the following:
- Find all instances of
<Box color="red" /> - Replace them with
<Box backgroundColor="red" />
Before
import { Box } from "@cambly/syntax-ui";
<Box color="red" />;After
import { Box } from "@cambly/syntax-ui";
<Box backgroundColor="red" />;Usage
Installation
npm install --save-dev @cambly/syntax-codemodsRunning a codemod
npx @cambly/syntax-codemods -c={codemod id} -p=relative/path/to/code/to/modify