ast-node-finder
v5.1.0
Published
JSCodeshift find api automatically generated from code
Downloads
18
Maintainers
Readme
ast-node-finder
jscodeshift find api automatically generated from code
Checkout the api in this playground
Read the introductory blog post for more details.
Usage
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));
Output
root.find(j.CallExpression, {
callee: {
object: { object: { name: 'foo' },
property: { name: 'bar' }
},
property: { name: 'baz' }
}
})
.forEach(path => {
// Manipulate the path (node) here
});