@markuplint/ml-core 4.13.2 → 4.18.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/ARCHITECTURE.ja.md +467 -0
- package/ARCHITECTURE.md +467 -0
- package/CHANGELOG.md +14 -2
- package/README.md +5 -0
- package/SKILL.md +61 -0
- package/docs/linting-pipeline.ja.md +303 -0
- package/docs/linting-pipeline.md +303 -0
- package/docs/maintenance.ja.md +210 -0
- package/docs/maintenance.md +210 -0
- package/docs/ml-dom/attr.ja.md +95 -0
- package/docs/ml-dom/attr.md +95 -0
- package/docs/ml-dom/block.ja.md +272 -0
- package/docs/ml-dom/block.md +272 -0
- package/docs/ml-dom/document.ja.md +141 -0
- package/docs/ml-dom/document.md +141 -0
- package/docs/ml-dom/element.ja.md +176 -0
- package/docs/ml-dom/element.md +176 -0
- package/docs/ml-dom/helpers.ja.md +203 -0
- package/docs/ml-dom/helpers.md +203 -0
- package/docs/ml-dom/node.ja.md +200 -0
- package/docs/ml-dom/node.md +200 -0
- package/docs/ml-dom/others.ja.md +119 -0
- package/docs/ml-dom/others.md +119 -0
- package/docs/ml-dom/overview.ja.md +102 -0
- package/docs/ml-dom/overview.md +102 -0
- package/docs/ml-dom/pretender.ja.md +269 -0
- package/docs/ml-dom/pretender.md +269 -0
- package/docs/ml-dom/rule-mapping.ja.md +371 -0
- package/docs/ml-dom/rule-mapping.md +371 -0
- package/docs/ml-dom.ja.md +18 -0
- package/docs/ml-dom.md +18 -0
- package/docs/rule-system.ja.md +270 -0
- package/docs/rule-system.md +270 -0
- package/lib/convert-ruleset.d.ts +7 -0
- package/lib/convert-ruleset.js +7 -0
- package/lib/debug.d.ts +4 -0
- package/lib/debug.js +4 -0
- package/lib/ml-core.d.ts +36 -0
- package/lib/ml-core.js +29 -0
- package/lib/ml-dom/helper/get-indent.d.ts +4 -1
- package/lib/ml-dom/helper/get-indent.js +4 -1
- package/lib/ml-dom/node/attr.d.ts +65 -4
- package/lib/ml-dom/node/attr.js +53 -4
- package/lib/ml-dom/node/block.d.ts +21 -0
- package/lib/ml-dom/node/block.js +14 -0
- package/lib/ml-dom/node/child-node.d.ts +9 -0
- package/lib/ml-dom/node/child-node.js +9 -0
- package/lib/ml-dom/node/comment.d.ts +7 -0
- package/lib/ml-dom/node/comment.js +7 -0
- package/lib/ml-dom/node/document-fragment.d.ts +8 -0
- package/lib/ml-dom/node/document-fragment.js +8 -0
- package/lib/ml-dom/node/document-type.d.ts +22 -0
- package/lib/ml-dom/node/document-type.js +13 -0
- package/lib/ml-dom/node/document.d.ts +98 -4
- package/lib/ml-dom/node/document.js +87 -2
- package/lib/ml-dom/node/element.d.ts +164 -11
- package/lib/ml-dom/node/element.js +135 -6
- package/lib/ml-dom/node/node.d.ts +23 -0
- package/lib/ml-dom/node/node.js +29 -0
- package/lib/ml-dom/node/text.d.ts +12 -0
- package/lib/ml-dom/node/text.js +12 -0
- package/lib/ml-dom/node/types.d.ts +68 -0
- package/lib/ml-dom/token/token.d.ts +42 -0
- package/lib/ml-dom/token/token.js +36 -0
- package/lib/ml-rule/create-rule.d.ts +9 -0
- package/lib/ml-rule/create-rule.js +9 -0
- package/lib/ml-rule/ml-rule.d.ts +33 -0
- package/lib/ml-rule/ml-rule.js +30 -0
- package/lib/ml-rule/types.d.ts +41 -0
- package/lib/plugin/plugin.d.ts +8 -0
- package/lib/plugin/plugin.js +8 -0
- package/lib/plugin/types.d.ts +21 -0
- package/lib/ruleset/index.d.ts +10 -0
- package/lib/ruleset/index.js +7 -0
- package/lib/test/index.d.ts +42 -1
- package/lib/test/index.js +35 -1
- package/lib/types.d.ts +8 -0
- package/lib/violation-collector.d.ts +33 -0
- package/lib/violation-collector.js +33 -0
- package/package.json +14 -14
package/lib/ml-dom/node/attr.js
CHANGED
|
@@ -15,22 +15,61 @@ import { MLToken } from '../token/token.js';
|
|
|
15
15
|
import { MLDomTokenList } from './dom-token-list.js';
|
|
16
16
|
import { MLNode } from './node.js';
|
|
17
17
|
import { UnexpectedCallError } from './unexpected-call-error.js';
|
|
18
|
+
/**
|
|
19
|
+
* Represents a DOM Attr (attribute) node wrapper in the markuplint DOM tree.
|
|
20
|
+
* Wraps an AST attribute token and provides access to the attribute's name, value,
|
|
21
|
+
* tokens (name, equal sign, quotes, value), and metadata such as whether
|
|
22
|
+
* the attribute is a directive or has a dynamic value.
|
|
23
|
+
*
|
|
24
|
+
* @template T - The rule configuration value type
|
|
25
|
+
* @template O - The rule options type
|
|
26
|
+
*/
|
|
18
27
|
export class MLAttr extends MLNode {
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new MLAttr instance from an AST attribute token.
|
|
30
|
+
*
|
|
31
|
+
* @param astToken - The AST attribute token to wrap
|
|
32
|
+
* @param ownElement - The element that owns this attribute
|
|
33
|
+
*/
|
|
19
34
|
constructor(astToken,
|
|
20
35
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
21
36
|
ownElement) {
|
|
22
37
|
super(astToken, ownElement.ownerMLDocument);
|
|
38
|
+
/**
|
|
39
|
+
* The end quote token of the attribute value, or null if the attribute has no value or quotes.
|
|
40
|
+
*/
|
|
23
41
|
this.endQuote = null;
|
|
42
|
+
/**
|
|
43
|
+
* The equal sign token between the attribute name and value, or null if absent.
|
|
44
|
+
*/
|
|
24
45
|
this.equal = null;
|
|
25
46
|
_MLAttr_localName.set(this, void 0);
|
|
47
|
+
/**
|
|
48
|
+
* The token representing the attribute name, or null for spread attributes.
|
|
49
|
+
*/
|
|
26
50
|
this.nameNode = null;
|
|
27
51
|
_MLAttr_namespaceURI.set(this, void 0);
|
|
28
52
|
_MLAttr_potentialName.set(this, void 0);
|
|
29
53
|
_MLAttr_potentialValue.set(this, void 0);
|
|
54
|
+
/**
|
|
55
|
+
* The whitespace token after the equal sign, or null if absent.
|
|
56
|
+
*/
|
|
30
57
|
this.spacesAfterEqual = null;
|
|
58
|
+
/**
|
|
59
|
+
* The whitespace token before the equal sign, or null if absent.
|
|
60
|
+
*/
|
|
31
61
|
this.spacesBeforeEqual = null;
|
|
62
|
+
/**
|
|
63
|
+
* The whitespace token before the attribute name, or null if absent.
|
|
64
|
+
*/
|
|
32
65
|
this.spacesBeforeName = null;
|
|
66
|
+
/**
|
|
67
|
+
* The start quote token of the attribute value, or null if the attribute has no value or quotes.
|
|
68
|
+
*/
|
|
33
69
|
this.startQuote = null;
|
|
70
|
+
/**
|
|
71
|
+
* The token representing the attribute value, or null if the attribute has no value.
|
|
72
|
+
*/
|
|
34
73
|
this.valueNode = null;
|
|
35
74
|
/**
|
|
36
75
|
* Returns the "string" if HTML syntax. Otherwise, returns a type in its syntax.
|
|
@@ -70,9 +109,8 @@ export class MLAttr extends MLNode {
|
|
|
70
109
|
__classPrivateFieldSet(this, _MLAttr_namespaceURI, ns.namespaceURI, "f");
|
|
71
110
|
}
|
|
72
111
|
/**
|
|
73
|
-
*
|
|
112
|
+
* Returns the local name portion of the attribute (without namespace prefix).
|
|
74
113
|
*
|
|
75
|
-
* @unsupported
|
|
76
114
|
* @implements DOM API: `Attr`
|
|
77
115
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-attr-localname
|
|
78
116
|
*/
|
|
@@ -80,6 +118,7 @@ export class MLAttr extends MLNode {
|
|
|
80
118
|
return __classPrivateFieldGet(this, _MLAttr_localName, "f");
|
|
81
119
|
}
|
|
82
120
|
/**
|
|
121
|
+
* Returns the qualified attribute name (the potential name resolved by the parser).
|
|
83
122
|
*
|
|
84
123
|
* @implements DOM API: `Attr`
|
|
85
124
|
* @see https://dom.spec.whatwg.org/#dom-attr-name
|
|
@@ -88,9 +127,8 @@ export class MLAttr extends MLNode {
|
|
|
88
127
|
return __classPrivateFieldGet(this, _MLAttr_potentialName, "f");
|
|
89
128
|
}
|
|
90
129
|
/**
|
|
91
|
-
*
|
|
130
|
+
* Returns the namespace URI of this attribute, resolved from the attribute name.
|
|
92
131
|
*
|
|
93
|
-
* @unsupported
|
|
94
132
|
* @implements DOM API: `Attr`
|
|
95
133
|
* @see https://dom.spec.whatwg.org/#ref-for-dom-attr-namespaceuri
|
|
96
134
|
*/
|
|
@@ -111,6 +149,12 @@ export class MLAttr extends MLNode {
|
|
|
111
149
|
get nodeType() {
|
|
112
150
|
return this.ATTRIBUTE_NODE;
|
|
113
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Returns the attribute value, equivalent to the `value` property.
|
|
154
|
+
*
|
|
155
|
+
* @implements DOM API: `Attr`
|
|
156
|
+
* @see https://dom.spec.whatwg.org/#dom-node-nodevalue
|
|
157
|
+
*/
|
|
114
158
|
get nodeValue() {
|
|
115
159
|
return this.value;
|
|
116
160
|
}
|
|
@@ -173,7 +217,12 @@ export class MLAttr extends MLNode {
|
|
|
173
217
|
this.valueNode?.fix(raw);
|
|
174
218
|
}
|
|
175
219
|
/**
|
|
220
|
+
* Returns a normalized string representation of the attribute,
|
|
221
|
+
* stripping extraneous whitespace around the name, equal sign, and value tokens.
|
|
222
|
+
* Falls back to the raw string if any token is missing.
|
|
223
|
+
*
|
|
176
224
|
* @implements `@markuplint/ml-core` API: `MLAttr`
|
|
225
|
+
* @returns The normalized attribute string
|
|
177
226
|
*/
|
|
178
227
|
toNormalizeString() {
|
|
179
228
|
if (this.nameNode && this.equal && this.startQuote && this.valueNode && this.endQuote) {
|
|
@@ -4,9 +4,30 @@ import type { MarkuplintPreprocessorBlockType } from './types.js';
|
|
|
4
4
|
import type { MLASTPreprocessorSpecificBlock, MLASTPreprocessorSpecificBlockConditionalType } from '@markuplint/ml-ast';
|
|
5
5
|
import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
|
|
6
6
|
import { MLNode } from './node.js';
|
|
7
|
+
/**
|
|
8
|
+
* Represents a preprocessor-specific block node in the markuplint DOM tree.
|
|
9
|
+
* These nodes correspond to template engine constructs such as conditionals (`if`/`else`),
|
|
10
|
+
* loops (`each`), and other preprocessor directives that are not part of standard HTML.
|
|
11
|
+
*
|
|
12
|
+
* @template T - The rule configuration value type
|
|
13
|
+
* @template O - The rule options type
|
|
14
|
+
*/
|
|
7
15
|
export declare class MLBlock<T extends RuleConfigValue, O extends PlainData = undefined> extends MLNode<T, O, MLASTPreprocessorSpecificBlock> {
|
|
16
|
+
/**
|
|
17
|
+
* The type of conditional this block represents (e.g., `if`, `each`, `switch:case`).
|
|
18
|
+
*/
|
|
8
19
|
readonly conditionalType: MLASTPreprocessorSpecificBlockConditionalType;
|
|
20
|
+
/**
|
|
21
|
+
* Whether this block is transparent, meaning its children are treated
|
|
22
|
+
* as belonging to the parent node for tree traversal purposes.
|
|
23
|
+
*/
|
|
9
24
|
readonly isTransparent: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new MLBlock instance.
|
|
27
|
+
*
|
|
28
|
+
* @param astNode - The AST preprocessor block node to wrap
|
|
29
|
+
* @param document - The owning document
|
|
30
|
+
*/
|
|
10
31
|
constructor(astNode: MLASTPreprocessorSpecificBlock, document: MLDocument<T, O>);
|
|
11
32
|
/**
|
|
12
33
|
* Returns a string appropriate for the type of node as `MLBlock`
|
package/lib/ml-dom/node/block.js
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import { after, before, remove, replaceWith } from '../manipulations/child-node-methods.js';
|
|
2
2
|
import { MLNode } from './node.js';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a preprocessor-specific block node in the markuplint DOM tree.
|
|
5
|
+
* These nodes correspond to template engine constructs such as conditionals (`if`/`else`),
|
|
6
|
+
* loops (`each`), and other preprocessor directives that are not part of standard HTML.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The rule configuration value type
|
|
9
|
+
* @template O - The rule options type
|
|
10
|
+
*/
|
|
3
11
|
export class MLBlock extends MLNode {
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new MLBlock instance.
|
|
14
|
+
*
|
|
15
|
+
* @param astNode - The AST preprocessor block node to wrap
|
|
16
|
+
* @param document - The owning document
|
|
17
|
+
*/
|
|
4
18
|
constructor(astNode,
|
|
5
19
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
6
20
|
document) {
|
|
@@ -15,4 +15,13 @@ import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
|
|
|
15
15
|
* @see https://dom.spec.whatwg.org/#idl-index
|
|
16
16
|
*/
|
|
17
17
|
export type MLChildNode<T extends RuleConfigValue, O extends PlainData = undefined> = MLDocumentType<T, O> | MLCharacterData<T, O> | MLElement<T, O> | MLBlock<T, O>;
|
|
18
|
+
/**
|
|
19
|
+
* Determines whether the given node is a child node type
|
|
20
|
+
* (DocumentType, CDATA, Comment, Text, Element, or preprocessor block).
|
|
21
|
+
*
|
|
22
|
+
* @template T - The rule configuration value type
|
|
23
|
+
* @template O - The rule options type
|
|
24
|
+
* @param node - The node to check
|
|
25
|
+
* @returns True if the node is one of the child node types
|
|
26
|
+
*/
|
|
18
27
|
export declare function isChildNode<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>): node is MLChildNode<T, O>;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines whether the given node is a child node type
|
|
3
|
+
* (DocumentType, CDATA, Comment, Text, Element, or preprocessor block).
|
|
4
|
+
*
|
|
5
|
+
* @template T - The rule configuration value type
|
|
6
|
+
* @template O - The rule options type
|
|
7
|
+
* @param node - The node to check
|
|
8
|
+
* @returns True if the node is one of the child node types
|
|
9
|
+
*/
|
|
1
10
|
export function isChildNode(
|
|
2
11
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
3
12
|
node) {
|
|
@@ -2,6 +2,13 @@ import type { CommentNodeType } from './types.js';
|
|
|
2
2
|
import type { MLASTComment } from '@markuplint/ml-ast';
|
|
3
3
|
import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
|
|
4
4
|
import { MLCharacterData } from './character-data.js';
|
|
5
|
+
/**
|
|
6
|
+
* Represents a DOM Comment node wrapper in the markuplint DOM tree.
|
|
7
|
+
* Wraps an AST comment token and implements the standard DOM `Comment` interface.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The rule configuration value type
|
|
10
|
+
* @template O - The rule options type
|
|
11
|
+
*/
|
|
5
12
|
export declare class MLComment<T extends RuleConfigValue, O extends PlainData = undefined> extends MLCharacterData<T, O, MLASTComment> implements Comment {
|
|
6
13
|
/**
|
|
7
14
|
* Returns a string appropriate for the type of node as `Attr`
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { MLCharacterData } from './character-data.js';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a DOM Comment node wrapper in the markuplint DOM tree.
|
|
4
|
+
* Wraps an AST comment token and implements the standard DOM `Comment` interface.
|
|
5
|
+
*
|
|
6
|
+
* @template T - The rule configuration value type
|
|
7
|
+
* @template O - The rule options type
|
|
8
|
+
*/
|
|
2
9
|
export class MLComment extends MLCharacterData {
|
|
3
10
|
/**
|
|
4
11
|
* Returns a string appropriate for the type of node as `Attr`
|
|
@@ -2,6 +2,14 @@ import type { DocumentFragmentNodeType } from './types.js';
|
|
|
2
2
|
import type { MLASTNode } from '@markuplint/ml-ast';
|
|
3
3
|
import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
|
|
4
4
|
import { MLParentNode } from './parent-node.js';
|
|
5
|
+
/**
|
|
6
|
+
* Represents a DOM DocumentFragment node wrapper in the markuplint DOM tree.
|
|
7
|
+
* Used for JSX fragments and similar constructs where a set of nodes
|
|
8
|
+
* is grouped without a wrapping element.
|
|
9
|
+
*
|
|
10
|
+
* @template T - The rule configuration value type
|
|
11
|
+
* @template O - The rule options type
|
|
12
|
+
*/
|
|
5
13
|
export declare class MLDocumentFragment<T extends RuleConfigValue, O extends PlainData = undefined> extends MLParentNode<T, O, MLASTNode> implements DocumentFragment {
|
|
6
14
|
/**
|
|
7
15
|
* Returns a string appropriate for the type of node as `DocumentFragment`
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { MLParentNode } from './parent-node.js';
|
|
2
2
|
import { UnexpectedCallError } from './unexpected-call-error.js';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a DOM DocumentFragment node wrapper in the markuplint DOM tree.
|
|
5
|
+
* Used for JSX fragments and similar constructs where a set of nodes
|
|
6
|
+
* is grouped without a wrapping element.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The rule configuration value type
|
|
9
|
+
* @template O - The rule options type
|
|
10
|
+
*/
|
|
3
11
|
export class MLDocumentFragment extends MLParentNode {
|
|
4
12
|
/**
|
|
5
13
|
* Returns a string appropriate for the type of node as `DocumentFragment`
|
|
@@ -4,10 +4,32 @@ import type { DocumentTypeNodeType } from './types.js';
|
|
|
4
4
|
import type { MLASTDoctype } from '@markuplint/ml-ast';
|
|
5
5
|
import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
|
|
6
6
|
import { MLNode } from './node.js';
|
|
7
|
+
/**
|
|
8
|
+
* Represents a DOM DocumentType node wrapper in the markuplint DOM tree.
|
|
9
|
+
* Wraps the `<!DOCTYPE ...>` declaration and implements the standard DOM `DocumentType` interface.
|
|
10
|
+
*
|
|
11
|
+
* @template T - The rule configuration value type
|
|
12
|
+
* @template O - The rule options type
|
|
13
|
+
*/
|
|
7
14
|
export declare class MLDocumentType<T extends RuleConfigValue, O extends PlainData = undefined> extends MLNode<T, O, MLASTDoctype> implements DocumentType {
|
|
15
|
+
/**
|
|
16
|
+
* The name of the document type (e.g., `"html"`).
|
|
17
|
+
*/
|
|
8
18
|
readonly name: string;
|
|
19
|
+
/**
|
|
20
|
+
* The public identifier of the document type, or an empty string if not specified.
|
|
21
|
+
*/
|
|
9
22
|
readonly publicId: string;
|
|
23
|
+
/**
|
|
24
|
+
* The system identifier of the document type, or an empty string if not specified.
|
|
25
|
+
*/
|
|
10
26
|
readonly systemId: string;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new MLDocumentType instance.
|
|
29
|
+
*
|
|
30
|
+
* @param astNode - The AST doctype node to wrap
|
|
31
|
+
* @param document - The owning document
|
|
32
|
+
*/
|
|
11
33
|
constructor(astNode: MLASTDoctype, document: MLDocument<T, O>);
|
|
12
34
|
/**
|
|
13
35
|
* Returns a string appropriate for the type of node as `DocumentType`
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { after, before, remove, replaceWith } from '../manipulations/child-node-methods.js';
|
|
2
2
|
import { MLNode } from './node.js';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a DOM DocumentType node wrapper in the markuplint DOM tree.
|
|
5
|
+
* Wraps the `<!DOCTYPE ...>` declaration and implements the standard DOM `DocumentType` interface.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The rule configuration value type
|
|
8
|
+
* @template O - The rule options type
|
|
9
|
+
*/
|
|
3
10
|
export class MLDocumentType extends MLNode {
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new MLDocumentType instance.
|
|
13
|
+
*
|
|
14
|
+
* @param astNode - The AST doctype node to wrap
|
|
15
|
+
* @param document - The owning document
|
|
16
|
+
*/
|
|
4
17
|
constructor(astNode,
|
|
5
18
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
6
19
|
document) {
|
|
@@ -14,6 +14,15 @@ import type { EndTagType, MLASTDocument } from '@markuplint/ml-ast';
|
|
|
14
14
|
import type { PlainData, Pretender, RuleConfigValue } from '@markuplint/ml-config';
|
|
15
15
|
import type { ARIAVersion, MLMLSpec } from '@markuplint/ml-spec';
|
|
16
16
|
import { MLParentNode } from './parent-node.js';
|
|
17
|
+
/**
|
|
18
|
+
* Represents a DOM Document node wrapper in the markuplint DOM tree.
|
|
19
|
+
* Serves as the root node of the parsed document, managing the node list,
|
|
20
|
+
* rule mappings, pretender initialization, accessibility computation,
|
|
21
|
+
* and document-level configuration (end tag handling, booleanish values, etc.).
|
|
22
|
+
*
|
|
23
|
+
* @template T - The rule configuration value type
|
|
24
|
+
* @template O - The rule options type
|
|
25
|
+
*/
|
|
17
26
|
export declare class MLDocument<T extends RuleConfigValue, O extends PlainData = undefined> extends MLParentNode<T, O> implements Document {
|
|
18
27
|
#private;
|
|
19
28
|
/**
|
|
@@ -30,7 +39,9 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
|
|
|
30
39
|
*/
|
|
31
40
|
readonly booleanish: boolean;
|
|
32
41
|
/**
|
|
33
|
-
*
|
|
42
|
+
* The rule currently being evaluated during a lint pass.
|
|
43
|
+
* Set by the linting engine before rule evaluation begins and used by nodes
|
|
44
|
+
* to retrieve their rule configuration. Null when no rule is being evaluated.
|
|
34
45
|
*/
|
|
35
46
|
currentRule: Readonly<MLRule<T, O>> | null;
|
|
36
47
|
/**
|
|
@@ -40,11 +51,13 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
|
|
|
40
51
|
*/
|
|
41
52
|
readonly endTag: EndTagType;
|
|
42
53
|
/**
|
|
43
|
-
*
|
|
54
|
+
* Whether this document represents a fragment rather than a complete document.
|
|
55
|
+
* Fragment documents may lack root-level elements like `<html>`, `<head>`, or `<body>`.
|
|
44
56
|
*/
|
|
45
57
|
readonly isFragment: boolean;
|
|
46
58
|
/**
|
|
47
|
-
*
|
|
59
|
+
* A flat, ordered array of all markuplint DOM nodes in the document,
|
|
60
|
+
* used for sequential traversal and token-level operations.
|
|
48
61
|
*/
|
|
49
62
|
readonly nodeList: ReadonlyArray<MLNode<T, O>>;
|
|
50
63
|
readonly ontouchcancel?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
|
|
@@ -52,9 +65,14 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
|
|
|
52
65
|
readonly ontouchmove?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
|
|
53
66
|
readonly ontouchstart?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
|
|
54
67
|
/**
|
|
55
|
-
*
|
|
68
|
+
* The ML specification data used for element/attribute lookups, ARIA role resolution,
|
|
69
|
+
* and other spec-driven computations.
|
|
56
70
|
*/
|
|
57
71
|
readonly specs: MLMLSpec;
|
|
72
|
+
/**
|
|
73
|
+
* Whether tag name comparisons should be case-sensitive.
|
|
74
|
+
* When false (default for HTML), tag names are compared case-insensitively.
|
|
75
|
+
*/
|
|
58
76
|
readonly tagNameCaseSensitive: boolean;
|
|
59
77
|
/**
|
|
60
78
|
*
|
|
@@ -82,6 +100,14 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
|
|
|
82
100
|
* @implements DOM API: `Document`
|
|
83
101
|
*/
|
|
84
102
|
get activeElement(): Element | null;
|
|
103
|
+
/**
|
|
104
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
105
|
+
*
|
|
106
|
+
* @deprecated
|
|
107
|
+
* @unsupported
|
|
108
|
+
* @implements DOM API: `Document`
|
|
109
|
+
*/
|
|
110
|
+
get activeViewTransition(): ViewTransition | null;
|
|
85
111
|
/**
|
|
86
112
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
87
113
|
*
|
|
@@ -179,6 +205,14 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
|
|
|
179
205
|
* @implements DOM API: `Document`
|
|
180
206
|
*/
|
|
181
207
|
get currentScript(): HTMLOrSVGScriptElement | null;
|
|
208
|
+
/**
|
|
209
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
210
|
+
*
|
|
211
|
+
* @deprecated
|
|
212
|
+
* @unsupported
|
|
213
|
+
* @implements DOM API: `Document`
|
|
214
|
+
*/
|
|
215
|
+
get customElementRegistry(): CustomElementRegistry | null;
|
|
182
216
|
/**
|
|
183
217
|
* Window object for calling the `getComputedStyle` and the `getPropertyValue` that
|
|
184
218
|
* are needed by **Accessible Name and Description Computation**.
|
|
@@ -494,6 +528,14 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
|
|
|
494
528
|
* @implements DOM API: `Document`
|
|
495
529
|
*/
|
|
496
530
|
get onclose(): ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
531
|
+
/**
|
|
532
|
+
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
533
|
+
*
|
|
534
|
+
* @deprecated
|
|
535
|
+
* @unsupported
|
|
536
|
+
* @implements DOM API: `Document`
|
|
537
|
+
*/
|
|
538
|
+
get oncommand(): ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
497
539
|
/**
|
|
498
540
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
499
541
|
*
|
|
@@ -1435,7 +1477,11 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
|
|
|
1435
1477
|
*/
|
|
1436
1478
|
createTreeWalker(root: Node, whatToShow?: number, filter?: NodeFilter | null): TreeWalker;
|
|
1437
1479
|
/**
|
|
1480
|
+
* Returns a debug-friendly string array representing the structure of the document's
|
|
1481
|
+
* node list, useful for debugging and test assertions.
|
|
1482
|
+
*
|
|
1438
1483
|
* @implements `@markuplint/ml-core` API: `MLDocument`
|
|
1484
|
+
* @returns An array of strings describing each node in the document
|
|
1439
1485
|
*/
|
|
1440
1486
|
debugMap(): string[];
|
|
1441
1487
|
/**
|
|
@@ -1488,6 +1534,15 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
|
|
|
1488
1534
|
* @implements DOM API: `Document`
|
|
1489
1535
|
*/
|
|
1490
1536
|
exitPointerLock(): void;
|
|
1537
|
+
/**
|
|
1538
|
+
* Computes the accessibility properties for the given node, including its
|
|
1539
|
+
* ARIA role, accessible name, focusability, and ARIA property values.
|
|
1540
|
+
* Returns null for non-element nodes.
|
|
1541
|
+
*
|
|
1542
|
+
* @param node - The node to compute accessibility properties for
|
|
1543
|
+
* @param ariaVersion - The ARIA specification version to use for computation
|
|
1544
|
+
* @returns The computed accessibility properties, or null for non-element nodes
|
|
1545
|
+
*/
|
|
1491
1546
|
getAccessibilityProp(node: MLNode<T, O>, ariaVersion?: ARIAVersion): AccessibilityProperties | null;
|
|
1492
1547
|
/**
|
|
1493
1548
|
* **IT THROWS AN ERROR WHEN CALLING THIS.**
|
|
@@ -1536,7 +1591,11 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
|
|
|
1536
1591
|
*/
|
|
1537
1592
|
getSelection(): Selection | null;
|
|
1538
1593
|
/**
|
|
1594
|
+
* Returns a flat, offset-sorted list of all tokens in the document,
|
|
1595
|
+
* including element close tags. The result is cached after the first call.
|
|
1596
|
+
*
|
|
1539
1597
|
* @implements `@markuplint/ml-core` API: `MLDocument`
|
|
1598
|
+
* @returns A frozen array of tokens sorted by their starting offset
|
|
1540
1599
|
*/
|
|
1541
1600
|
getTokenList(): readonly MLToken<import("@markuplint/ml-ast").MLASTToken>[];
|
|
1542
1601
|
/**
|
|
@@ -1623,11 +1682,20 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
|
|
|
1623
1682
|
*/
|
|
1624
1683
|
requestStorageAccess(): Promise<void>;
|
|
1625
1684
|
/**
|
|
1685
|
+
* Searches for a node at the given source location (line and column).
|
|
1686
|
+
*
|
|
1626
1687
|
* @implements `@markuplint/ml-core` API: `MLDocument`
|
|
1688
|
+
* @param line - The 1-based line number to search at
|
|
1689
|
+
* @param col - The 1-based column number to search at
|
|
1690
|
+
* @returns The node at the given location, or null if not found
|
|
1627
1691
|
*/
|
|
1628
1692
|
searchNodeByLocation(line: number, col: number): MLNode<T, O, import("@markuplint/ml-ast").MLASTNode> | null;
|
|
1629
1693
|
/**
|
|
1694
|
+
* Sets the currently active rule for this document. Called by the linting engine
|
|
1695
|
+
* before each rule evaluation pass.
|
|
1696
|
+
*
|
|
1630
1697
|
* @implements `@markuplint/ml-core` API: `MLDocument`
|
|
1698
|
+
* @param rule - The rule to set as current, or null to clear
|
|
1631
1699
|
*/
|
|
1632
1700
|
setRule(rule: Readonly<MLRule<T, O>> | null): void;
|
|
1633
1701
|
/**
|
|
@@ -1638,11 +1706,25 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
|
|
|
1638
1706
|
*/
|
|
1639
1707
|
startViewTransition(callbackOptions?: ViewTransitionUpdateCallback): ViewTransition;
|
|
1640
1708
|
/**
|
|
1709
|
+
* Returns a string representation of the entire document. When `fixed` is true,
|
|
1710
|
+
* returns the document with all lint fixes applied by substituting
|
|
1711
|
+
* fixed token content at the appropriate offsets.
|
|
1712
|
+
*
|
|
1641
1713
|
* @implements `@markuplint/ml-core` API: `MLDocument`
|
|
1714
|
+
* @param fixed - When true, returns the fixed content; otherwise returns the original raw content
|
|
1715
|
+
* @returns The string content of the document
|
|
1642
1716
|
*/
|
|
1643
1717
|
toString(fixed?: boolean): string;
|
|
1644
1718
|
/**
|
|
1719
|
+
* Walks the document tree, visiting nodes of the specified type and invoking
|
|
1720
|
+
* the walker callback for each one. Supports walking Element, Text, Comment,
|
|
1721
|
+
* Attr, and ElementCloseTag node types.
|
|
1722
|
+
*
|
|
1645
1723
|
* @implements `@markuplint/ml-core` API: `MLDocument`
|
|
1724
|
+
* @param type - The node type to walk over
|
|
1725
|
+
* @param walker - The callback to invoke for each matching node
|
|
1726
|
+
* @param skipWhenRuleIsDisabled - When true, skips nodes where the current rule is disabled
|
|
1727
|
+
* @returns A promise that resolves when all matching nodes have been visited
|
|
1646
1728
|
*/
|
|
1647
1729
|
walkOn(type: 'Element', walker: Walker<T, O, MLElement<T, O>>, skipWhenRuleIsDisabled?: boolean): Promise<void>;
|
|
1648
1730
|
walkOn(type: 'Text', walker: Walker<T, O, MLText<T, O>>, skipWhenRuleIsDisabled?: boolean): Promise<void>;
|
|
@@ -1663,6 +1745,18 @@ export declare class MLDocument<T extends RuleConfigValue, O extends PlainData =
|
|
|
1663
1745
|
* @implements DOM API: `Document`
|
|
1664
1746
|
*/
|
|
1665
1747
|
writeln(...text: readonly string[]): void;
|
|
1748
|
+
/**
|
|
1749
|
+
* Initializes pretender contexts for all element nodes in the document.
|
|
1750
|
+
*
|
|
1751
|
+
* @param pretenders - Optional pretender configurations from the document options
|
|
1752
|
+
*/
|
|
1666
1753
|
private _pretending;
|
|
1754
|
+
/**
|
|
1755
|
+
* Maps the ruleset configuration to each node in the document.
|
|
1756
|
+
* Applies global rules, node-specific rules (by selector), and
|
|
1757
|
+
* child-node rules to build the per-node rule configuration.
|
|
1758
|
+
*
|
|
1759
|
+
* @param ruleset - The ruleset containing rules, nodeRules, and childNodeRules
|
|
1760
|
+
*/
|
|
1667
1761
|
private _ruleMapping;
|
|
1668
1762
|
}
|