Skip to content

Instantly share code, notes, and snippets.

@perjansson
Last active December 1, 2017 08:39
Show Gist options
  • Save perjansson/553cb4b28af60955909915ceefc86ceb to your computer and use it in GitHub Desktop.
Save perjansson/553cb4b28af60955909915ceefc86ceb to your computer and use it in GitHub Desktop.
const transformer = (file, api) => {
/* get the jscodeshift helper */
const j = api.jscodeshift;
/* create a js object representation of your source code */
const root = j(file.source);
return root
.find(/* grab the code you want to update */)
.forEach(/* do something to it */)
.toSource(/* return the newly printed code */);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment