[d565449] | 1 | // Generated by dts-bundle v0.7.3
|
---|
| 2 |
|
---|
| 3 | declare module "@eslint-community/regexpp" {
|
---|
| 4 | import * as AST from "@eslint-community/regexpp/ast";
|
---|
| 5 | import { RegExpParser } from "@eslint-community/regexpp/parser";
|
---|
| 6 | import { RegExpValidator } from "@eslint-community/regexpp/validator";
|
---|
| 7 | import { RegExpVisitor } from "@eslint-community/regexpp/visitor";
|
---|
| 8 | export { RegExpSyntaxError } from "@eslint-community/regexpp/regexp-syntax-error";
|
---|
| 9 | export { AST, RegExpParser, RegExpValidator };
|
---|
| 10 | /**
|
---|
| 11 | * Parse a given regular expression literal then make AST object.
|
---|
| 12 | * @param source The source code to parse.
|
---|
| 13 | * @param options The options to parse.
|
---|
| 14 | * @returns The AST of the regular expression.
|
---|
| 15 | */
|
---|
| 16 | export function parseRegExpLiteral(
|
---|
| 17 | source: RegExp | string,
|
---|
| 18 | options?: RegExpParser.Options
|
---|
| 19 | ): AST.RegExpLiteral;
|
---|
| 20 | /**
|
---|
| 21 | * Validate a given regular expression literal.
|
---|
| 22 | * @param source The source code to validate.
|
---|
| 23 | * @param options The options to validate.
|
---|
| 24 | */
|
---|
| 25 | export function validateRegExpLiteral(
|
---|
| 26 | source: string,
|
---|
| 27 | options?: RegExpValidator.Options
|
---|
| 28 | ): void;
|
---|
| 29 | export function visitRegExpAST(
|
---|
| 30 | node: AST.Node,
|
---|
| 31 | handlers: RegExpVisitor.Handlers
|
---|
| 32 | ): void;
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | declare module "@eslint-community/regexpp/ast" {
|
---|
| 36 | /**
|
---|
| 37 | * The type which includes all nodes.
|
---|
| 38 | */
|
---|
| 39 | export type Node = BranchNode | LeafNode;
|
---|
| 40 | /**
|
---|
| 41 | * The type which includes all branch nodes.
|
---|
| 42 | */
|
---|
| 43 | export type BranchNode =
|
---|
| 44 | | Alternative
|
---|
| 45 | | CapturingGroup
|
---|
| 46 | | CharacterClass
|
---|
| 47 | | CharacterClassRange
|
---|
| 48 | | ClassIntersection
|
---|
| 49 | | ClassStringDisjunction
|
---|
| 50 | | ClassSubtraction
|
---|
| 51 | | ExpressionCharacterClass
|
---|
| 52 | | Group
|
---|
| 53 | | LookaroundAssertion
|
---|
| 54 | | Pattern
|
---|
| 55 | | Quantifier
|
---|
| 56 | | RegExpLiteral
|
---|
| 57 | | StringAlternative;
|
---|
| 58 | /**
|
---|
| 59 | * The type which includes all leaf nodes.
|
---|
| 60 | */
|
---|
| 61 | export type LeafNode =
|
---|
| 62 | | Backreference
|
---|
| 63 | | BoundaryAssertion
|
---|
| 64 | | Character
|
---|
| 65 | | CharacterSet
|
---|
| 66 | | Flags;
|
---|
| 67 | /**
|
---|
| 68 | * The type which includes all atom nodes.
|
---|
| 69 | */
|
---|
| 70 | export type Element = Assertion | QuantifiableElement | Quantifier;
|
---|
| 71 | /**
|
---|
| 72 | * The type which includes all atom nodes that Quantifier node can have as children.
|
---|
| 73 | */
|
---|
| 74 | export type QuantifiableElement =
|
---|
| 75 | | Backreference
|
---|
| 76 | | CapturingGroup
|
---|
| 77 | | Character
|
---|
| 78 | | CharacterClass
|
---|
| 79 | | CharacterSet
|
---|
| 80 | | ExpressionCharacterClass
|
---|
| 81 | | Group
|
---|
| 82 | | LookaheadAssertion;
|
---|
| 83 | /**
|
---|
| 84 | * The type which includes all character class atom nodes.
|
---|
| 85 | */
|
---|
| 86 | export type CharacterClassElement =
|
---|
| 87 | | ClassRangesCharacterClassElement
|
---|
| 88 | | UnicodeSetsCharacterClassElement;
|
---|
| 89 | export type ClassRangesCharacterClassElement =
|
---|
| 90 | | Character
|
---|
| 91 | | CharacterClassRange
|
---|
| 92 | | CharacterUnicodePropertyCharacterSet
|
---|
| 93 | | EscapeCharacterSet;
|
---|
| 94 | export type UnicodeSetsCharacterClassElement =
|
---|
| 95 | | Character
|
---|
| 96 | | CharacterClassRange
|
---|
| 97 | | ClassStringDisjunction
|
---|
| 98 | | EscapeCharacterSet
|
---|
| 99 | | ExpressionCharacterClass
|
---|
| 100 | | UnicodePropertyCharacterSet
|
---|
| 101 | | UnicodeSetsCharacterClass;
|
---|
| 102 | /**
|
---|
| 103 | * The type which defines common properties for all node types.
|
---|
| 104 | */
|
---|
| 105 | export interface NodeBase {
|
---|
| 106 | /** The node type. */
|
---|
| 107 | type: Node["type"];
|
---|
| 108 | /** The parent node. */
|
---|
| 109 | parent: Node["parent"];
|
---|
| 110 | /** The 0-based index that this node starts. */
|
---|
| 111 | start: number;
|
---|
| 112 | /** The 0-based index that this node ends. */
|
---|
| 113 | end: number;
|
---|
| 114 | /** The raw text of this node. */
|
---|
| 115 | raw: string;
|
---|
| 116 | }
|
---|
| 117 | /**
|
---|
| 118 | * The root node.
|
---|
| 119 | */
|
---|
| 120 | export interface RegExpLiteral extends NodeBase {
|
---|
| 121 | type: "RegExpLiteral";
|
---|
| 122 | parent: null;
|
---|
| 123 | pattern: Pattern;
|
---|
| 124 | flags: Flags;
|
---|
| 125 | }
|
---|
| 126 | /**
|
---|
| 127 | * The pattern.
|
---|
| 128 | */
|
---|
| 129 | export interface Pattern extends NodeBase {
|
---|
| 130 | type: "Pattern";
|
---|
| 131 | parent: RegExpLiteral | null;
|
---|
| 132 | alternatives: Alternative[];
|
---|
| 133 | }
|
---|
| 134 | /**
|
---|
| 135 | * The alternative.
|
---|
| 136 | * E.g. `a|b`
|
---|
| 137 | */
|
---|
| 138 | export interface Alternative extends NodeBase {
|
---|
| 139 | type: "Alternative";
|
---|
| 140 | parent: CapturingGroup | Group | LookaroundAssertion | Pattern;
|
---|
| 141 | elements: Element[];
|
---|
| 142 | }
|
---|
| 143 | /**
|
---|
| 144 | * The uncapturing group.
|
---|
| 145 | * E.g. `(?:ab)`
|
---|
| 146 | */
|
---|
| 147 | export interface Group extends NodeBase {
|
---|
| 148 | type: "Group";
|
---|
| 149 | parent: Alternative | Quantifier;
|
---|
| 150 | alternatives: Alternative[];
|
---|
| 151 | }
|
---|
| 152 | /**
|
---|
| 153 | * The capturing group.
|
---|
| 154 | * E.g. `(ab)`, `(?<name>ab)`
|
---|
| 155 | */
|
---|
| 156 | export interface CapturingGroup extends NodeBase {
|
---|
| 157 | type: "CapturingGroup";
|
---|
| 158 | parent: Alternative | Quantifier;
|
---|
| 159 | name: string | null;
|
---|
| 160 | alternatives: Alternative[];
|
---|
| 161 | references: Backreference[];
|
---|
| 162 | }
|
---|
| 163 | /**
|
---|
| 164 | * The lookaround assertion.
|
---|
| 165 | */
|
---|
| 166 | export type LookaroundAssertion = LookaheadAssertion | LookbehindAssertion;
|
---|
| 167 | /**
|
---|
| 168 | * The lookahead assertion.
|
---|
| 169 | * E.g. `(?=ab)`, `(?!ab)`
|
---|
| 170 | */
|
---|
| 171 | export interface LookaheadAssertion extends NodeBase {
|
---|
| 172 | type: "Assertion";
|
---|
| 173 | parent: Alternative | Quantifier;
|
---|
| 174 | kind: "lookahead";
|
---|
| 175 | negate: boolean;
|
---|
| 176 | alternatives: Alternative[];
|
---|
| 177 | }
|
---|
| 178 | /**
|
---|
| 179 | * The lookbehind assertion.
|
---|
| 180 | * E.g. `(?<=ab)`, `(?<!ab)`
|
---|
| 181 | */
|
---|
| 182 | export interface LookbehindAssertion extends NodeBase {
|
---|
| 183 | type: "Assertion";
|
---|
| 184 | parent: Alternative;
|
---|
| 185 | kind: "lookbehind";
|
---|
| 186 | negate: boolean;
|
---|
| 187 | alternatives: Alternative[];
|
---|
| 188 | }
|
---|
| 189 | /**
|
---|
| 190 | * The quantifier.
|
---|
| 191 | * E.g. `a?`, `a*`, `a+`, `a{1,2}`, `a??`, `a*?`, `a+?`, `a{1,2}?`
|
---|
| 192 | */
|
---|
| 193 | export interface Quantifier extends NodeBase {
|
---|
| 194 | type: "Quantifier";
|
---|
| 195 | parent: Alternative;
|
---|
| 196 | min: number;
|
---|
| 197 | max: number;
|
---|
| 198 | greedy: boolean;
|
---|
| 199 | element: QuantifiableElement;
|
---|
| 200 | }
|
---|
| 201 | /**
|
---|
| 202 | * The character class.
|
---|
| 203 | * E.g. `[ab]`, `[^ab]`
|
---|
| 204 | */
|
---|
| 205 | export type CharacterClass =
|
---|
| 206 | | ClassRangesCharacterClass
|
---|
| 207 | | UnicodeSetsCharacterClass;
|
---|
| 208 | interface BaseCharacterClass extends NodeBase {
|
---|
| 209 | type: "CharacterClass";
|
---|
| 210 | parent:
|
---|
| 211 | | Alternative
|
---|
| 212 | | ClassIntersection
|
---|
| 213 | | ClassSubtraction
|
---|
| 214 | | Quantifier
|
---|
| 215 | | UnicodeSetsCharacterClass;
|
---|
| 216 | unicodeSets: boolean;
|
---|
| 217 | negate: boolean;
|
---|
| 218 | elements: CharacterClassElement[];
|
---|
| 219 | }
|
---|
| 220 | /**
|
---|
| 221 | * The character class used in legacy (neither `u` nor `v` flag) and Unicode mode (`u` flag).
|
---|
| 222 | *
|
---|
| 223 | * This character class is guaranteed to **not** contain strings.
|
---|
| 224 | *
|
---|
| 225 | * In Unicode sets mode (`v` flag), {@link UnicodeSetsCharacterClass} is used.
|
---|
| 226 | */
|
---|
| 227 | export interface ClassRangesCharacterClass extends BaseCharacterClass {
|
---|
| 228 | parent: Alternative | Quantifier;
|
---|
| 229 | unicodeSets: false;
|
---|
| 230 | elements: ClassRangesCharacterClassElement[];
|
---|
| 231 | }
|
---|
| 232 | /**
|
---|
| 233 | * The character class used in Unicode sets mode (`v` flag).
|
---|
| 234 | *
|
---|
| 235 | * This character class may contain strings.
|
---|
| 236 | */
|
---|
| 237 | export interface UnicodeSetsCharacterClass extends BaseCharacterClass {
|
---|
| 238 | parent:
|
---|
| 239 | | Alternative
|
---|
| 240 | | ClassIntersection
|
---|
| 241 | | ClassSubtraction
|
---|
| 242 | | Quantifier
|
---|
| 243 | | UnicodeSetsCharacterClass;
|
---|
| 244 | unicodeSets: true;
|
---|
| 245 | elements: UnicodeSetsCharacterClassElement[];
|
---|
| 246 | }
|
---|
| 247 | /**
|
---|
| 248 | * The character class.
|
---|
| 249 | * E.g. `[a-b]`
|
---|
| 250 | */
|
---|
| 251 | export interface CharacterClassRange extends NodeBase {
|
---|
| 252 | type: "CharacterClassRange";
|
---|
| 253 | parent: CharacterClass;
|
---|
| 254 | min: Character;
|
---|
| 255 | max: Character;
|
---|
| 256 | }
|
---|
| 257 | /**
|
---|
| 258 | * The assertion.
|
---|
| 259 | */
|
---|
| 260 | export type Assertion = BoundaryAssertion | LookaroundAssertion;
|
---|
| 261 | /**
|
---|
| 262 | * The boundary assertion.
|
---|
| 263 | */
|
---|
| 264 | export type BoundaryAssertion = EdgeAssertion | WordBoundaryAssertion;
|
---|
| 265 | /**
|
---|
| 266 | * The edge boundary assertion.
|
---|
| 267 | * E.g. `^`, `$`
|
---|
| 268 | */
|
---|
| 269 | export interface EdgeAssertion extends NodeBase {
|
---|
| 270 | type: "Assertion";
|
---|
| 271 | parent: Alternative | Quantifier;
|
---|
| 272 | kind: "end" | "start";
|
---|
| 273 | }
|
---|
| 274 | /**
|
---|
| 275 | * The word bondary assertion.
|
---|
| 276 | * E.g. `\b`, `\B`
|
---|
| 277 | */
|
---|
| 278 | export interface WordBoundaryAssertion extends NodeBase {
|
---|
| 279 | type: "Assertion";
|
---|
| 280 | parent: Alternative | Quantifier;
|
---|
| 281 | kind: "word";
|
---|
| 282 | negate: boolean;
|
---|
| 283 | }
|
---|
| 284 | /**
|
---|
| 285 | * The character set.
|
---|
| 286 | */
|
---|
| 287 | export type CharacterSet =
|
---|
| 288 | | AnyCharacterSet
|
---|
| 289 | | EscapeCharacterSet
|
---|
| 290 | | UnicodePropertyCharacterSet;
|
---|
| 291 | /**
|
---|
| 292 | * The dot.
|
---|
| 293 | * E.g. `.`
|
---|
| 294 | */
|
---|
| 295 | export interface AnyCharacterSet extends NodeBase {
|
---|
| 296 | type: "CharacterSet";
|
---|
| 297 | parent: Alternative | Quantifier;
|
---|
| 298 | kind: "any";
|
---|
| 299 | }
|
---|
| 300 | /**
|
---|
| 301 | * The character class escape.
|
---|
| 302 | * E.g. `\d`, `\s`, `\w`, `\D`, `\S`, `\W`
|
---|
| 303 | */
|
---|
| 304 | export interface EscapeCharacterSet extends NodeBase {
|
---|
| 305 | type: "CharacterSet";
|
---|
| 306 | parent:
|
---|
| 307 | | Alternative
|
---|
| 308 | | CharacterClass
|
---|
| 309 | | ClassIntersection
|
---|
| 310 | | ClassSubtraction
|
---|
| 311 | | Quantifier;
|
---|
| 312 | kind: "digit" | "space" | "word";
|
---|
| 313 | negate: boolean;
|
---|
| 314 | }
|
---|
| 315 | /**
|
---|
| 316 | * The unicode property escape.
|
---|
| 317 | * E.g. `\p{ASCII}`, `\P{ASCII}`, `\p{Script=Hiragana}`
|
---|
| 318 | */
|
---|
| 319 | export type UnicodePropertyCharacterSet =
|
---|
| 320 | | CharacterUnicodePropertyCharacterSet
|
---|
| 321 | | StringsUnicodePropertyCharacterSet;
|
---|
| 322 | interface BaseUnicodePropertyCharacterSet extends NodeBase {
|
---|
| 323 | type: "CharacterSet";
|
---|
| 324 | parent:
|
---|
| 325 | | Alternative
|
---|
| 326 | | CharacterClass
|
---|
| 327 | | ClassIntersection
|
---|
| 328 | | ClassSubtraction
|
---|
| 329 | | Quantifier;
|
---|
| 330 | kind: "property";
|
---|
| 331 | strings: boolean;
|
---|
| 332 | key: string;
|
---|
| 333 | value: string | null;
|
---|
| 334 | negate: boolean;
|
---|
| 335 | }
|
---|
| 336 | export interface CharacterUnicodePropertyCharacterSet
|
---|
| 337 | extends BaseUnicodePropertyCharacterSet {
|
---|
| 338 | strings: false;
|
---|
| 339 | value: string | null;
|
---|
| 340 | negate: boolean;
|
---|
| 341 | }
|
---|
| 342 | /** StringsUnicodePropertyCharacterSet is Unicode property escape with property of strings. */
|
---|
| 343 | export interface StringsUnicodePropertyCharacterSet
|
---|
| 344 | extends BaseUnicodePropertyCharacterSet {
|
---|
| 345 | parent:
|
---|
| 346 | | Alternative
|
---|
| 347 | | ClassIntersection
|
---|
| 348 | | ClassSubtraction
|
---|
| 349 | | Quantifier
|
---|
| 350 | | UnicodeSetsCharacterClass;
|
---|
| 351 | strings: true;
|
---|
| 352 | value: null;
|
---|
| 353 | negate: false;
|
---|
| 354 | }
|
---|
| 355 | /**
|
---|
| 356 | * The expression character class.
|
---|
| 357 | * E.g. `[a--b]`, `[a&&b]`,`[^a--b]`, `[^a&&b]`
|
---|
| 358 | */
|
---|
| 359 | export interface ExpressionCharacterClass extends NodeBase {
|
---|
| 360 | type: "ExpressionCharacterClass";
|
---|
| 361 | parent:
|
---|
| 362 | | Alternative
|
---|
| 363 | | ClassIntersection
|
---|
| 364 | | ClassSubtraction
|
---|
| 365 | | Quantifier
|
---|
| 366 | | UnicodeSetsCharacterClass;
|
---|
| 367 | negate: boolean;
|
---|
| 368 | expression: ClassIntersection | ClassSubtraction;
|
---|
| 369 | }
|
---|
| 370 | export type ClassSetOperand =
|
---|
| 371 | | Character
|
---|
| 372 | | ClassStringDisjunction
|
---|
| 373 | | EscapeCharacterSet
|
---|
| 374 | | ExpressionCharacterClass
|
---|
| 375 | | UnicodePropertyCharacterSet
|
---|
| 376 | | UnicodeSetsCharacterClass;
|
---|
| 377 | /**
|
---|
| 378 | * The character class intersection.
|
---|
| 379 | * E.g. `a&&b`
|
---|
| 380 | */
|
---|
| 381 | export interface ClassIntersection extends NodeBase {
|
---|
| 382 | type: "ClassIntersection";
|
---|
| 383 | parent: ClassIntersection | ExpressionCharacterClass;
|
---|
| 384 | left: ClassIntersection | ClassSetOperand;
|
---|
| 385 | right: ClassSetOperand;
|
---|
| 386 | }
|
---|
| 387 | /**
|
---|
| 388 | * The character class subtraction.
|
---|
| 389 | * E.g. `a--b`
|
---|
| 390 | */
|
---|
| 391 | export interface ClassSubtraction extends NodeBase {
|
---|
| 392 | type: "ClassSubtraction";
|
---|
| 393 | parent: ClassSubtraction | ExpressionCharacterClass;
|
---|
| 394 | left: ClassSetOperand | ClassSubtraction;
|
---|
| 395 | right: ClassSetOperand;
|
---|
| 396 | }
|
---|
| 397 | /**
|
---|
| 398 | * The character class string disjunction.
|
---|
| 399 | * E.g. `\q{a|b}`
|
---|
| 400 | */
|
---|
| 401 | export interface ClassStringDisjunction extends NodeBase {
|
---|
| 402 | type: "ClassStringDisjunction";
|
---|
| 403 | parent: ClassIntersection | ClassSubtraction | UnicodeSetsCharacterClass;
|
---|
| 404 | alternatives: StringAlternative[];
|
---|
| 405 | }
|
---|
| 406 | /** StringAlternative is only used for `\q{alt}`({@link ClassStringDisjunction}). */
|
---|
| 407 | export interface StringAlternative extends NodeBase {
|
---|
| 408 | type: "StringAlternative";
|
---|
| 409 | parent: ClassStringDisjunction;
|
---|
| 410 | elements: Character[];
|
---|
| 411 | }
|
---|
| 412 | /**
|
---|
| 413 | * The character.
|
---|
| 414 | * This includes escape sequences which mean a character.
|
---|
| 415 | * E.g. `a`, `あ`, `✿`, `\x65`, `\u0065`, `\u{65}`, `\/`
|
---|
| 416 | */
|
---|
| 417 | export interface Character extends NodeBase {
|
---|
| 418 | type: "Character";
|
---|
| 419 | parent:
|
---|
| 420 | | Alternative
|
---|
| 421 | | CharacterClass
|
---|
| 422 | | CharacterClassRange
|
---|
| 423 | | ClassIntersection
|
---|
| 424 | | ClassSubtraction
|
---|
| 425 | | Quantifier
|
---|
| 426 | | StringAlternative;
|
---|
| 427 | value: number;
|
---|
| 428 | }
|
---|
| 429 | /**
|
---|
| 430 | * The backreference.
|
---|
| 431 | * E.g. `\1`, `\k<name>`
|
---|
| 432 | */
|
---|
| 433 | export type Backreference = AmbiguousBackreference | UnambiguousBackreference;
|
---|
| 434 | interface BaseBackreference extends NodeBase {
|
---|
| 435 | type: "Backreference";
|
---|
| 436 | parent: Alternative | Quantifier;
|
---|
| 437 | ref: number | string;
|
---|
| 438 | ambiguous: boolean;
|
---|
| 439 | resolved: CapturingGroup | CapturingGroup[];
|
---|
| 440 | }
|
---|
| 441 | export interface AmbiguousBackreference extends BaseBackreference {
|
---|
| 442 | ref: string;
|
---|
| 443 | ambiguous: true;
|
---|
| 444 | resolved: CapturingGroup[];
|
---|
| 445 | }
|
---|
| 446 | export interface UnambiguousBackreference extends BaseBackreference {
|
---|
| 447 | ambiguous: false;
|
---|
| 448 | resolved: CapturingGroup;
|
---|
| 449 | }
|
---|
| 450 | /**
|
---|
| 451 | * The flags.
|
---|
| 452 | */
|
---|
| 453 | export interface Flags extends NodeBase {
|
---|
| 454 | type: "Flags";
|
---|
| 455 | parent: RegExpLiteral | null;
|
---|
| 456 | dotAll: boolean;
|
---|
| 457 | global: boolean;
|
---|
| 458 | hasIndices: boolean;
|
---|
| 459 | ignoreCase: boolean;
|
---|
| 460 | multiline: boolean;
|
---|
| 461 | sticky: boolean;
|
---|
| 462 | unicode: boolean;
|
---|
| 463 | unicodeSets: boolean;
|
---|
| 464 | }
|
---|
| 465 | export {};
|
---|
| 466 | }
|
---|
| 467 |
|
---|
| 468 | declare module "@eslint-community/regexpp/parser" {
|
---|
| 469 | import type {
|
---|
| 470 | Flags,
|
---|
| 471 | RegExpLiteral,
|
---|
| 472 | Pattern,
|
---|
| 473 | } from "@eslint-community/regexpp/ast";
|
---|
| 474 | import type { EcmaVersion } from "@eslint-community/regexpp/ecma-versions";
|
---|
| 475 | export namespace RegExpParser {
|
---|
| 476 | /**
|
---|
| 477 | * The options for RegExpParser construction.
|
---|
| 478 | */
|
---|
| 479 | interface Options {
|
---|
| 480 | /**
|
---|
| 481 | * The flag to disable Annex B syntax. Default is `false`.
|
---|
| 482 | */
|
---|
| 483 | strict?: boolean;
|
---|
| 484 | /**
|
---|
| 485 | * ECMAScript version. Default is `2025`.
|
---|
| 486 | * - `2015` added `u` and `y` flags.
|
---|
| 487 | * - `2018` added `s` flag, Named Capturing Group, Lookbehind Assertion,
|
---|
| 488 | * and Unicode Property Escape.
|
---|
| 489 | * - `2019`, `2020`, and `2021` added more valid Unicode Property Escapes.
|
---|
| 490 | * - `2022` added `d` flag.
|
---|
| 491 | * - `2023` added more valid Unicode Property Escapes.
|
---|
| 492 | * - `2024` added `v` flag.
|
---|
| 493 | * - `2025` added duplicate named capturing groups.
|
---|
| 494 | */
|
---|
| 495 | ecmaVersion?: EcmaVersion;
|
---|
| 496 | }
|
---|
| 497 | }
|
---|
| 498 | export class RegExpParser {
|
---|
| 499 | /**
|
---|
| 500 | * Initialize this parser.
|
---|
| 501 | * @param options The options of parser.
|
---|
| 502 | */
|
---|
| 503 | constructor(options?: RegExpParser.Options);
|
---|
| 504 | /**
|
---|
| 505 | * Parse a regular expression literal. E.g. "/abc/g"
|
---|
| 506 | * @param source The source code to parse.
|
---|
| 507 | * @param start The start index in the source code.
|
---|
| 508 | * @param end The end index in the source code.
|
---|
| 509 | * @returns The AST of the given regular expression.
|
---|
| 510 | */
|
---|
| 511 | parseLiteral(source: string, start?: number, end?: number): RegExpLiteral;
|
---|
| 512 | /**
|
---|
| 513 | * Parse a regular expression flags. E.g. "gim"
|
---|
| 514 | * @param source The source code to parse.
|
---|
| 515 | * @param start The start index in the source code.
|
---|
| 516 | * @param end The end index in the source code.
|
---|
| 517 | * @returns The AST of the given flags.
|
---|
| 518 | */
|
---|
| 519 | parseFlags(source: string, start?: number, end?: number): Flags;
|
---|
| 520 | /**
|
---|
| 521 | * Parse a regular expression pattern. E.g. "abc"
|
---|
| 522 | * @param source The source code to parse.
|
---|
| 523 | * @param start The start index in the source code.
|
---|
| 524 | * @param end The end index in the source code.
|
---|
| 525 | * @param flags The flags.
|
---|
| 526 | * @returns The AST of the given pattern.
|
---|
| 527 | */
|
---|
| 528 | parsePattern(
|
---|
| 529 | source: string,
|
---|
| 530 | start?: number,
|
---|
| 531 | end?: number,
|
---|
| 532 | flags?: {
|
---|
| 533 | unicode?: boolean;
|
---|
| 534 | unicodeSets?: boolean;
|
---|
| 535 | }
|
---|
| 536 | ): Pattern;
|
---|
| 537 | /**
|
---|
| 538 | * @deprecated Backward compatibility
|
---|
| 539 | * Use object `flags` instead of boolean `uFlag`.
|
---|
| 540 | *
|
---|
| 541 | * @param source The source code to parse.
|
---|
| 542 | * @param start The start index in the source code.
|
---|
| 543 | * @param end The end index in the source code.
|
---|
| 544 | * @param uFlag The flag to set unicode mode.
|
---|
| 545 | * @returns The AST of the given pattern.
|
---|
| 546 | */
|
---|
| 547 | parsePattern(
|
---|
| 548 | source: string,
|
---|
| 549 | start?: number,
|
---|
| 550 | end?: number,
|
---|
| 551 | uFlag?: boolean
|
---|
| 552 | ): Pattern;
|
---|
| 553 | }
|
---|
| 554 | }
|
---|
| 555 |
|
---|
| 556 | declare module "@eslint-community/regexpp/validator" {
|
---|
| 557 | import type { EcmaVersion } from "@eslint-community/regexpp/ecma-versions";
|
---|
| 558 | export type RegExpValidatorSourceContext = {
|
---|
| 559 | readonly source: string;
|
---|
| 560 | readonly start: number;
|
---|
| 561 | readonly end: number;
|
---|
| 562 | readonly kind: "flags" | "literal" | "pattern";
|
---|
| 563 | };
|
---|
| 564 | export namespace RegExpValidator {
|
---|
| 565 | /**
|
---|
| 566 | * The options for RegExpValidator construction.
|
---|
| 567 | */
|
---|
| 568 | interface Options {
|
---|
| 569 | /**
|
---|
| 570 | * The flag to disable Annex B syntax. Default is `false`.
|
---|
| 571 | */
|
---|
| 572 | strict?: boolean;
|
---|
| 573 | /**
|
---|
| 574 | * ECMAScript version. Default is `2025`.
|
---|
| 575 | * - `2015` added `u` and `y` flags.
|
---|
| 576 | * - `2018` added `s` flag, Named Capturing Group, Lookbehind Assertion,
|
---|
| 577 | * and Unicode Property Escape.
|
---|
| 578 | * - `2019`, `2020`, and `2021` added more valid Unicode Property Escapes.
|
---|
| 579 | * - `2022` added `d` flag.
|
---|
| 580 | * - `2023` added more valid Unicode Property Escapes.
|
---|
| 581 | * - `2024` added `v` flag.
|
---|
| 582 | * - `2025` added duplicate named capturing groups.
|
---|
| 583 | */
|
---|
| 584 | ecmaVersion?: EcmaVersion;
|
---|
| 585 | /**
|
---|
| 586 | * A function that is called when the validator entered a RegExp literal.
|
---|
| 587 | * @param start The 0-based index of the first character.
|
---|
| 588 | */
|
---|
| 589 | onLiteralEnter?: (start: number) => void;
|
---|
| 590 | /**
|
---|
| 591 | * A function that is called when the validator left a RegExp literal.
|
---|
| 592 | * @param start The 0-based index of the first character.
|
---|
| 593 | * @param end The next 0-based index of the last character.
|
---|
| 594 | */
|
---|
| 595 | onLiteralLeave?: (start: number, end: number) => void;
|
---|
| 596 | /**
|
---|
| 597 | * A function that is called when the validator found flags.
|
---|
| 598 | * @param start The 0-based index of the first character.
|
---|
| 599 | * @param end The next 0-based index of the last character.
|
---|
| 600 | * @param flags.global `g` flag.
|
---|
| 601 | * @param flags.ignoreCase `i` flag.
|
---|
| 602 | * @param flags.multiline `m` flag.
|
---|
| 603 | * @param flags.unicode `u` flag.
|
---|
| 604 | * @param flags.sticky `y` flag.
|
---|
| 605 | * @param flags.dotAll `s` flag.
|
---|
| 606 | * @param flags.hasIndices `d` flag.
|
---|
| 607 | * @param flags.unicodeSets `v` flag.
|
---|
| 608 | */
|
---|
| 609 | onRegExpFlags?: (
|
---|
| 610 | start: number,
|
---|
| 611 | end: number,
|
---|
| 612 | flags: {
|
---|
| 613 | global: boolean;
|
---|
| 614 | ignoreCase: boolean;
|
---|
| 615 | multiline: boolean;
|
---|
| 616 | unicode: boolean;
|
---|
| 617 | sticky: boolean;
|
---|
| 618 | dotAll: boolean;
|
---|
| 619 | hasIndices: boolean;
|
---|
| 620 | unicodeSets: boolean;
|
---|
| 621 | }
|
---|
| 622 | ) => void;
|
---|
| 623 | /**
|
---|
| 624 | * A function that is called when the validator found flags.
|
---|
| 625 | * @param start The 0-based index of the first character.
|
---|
| 626 | * @param end The next 0-based index of the last character.
|
---|
| 627 | * @param global `g` flag.
|
---|
| 628 | * @param ignoreCase `i` flag.
|
---|
| 629 | * @param multiline `m` flag.
|
---|
| 630 | * @param unicode `u` flag.
|
---|
| 631 | * @param sticky `y` flag.
|
---|
| 632 | * @param dotAll `s` flag.
|
---|
| 633 | * @param hasIndices `d` flag.
|
---|
| 634 | *
|
---|
| 635 | * @deprecated Use `onRegExpFlags` instead.
|
---|
| 636 | */
|
---|
| 637 | onFlags?: (
|
---|
| 638 | start: number,
|
---|
| 639 | end: number,
|
---|
| 640 | global: boolean,
|
---|
| 641 | ignoreCase: boolean,
|
---|
| 642 | multiline: boolean,
|
---|
| 643 | unicode: boolean,
|
---|
| 644 | sticky: boolean,
|
---|
| 645 | dotAll: boolean,
|
---|
| 646 | hasIndices: boolean
|
---|
| 647 | ) => void;
|
---|
| 648 | /**
|
---|
| 649 | * A function that is called when the validator entered a pattern.
|
---|
| 650 | * @param start The 0-based index of the first character.
|
---|
| 651 | */
|
---|
| 652 | onPatternEnter?: (start: number) => void;
|
---|
| 653 | /**
|
---|
| 654 | * A function that is called when the validator left a pattern.
|
---|
| 655 | * @param start The 0-based index of the first character.
|
---|
| 656 | * @param end The next 0-based index of the last character.
|
---|
| 657 | */
|
---|
| 658 | onPatternLeave?: (start: number, end: number) => void;
|
---|
| 659 | /**
|
---|
| 660 | * A function that is called when the validator entered a disjunction.
|
---|
| 661 | * @param start The 0-based index of the first character.
|
---|
| 662 | */
|
---|
| 663 | onDisjunctionEnter?: (start: number) => void;
|
---|
| 664 | /**
|
---|
| 665 | * A function that is called when the validator left a disjunction.
|
---|
| 666 | * @param start The 0-based index of the first character.
|
---|
| 667 | * @param end The next 0-based index of the last character.
|
---|
| 668 | */
|
---|
| 669 | onDisjunctionLeave?: (start: number, end: number) => void;
|
---|
| 670 | /**
|
---|
| 671 | * A function that is called when the validator entered an alternative.
|
---|
| 672 | * @param start The 0-based index of the first character.
|
---|
| 673 | * @param index The 0-based index of alternatives in a disjunction.
|
---|
| 674 | */
|
---|
| 675 | onAlternativeEnter?: (start: number, index: number) => void;
|
---|
| 676 | /**
|
---|
| 677 | * A function that is called when the validator left an alternative.
|
---|
| 678 | * @param start The 0-based index of the first character.
|
---|
| 679 | * @param end The next 0-based index of the last character.
|
---|
| 680 | * @param index The 0-based index of alternatives in a disjunction.
|
---|
| 681 | */
|
---|
| 682 | onAlternativeLeave?: (start: number, end: number, index: number) => void;
|
---|
| 683 | /**
|
---|
| 684 | * A function that is called when the validator entered an uncapturing group.
|
---|
| 685 | * @param start The 0-based index of the first character.
|
---|
| 686 | */
|
---|
| 687 | onGroupEnter?: (start: number) => void;
|
---|
| 688 | /**
|
---|
| 689 | * A function that is called when the validator left an uncapturing group.
|
---|
| 690 | * @param start The 0-based index of the first character.
|
---|
| 691 | * @param end The next 0-based index of the last character.
|
---|
| 692 | */
|
---|
| 693 | onGroupLeave?: (start: number, end: number) => void;
|
---|
| 694 | /**
|
---|
| 695 | * A function that is called when the validator entered a capturing group.
|
---|
| 696 | * @param start The 0-based index of the first character.
|
---|
| 697 | * @param name The group name.
|
---|
| 698 | */
|
---|
| 699 | onCapturingGroupEnter?: (start: number, name: string | null) => void;
|
---|
| 700 | /**
|
---|
| 701 | * A function that is called when the validator left a capturing group.
|
---|
| 702 | * @param start The 0-based index of the first character.
|
---|
| 703 | * @param end The next 0-based index of the last character.
|
---|
| 704 | * @param name The group name.
|
---|
| 705 | */
|
---|
| 706 | onCapturingGroupLeave?: (
|
---|
| 707 | start: number,
|
---|
| 708 | end: number,
|
---|
| 709 | name: string | null
|
---|
| 710 | ) => void;
|
---|
| 711 | /**
|
---|
| 712 | * A function that is called when the validator found a quantifier.
|
---|
| 713 | * @param start The 0-based index of the first character.
|
---|
| 714 | * @param end The next 0-based index of the last character.
|
---|
| 715 | * @param min The minimum number of repeating.
|
---|
| 716 | * @param max The maximum number of repeating.
|
---|
| 717 | * @param greedy The flag to choose the longest matching.
|
---|
| 718 | */
|
---|
| 719 | onQuantifier?: (
|
---|
| 720 | start: number,
|
---|
| 721 | end: number,
|
---|
| 722 | min: number,
|
---|
| 723 | max: number,
|
---|
| 724 | greedy: boolean
|
---|
| 725 | ) => void;
|
---|
| 726 | /**
|
---|
| 727 | * A function that is called when the validator entered a lookahead/lookbehind assertion.
|
---|
| 728 | * @param start The 0-based index of the first character.
|
---|
| 729 | * @param kind The kind of the assertion.
|
---|
| 730 | * @param negate The flag which represents that the assertion is negative.
|
---|
| 731 | */
|
---|
| 732 | onLookaroundAssertionEnter?: (
|
---|
| 733 | start: number,
|
---|
| 734 | kind: "lookahead" | "lookbehind",
|
---|
| 735 | negate: boolean
|
---|
| 736 | ) => void;
|
---|
| 737 | /**
|
---|
| 738 | * A function that is called when the validator left a lookahead/lookbehind assertion.
|
---|
| 739 | * @param start The 0-based index of the first character.
|
---|
| 740 | * @param end The next 0-based index of the last character.
|
---|
| 741 | * @param kind The kind of the assertion.
|
---|
| 742 | * @param negate The flag which represents that the assertion is negative.
|
---|
| 743 | */
|
---|
| 744 | onLookaroundAssertionLeave?: (
|
---|
| 745 | start: number,
|
---|
| 746 | end: number,
|
---|
| 747 | kind: "lookahead" | "lookbehind",
|
---|
| 748 | negate: boolean
|
---|
| 749 | ) => void;
|
---|
| 750 | /**
|
---|
| 751 | * A function that is called when the validator found an edge boundary assertion.
|
---|
| 752 | * @param start The 0-based index of the first character.
|
---|
| 753 | * @param end The next 0-based index of the last character.
|
---|
| 754 | * @param kind The kind of the assertion.
|
---|
| 755 | */
|
---|
| 756 | onEdgeAssertion?: (
|
---|
| 757 | start: number,
|
---|
| 758 | end: number,
|
---|
| 759 | kind: "end" | "start"
|
---|
| 760 | ) => void;
|
---|
| 761 | /**
|
---|
| 762 | * A function that is called when the validator found a word boundary assertion.
|
---|
| 763 | * @param start The 0-based index of the first character.
|
---|
| 764 | * @param end The next 0-based index of the last character.
|
---|
| 765 | * @param kind The kind of the assertion.
|
---|
| 766 | * @param negate The flag which represents that the assertion is negative.
|
---|
| 767 | */
|
---|
| 768 | onWordBoundaryAssertion?: (
|
---|
| 769 | start: number,
|
---|
| 770 | end: number,
|
---|
| 771 | kind: "word",
|
---|
| 772 | negate: boolean
|
---|
| 773 | ) => void;
|
---|
| 774 | /**
|
---|
| 775 | * A function that is called when the validator found a dot.
|
---|
| 776 | * @param start The 0-based index of the first character.
|
---|
| 777 | * @param end The next 0-based index of the last character.
|
---|
| 778 | * @param kind The kind of the character set.
|
---|
| 779 | */
|
---|
| 780 | onAnyCharacterSet?: (start: number, end: number, kind: "any") => void;
|
---|
| 781 | /**
|
---|
| 782 | * A function that is called when the validator found a character set escape.
|
---|
| 783 | * @param start The 0-based index of the first character.
|
---|
| 784 | * @param end The next 0-based index of the last character.
|
---|
| 785 | * @param kind The kind of the character set.
|
---|
| 786 | * @param negate The flag which represents that the character set is negative.
|
---|
| 787 | */
|
---|
| 788 | onEscapeCharacterSet?: (
|
---|
| 789 | start: number,
|
---|
| 790 | end: number,
|
---|
| 791 | kind: "digit" | "space" | "word",
|
---|
| 792 | negate: boolean
|
---|
| 793 | ) => void;
|
---|
| 794 | /**
|
---|
| 795 | * A function that is called when the validator found a Unicode proerty escape.
|
---|
| 796 | * @param start The 0-based index of the first character.
|
---|
| 797 | * @param end The next 0-based index of the last character.
|
---|
| 798 | * @param kind The kind of the character set.
|
---|
| 799 | * @param key The property name.
|
---|
| 800 | * @param value The property value.
|
---|
| 801 | * @param negate The flag which represents that the character set is negative.
|
---|
| 802 | * @param strings If true, the given property is property of strings.
|
---|
| 803 | */
|
---|
| 804 | onUnicodePropertyCharacterSet?: (
|
---|
| 805 | start: number,
|
---|
| 806 | end: number,
|
---|
| 807 | kind: "property",
|
---|
| 808 | key: string,
|
---|
| 809 | value: string | null,
|
---|
| 810 | negate: boolean,
|
---|
| 811 | strings: boolean
|
---|
| 812 | ) => void;
|
---|
| 813 | /**
|
---|
| 814 | * A function that is called when the validator found a character.
|
---|
| 815 | * @param start The 0-based index of the first character.
|
---|
| 816 | * @param end The next 0-based index of the last character.
|
---|
| 817 | * @param value The code point of the character.
|
---|
| 818 | */
|
---|
| 819 | onCharacter?: (start: number, end: number, value: number) => void;
|
---|
| 820 | /**
|
---|
| 821 | * A function that is called when the validator found a backreference.
|
---|
| 822 | * @param start The 0-based index of the first character.
|
---|
| 823 | * @param end The next 0-based index of the last character.
|
---|
| 824 | * @param ref The key of the referred capturing group.
|
---|
| 825 | */
|
---|
| 826 | onBackreference?: (
|
---|
| 827 | start: number,
|
---|
| 828 | end: number,
|
---|
| 829 | ref: number | string
|
---|
| 830 | ) => void;
|
---|
| 831 | /**
|
---|
| 832 | * A function that is called when the validator entered a character class.
|
---|
| 833 | * @param start The 0-based index of the first character.
|
---|
| 834 | * @param negate The flag which represents that the character class is negative.
|
---|
| 835 | * @param unicodeSets `true` if unicodeSets mode.
|
---|
| 836 | */
|
---|
| 837 | onCharacterClassEnter?: (
|
---|
| 838 | start: number,
|
---|
| 839 | negate: boolean,
|
---|
| 840 | unicodeSets: boolean
|
---|
| 841 | ) => void;
|
---|
| 842 | /**
|
---|
| 843 | * A function that is called when the validator left a character class.
|
---|
| 844 | * @param start The 0-based index of the first character.
|
---|
| 845 | * @param end The next 0-based index of the last character.
|
---|
| 846 | * @param negate The flag which represents that the character class is negative.
|
---|
| 847 | */
|
---|
| 848 | onCharacterClassLeave?: (
|
---|
| 849 | start: number,
|
---|
| 850 | end: number,
|
---|
| 851 | negate: boolean
|
---|
| 852 | ) => void;
|
---|
| 853 | /**
|
---|
| 854 | * A function that is called when the validator found a character class range.
|
---|
| 855 | * @param start The 0-based index of the first character.
|
---|
| 856 | * @param end The next 0-based index of the last character.
|
---|
| 857 | * @param min The minimum code point of the range.
|
---|
| 858 | * @param max The maximum code point of the range.
|
---|
| 859 | */
|
---|
| 860 | onCharacterClassRange?: (
|
---|
| 861 | start: number,
|
---|
| 862 | end: number,
|
---|
| 863 | min: number,
|
---|
| 864 | max: number
|
---|
| 865 | ) => void;
|
---|
| 866 | /**
|
---|
| 867 | * A function that is called when the validator found a class intersection.
|
---|
| 868 | * @param start The 0-based index of the first character.
|
---|
| 869 | * @param end The next 0-based index of the last character.
|
---|
| 870 | */
|
---|
| 871 | onClassIntersection?: (start: number, end: number) => void;
|
---|
| 872 | /**
|
---|
| 873 | * A function that is called when the validator found a class subtraction.
|
---|
| 874 | * @param start The 0-based index of the first character.
|
---|
| 875 | * @param end The next 0-based index of the last character.
|
---|
| 876 | */
|
---|
| 877 | onClassSubtraction?: (start: number, end: number) => void;
|
---|
| 878 | /**
|
---|
| 879 | * A function that is called when the validator entered a class string disjunction.
|
---|
| 880 | * @param start The 0-based index of the first character.
|
---|
| 881 | */
|
---|
| 882 | onClassStringDisjunctionEnter?: (start: number) => void;
|
---|
| 883 | /**
|
---|
| 884 | * A function that is called when the validator left a class string disjunction.
|
---|
| 885 | * @param start The 0-based index of the first character.
|
---|
| 886 | * @param end The next 0-based index of the last character.
|
---|
| 887 | */
|
---|
| 888 | onClassStringDisjunctionLeave?: (start: number, end: number) => void;
|
---|
| 889 | /**
|
---|
| 890 | * A function that is called when the validator entered a string alternative.
|
---|
| 891 | * @param start The 0-based index of the first character.
|
---|
| 892 | * @param index The 0-based index of alternatives in a disjunction.
|
---|
| 893 | */
|
---|
| 894 | onStringAlternativeEnter?: (start: number, index: number) => void;
|
---|
| 895 | /**
|
---|
| 896 | * A function that is called when the validator left a string alternative.
|
---|
| 897 | * @param start The 0-based index of the first character.
|
---|
| 898 | * @param end The next 0-based index of the last character.
|
---|
| 899 | * @param index The 0-based index of alternatives in a disjunction.
|
---|
| 900 | */
|
---|
| 901 | onStringAlternativeLeave?: (
|
---|
| 902 | start: number,
|
---|
| 903 | end: number,
|
---|
| 904 | index: number
|
---|
| 905 | ) => void;
|
---|
| 906 | }
|
---|
| 907 | }
|
---|
| 908 | /**
|
---|
| 909 | * The regular expression validator.
|
---|
| 910 | */
|
---|
| 911 | export class RegExpValidator {
|
---|
| 912 | /**
|
---|
| 913 | * Initialize this validator.
|
---|
| 914 | * @param options The options of validator.
|
---|
| 915 | */
|
---|
| 916 | constructor(options?: RegExpValidator.Options);
|
---|
| 917 | /**
|
---|
| 918 | * Validate a regular expression literal. E.g. "/abc/g"
|
---|
| 919 | * @param source The source code to validate.
|
---|
| 920 | * @param start The start index in the source code.
|
---|
| 921 | * @param end The end index in the source code.
|
---|
| 922 | */
|
---|
| 923 | validateLiteral(source: string, start?: number, end?: number): void;
|
---|
| 924 | /**
|
---|
| 925 | * Validate a regular expression flags. E.g. "gim"
|
---|
| 926 | * @param source The source code to validate.
|
---|
| 927 | * @param start The start index in the source code.
|
---|
| 928 | * @param end The end index in the source code.
|
---|
| 929 | */
|
---|
| 930 | validateFlags(source: string, start?: number, end?: number): void;
|
---|
| 931 | /**
|
---|
| 932 | * Validate a regular expression pattern. E.g. "abc"
|
---|
| 933 | * @param source The source code to validate.
|
---|
| 934 | * @param start The start index in the source code.
|
---|
| 935 | * @param end The end index in the source code.
|
---|
| 936 | * @param flags The flags.
|
---|
| 937 | */
|
---|
| 938 | validatePattern(
|
---|
| 939 | source: string,
|
---|
| 940 | start?: number,
|
---|
| 941 | end?: number,
|
---|
| 942 | flags?: {
|
---|
| 943 | unicode?: boolean;
|
---|
| 944 | unicodeSets?: boolean;
|
---|
| 945 | }
|
---|
| 946 | ): void;
|
---|
| 947 | /**
|
---|
| 948 | * @deprecated Backward compatibility
|
---|
| 949 | * Use object `flags` instead of boolean `uFlag`.
|
---|
| 950 | * @param source The source code to validate.
|
---|
| 951 | * @param start The start index in the source code.
|
---|
| 952 | * @param end The end index in the source code.
|
---|
| 953 | * @param uFlag The flag to set unicode mode.
|
---|
| 954 | */
|
---|
| 955 | validatePattern(
|
---|
| 956 | source: string,
|
---|
| 957 | start?: number,
|
---|
| 958 | end?: number,
|
---|
| 959 | uFlag?: boolean
|
---|
| 960 | ): void;
|
---|
| 961 | }
|
---|
| 962 | }
|
---|
| 963 |
|
---|
| 964 | declare module "@eslint-community/regexpp/visitor" {
|
---|
| 965 | import type {
|
---|
| 966 | Alternative,
|
---|
| 967 | Assertion,
|
---|
| 968 | Backreference,
|
---|
| 969 | CapturingGroup,
|
---|
| 970 | Character,
|
---|
| 971 | CharacterClass,
|
---|
| 972 | CharacterClassRange,
|
---|
| 973 | CharacterSet,
|
---|
| 974 | ClassIntersection,
|
---|
| 975 | ClassStringDisjunction,
|
---|
| 976 | ClassSubtraction,
|
---|
| 977 | ExpressionCharacterClass,
|
---|
| 978 | Flags,
|
---|
| 979 | Group,
|
---|
| 980 | Node,
|
---|
| 981 | Pattern,
|
---|
| 982 | Quantifier,
|
---|
| 983 | RegExpLiteral,
|
---|
| 984 | StringAlternative,
|
---|
| 985 | } from "@eslint-community/regexpp/ast";
|
---|
| 986 | /**
|
---|
| 987 | * The visitor to walk on AST.
|
---|
| 988 | */
|
---|
| 989 | export class RegExpVisitor {
|
---|
| 990 | /**
|
---|
| 991 | * Initialize this visitor.
|
---|
| 992 | * @param handlers Callbacks for each node.
|
---|
| 993 | */
|
---|
| 994 | constructor(handlers: RegExpVisitor.Handlers);
|
---|
| 995 | /**
|
---|
| 996 | * Visit a given node and descendant nodes.
|
---|
| 997 | * @param node The root node to visit tree.
|
---|
| 998 | */
|
---|
| 999 | visit(node: Node): void;
|
---|
| 1000 | }
|
---|
| 1001 | export namespace RegExpVisitor {
|
---|
| 1002 | interface Handlers {
|
---|
| 1003 | onAlternativeEnter?: (node: Alternative) => void;
|
---|
| 1004 | onAlternativeLeave?: (node: Alternative) => void;
|
---|
| 1005 | onAssertionEnter?: (node: Assertion) => void;
|
---|
| 1006 | onAssertionLeave?: (node: Assertion) => void;
|
---|
| 1007 | onBackreferenceEnter?: (node: Backreference) => void;
|
---|
| 1008 | onBackreferenceLeave?: (node: Backreference) => void;
|
---|
| 1009 | onCapturingGroupEnter?: (node: CapturingGroup) => void;
|
---|
| 1010 | onCapturingGroupLeave?: (node: CapturingGroup) => void;
|
---|
| 1011 | onCharacterEnter?: (node: Character) => void;
|
---|
| 1012 | onCharacterLeave?: (node: Character) => void;
|
---|
| 1013 | onCharacterClassEnter?: (node: CharacterClass) => void;
|
---|
| 1014 | onCharacterClassLeave?: (node: CharacterClass) => void;
|
---|
| 1015 | onCharacterClassRangeEnter?: (node: CharacterClassRange) => void;
|
---|
| 1016 | onCharacterClassRangeLeave?: (node: CharacterClassRange) => void;
|
---|
| 1017 | onCharacterSetEnter?: (node: CharacterSet) => void;
|
---|
| 1018 | onCharacterSetLeave?: (node: CharacterSet) => void;
|
---|
| 1019 | onClassIntersectionEnter?: (node: ClassIntersection) => void;
|
---|
| 1020 | onClassIntersectionLeave?: (node: ClassIntersection) => void;
|
---|
| 1021 | onClassStringDisjunctionEnter?: (node: ClassStringDisjunction) => void;
|
---|
| 1022 | onClassStringDisjunctionLeave?: (node: ClassStringDisjunction) => void;
|
---|
| 1023 | onClassSubtractionEnter?: (node: ClassSubtraction) => void;
|
---|
| 1024 | onClassSubtractionLeave?: (node: ClassSubtraction) => void;
|
---|
| 1025 | onExpressionCharacterClassEnter?: (
|
---|
| 1026 | node: ExpressionCharacterClass
|
---|
| 1027 | ) => void;
|
---|
| 1028 | onExpressionCharacterClassLeave?: (
|
---|
| 1029 | node: ExpressionCharacterClass
|
---|
| 1030 | ) => void;
|
---|
| 1031 | onFlagsEnter?: (node: Flags) => void;
|
---|
| 1032 | onFlagsLeave?: (node: Flags) => void;
|
---|
| 1033 | onGroupEnter?: (node: Group) => void;
|
---|
| 1034 | onGroupLeave?: (node: Group) => void;
|
---|
| 1035 | onPatternEnter?: (node: Pattern) => void;
|
---|
| 1036 | onPatternLeave?: (node: Pattern) => void;
|
---|
| 1037 | onQuantifierEnter?: (node: Quantifier) => void;
|
---|
| 1038 | onQuantifierLeave?: (node: Quantifier) => void;
|
---|
| 1039 | onRegExpLiteralEnter?: (node: RegExpLiteral) => void;
|
---|
| 1040 | onRegExpLiteralLeave?: (node: RegExpLiteral) => void;
|
---|
| 1041 | onStringAlternativeEnter?: (node: StringAlternative) => void;
|
---|
| 1042 | onStringAlternativeLeave?: (node: StringAlternative) => void;
|
---|
| 1043 | }
|
---|
| 1044 | }
|
---|
| 1045 | }
|
---|
| 1046 |
|
---|
| 1047 | declare module "@eslint-community/regexpp/regexp-syntax-error" {
|
---|
| 1048 | import type { RegExpValidatorSourceContext } from "@eslint-community/regexpp/validator";
|
---|
| 1049 | export class RegExpSyntaxError extends SyntaxError {
|
---|
| 1050 | index: number;
|
---|
| 1051 | constructor(message: string, index: number);
|
---|
| 1052 | }
|
---|
| 1053 | export function newRegExpSyntaxError(
|
---|
| 1054 | srcCtx: RegExpValidatorSourceContext,
|
---|
| 1055 | flags: {
|
---|
| 1056 | unicode: boolean;
|
---|
| 1057 | unicodeSets: boolean;
|
---|
| 1058 | },
|
---|
| 1059 | index: number,
|
---|
| 1060 | message: string
|
---|
| 1061 | ): RegExpSyntaxError;
|
---|
| 1062 | }
|
---|
| 1063 |
|
---|
| 1064 | declare module "@eslint-community/regexpp/ecma-versions" {
|
---|
| 1065 | export type EcmaVersion =
|
---|
| 1066 | | 5
|
---|
| 1067 | | 2015
|
---|
| 1068 | | 2016
|
---|
| 1069 | | 2017
|
---|
| 1070 | | 2018
|
---|
| 1071 | | 2019
|
---|
| 1072 | | 2020
|
---|
| 1073 | | 2021
|
---|
| 1074 | | 2022
|
---|
| 1075 | | 2023
|
---|
| 1076 | | 2024
|
---|
| 1077 | | 2025;
|
---|
| 1078 | export const latestEcmaVersion = 2025;
|
---|
| 1079 | }
|
---|