UNPKG

2.1 kBTypeScriptView Raw
1import type { TextlintRuleContext } from "@textlint/types";
2import { TxtNode } from "@textlint/ast-node-types";
3/**
4 * RuleHelper is helper class for textlint.
5 * @class RuleHelper
6 */
7export default class RuleHelper {
8 private _ruleContext;
9 /**
10 * Initialize RuleHelper with RuleContext object.
11 * @param ruleContext the ruleContext is context object of the rule.
12 */
13 constructor(ruleContext: Readonly<TextlintRuleContext>);
14 /**
15 * Get parents of node.
16 * The parent nodes are returned in order from the closest parent to the outer ones.
17 * {@link node} is not contained in the results.
18 * @param {TxtNode} node the node is start point.
19 */
20 getParents(node: TxtNode): import("@textlint/ast-node-types").TxtParentNode[];
21 /**
22 * Return true if `node` is wrapped any one of node {@link types}.
23 * @param {TxtNode} node is target node
24 * @param {string[]} types are wrapped target node
25 * @returns {boolean}
26 */
27 isChildNode(node: TxtNode, types: string[]): boolean;
28 /**
29 * Return true if the node is Str node and fill following conditions
30 *
31 * - the node is Str node
32 * - the node is under the Paragraph node
33 * - the node is not under the BlockQuote
34 *
35 * This function is useful for common use-case.
36 * If you want to lint Str node, but you not want to lint styled node, this function is useful.
37 * styled node is Link, Strong, BlockQuote, Header etc...
38 * Opposite of it, plain str node is just under the Paragraph node.
39 *
40 * @example
41 *
42 * Return true
43 *
44 * ---
45 * str str str
46 * - list text
47 * ---
48 *
49 * Return false
50 *
51 * ----
52 * # Header
53 * ![alt text](https://example.com)
54 * [link title](https://example.com)
55 * > BlockQuote
56 * **Strong**
57 * [^footnote]: text text
58 * ----
59 *
60 * Summary:
61 *
62 * Return true if the node is plain text.
63 * In other words, return false if the node is styled
64 *
65 * @param node
66 */
67 isPlainStrNode(node: TxtNode): boolean;
68}