@markuplint/ml-core 3.9.0 → 3.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +1 -11
- package/lib/ml-core.d.ts +11 -22
- package/lib/ml-dom/helper/create-node.d.ts +1 -5
- package/lib/ml-dom/helper/getIndent.d.ts +7 -7
- package/lib/ml-dom/helper/walkers.d.ts +4 -14
- package/lib/ml-dom/manipulations/child-node-methods.d.ts +5 -18
- package/lib/ml-dom/manipulations/get-children.d.ts +1 -3
- package/lib/ml-dom/node/attr.d.ts +90 -93
- package/lib/ml-dom/node/block.d.ts +31 -35
- package/lib/ml-dom/node/character-data.d.ts +52 -59
- package/lib/ml-dom/node/child-node.d.ts +2 -9
- package/lib/ml-dom/node/comment.d.ts +12 -15
- package/lib/ml-dom/node/document-fragment.d.ts +19 -22
- package/lib/ml-dom/node/document-type.d.ts +31 -34
- package/lib/ml-dom/node/document.d.ts +1583 -1600
- package/lib/ml-dom/node/document.js +12 -1
- package/lib/ml-dom/node/dom-token-list.d.ts +26 -26
- package/lib/ml-dom/node/element.d.ts +1904 -1902
- package/lib/ml-dom/node/element.js +17 -1
- package/lib/ml-dom/node/named-node-map.d.ts +39 -44
- package/lib/ml-dom/node/node-list.d.ts +3 -9
- package/lib/ml-dom/node/node-store.d.ts +3 -8
- package/lib/ml-dom/node/node-store.js +1 -1
- package/lib/ml-dom/node/node.d.ts +471 -491
- package/lib/ml-dom/node/parent-node.d.ts +57 -66
- package/lib/ml-dom/node/rule-mapper.d.ts +7 -7
- package/lib/ml-dom/node/text.d.ts +46 -49
- package/lib/ml-dom/node/types.d.ts +12 -80
- package/lib/ml-dom/node/unexpected-call-error.d.ts +2 -1
- package/lib/ml-dom/token/token.d.ts +44 -44
- package/lib/ml-rule/create-rule.d.ts +1 -3
- package/lib/ml-rule/create-test-rule.d.ts +3 -5
- package/lib/ml-rule/ml-rule-context.d.ts +47 -55
- package/lib/ml-rule/ml-rule.d.ts +23 -33
- package/lib/ml-rule/ml-rule.js +5 -1
- package/lib/ml-rule/types.d.ts +13 -31
- package/lib/plugin/plugin.d.ts +1 -3
- package/lib/plugin/types.d.ts +5 -5
- package/lib/ruleset/index.d.ts +4 -4
- package/lib/test/index.d.ts +7 -19
- package/lib/types.d.ts +8 -8
- package/lib/utils/get-location-from-chars.d.ts +4 -9
- package/package.json +14 -14
- package/test/ml-dom/ml-rule/create-rule.spec.js +108 -0
|
@@ -6,70 +6,61 @@ import { MLNode } from './node';
|
|
|
6
6
|
*
|
|
7
7
|
* @see https://dom.spec.whatwg.org/#interface-parentnode
|
|
8
8
|
*/
|
|
9
|
-
export declare abstract class MLParentNode<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
*
|
|
67
|
-
* @unsupported
|
|
68
|
-
* @implements DOM API: `Element`, `Document`, `DocumentFragment`
|
|
69
|
-
* @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-replacechildren%E2%91%A0
|
|
70
|
-
*/
|
|
71
|
-
replaceChildren(...nodes: (string | Node)[]): void;
|
|
72
|
-
protected _descendantsToArray<N extends MLNode<T, O>>(
|
|
73
|
-
filter?: (node: MLNode<T, O>) => N | null | void,
|
|
74
|
-
): ReadonlyArray<N>;
|
|
9
|
+
export declare abstract class MLParentNode<T extends RuleConfigValue, O extends PlainData = undefined, A extends MLASTAbstractNode = MLASTAbstractNode> extends MLNode<T, O, A> implements ParentNode {
|
|
10
|
+
#private;
|
|
11
|
+
/**
|
|
12
|
+
* @implements DOM API: `Element`, `Document`, `DocumentFragment`
|
|
13
|
+
* @see https://dom.spec.whatwg.org/#dom-parentnode-childelementcount
|
|
14
|
+
*/
|
|
15
|
+
get childElementCount(): number;
|
|
16
|
+
/**
|
|
17
|
+
* @implements DOM API: `Element`, `Document`, `DocumentFragment`
|
|
18
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-children%E2%91%A0
|
|
19
|
+
*/
|
|
20
|
+
get children(): HTMLCollectionOf<MLElement<T, O>>;
|
|
21
|
+
/**
|
|
22
|
+
* @implements DOM API: `Element`, `Document`, `DocumentFragment`
|
|
23
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-firstelementchild%E2%91%A0
|
|
24
|
+
*/
|
|
25
|
+
get firstElementChild(): MLElement<T, O> | null;
|
|
26
|
+
/**
|
|
27
|
+
* @implements DOM API: `Element`, `Document`, `DocumentFragment`
|
|
28
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-lastelementchild%E2%91%A0
|
|
29
|
+
*/
|
|
30
|
+
get lastElementChild(): MLElement<T, O> | null;
|
|
31
|
+
/**
|
|
32
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
33
|
+
*
|
|
34
|
+
* @unsupported
|
|
35
|
+
* @implements DOM API: `Element`, `Document`, `DocumentFragment`
|
|
36
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-append%E2%91%A0
|
|
37
|
+
*/
|
|
38
|
+
append(...nodes: (string | Node)[]): void;
|
|
39
|
+
/**
|
|
40
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
41
|
+
*
|
|
42
|
+
* @unsupported
|
|
43
|
+
* @implements DOM API: `Element`, `Document`, `DocumentFragment`
|
|
44
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-prepend%E2%91%A0
|
|
45
|
+
*/
|
|
46
|
+
prepend(...nodes: (string | Node)[]): void;
|
|
47
|
+
/**
|
|
48
|
+
* @implements DOM API: `Element`, `Document`, `DocumentFragment`
|
|
49
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-queryselector%E2%91%A0
|
|
50
|
+
*/
|
|
51
|
+
querySelector(selectors: string): MLElement<T, O> | null;
|
|
52
|
+
/**
|
|
53
|
+
* @implements DOM API: `Element`, `Document`, `DocumentFragment`
|
|
54
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-queryselectorall%E2%91%A0
|
|
55
|
+
*/
|
|
56
|
+
querySelectorAll(selectors: string): NodeListOf<MLElement<T, O>>;
|
|
57
|
+
/**
|
|
58
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
59
|
+
*
|
|
60
|
+
* @unsupported
|
|
61
|
+
* @implements DOM API: `Element`, `Document`, `DocumentFragment`
|
|
62
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-parentnode-replacechildren%E2%91%A0
|
|
63
|
+
*/
|
|
64
|
+
replaceChildren(...nodes: (string | Node)[]): void;
|
|
65
|
+
protected _descendantsToArray<N extends MLNode<T, O>>(filter?: (node: MLNode<T, O>) => N | null | void): ReadonlyArray<N>;
|
|
75
66
|
}
|
|
@@ -4,14 +4,14 @@ import type { AnyRule } from '@markuplint/ml-config';
|
|
|
4
4
|
import type { Specificity } from '@markuplint/selector';
|
|
5
5
|
type RuleType = 'rules' | 'nodeRules' | 'childNodeRules';
|
|
6
6
|
type MappingLayer = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
readonly from: RuleType;
|
|
8
|
+
readonly specificity: Specificity;
|
|
9
|
+
readonly rule: AnyRule;
|
|
10
10
|
};
|
|
11
11
|
export declare class RuleMapper {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
#private;
|
|
13
|
+
constructor(document: MLDocument<any, any>);
|
|
14
|
+
apply(): void;
|
|
15
|
+
set(node: MLNode<any, any>, ruleName: string, rule: MappingLayer): void;
|
|
16
16
|
}
|
|
17
17
|
export {};
|
|
@@ -2,53 +2,50 @@ import type { TextNodeType } from './types';
|
|
|
2
2
|
import type { MLASTText } from '@markuplint/ml-ast';
|
|
3
3
|
import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
|
|
4
4
|
import { MLCharacterData } from './character-data';
|
|
5
|
-
export declare class MLText<T extends RuleConfigValue, O extends PlainData = undefined>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
* @see https://dom.spec.whatwg.org/#ref-for-dom-text-wholetext%E2%91%A0
|
|
52
|
-
*/
|
|
53
|
-
splitText(offset: number): Text;
|
|
5
|
+
export declare class MLText<T extends RuleConfigValue, O extends PlainData = undefined> extends MLCharacterData<T, O, MLASTText> implements Text {
|
|
6
|
+
/**
|
|
7
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
8
|
+
*
|
|
9
|
+
* @unsupported
|
|
10
|
+
* @implements DOM API: `Text`
|
|
11
|
+
*/
|
|
12
|
+
get assignedSlot(): HTMLSlotElement;
|
|
13
|
+
/**
|
|
14
|
+
* Returns a string appropriate for the type of node as `Text`
|
|
15
|
+
*
|
|
16
|
+
* @see https://dom.spec.whatwg.org/#ref-for-attr%E2%91%A4
|
|
17
|
+
*/
|
|
18
|
+
get nodeName(): "#text";
|
|
19
|
+
/**
|
|
20
|
+
* Returns a number appropriate for the type of `Text`
|
|
21
|
+
*/
|
|
22
|
+
get nodeType(): TextNodeType;
|
|
23
|
+
get textContent(): string | null;
|
|
24
|
+
/**
|
|
25
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
26
|
+
*
|
|
27
|
+
* @unsupported
|
|
28
|
+
* @implements DOM API: `Text`
|
|
29
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-text-splittext%E2%91%A0
|
|
30
|
+
*/
|
|
31
|
+
get wholeText(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Returns `true` if a parent element is `<script>` or `<style>`
|
|
34
|
+
*
|
|
35
|
+
* @implements `@markuplint/ml-core` API: `MLText`
|
|
36
|
+
* @see https://html.spec.whatwg.org/multipage/syntax.html#raw-text-elements
|
|
37
|
+
*/
|
|
38
|
+
isRawTextElementContent(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* @implements `@markuplint/ml-core` API: `MLText`
|
|
41
|
+
*/
|
|
42
|
+
isWhitespace(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
45
|
+
*
|
|
46
|
+
* @unsupported
|
|
47
|
+
* @implements DOM API: `Text`
|
|
48
|
+
* @see https://dom.spec.whatwg.org/#ref-for-dom-text-wholetext%E2%91%A0
|
|
49
|
+
*/
|
|
50
|
+
splitText(offset: number): Text;
|
|
54
51
|
}
|
|
@@ -8,58 +8,10 @@ import type { MLElement } from './element';
|
|
|
8
8
|
import type { MLNode } from './node';
|
|
9
9
|
import type { MLText } from './text';
|
|
10
10
|
import type { MLToken } from '../token/token';
|
|
11
|
-
import type {
|
|
12
|
-
MLASTAbstractNode,
|
|
13
|
-
MLASTAttr,
|
|
14
|
-
MLASTComment,
|
|
15
|
-
MLASTDoctype,
|
|
16
|
-
MLASTElement,
|
|
17
|
-
MLASTParentNode,
|
|
18
|
-
MLASTPreprocessorSpecificBlock,
|
|
19
|
-
MLASTText,
|
|
20
|
-
MLToken as MLASTToken,
|
|
21
|
-
} from '@markuplint/ml-ast/';
|
|
11
|
+
import type { MLASTAbstractNode, MLASTAttr, MLASTComment, MLASTDoctype, MLASTElement, MLASTParentNode, MLASTPreprocessorSpecificBlock, MLASTText, MLToken as MLASTToken } from '@markuplint/ml-ast/';
|
|
22
12
|
import type { PlainData, PretenderARIA, RuleConfigValue } from '@markuplint/ml-config';
|
|
23
|
-
export type MappedNode<N, T extends RuleConfigValue, O extends PlainData = undefined> = N extends MLASTElement
|
|
24
|
-
|
|
25
|
-
: N extends MLASTParentNode
|
|
26
|
-
? MLElement<T, O>
|
|
27
|
-
: N extends MLASTComment
|
|
28
|
-
? MLComment<T, O>
|
|
29
|
-
: N extends MLASTText
|
|
30
|
-
? MLText<T, O>
|
|
31
|
-
: N extends MLASTDoctype
|
|
32
|
-
? MLDocumentType<T, O>
|
|
33
|
-
: N extends MLASTPreprocessorSpecificBlock
|
|
34
|
-
? MLBlock<T, O>
|
|
35
|
-
: N extends MLASTAbstractNode
|
|
36
|
-
? MLNode<T, O, MLASTAbstractNode>
|
|
37
|
-
: N extends MLASTAttr
|
|
38
|
-
? MLAttr<T, O>
|
|
39
|
-
: N extends MLASTToken
|
|
40
|
-
? MLToken
|
|
41
|
-
: never;
|
|
42
|
-
export type NodeTypeOf<
|
|
43
|
-
NT extends NodeType,
|
|
44
|
-
T extends RuleConfigValue,
|
|
45
|
-
O extends PlainData = undefined,
|
|
46
|
-
> = NT extends ElementNodeType
|
|
47
|
-
? MLElement<T, O>
|
|
48
|
-
: NT extends CommentNodeType
|
|
49
|
-
? MLComment<T, O>
|
|
50
|
-
: NT extends TextNodeType
|
|
51
|
-
? MLText<T, O>
|
|
52
|
-
: NT extends DocumentNodeType
|
|
53
|
-
? MLDocument<T, O>
|
|
54
|
-
: NT extends DocumentTypeNodeType
|
|
55
|
-
? MLDocumentType<T, O>
|
|
56
|
-
: NT extends DocumentFragmentNodeType
|
|
57
|
-
? MLDocumentFragment<T, O>
|
|
58
|
-
: NT extends MarkuplintPreprocessorBlockType
|
|
59
|
-
? MLBlock<T, O>
|
|
60
|
-
: NT extends AttributeNodeType
|
|
61
|
-
? MLAttr<T, O>
|
|
62
|
-
: never;
|
|
13
|
+
export type MappedNode<N, T extends RuleConfigValue, O extends PlainData = undefined> = N extends MLASTElement ? MLElement<T, O> : N extends MLASTParentNode ? MLElement<T, O> : N extends MLASTComment ? MLComment<T, O> : N extends MLASTText ? MLText<T, O> : N extends MLASTDoctype ? MLDocumentType<T, O> : N extends MLASTPreprocessorSpecificBlock ? MLBlock<T, O> : N extends MLASTAbstractNode ? MLNode<T, O, MLASTAbstractNode> : N extends MLASTAttr ? MLAttr<T, O> : N extends MLASTToken ? MLToken : never;
|
|
14
|
+
export type NodeTypeOf<NT extends NodeType, T extends RuleConfigValue, O extends PlainData = undefined> = NT extends ElementNodeType ? MLElement<T, O> : NT extends CommentNodeType ? MLComment<T, O> : NT extends TextNodeType ? MLText<T, O> : NT extends DocumentNodeType ? MLDocument<T, O> : NT extends DocumentTypeNodeType ? MLDocumentType<T, O> : NT extends DocumentFragmentNodeType ? MLDocumentFragment<T, O> : NT extends MarkuplintPreprocessorBlockType ? MLBlock<T, O> : NT extends AttributeNodeType ? MLAttr<T, O> : never;
|
|
63
15
|
export type ElementNodeType = 1;
|
|
64
16
|
export type AttributeNodeType = 2;
|
|
65
17
|
export type TextNodeType = 3;
|
|
@@ -70,34 +22,14 @@ export type DocumentNodeType = 9;
|
|
|
70
22
|
export type DocumentTypeNodeType = 10;
|
|
71
23
|
export type DocumentFragmentNodeType = 11;
|
|
72
24
|
export type MarkuplintPreprocessorBlockType = 101;
|
|
73
|
-
export type NodeType =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
| CommentNodeType
|
|
80
|
-
| DocumentNodeType
|
|
81
|
-
| DocumentTypeNodeType
|
|
82
|
-
| DocumentFragmentNodeType
|
|
83
|
-
| MarkuplintPreprocessorBlockType;
|
|
84
|
-
export type PretenderContext<N extends MLElement<T, O>, T extends RuleConfigValue, O extends PlainData = undefined> =
|
|
85
|
-
| PretenderContextPretender<N, T, O>
|
|
86
|
-
| PretenderContextPretended<N, T, O>;
|
|
87
|
-
export type PretenderContextPretender<
|
|
88
|
-
N extends MLElement<T, O>,
|
|
89
|
-
T extends RuleConfigValue,
|
|
90
|
-
O extends PlainData = undefined,
|
|
91
|
-
> = {
|
|
92
|
-
readonly type: 'pretender';
|
|
93
|
-
readonly as: N;
|
|
94
|
-
readonly aria?: PretenderARIA;
|
|
25
|
+
export type NodeType = ElementNodeType | AttributeNodeType | TextNodeType | CDATASectionNodeType | ProcessingInstructionNodeType | CommentNodeType | DocumentNodeType | DocumentTypeNodeType | DocumentFragmentNodeType | MarkuplintPreprocessorBlockType;
|
|
26
|
+
export type PretenderContext<N extends MLElement<T, O>, T extends RuleConfigValue, O extends PlainData = undefined> = PretenderContextPretender<N, T, O> | PretenderContextPretended<N, T, O>;
|
|
27
|
+
export type PretenderContextPretender<N extends MLElement<T, O>, T extends RuleConfigValue, O extends PlainData = undefined> = {
|
|
28
|
+
readonly type: 'pretender';
|
|
29
|
+
readonly as: N;
|
|
30
|
+
readonly aria?: PretenderARIA;
|
|
95
31
|
};
|
|
96
|
-
export type PretenderContextPretended<
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
O extends PlainData = undefined,
|
|
100
|
-
> = {
|
|
101
|
-
readonly type: 'origin';
|
|
102
|
-
readonly origin: N;
|
|
32
|
+
export type PretenderContextPretended<N extends MLElement<T, O>, T extends RuleConfigValue, O extends PlainData = undefined> = {
|
|
33
|
+
readonly type: 'origin';
|
|
34
|
+
readonly origin: N;
|
|
103
35
|
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export default class UnexpectedCallError extends Error {
|
|
1
|
+
export default class UnexpectedCallError extends Error {
|
|
2
|
+
}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
import type { MLToken as MLASTToken } from '@markuplint/ml-ast';
|
|
2
2
|
export declare class MLToken<A extends MLASTToken = MLASTToken> {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
3
|
+
#private;
|
|
4
|
+
readonly uuid: string;
|
|
5
|
+
protected readonly _astToken: A;
|
|
6
|
+
constructor(astToken: A);
|
|
7
|
+
/**
|
|
8
|
+
* @implements `@markuplint/ml-core` API: `MLDOMToken`
|
|
9
|
+
*/
|
|
10
|
+
get endCol(): number;
|
|
11
|
+
/**
|
|
12
|
+
* @implements `@markuplint/ml-core` API: `MLDOMToken`
|
|
13
|
+
*/
|
|
14
|
+
get endLine(): number;
|
|
15
|
+
/**
|
|
16
|
+
* @implements `@markuplint/ml-core` API: `MLDOMToken`
|
|
17
|
+
*/
|
|
18
|
+
get endOffset(): number;
|
|
19
|
+
/**
|
|
20
|
+
* @implements `@markuplint/ml-core` API: `MLDOMToken`
|
|
21
|
+
*/
|
|
22
|
+
get originRaw(): string;
|
|
23
|
+
/**
|
|
24
|
+
* @implements `@markuplint/ml-core` API: `MLDOMToken`
|
|
25
|
+
*/
|
|
26
|
+
get raw(): string;
|
|
27
|
+
/**
|
|
28
|
+
* @implements `@markuplint/ml-core` API: `MLDOMToken`
|
|
29
|
+
*/
|
|
30
|
+
get startCol(): number;
|
|
31
|
+
/**
|
|
32
|
+
* @implements `@markuplint/ml-core` API: `MLDOMToken`
|
|
33
|
+
*/
|
|
34
|
+
get startLine(): number;
|
|
35
|
+
/**
|
|
36
|
+
* @implements `@markuplint/ml-core` API: `MLDOMToken`
|
|
37
|
+
*/
|
|
38
|
+
get startOffset(): number;
|
|
39
|
+
/**
|
|
40
|
+
* @implements `@markuplint/ml-core` API: `MLDOMToken`
|
|
41
|
+
*/
|
|
42
|
+
fix(raw: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* @implements `@markuplint/ml-core` API: `MLDOMToken`
|
|
45
|
+
*/
|
|
46
|
+
toString(): string;
|
|
47
47
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import type { RuleSeed } from './types';
|
|
2
2
|
import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
|
|
3
|
-
export declare function createRule<T extends RuleConfigValue, O extends PlainData = undefined>(
|
|
4
|
-
seed: Readonly<RuleSeed<T, O>>,
|
|
5
|
-
): Readonly<RuleSeed<T, O>>;
|
|
3
|
+
export declare function createRule<T extends RuleConfigValue, O extends PlainData = undefined>(seed: Readonly<RuleSeed<T, O>>): Readonly<RuleSeed<T, O>>;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { RuleSeed } from './types';
|
|
2
2
|
import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
|
|
3
3
|
import { MLRule } from './ml-rule';
|
|
4
|
-
export declare function createRule<T extends RuleConfigValue, O extends PlainData = undefined>(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
},
|
|
8
|
-
): MLRule<T, O>;
|
|
4
|
+
export declare function createRule<T extends RuleConfigValue, O extends PlainData = undefined>(seed: Readonly<RuleSeed<T, O>> & {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
}): MLRule<T, O>;
|
|
@@ -3,59 +3,51 @@ import type { MLDocument } from '../ml-dom/node/document';
|
|
|
3
3
|
import type { LocaleSet, Translator } from '@markuplint/i18n';
|
|
4
4
|
import type { PlainData, Report, RuleConfigValue } from '@markuplint/ml-config';
|
|
5
5
|
export declare class MLRuleContext<T extends RuleConfigValue, O extends PlainData = undefined> {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
report: {
|
|
54
|
-
(report: Report<T, O>): undefined;
|
|
55
|
-
(report: CheckerReport<T, O>): boolean;
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
report(report: Report<T, O>): undefined;
|
|
59
|
-
report(report: CheckerReport<T, O>): boolean;
|
|
60
|
-
private _push;
|
|
6
|
+
#private;
|
|
7
|
+
readonly document: MLDocument<T, O>;
|
|
8
|
+
readonly locale: string;
|
|
9
|
+
readonly translate: Translator;
|
|
10
|
+
constructor(document: MLDocument<T, O>, locale: LocaleSet);
|
|
11
|
+
get reports(): ({
|
|
12
|
+
message: string;
|
|
13
|
+
line: number;
|
|
14
|
+
col: number;
|
|
15
|
+
raw: string;
|
|
16
|
+
} | {
|
|
17
|
+
message: string;
|
|
18
|
+
scope: import("@markuplint/ml-config").Scope<T, O>;
|
|
19
|
+
} | {
|
|
20
|
+
message: string;
|
|
21
|
+
scope: import("@markuplint/ml-config").Scope<T, O>;
|
|
22
|
+
line: number;
|
|
23
|
+
col: number;
|
|
24
|
+
raw: string;
|
|
25
|
+
})[];
|
|
26
|
+
provide(): {
|
|
27
|
+
document: MLDocument<T, O>;
|
|
28
|
+
translate: Translator;
|
|
29
|
+
t: Translator;
|
|
30
|
+
reports: ({
|
|
31
|
+
message: string;
|
|
32
|
+
line: number;
|
|
33
|
+
col: number;
|
|
34
|
+
raw: string;
|
|
35
|
+
} | {
|
|
36
|
+
message: string;
|
|
37
|
+
scope: import("@markuplint/ml-config").Scope<T, O>;
|
|
38
|
+
} | {
|
|
39
|
+
message: string;
|
|
40
|
+
scope: import("@markuplint/ml-config").Scope<T, O>;
|
|
41
|
+
line: number;
|
|
42
|
+
col: number;
|
|
43
|
+
raw: string;
|
|
44
|
+
})[];
|
|
45
|
+
report: {
|
|
46
|
+
(report: Report<T, O>): undefined;
|
|
47
|
+
(report: CheckerReport<T, O>): boolean;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
report(report: Report<T, O>): undefined;
|
|
51
|
+
report(report: CheckerReport<T, O>): boolean;
|
|
52
|
+
private _push;
|
|
61
53
|
}
|
package/lib/ml-rule/ml-rule.d.ts
CHANGED
|
@@ -2,39 +2,29 @@ import type { RuleSeed } from './types';
|
|
|
2
2
|
import type { Ruleset } from '..';
|
|
3
3
|
import type { MLDocument } from '../ml-dom/node/document';
|
|
4
4
|
import type { LocaleSet } from '@markuplint/i18n';
|
|
5
|
-
import type {
|
|
6
|
-
GlobalRuleInfo,
|
|
7
|
-
PlainData,
|
|
8
|
-
Rule,
|
|
9
|
-
RuleConfigValue,
|
|
10
|
-
RuleInfo,
|
|
11
|
-
Severity,
|
|
12
|
-
Violation,
|
|
13
|
-
} from '@markuplint/ml-config';
|
|
5
|
+
import type { GlobalRuleInfo, PlainData, Rule, RuleConfigValue, RuleInfo, Severity, Violation } from '@markuplint/ml-config';
|
|
14
6
|
export declare class MLRule<T extends RuleConfigValue, O extends PlainData = undefined> {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
verify(document: MLDocument<T, O>, locale: LocaleSet, fix: boolean): Promise<Violation[]>;
|
|
38
|
-
private _optimize;
|
|
7
|
+
#private;
|
|
8
|
+
readonly defaultOptions: O;
|
|
9
|
+
readonly defaultSeverity: Severity;
|
|
10
|
+
readonly defaultValue: T;
|
|
11
|
+
readonly name: string;
|
|
12
|
+
constructor(o: Readonly<RuleSeed<T, O>> & {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* The following getter is unused internally,
|
|
17
|
+
* only for extending from 3rd party library
|
|
18
|
+
*/
|
|
19
|
+
protected get f(): RuleSeed<T, O>['fix'];
|
|
20
|
+
/**
|
|
21
|
+
* The following getter is unused internally,
|
|
22
|
+
* only for extending from 3rd party library
|
|
23
|
+
*/
|
|
24
|
+
protected get v(): RuleSeed<T, O>['verify'];
|
|
25
|
+
getRuleInfo(ruleSet: Ruleset, ruleName: string): GlobalRuleInfo<T, O>;
|
|
26
|
+
optimizeOption(configSettings: Rule<T, O> | null | undefined): RuleInfo<T, O>;
|
|
27
|
+
verify(document: MLDocument<T, O>, locale: LocaleSet, fix: boolean): Promise<Violation[]>;
|
|
28
|
+
private _optimize;
|
|
39
29
|
}
|
|
40
30
|
export type AnyMLRule = MLRule<RuleConfigValue, PlainData>;
|