@markuplint/ml-core 3.0.0-alpha.0 → 3.0.0-alpha.2

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.
Files changed (85) hide show
  1. package/lib/ml-core.d.ts +1 -1
  2. package/lib/ml-core.js +12 -7
  3. package/lib/ml-dom/helper/accname.d.ts +2 -1
  4. package/lib/ml-dom/helper/accname.js +51 -2
  5. package/lib/ml-dom/helper/create-node.d.ts +2 -2
  6. package/lib/ml-dom/helper/create-node.js +1 -1
  7. package/lib/ml-dom/helper/debug.js +1 -1
  8. package/lib/ml-dom/helper/getIndent.d.ts +1 -1
  9. package/lib/ml-dom/node/attr.d.ts +5 -5
  10. package/lib/ml-dom/node/attr.js +9 -9
  11. package/lib/ml-dom/node/block.d.ts +1 -1
  12. package/lib/ml-dom/node/character-data.d.ts +2 -2
  13. package/lib/ml-dom/node/document-fragment.d.ts +2 -2
  14. package/lib/ml-dom/node/document-type.d.ts +1 -1
  15. package/lib/ml-dom/node/document.d.ts +28 -19
  16. package/lib/ml-dom/node/document.js +40 -17
  17. package/lib/ml-dom/node/dom-token-list.d.ts +2 -2
  18. package/lib/ml-dom/node/dom-token-list.js +6 -6
  19. package/lib/ml-dom/node/element.d.ts +53 -30
  20. package/lib/ml-dom/node/element.js +203 -50
  21. package/lib/ml-dom/node/node-list.d.ts +1 -1
  22. package/lib/ml-dom/node/node-store.d.ts +3 -3
  23. package/lib/ml-dom/node/node.d.ts +19 -12
  24. package/lib/ml-dom/node/node.js +35 -26
  25. package/lib/ml-dom/node/parent-node.d.ts +2 -2
  26. package/lib/ml-dom/node/types.d.ts +13 -3
  27. package/lib/ml-dom/token/token.d.ts +1 -1
  28. package/lib/ml-rule/ml-rule-context.d.ts +2 -1
  29. package/lib/ml-rule/ml-rule-context.js +19 -2
  30. package/lib/ml-rule/ml-rule.d.ts +4 -4
  31. package/lib/ml-rule/ml-rule.js +4 -4
  32. package/lib/ml-rule/types.d.ts +1 -1
  33. package/lib/test/index.d.ts +2 -1
  34. package/lib/test/index.js +5 -3
  35. package/lib/types.d.ts +3 -2
  36. package/package.json +11 -11
  37. package/tsconfig.tsbuildinfo +1 -1
  38. package/lib/ml-dom/document.d.ts +0 -94
  39. package/lib/ml-dom/document.js +0 -273
  40. package/lib/ml-dom/helper/index.d.ts +0 -4
  41. package/lib/ml-dom/helper/index.js +0 -12
  42. package/lib/ml-dom/helper/mapped-nodes.d.ts +0 -52
  43. package/lib/ml-dom/helper/mapped-nodes.js +0 -2
  44. package/lib/ml-dom/helper/match-selector.d.ts +0 -20
  45. package/lib/ml-dom/helper/match-selector.js +0 -233
  46. package/lib/ml-dom/helper/node-store.d.ts +0 -12
  47. package/lib/ml-dom/helper/node-store.js +0 -28
  48. package/lib/ml-dom/helper/selector.d.ts +0 -11
  49. package/lib/ml-dom/helper/selector.js +0 -549
  50. package/lib/ml-dom/rule-mapper.d.ts +0 -16
  51. package/lib/ml-dom/rule-mapper.js +0 -57
  52. package/lib/ml-dom/tokens/abstract-element.d.ts +0 -54
  53. package/lib/ml-dom/tokens/abstract-element.js +0 -249
  54. package/lib/ml-dom/tokens/attribute.d.ts +0 -42
  55. package/lib/ml-dom/tokens/attribute.js +0 -85
  56. package/lib/ml-dom/tokens/comment.d.ts +0 -12
  57. package/lib/ml-dom/tokens/comment.js +0 -15
  58. package/lib/ml-dom/tokens/doctype.d.ts +0 -18
  59. package/lib/ml-dom/tokens/doctype.js +0 -32
  60. package/lib/ml-dom/tokens/element-close-tag.d.ts +0 -27
  61. package/lib/ml-dom/tokens/element-close-tag.js +0 -45
  62. package/lib/ml-dom/tokens/element.d.ts +0 -26
  63. package/lib/ml-dom/tokens/element.js +0 -66
  64. package/lib/ml-dom/tokens/index.d.ts +0 -10
  65. package/lib/ml-dom/tokens/index.js +0 -26
  66. package/lib/ml-dom/tokens/node.d.ts +0 -46
  67. package/lib/ml-dom/tokens/node.js +0 -126
  68. package/lib/ml-dom/tokens/omitted-element.d.ts +0 -13
  69. package/lib/ml-dom/tokens/omitted-element.js +0 -12
  70. package/lib/ml-dom/tokens/preprocessor-specific-attribute.d.ts +0 -24
  71. package/lib/ml-dom/tokens/preprocessor-specific-attribute.js +0 -37
  72. package/lib/ml-dom/tokens/preprocessor-specific-block.d.ts +0 -14
  73. package/lib/ml-dom/tokens/preprocessor-specific-block.js +0 -16
  74. package/lib/ml-dom/tokens/text.d.ts +0 -19
  75. package/lib/ml-dom/tokens/text.js +0 -26
  76. package/lib/ml-dom/tokens/token.d.ts +0 -16
  77. package/lib/ml-dom/tokens/token.js +0 -55
  78. package/lib/ml-dom/types.d.ts +0 -49
  79. package/lib/ml-dom/types.js +0 -2
  80. package/lib/selector/is-pure-html-element.d.ts +0 -1
  81. package/lib/selector/is-pure-html-element.js +0 -7
  82. package/lib/selector/match-selector.d.ts +0 -14
  83. package/lib/selector/match-selector.js +0 -230
  84. package/lib/selector/selector.d.ts +0 -9
  85. package/lib/selector/selector.js +0 -561
@@ -5,10 +5,10 @@ import type { MLDocument } from './document';
5
5
  import type { MLDocumentFragment } from './document-fragment';
6
6
  import type { MLElement } from './element';
7
7
  import type { MarkuplintPreprocessorBlockType, NodeType, NodeTypeOf } from './types';
8
- import type { MLASTAbstructNode } from '@markuplint/ml-ast';
8
+ import type { MLASTAbstractNode } from '@markuplint/ml-ast';
9
9
  import type { AnyRule, RuleConfigValue } from '@markuplint/ml-config';
10
10
  import { MLToken } from '../token/token';
11
- export declare abstract class MLNode<T extends RuleConfigValue, O = null, A extends MLASTAbstructNode = MLASTAbstructNode> extends MLToken<A> implements Node {
11
+ export declare abstract class MLNode<T extends RuleConfigValue, O = null, A extends MLASTAbstractNode = MLASTAbstractNode> extends MLToken<A> implements Node {
12
12
  #private;
13
13
  /**
14
14
  * @implements DOM API: `Node`
@@ -102,13 +102,17 @@ export declare abstract class MLNode<T extends RuleConfigValue, O = null, A exte
102
102
  * @see https://dom.spec.whatwg.org/#interface-node
103
103
  */
104
104
  readonly PROCESSING_INSTRUCTION_NODE = 7;
105
- readonly rules: Record<string, AnyRule>;
106
105
  /**
107
106
  * @implements DOM API: `Node`
108
107
  * @see https://dom.spec.whatwg.org/#interface-node
109
108
  */
110
109
  readonly TEXT_NODE = 3;
110
+ /**
111
+ *
112
+ */
113
+ readonly rules: Record<string, AnyRule>;
111
114
  protected _astToken: A;
115
+ constructor(astNode: A, document: MLDocument<T, O>);
112
116
  /**
113
117
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
114
118
  *
@@ -250,14 +254,6 @@ export declare abstract class MLNode<T extends RuleConfigValue, O = null, A exte
250
254
  * @see https://dom.spec.whatwg.org/#ref-for-dom-node-parentnode%E2%91%A0
251
255
  */
252
256
  get parentNode(): MLDocument<any, any> | MLDocumentFragment<any, any> | MLElement<T, O> | null;
253
- /**
254
- * **IT THROWS AN ERROR WHEN CALLING THIS.**
255
- *
256
- * @unsupported
257
- * @implements DOM API: `Node`
258
- * @see https://dom.spec.whatwg.org/#ref-for-dom-node-previoussibling%E2%91%A0
259
- */
260
- get previousSibling(): ChildNode | null;
261
257
  /**
262
258
  * @implements `@markuplint/ml-core` API: `MLNode`
263
259
  */
@@ -266,6 +262,14 @@ export declare abstract class MLNode<T extends RuleConfigValue, O = null, A exte
266
262
  * @implements `@markuplint/ml-core` API: `MLNode`
267
263
  */
268
264
  get prevToken(): MLNode<T, O> | null;
265
+ /**
266
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
267
+ *
268
+ * @unsupported
269
+ * @implements DOM API: `Node`
270
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-node-previoussibling%E2%91%A0
271
+ */
272
+ get previousSibling(): ChildNode | null;
269
273
  /**
270
274
  * @implements `@markuplint/ml-core` API: `MLNode`
271
275
  */
@@ -319,7 +323,6 @@ export declare abstract class MLNode<T extends RuleConfigValue, O = null, A exte
319
323
  * @see https://dom.spec.whatwg.org/#dom-node-textcontent
320
324
  */
321
325
  get textContent(): string | null;
322
- constructor(astNode: A, document: MLDocument<T, O>);
323
326
  /**
324
327
  * **IT THROWS AN ERROR WHEN CALLING THIS.**
325
328
  *
@@ -472,4 +475,8 @@ export declare abstract class MLNode<T extends RuleConfigValue, O = null, A exte
472
475
  * @see https://dom.spec.whatwg.org/#dom-node-replacechild
473
476
  */
474
477
  replaceChild<T extends Node>(node: Node, child: T): T;
478
+ /**
479
+ * @implements `@markuplint/ml-core` API: `MLNode`
480
+ */
481
+ resetChildren(childNodes?: NodeListOf<MLChildNode<T, O>>): void;
475
482
  }
@@ -11,21 +11,6 @@ const unexpected_call_error_1 = tslib_1.__importDefault(require("./unexpected-ca
11
11
  class MLNode extends token_1.MLToken {
12
12
  constructor(astNode, document) {
13
13
  super(astNode);
14
- /**
15
- * Cached `childNodes` property
16
- */
17
- _MLNode_childNodes.set(this, void 0);
18
- /**
19
- * Owner `Document`
20
- *
21
- * @implements DOM API: `Node`
22
- * @see https://dom.spec.whatwg.org/#ref-for-dom-node-ownerdocument
23
- */
24
- _MLNode_ownerDocument.set(this, void 0);
25
- /**
26
- * Cached `prevToken` property
27
- */
28
- _MLNode_prevToken.set(this, void 0);
29
14
  /**
30
15
  * @implements DOM API: `Node`
31
16
  * @see https://dom.spec.whatwg.org/#interface-node
@@ -118,12 +103,30 @@ class MLNode extends token_1.MLToken {
118
103
  * @see https://dom.spec.whatwg.org/#interface-node
119
104
  */
120
105
  this.PROCESSING_INSTRUCTION_NODE = 7;
121
- this.rules = {};
122
106
  /**
123
107
  * @implements DOM API: `Node`
124
108
  * @see https://dom.spec.whatwg.org/#interface-node
125
109
  */
126
110
  this.TEXT_NODE = 3;
111
+ /**
112
+ * Cached `childNodes` property
113
+ */
114
+ _MLNode_childNodes.set(this, void 0);
115
+ /**
116
+ * Owner `Document`
117
+ *
118
+ * @implements DOM API: `Node`
119
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-node-ownerdocument
120
+ */
121
+ _MLNode_ownerDocument.set(this, void 0);
122
+ /**
123
+ * Cached `prevToken` property
124
+ */
125
+ _MLNode_prevToken.set(this, void 0);
126
+ /**
127
+ *
128
+ */
129
+ this.rules = {};
127
130
  this._astToken = astNode;
128
131
  tslib_1.__classPrivateFieldSet(this, _MLNode_ownerDocument, document, "f");
129
132
  node_store_1.nodeStore.setNode(astNode, this);
@@ -351,16 +354,6 @@ class MLNode extends token_1.MLToken {
351
354
  }
352
355
  return parentNode;
353
356
  }
354
- /**
355
- * **IT THROWS AN ERROR WHEN CALLING THIS.**
356
- *
357
- * @unsupported
358
- * @implements DOM API: `Node`
359
- * @see https://dom.spec.whatwg.org/#ref-for-dom-node-previoussibling%E2%91%A0
360
- */
361
- get previousSibling() {
362
- throw new unexpected_call_error_1.default('Not supported "previousSibling" property');
363
- }
364
357
  /**
365
358
  * @implements `@markuplint/ml-core` API: `MLNode`
366
359
  */
@@ -398,6 +391,16 @@ class MLNode extends token_1.MLToken {
398
391
  tslib_1.__classPrivateFieldSet(this, _MLNode_prevToken, this.ownerMLDocument.nodeList[index - 1] || null, "f");
399
392
  return tslib_1.__classPrivateFieldGet(this, _MLNode_prevToken, "f") || null;
400
393
  }
394
+ /**
395
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
396
+ *
397
+ * @unsupported
398
+ * @implements DOM API: `Node`
399
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-node-previoussibling%E2%91%A0
400
+ */
401
+ get previousSibling() {
402
+ throw new unexpected_call_error_1.default('Not supported "previousSibling" property');
403
+ }
401
404
  /**
402
405
  * @implements `@markuplint/ml-core` API: `MLNode`
403
406
  */
@@ -661,6 +664,12 @@ class MLNode extends token_1.MLToken {
661
664
  replaceChild(node, child) {
662
665
  throw new unexpected_call_error_1.default('Not supported "removeChild" method');
663
666
  }
667
+ /**
668
+ * @implements `@markuplint/ml-core` API: `MLNode`
669
+ */
670
+ resetChildren(childNodes) {
671
+ tslib_1.__classPrivateFieldSet(this, _MLNode_childNodes, childNodes !== null && childNodes !== void 0 ? childNodes : tslib_1.__classPrivateFieldGet(this, _MLNode_childNodes, "f"), "f");
672
+ }
664
673
  }
665
674
  exports.MLNode = MLNode;
666
675
  _MLNode_childNodes = new WeakMap(), _MLNode_ownerDocument = new WeakMap(), _MLNode_prevToken = new WeakMap();
@@ -1,12 +1,12 @@
1
1
  import type { MLElement } from './element';
2
- import type { MLASTAbstructNode } from '@markuplint/ml-ast';
2
+ import type { MLASTAbstractNode } from '@markuplint/ml-ast';
3
3
  import type { RuleConfigValue } from '@markuplint/ml-config';
4
4
  import { MLNode } from './node';
5
5
  /**
6
6
  *
7
7
  * @see https://dom.spec.whatwg.org/#interface-parentnode
8
8
  */
9
- export declare abstract class MLParentNode<T extends RuleConfigValue, O = null, A extends MLASTAbstructNode = MLASTAbstructNode> extends MLNode<T, O, A> implements ParentNode {
9
+ export declare abstract class MLParentNode<T extends RuleConfigValue, O = null, A extends MLASTAbstractNode = MLASTAbstractNode> extends MLNode<T, O, A> implements ParentNode {
10
10
  #private;
11
11
  /**
12
12
  * @implements DOM API: `Element`, `Document`, `DocumentFragment`
@@ -8,9 +8,9 @@ import type { MLDocumentType } from './document-type';
8
8
  import type { MLElement } from './element';
9
9
  import type { MLNode } from './node';
10
10
  import type { MLText } from './text';
11
- import type { MLASTAbstructNode, MLASTAttr, MLASTComment, MLASTDoctype, MLASTElement, MLASTParentNode, MLASTPreprocessorSpecificBlock, MLASTText, MLToken as MLASTToken } from '@markuplint/ml-ast/';
12
- import type { RuleConfigValue } from '@markuplint/ml-config';
13
- export declare type MappedNode<N, T extends RuleConfigValue, O = null> = 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 MLASTAbstructNode ? MLNode<T, O, MLASTAbstructNode> : N extends MLASTAttr ? MLAttr<T, O> : N extends MLASTToken ? MLToken : never;
11
+ import type { MLASTAbstractNode, MLASTAttr, MLASTComment, MLASTDoctype, MLASTElement, MLASTParentNode, MLASTPreprocessorSpecificBlock, MLASTText, MLToken as MLASTToken } from '@markuplint/ml-ast/';
12
+ import type { PretenderARIA, RuleConfigValue } from '@markuplint/ml-config';
13
+ export declare type MappedNode<N, T extends RuleConfigValue, O = null> = 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
14
  export declare type NodeTypeOf<NT extends NodeType, T extends RuleConfigValue, O = null> = 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;
15
15
  export declare type ElementNodeType = 1;
16
16
  export declare type AttributeNodeType = 2;
@@ -23,3 +23,13 @@ export declare type DocumentTypeNodeType = 10;
23
23
  export declare type DocumentFragmentNodeType = 11;
24
24
  export declare type MarkuplintPreprocessorBlockType = 101;
25
25
  export declare type NodeType = ElementNodeType | AttributeNodeType | TextNodeType | CDATASectionNodeType | ProcessingInstructionNodeType | CommentNodeType | DocumentNodeType | DocumentTypeNodeType | DocumentFragmentNodeType | MarkuplintPreprocessorBlockType;
26
+ export declare type PretenderContext<N extends MLElement<T, O>, T extends RuleConfigValue, O = null> = PretenderContextPretender<N, T, O> | PretenderContextPretended<N, T, O>;
27
+ export declare type PretenderContextPretender<N extends MLElement<T, O>, T extends RuleConfigValue, O = null> = {
28
+ readonly type: 'pretender';
29
+ readonly as: N;
30
+ readonly aria?: PretenderARIA;
31
+ };
32
+ export declare type PretenderContextPretended<N extends MLElement<T, O>, T extends RuleConfigValue, O = null> = {
33
+ readonly type: 'origin';
34
+ readonly origin: N;
35
+ };
@@ -3,6 +3,7 @@ export declare class MLToken<A extends MLASTToken = MLASTToken> {
3
3
  #private;
4
4
  readonly uuid: string;
5
5
  protected readonly _astToken: A;
6
+ constructor(astToken: A);
6
7
  /**
7
8
  * @implements `@markuplint/ml-core` API: `MLDOMToken`
8
9
  */
@@ -35,7 +36,6 @@ export declare class MLToken<A extends MLASTToken = MLASTToken> {
35
36
  * @implements `@markuplint/ml-core` API: `MLDOMToken`
36
37
  */
37
38
  get startOffset(): number;
38
- constructor(astToken: A);
39
39
  /**
40
40
  * @implements `@markuplint/ml-core` API: `MLDOMToken`
41
41
  */
@@ -7,6 +7,7 @@ export declare class MLRuleContext<T extends RuleConfigValue, O = null> {
7
7
  readonly document: MLDocument<T, O>;
8
8
  readonly locale: string;
9
9
  readonly translate: Translator;
10
+ constructor(document: MLDocument<T, O>, locale: LocaleSet);
10
11
  get reports(): ({
11
12
  message: string;
12
13
  line: number;
@@ -22,7 +23,6 @@ export declare class MLRuleContext<T extends RuleConfigValue, O = null> {
22
23
  col: number;
23
24
  raw: string;
24
25
  })[];
25
- constructor(document: MLDocument<T, O>, locale: LocaleSet);
26
26
  provide(): {
27
27
  document: MLDocument<T, O>;
28
28
  translate: Translator;
@@ -49,4 +49,5 @@ export declare class MLRuleContext<T extends RuleConfigValue, O = null> {
49
49
  };
50
50
  report(report: Report<T, O>): undefined;
51
51
  report(report: CheckerReport<T, O>): boolean;
52
+ private _push;
52
53
  }
@@ -30,12 +30,17 @@ class MLRuleContext {
30
30
  if (typeof report === 'function') {
31
31
  const r = report(this.translate);
32
32
  if (r) {
33
- tslib_1.__classPrivateFieldGet(this, _MLRuleContext_reports, "f").push(r);
33
+ this._push(r);
34
34
  return true;
35
35
  }
36
36
  return false;
37
37
  }
38
- tslib_1.__classPrivateFieldGet(this, _MLRuleContext_reports, "f").push(report);
38
+ this._push(report);
39
+ }
40
+ _push(report) {
41
+ if (!tslib_1.__classPrivateFieldGet(this, _MLRuleContext_reports, "f").find(r => is(r, report))) {
42
+ tslib_1.__classPrivateFieldGet(this, _MLRuleContext_reports, "f").push(report);
43
+ }
39
44
  }
40
45
  }
41
46
  exports.MLRuleContext = MLRuleContext;
@@ -48,3 +53,15 @@ function finish(message, locale = 'en') {
48
53
  }
49
54
  return message;
50
55
  }
56
+ function is(r1, r2) {
57
+ if ('col' in r1 && 'col' in r2) {
58
+ return r1.col === r2.col && r1.line === r2.line && r1.message === r2.message && r1.raw === r2.raw;
59
+ }
60
+ if ('scope' in r1) {
61
+ if (!('scope' in r2)) {
62
+ return false;
63
+ }
64
+ return r1.scope === r2.scope && r1.message === r2.message;
65
+ }
66
+ return false;
67
+ }
@@ -6,9 +6,12 @@ import type { GlobalRuleInfo, RuleConfig, RuleConfigValue, RuleInfo, Severity, V
6
6
  export declare class MLRule<T extends RuleConfigValue, O = null> {
7
7
  #private;
8
8
  readonly defaultOptions: O;
9
- readonly defaultServerity: Severity;
9
+ readonly defaultSeverity: Severity;
10
10
  readonly defaultValue: T;
11
11
  readonly name: string;
12
+ constructor(o: RuleSeed<T, O> & {
13
+ name: string;
14
+ });
12
15
  /**
13
16
  * The following getter is unused internally,
14
17
  * only for extending from 3rd party library
@@ -19,9 +22,6 @@ export declare class MLRule<T extends RuleConfigValue, O = null> {
19
22
  * only for extending from 3rd party library
20
23
  */
21
24
  protected get v(): RuleSeed<T, O>['verify'];
22
- constructor(o: RuleSeed<T, O> & {
23
- name: string;
24
- });
25
25
  getRuleInfo(ruleSet: Ruleset, ruleName: string): GlobalRuleInfo<T, O>;
26
26
  optimizeOption(configSettings: T | RuleConfig<T, O> | undefined): RuleInfo<T, O>;
27
27
  verify(document: MLDocument<T, O>, locale: LocaleSet, fix: boolean): Promise<Violation[]>;
@@ -10,7 +10,7 @@ class MLRule {
10
10
  _MLRule_f.set(this, void 0);
11
11
  _MLRule_v.set(this, void 0);
12
12
  this.name = o.name;
13
- this.defaultServerity = o.defaultServerity || 'error';
13
+ this.defaultSeverity = o.defaultSeverity || 'error';
14
14
  this.defaultValue = (_a = o.defaultValue) !== null && _a !== void 0 ? _a : true;
15
15
  this.defaultOptions = (_b = o.defaultOptions) !== null && _b !== void 0 ? _b : null;
16
16
  tslib_1.__classPrivateFieldSet(this, _MLRule_v, o.verify, "f");
@@ -42,7 +42,7 @@ class MLRule {
42
42
  if (configSettings === undefined || typeof configSettings === 'boolean') {
43
43
  return {
44
44
  disabled: !configSettings,
45
- severity: this.defaultServerity,
45
+ severity: this.defaultSeverity,
46
46
  value: this.defaultValue,
47
47
  option: this.defaultOptions,
48
48
  reason: undefined,
@@ -51,7 +51,7 @@ class MLRule {
51
51
  if (!Array.isArray(configSettings) && typeof configSettings === 'object' && configSettings !== null) {
52
52
  return {
53
53
  disabled: false,
54
- severity: configSettings.severity || this.defaultServerity,
54
+ severity: configSettings.severity || this.defaultSeverity,
55
55
  value: configSettings.value !== undefined ? configSettings.value : this.defaultValue,
56
56
  option: Array.isArray(this.defaultOptions)
57
57
  ? configSettings.option
@@ -70,7 +70,7 @@ class MLRule {
70
70
  }
71
71
  return {
72
72
  disabled: false,
73
- severity: this.defaultServerity,
73
+ severity: this.defaultSeverity,
74
74
  // @ts-ignore TODO: Wait for fix to bug of type guards in TypeScript
75
75
  value: configSettings == null ? this.defaultValue : configSettings,
76
76
  option: this.defaultOptions,
@@ -3,7 +3,7 @@ import type { MLRuleContext } from './ml-rule-context';
3
3
  import type { Translator } from '@markuplint/i18n';
4
4
  import type { Report, RuleConfigValue, Severity } from '@markuplint/ml-config';
5
5
  export declare type RuleSeed<T extends RuleConfigValue = boolean, O = null> = {
6
- defaultServerity?: Severity;
6
+ defaultSeverity?: Severity;
7
7
  defaultValue?: T;
8
8
  defaultOptions?: O;
9
9
  verify(context: ReturnType<MLRuleContext<T, O>['provide']>): void | Promise<void>;
@@ -5,9 +5,10 @@ import { Document } from '../ml-dom';
5
5
  export declare type CreateTestOptions = {
6
6
  config?: Config;
7
7
  parser?: MLMarkupLanguageParser;
8
+ specs?: MLMLSpec;
8
9
  };
9
10
  export declare function createTestDocument<T extends RuleConfigValue = any, O = any>(sourceCode: string, options?: CreateTestOptions): Document<T, O>;
10
- export declare function createTestNodeList(sourceCode: string, options?: CreateTestOptions): readonly import("../ml-dom/node/node").MLNode<any, any, import("@markuplint/ml-ast").MLASTAbstructNode>[];
11
+ export declare function createTestNodeList(sourceCode: string, options?: CreateTestOptions): readonly import("../ml-dom/node/node").MLNode<any, any, import("@markuplint/ml-ast").MLASTAbstractNode>[];
11
12
  export declare function createTestTokenList(sourceCode: string, options?: CreateTestOptions): readonly import("../ml-dom/token/token").MLToken<import("@markuplint/ml-ast").MLToken>[];
12
13
  export declare function createTestElement(sourceCode: string, options?: CreateTestOptions): import("../ml-dom").Element<any, any>;
13
14
  /**
package/lib/test/index.js CHANGED
@@ -1,13 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.dummySchemas = exports.createTestElement = exports.createTestTokenList = exports.createTestNodeList = exports.createTestDocument = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const html_parser_1 = require("@markuplint/html-parser");
6
+ const html_spec_1 = tslib_1.__importDefault(require("@markuplint/html-spec"));
5
7
  const convert_ruleset_1 = require("../convert-ruleset");
6
8
  const ml_dom_1 = require("../ml-dom");
7
9
  function createTestDocument(sourceCode, options) {
10
+ var _a;
8
11
  const ast = (options === null || options === void 0 ? void 0 : options.parser) ? options.parser.parse(sourceCode) : (0, html_parser_1.parse)(sourceCode);
9
12
  const ruleset = (0, convert_ruleset_1.convertRuleset)(options === null || options === void 0 ? void 0 : options.config);
10
- const document = new ml_dom_1.Document(ast, ruleset, [{}, {}]);
13
+ const document = new ml_dom_1.Document(ast, ruleset, [(_a = options === null || options === void 0 ? void 0 : options.specs) !== null && _a !== void 0 ? _a : {}, {}]);
11
14
  return document;
12
15
  }
13
16
  exports.createTestDocument = createTestDocument;
@@ -34,7 +37,6 @@ exports.createTestElement = createTestElement;
34
37
  * for test suite
35
38
  */
36
39
  function dummySchemas() {
37
- // @ts-ignore
38
- return [{}, {}];
40
+ return [html_spec_1.default];
39
41
  }
40
42
  exports.dummySchemas = dummySchemas;
package/lib/types.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import type { AnyMLRule } from './ml-rule';
2
2
  import type Ruleset from './ruleset';
3
3
  import type { LocaleSet } from '@markuplint/i18n';
4
- import type { MLMarkupLanguageParser } from '@markuplint/ml-ast';
5
- import type { ParserOptions } from '@markuplint/ml-config';
4
+ import type { MLMarkupLanguageParser, ParserOptions } from '@markuplint/ml-ast';
5
+ import type { Pretender } from '@markuplint/ml-config';
6
6
  import type { ExtendedSpec, MLMLSpec } from '@markuplint/ml-spec';
7
7
  export declare type MLSchema = Readonly<[MLMLSpec, ...ExtendedSpec[]]>;
8
8
  export declare type MLFabric = {
@@ -12,4 +12,5 @@ export declare type MLFabric = {
12
12
  locale: LocaleSet;
13
13
  schemas: MLSchema;
14
14
  parserOptions: ParserOptions;
15
+ pretenders: Pretender[];
15
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/ml-core",
3
- "version": "3.0.0-alpha.0",
3
+ "version": "3.0.0-alpha.2",
4
4
  "description": "The core module of markuplint",
5
5
  "repository": "git@github.com:markuplint/markuplint.git",
6
6
  "author": "Yusuke Hirao <yusukehirao@me.com>",
@@ -17,20 +17,20 @@
17
17
  "clean": "tsc --build --clean"
18
18
  },
19
19
  "dependencies": {
20
- "@markuplint/config-presets": "3.0.0-alpha.0",
21
- "@markuplint/i18n": "3.0.0-alpha.0",
22
- "@markuplint/ml-ast": "3.0.0-alpha.0",
23
- "@markuplint/ml-config": "3.0.0-alpha.0",
24
- "@markuplint/ml-spec": "3.0.0-alpha.0",
25
- "@markuplint/parser-utils": "3.0.0-alpha.0",
26
- "@markuplint/selector": "3.0.0-alpha.0",
20
+ "@markuplint/config-presets": "3.0.0-alpha.2",
21
+ "@markuplint/i18n": "3.0.0-alpha.2",
22
+ "@markuplint/ml-ast": "3.0.0-alpha.2",
23
+ "@markuplint/ml-config": "3.0.0-alpha.2",
24
+ "@markuplint/ml-spec": "3.0.0-alpha.2",
25
+ "@markuplint/parser-utils": "3.0.0-alpha.2",
26
+ "@markuplint/selector": "3.0.0-alpha.2",
27
27
  "debug": "^4.3.4",
28
28
  "postcss-selector-parser": "^6.0.10",
29
- "tslib": "^2.3.1"
29
+ "tslib": "^2.4.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@markuplint/html-parser": "3.0.0-alpha.0",
32
+ "@markuplint/html-parser": "3.0.0-alpha.2",
33
33
  "@types/debug": "^4.1.7"
34
34
  },
35
- "gitHead": "d32c522e016888e20bcbb5f09352c006b964f193"
35
+ "gitHead": "830bf8187b81bf5ca2f5f09b6f85a98395a58bdb"
36
36
  }