-
AST is a concept to transform source code into data structures that are easy to work with for various static analysis tools, e.g. ESLint's espree
-
Parsers transform code into Syntax Trees, they might diffefrom one another due to different implementation goals
-
Visitor pattern allows you to traverse the tree and perform some action on each node, e.g.
// ESLint example function create(context) { return { // This executes for every node with if statement IfStatement(node) { if (node.consequent.type !== "BlockStatement") { context.report({ node, message: "Use blocks with if statements", }); } }, }; }