Skip to content

Instantly share code, notes, and snippets.

@rajasegar
Last active December 20, 2019 09:06
Show Gist options
  • Save rajasegar/1901843ef265595d1e398897cdf3175d to your computer and use it in GitHub Desktop.
Save rajasegar/1901843ef265595d1e398897cdf3175d to your computer and use it in GitHub Desktop.
JARVIS codemod gist
{
"lang": "Javascript",
"parser": "recast",
"version": "1.0",
"nodeOp": "replace"
}
module.exports = function transformer(file, api) {
const j = api.jscodeshift;
const root = j(file.source);
const body = root.get().value.program.body;
let helloWorld = "HELLO WORLD GIST TRANSFORM";
root.find(j.CallExpression, {
callee: {
name: "foo"
}
}).replaceWith(path => {
return j.callExpression(j.memberExpression(j.identifier("foo"), j.identifier("bar"), false), []);
});
return root.toSource();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment