ESQuery is a library for querying the AST output by Esprima for patterns of syntax using a CSS style selector system. (Evacuated from Microsoft Github)
anonymous 27834d6169 typo | %!s(int64=5) %!d(string=hai) anos | |
---|---|---|
debian | %!s(int64=5) %!d(string=hai) anos | |
tests | %!s(int64=6) %!d(string=hai) anos | |
.gitignore | %!s(int64=11) %!d(string=hai) anos | |
.npmignore | %!s(int64=10) %!d(string=hai) anos | |
.travis.yml | %!s(int64=9) %!d(string=hai) anos | |
Makefile | %!s(int64=11) %!d(string=hai) anos | |
README.md | %!s(int64=10) %!d(string=hai) anos | |
esquery.js | %!s(int64=6) %!d(string=hai) anos | |
grammar.pegjs | %!s(int64=7) %!d(string=hai) anos | |
license.txt | %!s(int64=11) %!d(string=hai) anos | |
package.json | %!s(int64=6) %!d(string=hai) anos | |
parser.js | %!s(int64=7) %!d(string=hai) anos | |
testRunner.html | %!s(int64=11) %!d(string=hai) anos |
ESQuery is a library for querying the AST output by Esprima for patterns of syntax using a CSS style selector system. Check out the demo:
The following selectors are supported:
ForStatement
*
[attr]
[attr="foo"]
or [attr=123]
[attr=/foo.*/]
[attr!="foo"]
, [attr>2]
, [attr<3]
, [attr>=2]
, or [attr<=3]
[attr.level2="foo"]
FunctionDeclaration > Identifier.id
:first-child
or :last-child
:nth-child(2)
:nth-last-child(1)
ancestor descendant
parent > child
node ~ sibling
node + adjacent
:not(ForStatement)
:matches([attr] > :first-child, :last-child)
!IfStatement > [name="foo"]
:statement
, :expression
, :declaration
, :function
, or :pattern