Closed ianjennings closed 4 years ago
const matcher = astMatcher('__any.method(__str_foo, [__arr_opts])')
https://github.com/dumberjs/ast-matcher
const isRequire = matches({ "type": "VariableDeclaration", "declarations": (decs) => decs.length === 1 && isRequireDeclarator(decs[0]), "kind": "var" });
http://nene.github.io/2016/04/02/matches-ast
{ FunctionExpression(path: NodePath<t.FunctionExpression>): void { const argumentNameMatcher = m.capture(m.anyString()) const matcher = m.functionExpression( m.anything(), [m.identifier(argumentNameMatcher)], m.blockStatement([ m.returnStatement(m.fromCapture(m.identifier(argumentNameMatcher))), ]) ) if (matcher.match(path.node)) { path.replaceWith(t.identifier('IDENTITY')) } }, };
https://github.com/codemod-js/codemod/blob/master/packages/matchers/README.md
https://blog.scottlogic.com/2016/06/22/xslt-inspired-ast-transforms.html
Kamino closed and cloned this issue to MLH-Fellowship/babel-sandbox
Writing a Plugin
Matcher?
https://github.com/dumberjs/ast-matcher
http://nene.github.io/2016/04/02/matches-ast
https://github.com/codemod-js/codemod/blob/master/packages/matchers/README.md
https://blog.scottlogic.com/2016/06/22/xslt-inspired-ast-transforms.html