esquery (1.6.0)
Published 2026-02-24 13:56:21 +00:00 by atheaadmin
Installation
registry=npm install esquery@1.6.0"esquery": "1.6.0"About this package
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:
- AST node type:
ForStatement - wildcard:
* - attribute existence:
[attr] - attribute value:
[attr="foo"]or[attr=123] - attribute regex:
[attr=/foo.*/]or (with flags)[attr=/foo.*/is] - attribute conditions:
[attr!="foo"],[attr>2],[attr<3],[attr>=2], or[attr<=3] - nested attribute:
[attr.level2="foo"] - field:
FunctionDeclaration > Identifier.id - First or last child:
:first-childor:last-child - nth-child (no ax+b support):
:nth-child(2) - nth-last-child (no ax+b support):
:nth-last-child(1) - descendant:
ancestor descendant - child:
parent > child - following sibling:
node ~ sibling - adjacent sibling:
node + adjacent - negation:
:not(ForStatement) - has:
:has(ForStatement),:has(> ForStatement) - matches-any:
:matches([attr] > :first-child, :last-child) - subject indicator:
!IfStatement > [name="foo"] - class of AST node:
:statement,:expression,:declaration,:function, or:pattern
Dependencies
Dependencies
| ID | Version |
|---|---|
| estraverse | ^5.1.0 |
Development Dependencies
| ID | Version |
|---|---|
| @babel/core | ^7.9.0 |
| @babel/preset-env | ^7.9.5 |
| @babel/register | ^7.9.0 |
| @rollup/plugin-commonjs | ^11.1.0 |
| @rollup/plugin-json | ^4.0.2 |
| @rollup/plugin-node-resolve | ^7.1.3 |
| babel-plugin-transform-es2017-object-entries | 0.0.5 |
| chai | 4.2.0 |
| eslint | ^6.8.0 |
| esprima | ~4.0.1 |
| mocha | 7.1.1 |
| nyc | ^15.0.1 |
| pegjs | ~0.10.0 |
| rollup | ^1.32.1 |
| rollup-plugin-babel | ^4.4.0 |
| rollup-plugin-terser | ^5.3.0 |
Keywords
ast
ecmascript
javascript
query
