@khanacademy/wb-codemod
v2.0.0
Published
This package is a wrapper around [jscodeshift](https://github.com/facebook/jscodeshift/) to make it easier to run Wonder Blocks codemods on the Khan Academy's codebase.
Downloads
776
Readme
@khanacademy/wb-codemod
This package is a wrapper around jscodeshift to make it easier to run Wonder Blocks codemods on the Khan Academy's codebase.
Usage
To run a codemod, you can use the wb-codemod
command line tool. For example:
npx @khanacademy/wb-codemod -t template path/to/files
This will run the template
codemod on the files in path/to/files
. This
template
codemod is a file in the transforms
directory of this package.
Writing a codemod
To write a codemod, you can create a new file in the transforms
directory of
this package. The file should export a function that takes a file
argument, an
api
argument, and an optional options argument.
You can take a look at the existing codemods in the transforms/template.ts
file for an example of how to write a codemod.
Unit testing
To write unit tests for your codemod, you can create a new file in the
transforms/__test__
directory of this package.
See https://github.com/facebook/jscodeshift?tab=readme-ov-file#unit-testing for more information on how to write unit tests for your codemod.