WARNING: Repository moved here https://github.com/rajasegar/ast-tooling/tree/master/packages/ast-node-finder
jscodeshift find api automatically generated from code
Checkout the api in this playground
Read the introductory blog post for more details.
import { findQuery } from 'ast-node-finder';
import { parse } from 'recast';
const source = `foo.bar.baz(1,2,3)`;
const ast = parse(source);
// Pass the node from ast and get the find api
console.log(findQuery(ast.program.body[0].expression));root.find(j.CallExpression, {
callee: {
object: { object: { name: 'foo' },
property: { name: 'bar' }
},
property: { name: 'baz' }
}
})
.forEach(path => {
// Manipulate the path (node) here
});