@types/esquery

  • Version 1.0.1
  • Published
  • 7.06 kB
  • 1 dependency
  • MIT license

Install

npm i @types/esquery
yarn add @types/esquery
pnpm add @types/esquery

Overview

TypeScript definitions for esquery

Index

Functions

function match

match: (ast: any, selector: Selector) => Node[];
  • From a JS AST and a selector AST, collect all JS AST nodes that match the selector.

function matches

matches: (node: any, selector: Selector, ancestry: Node[]) => boolean;
  • Given a node and its ancestors, determine if node is matched by selector.

function parse

parse: (selector: string) => Selector;
  • Parse a selector and return its AST.

function query

query: (ast: any, selector: string) => Node[];
  • Query the code AST using the selector string.

Interfaces

interface Adjacent

interface Adjacent extends BinarySelectorAtom {}

    property type

    type: 'adjacent';

      interface Atom

      interface Atom {}

        property type

        type: string;

          interface Attribute

          interface Attribute extends SubjectSelectorAtom {}

            property name

            name: string;

              property operator

              operator?: '=' | '!=' | '>' | '<' | '>=' | '<=';

                property type

                type: 'attribute';

                  property value

                  value?: Literal | RegExpLiteral | Type;

                    interface BinarySelectorAtom

                    interface BinarySelectorAtom extends SubjectSelectorAtom {}

                      property left

                      left: SubjectSelector;

                        property right

                        right: SubjectSelector;

                          property type

                          type: 'child' | 'sibling' | 'adjacent' | 'descendant';

                            interface Child

                            interface Child extends BinarySelectorAtom {}

                              property type

                              type: 'child';

                                interface Class

                                interface Class extends Atom {}

                                  property name

                                  name: 'declaration' | 'expression' | 'function' | 'pattern' | 'statement';

                                    property type

                                    type: 'class';

                                      interface Descendant

                                      interface Descendant extends BinarySelectorAtom {}

                                        property type

                                        type: 'descendant';

                                          interface Field

                                          interface Field extends Atom {}

                                            property name

                                            name: string;

                                              property type

                                              type: 'field';

                                                interface Has

                                                interface Has extends MultiSelectorAtom {}

                                                  property type

                                                  type: 'has';

                                                    interface Identifier

                                                    interface Identifier extends SubjectSelectorAtom {}

                                                      property type

                                                      type: 'identifier';

                                                        property value

                                                        value: string;

                                                          interface LiteralAtom

                                                          interface LiteralAtom extends Atom {}

                                                            property type

                                                            type: 'literal';

                                                              property value

                                                              value: string | number;

                                                                interface Matches

                                                                interface Matches extends MultiSelectorAtom {}

                                                                  property type

                                                                  type: 'matches';

                                                                    interface MultiSelectorAtom

                                                                    interface MultiSelectorAtom extends SubjectSelectorAtom {}

                                                                      property selectors

                                                                      selectors: SubjectSelector[];

                                                                        interface Negation

                                                                        interface Negation extends MultiSelectorAtom {}

                                                                          property type

                                                                          type: 'not';

                                                                            interface NthChild

                                                                            interface NthChild extends NthSelectorAtom {}

                                                                              property type

                                                                              type: 'nth-child';

                                                                                interface NthLastChild

                                                                                interface NthLastChild extends NthSelectorAtom {}

                                                                                  property type

                                                                                  type: 'nth-last-child';

                                                                                    interface NthSelectorAtom

                                                                                    interface NthSelectorAtom extends SubjectSelectorAtom {}

                                                                                      property index

                                                                                      index: NumericLiteral;

                                                                                        interface NumericLiteral

                                                                                        interface NumericLiteral extends LiteralAtom {}

                                                                                          property value

                                                                                          value: number;

                                                                                            interface RegExpLiteral

                                                                                            interface RegExpLiteral extends Atom {}

                                                                                              property type

                                                                                              type: 'regexp';

                                                                                                property value

                                                                                                value: RegExp;

                                                                                                  interface Sequence

                                                                                                  interface Sequence extends MultiSelectorAtom {}

                                                                                                    property type

                                                                                                    type: 'compound';

                                                                                                      interface Sibling

                                                                                                      interface Sibling extends BinarySelectorAtom {}

                                                                                                        property type

                                                                                                        type: 'sibling';

                                                                                                          interface StringLiteral

                                                                                                          interface StringLiteral extends LiteralAtom {}

                                                                                                            property value

                                                                                                            value: string;

                                                                                                              interface SubjectSelectorAtom

                                                                                                              interface SubjectSelectorAtom extends Atom {}

                                                                                                                property subject

                                                                                                                subject?: boolean;

                                                                                                                  interface Type

                                                                                                                  interface Type extends Atom {}

                                                                                                                    property type

                                                                                                                    type: 'type';

                                                                                                                      property value

                                                                                                                      value: string;

                                                                                                                        interface Wildcard

                                                                                                                        interface Wildcard extends SubjectSelectorAtom {}

                                                                                                                          property type

                                                                                                                          type: 'wildcard';

                                                                                                                            property value

                                                                                                                            value: '*';

                                                                                                                              Type Aliases

                                                                                                                              type BinarySelector

                                                                                                                              type BinarySelector = Descendant | Child | Sibling | Adjacent;

                                                                                                                                type Literal

                                                                                                                                type Literal = StringLiteral | NumericLiteral;

                                                                                                                                  type MultiSelector

                                                                                                                                  type MultiSelector = Sequence | Negation | Matches | Has;

                                                                                                                                    type NthSelector

                                                                                                                                    type NthSelector = NthChild | NthLastChild;

                                                                                                                                      type Selector

                                                                                                                                      type Selector =
                                                                                                                                      | Field
                                                                                                                                      | Type
                                                                                                                                      | Sequence
                                                                                                                                      | Identifier
                                                                                                                                      | Wildcard
                                                                                                                                      | Attribute
                                                                                                                                      | NthChild
                                                                                                                                      | NthLastChild
                                                                                                                                      | Descendant
                                                                                                                                      | Child
                                                                                                                                      | Sibling
                                                                                                                                      | Adjacent
                                                                                                                                      | Negation
                                                                                                                                      | Matches
                                                                                                                                      | Has
                                                                                                                                      | Class;

                                                                                                                                        type SubjectSelector

                                                                                                                                        type SubjectSelector =
                                                                                                                                        | NthSelector
                                                                                                                                        | BinarySelector
                                                                                                                                        | MultiSelector
                                                                                                                                        | Identifier
                                                                                                                                        | Wildcard
                                                                                                                                        | Attribute;

                                                                                                                                          Package Files (1)

                                                                                                                                          Dependencies (1)

                                                                                                                                          Dev Dependencies (0)

                                                                                                                                          No dev dependencies.

                                                                                                                                          Peer Dependencies (0)

                                                                                                                                          No peer dependencies.

                                                                                                                                          Badge

                                                                                                                                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/esquery.

                                                                                                                                          • Markdown
                                                                                                                                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/esquery)
                                                                                                                                          • HTML
                                                                                                                                            <a href="https://www.jsdocs.io/package/@types/esquery"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>