//TODO Write linting rules to enforce your team’s code conventions ESLint ESTreebased AST Write your own javascript transpiling code Write powerful “code-mods” to automatically refactor thousands of legacy scripts from ES5 to ES6 + Visitor Pattern jscodeshift

Webpack Babel Uglifyjs Rollup ESLint Istanbul Ternjs jscodeshift

Abstract Syntax Tree cb http://flic.kr/p/gC4EkS

var foo = 'bar'; Program Body Variable Declaration Kind Declarations Variable Declarator Id Init Identifier Literal

var foo = 'bar'; { "type": "Program", "body": [ { "type": "VariableDeclaration", "declarations": [ { "type": "VariableDeclarator", "id": { "type": "Identifier", "name": "foo" }, "init": { "type": "Literal", "value": "bar" } } ], "kind": "var" } ] }

I/ { O{ Parse Traverse Manipulate Generate code cbd http://flic.kr/p/3xNFue

I/ { O{ Parse cbd http://flic.kr/p/3xNFue

astexplorer.net

I/ { Traverse O{ cbd http://flic.kr/p/3xNFue

ESLint

piggy·back (verb)

piggy·back (verb)

piggy·back (verb)

piggy·back (verb) window.Acme Acme window

This code is a simplified version of the eslint-plugin-piggyback plugin: https://github.com/cowchimp/eslint-plugin-piggyback

cb http://flic.kr/p/s8G9qy

I/ { Manipulate O{ cbd http://flic.kr/p/3xNFue

I/ { O { Generate code cbd http://flic.kr/p/3xNFue

jscodeshift

github.com/cowchimp/awesome-ast @cowchimp blog.cowchimp.com