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:

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-child or :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

Build Status

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
Details
npm
2026-02-24 13:56:21 +00:00
1
Joel Feenstra
BSD-3-Clause
latest
158 KiB
Assets (1)
Versions (1) View all
1.6.0 2026-02-24