I have a CallExpression like
myFunc(param1, param2, insert_here_param_3);
how to insert a param like that at the last place in of a function?
Since jscodeshift is undocumented I cannot really give an example other than the starting one.
export default function transformer(file, api) {
const j = api.jscodeshift;
return j(file.source)
.find(j.Identifier)
.forEach(path => {
if(path.node.name === "myFunc") {
// j(path). ???
}
})
.toSource();
}
There are different ways you can do this. First you can replace the entire CallExpression with a new one like this:
Or you can simply add a new parameter like this: