1 | interface PatternMatcher {
|
2 | /**
|
3 | * Iterate all matched parts in a given string.
|
4 | *
|
5 | * @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#matcher-execall}
|
6 | */
|
7 | execAll(str: string): IterableIterator<RegExpExecArray>;
|
8 | /**
|
9 | * Check whether this pattern matches a given string or not.
|
10 | *
|
11 | * @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#matcher-test}
|
12 | */
|
13 | test(str: string): boolean;
|
14 | /**
|
15 | * Replace all matched parts by a given replacer.
|
16 | *
|
17 | * @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#matcher-symbol-replace}
|
18 | * @example
|
19 | * const { PatternMatcher } = require("eslint-utils")
|
20 | * const matcher = new PatternMatcher(/\\p{Script=Greek}/g)
|
21 | *
|
22 | * module.exports = {
|
23 | * meta: {},
|
24 | * create(context) {
|
25 | * return {
|
26 | * "Literal[regex]"(node) {
|
27 | * const replacedPattern = node.regex.pattern.replace(
|
28 | * matcher,
|
29 | * "[\\u0370-\\u0373\\u0375-\\u0377\\u037A-\\u037D\\u037F\\u0384\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03E1\\u03F0-\\u03FF\\u1D26-\\u1D2A\\u1D5D-\\u1D61\\u1D66-\\u1D6A\\u1DBF\\u1F00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FC4\\u1FC6-\\u1FD3\\u1FD6-\\u1FDB\\u1FDD-\\u1FEF\\u1FF2-\\u1FF4\\u1FF6-\\u1FFE\\u2126\\uAB65]|\\uD800[\\uDD40-\\uDD8E\\uDDA0]|\\uD834[\\uDE00-\\uDE45]"
|
30 | * )
|
31 | * },
|
32 | * }
|
33 | * },
|
34 | * }
|
35 | */
|
36 | [Symbol.replace](str: string, replacer: string | ((...strs: string[]) => string)): string;
|
37 | }
|
38 | /**
|
39 | * The class to find a pattern in strings as handling escape sequences.
|
40 | * It ignores the found pattern if it's escaped with `\`.
|
41 | *
|
42 | * @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#patternmatcher-class}
|
43 | */
|
44 | declare const PatternMatcher: new (pattern: RegExp, options?: {
|
45 | escaped?: boolean | undefined;
|
46 | } | undefined) => PatternMatcher;
|
47 | export { PatternMatcher };
|
48 | //# sourceMappingURL=PatternMatcher.d.ts.map |
\ | No newline at end of file |