index.d.ts 37 KB

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