@markuplint/ml-core 2.3.3 → 3.0.0-alpha.1

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 (113) hide show
  1. package/lib/configs.d.ts +1 -1
  2. package/lib/configs.js +29 -9
  3. package/lib/index.d.ts +8 -8
  4. package/lib/index.js +18 -10
  5. package/lib/ml-core.d.ts +3 -3
  6. package/lib/ml-core.js +48 -44
  7. package/lib/ml-dom/helper/accname.d.ts +3 -2
  8. package/lib/ml-dom/helper/accname.js +53 -5
  9. package/lib/ml-dom/helper/create-node.d.ts +4 -5
  10. package/lib/ml-dom/helper/create-node.js +12 -16
  11. package/lib/ml-dom/helper/debug.d.ts +2 -2
  12. package/lib/ml-dom/helper/debug.js +35 -21
  13. package/lib/ml-dom/helper/getIndent.d.ts +5 -5
  14. package/lib/ml-dom/helper/getIndent.js +14 -14
  15. package/lib/ml-dom/helper/walkers.d.ts +5 -4
  16. package/lib/ml-dom/helper/walkers.js +39 -3
  17. package/lib/ml-dom/index.d.ts +8 -3
  18. package/lib/ml-dom/index.js +3 -15
  19. package/lib/ml-dom/manipulations/child-node-methods.d.ts +33 -0
  20. package/lib/ml-dom/manipulations/child-node-methods.js +73 -0
  21. package/lib/ml-dom/manipulations/get-children.d.ts +4 -0
  22. package/lib/ml-dom/manipulations/get-children.js +10 -0
  23. package/lib/ml-dom/node/attr.d.ts +98 -0
  24. package/lib/ml-dom/node/attr.js +157 -0
  25. package/lib/ml-dom/node/block.d.ts +38 -0
  26. package/lib/ml-dom/node/block.js +53 -0
  27. package/lib/ml-dom/node/character-data.d.ts +57 -0
  28. package/lib/ml-dom/node/character-data.js +87 -0
  29. package/lib/ml-dom/node/child-node.d.ts +9 -0
  30. package/lib/ml-dom/node/child-node.js +10 -0
  31. package/lib/ml-dom/node/comment.d.ts +17 -0
  32. package/lib/ml-dom/node/comment.js +24 -0
  33. package/lib/ml-dom/node/document-fragment.d.ts +24 -0
  34. package/lib/ml-dom/node/document-fragment.js +33 -0
  35. package/lib/ml-dom/node/document-type.d.ts +38 -0
  36. package/lib/ml-dom/node/document-type.js +52 -0
  37. package/lib/ml-dom/node/document.d.ts +1563 -0
  38. package/lib/ml-dom/node/document.js +2140 -0
  39. package/lib/ml-dom/node/dom-token-list.d.ts +33 -0
  40. package/lib/ml-dom/node/dom-token-list.js +137 -0
  41. package/lib/ml-dom/node/element.d.ts +1844 -0
  42. package/lib/ml-dom/node/element.js +2601 -0
  43. package/lib/ml-dom/node/named-node-map.d.ts +42 -0
  44. package/lib/ml-dom/node/named-node-map.js +64 -0
  45. package/lib/ml-dom/node/node-list.d.ts +6 -0
  46. package/lib/ml-dom/node/node-list.js +39 -0
  47. package/lib/ml-dom/node/node-store.d.ts +14 -0
  48. package/lib/ml-dom/{helper → node}/node-store.js +8 -4
  49. package/lib/ml-dom/node/node.d.ts +482 -0
  50. package/lib/ml-dom/node/node.js +675 -0
  51. package/lib/ml-dom/node/parent-node.d.ts +66 -0
  52. package/lib/ml-dom/node/parent-node.js +131 -0
  53. package/lib/ml-dom/node/rule-mapper.d.ts +17 -0
  54. package/lib/ml-dom/{rule-mapper.js → node/rule-mapper.js} +20 -28
  55. package/lib/ml-dom/node/text.d.ts +51 -0
  56. package/lib/ml-dom/node/text.js +76 -0
  57. package/lib/ml-dom/node/types.d.ts +35 -0
  58. package/lib/ml-dom/{types.js → node/types.js} +0 -0
  59. package/lib/ml-dom/node/unexpected-call-error.d.ts +2 -0
  60. package/lib/ml-dom/node/unexpected-call-error.js +5 -0
  61. package/lib/ml-dom/token/token.d.ts +47 -0
  62. package/lib/ml-dom/token/token.js +89 -0
  63. package/lib/ml-rule/ml-rule-context.d.ts +14 -10
  64. package/lib/ml-rule/ml-rule-context.js +29 -6
  65. package/lib/ml-rule/ml-rule.d.ts +12 -12
  66. package/lib/ml-rule/ml-rule.js +63 -63
  67. package/lib/ml-rule/types.d.ts +12 -2
  68. package/lib/ruleset/index.d.ts +2 -2
  69. package/lib/test/index.d.ts +3 -1
  70. package/lib/test/index.js +12 -5
  71. package/lib/types.d.ts +3 -2
  72. package/package.json +11 -10
  73. package/tsconfig.tsbuildinfo +1 -1
  74. package/lib/ml-dom/document.d.ts +0 -85
  75. package/lib/ml-dom/document.js +0 -273
  76. package/lib/ml-dom/helper/index.d.ts +0 -4
  77. package/lib/ml-dom/helper/index.js +0 -12
  78. package/lib/ml-dom/helper/mapped-nodes.d.ts +0 -4
  79. package/lib/ml-dom/helper/mapped-nodes.js +0 -2
  80. package/lib/ml-dom/helper/match-selector.d.ts +0 -16
  81. package/lib/ml-dom/helper/match-selector.js +0 -233
  82. package/lib/ml-dom/helper/node-store.d.ts +0 -9
  83. package/lib/ml-dom/helper/selector.d.ts +0 -11
  84. package/lib/ml-dom/helper/selector.js +0 -549
  85. package/lib/ml-dom/rule-mapper.d.ts +0 -16
  86. package/lib/ml-dom/tokens/abstract-element.d.ts +0 -49
  87. package/lib/ml-dom/tokens/abstract-element.js +0 -249
  88. package/lib/ml-dom/tokens/attribute.d.ts +0 -42
  89. package/lib/ml-dom/tokens/attribute.js +0 -85
  90. package/lib/ml-dom/tokens/comment.d.ts +0 -9
  91. package/lib/ml-dom/tokens/comment.js +0 -15
  92. package/lib/ml-dom/tokens/doctype.d.ts +0 -15
  93. package/lib/ml-dom/tokens/doctype.js +0 -32
  94. package/lib/ml-dom/tokens/element-close-tag.d.ts +0 -24
  95. package/lib/ml-dom/tokens/element-close-tag.js +0 -45
  96. package/lib/ml-dom/tokens/element.d.ts +0 -23
  97. package/lib/ml-dom/tokens/element.js +0 -66
  98. package/lib/ml-dom/tokens/index.d.ts +0 -10
  99. package/lib/ml-dom/tokens/index.js +0 -26
  100. package/lib/ml-dom/tokens/node.d.ts +0 -39
  101. package/lib/ml-dom/tokens/node.js +0 -126
  102. package/lib/ml-dom/tokens/omitted-element.d.ts +0 -10
  103. package/lib/ml-dom/tokens/omitted-element.js +0 -12
  104. package/lib/ml-dom/tokens/preprocessor-specific-attribute.d.ts +0 -24
  105. package/lib/ml-dom/tokens/preprocessor-specific-attribute.js +0 -37
  106. package/lib/ml-dom/tokens/preprocessor-specific-block.d.ts +0 -11
  107. package/lib/ml-dom/tokens/preprocessor-specific-block.js +0 -16
  108. package/lib/ml-dom/tokens/text.d.ts +0 -15
  109. package/lib/ml-dom/tokens/text.js +0 -26
  110. package/lib/ml-dom/tokens/token.d.ts +0 -16
  111. package/lib/ml-dom/tokens/token.js +0 -55
  112. package/lib/ml-dom/types.d.ts +0 -27
  113. package/markuplint-recommended.json +0 -196
@@ -5,10 +5,9 @@ exports.MLRuleContext = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  const i18n_1 = require("@markuplint/i18n");
7
7
  class MLRuleContext {
8
- constructor(document, locale, rule) {
8
+ constructor(document, locale) {
9
9
  _MLRuleContext_reports.set(this, []);
10
10
  this.document = document;
11
- this.globalRule = rule;
12
11
  this.translate = (0, i18n_1.translator)(locale);
13
12
  this.locale = locale.locale;
14
13
  }
@@ -18,19 +17,31 @@ class MLRuleContext {
18
17
  message: finish(report.message),
19
18
  }));
20
19
  }
21
- report(report) {
22
- tslib_1.__classPrivateFieldGet(this, _MLRuleContext_reports, "f").push(report);
23
- }
24
20
  provide() {
25
21
  return {
26
22
  document: this.document,
27
23
  translate: this.translate,
28
24
  t: this.translate,
29
- globalRule: this.globalRule,
30
25
  reports: this.reports,
31
26
  report: this.report.bind(this),
32
27
  };
33
28
  }
29
+ report(report) {
30
+ if (typeof report === 'function') {
31
+ const r = report(this.translate);
32
+ if (r) {
33
+ this._push(r);
34
+ return true;
35
+ }
36
+ return false;
37
+ }
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
+ }
44
+ }
34
45
  }
35
46
  exports.MLRuleContext = MLRuleContext;
36
47
  _MLRuleContext_reports = new WeakMap();
@@ -42,3 +53,15 @@ function finish(message, locale = 'en') {
42
53
  }
43
54
  return message;
44
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
+ }
@@ -1,30 +1,30 @@
1
1
  import type { Ruleset } from '..';
2
- import type Document from '../ml-dom/document';
2
+ import type { MLDocument } from '../ml-dom/node/document';
3
3
  import type { RuleSeed } from './types';
4
4
  import type { LocaleSet } from '@markuplint/i18n';
5
- import type { GlobalRuleInfo, RuleConfig, RuleConfigValue, RuleInfo, Rules, Severity, Violation } from '@markuplint/ml-config';
5
+ import type { GlobalRuleInfo, RuleConfig, RuleConfigValue, RuleInfo, Severity, Violation } from '@markuplint/ml-config';
6
6
  export declare class MLRule<T extends RuleConfigValue, O = null> {
7
7
  #private;
8
- readonly name: string;
9
- readonly defaultServerity: Severity;
10
- readonly defaultValue: T;
11
8
  readonly defaultOptions: O;
9
+ readonly defaultSeverity: Severity;
10
+ readonly defaultValue: T;
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
15
18
  */
16
- protected get v(): RuleSeed<T, O>['verify'];
19
+ protected get f(): RuleSeed<T, O>['fix'];
17
20
  /**
18
21
  * The following getter is unused internally,
19
22
  * only for extending from 3rd party library
20
23
  */
21
- protected get f(): RuleSeed<T, O>['fix'];
22
- constructor(o: RuleSeed<T, O> & {
23
- name: string;
24
- });
25
- verify(document: Document<T, O>, locale: LocaleSet, globalRule: RuleInfo<T, O>, fix: boolean): Promise<Violation[]>;
24
+ protected get v(): RuleSeed<T, O>['verify'];
26
25
  getRuleInfo(ruleSet: Ruleset, ruleName: string): GlobalRuleInfo<T, O>;
27
- _optimize(rules: Rules | undefined, ruleName: string): RuleInfo<T, O>;
28
26
  optimizeOption(configSettings: T | RuleConfig<T, O> | undefined): RuleInfo<T, O>;
27
+ verify(document: MLDocument<T, O>, locale: LocaleSet, fix: boolean): Promise<Violation[]>;
28
+ private _optimize;
29
29
  }
30
30
  export declare type AnyMLRule = MLRule<RuleConfigValue, unknown>;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- var _MLRule_v, _MLRule_f;
2
+ var _MLRule_f, _MLRule_v;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.MLRule = void 0;
5
5
  const tslib_1 = require("tslib");
@@ -7,10 +7,10 @@ const ml_rule_context_1 = require("./ml-rule-context");
7
7
  class MLRule {
8
8
  constructor(o) {
9
9
  var _a, _b;
10
- _MLRule_v.set(this, void 0);
11
10
  _MLRule_f.set(this, void 0);
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");
@@ -20,22 +20,69 @@ class MLRule {
20
20
  * The following getter is unused internally,
21
21
  * only for extending from 3rd party library
22
22
  */
23
- get v() {
24
- return tslib_1.__classPrivateFieldGet(this, _MLRule_v, "f");
23
+ get f() {
24
+ return tslib_1.__classPrivateFieldGet(this, _MLRule_f, "f");
25
25
  }
26
26
  /**
27
27
  * The following getter is unused internally,
28
28
  * only for extending from 3rd party library
29
29
  */
30
- get f() {
31
- return tslib_1.__classPrivateFieldGet(this, _MLRule_f, "f");
30
+ get v() {
31
+ return tslib_1.__classPrivateFieldGet(this, _MLRule_v, "f");
32
+ }
33
+ getRuleInfo(ruleSet, ruleName) {
34
+ const info = this._optimize(ruleSet.rules, ruleName);
35
+ return {
36
+ ...info,
37
+ nodeRules: ruleSet.nodeRules.map(r => this._optimize(r.rules, ruleName)).filter(r => !r.disabled),
38
+ childNodeRules: ruleSet.childNodeRules.map(r => this._optimize(r.rules, ruleName)).filter(r => !r.disabled),
39
+ };
40
+ }
41
+ optimizeOption(configSettings) {
42
+ if (configSettings === undefined || typeof configSettings === 'boolean') {
43
+ return {
44
+ disabled: !configSettings,
45
+ severity: this.defaultSeverity,
46
+ value: this.defaultValue,
47
+ option: this.defaultOptions,
48
+ reason: undefined,
49
+ };
50
+ }
51
+ if (!Array.isArray(configSettings) && typeof configSettings === 'object' && configSettings !== null) {
52
+ return {
53
+ disabled: false,
54
+ severity: configSettings.severity || this.defaultSeverity,
55
+ value: configSettings.value !== undefined ? configSettings.value : this.defaultValue,
56
+ option: Array.isArray(this.defaultOptions)
57
+ ? configSettings.option
58
+ ? // prettier-ignore
59
+ // @ts-ignore for "as" casting
60
+ this.defaultOptions.concat(configSettings.option)
61
+ : this.defaultOptions
62
+ : this.defaultOptions !== null &&
63
+ typeof this.defaultOptions === 'object' &&
64
+ // for example `configSettings.option === true`
65
+ (configSettings.option == null || typeof configSettings.option === 'object')
66
+ ? { ...this.defaultOptions, ...(configSettings.option || {}) }
67
+ : configSettings.option || this.defaultOptions,
68
+ reason: configSettings.reason,
69
+ };
70
+ }
71
+ return {
72
+ disabled: false,
73
+ severity: this.defaultSeverity,
74
+ // @ts-ignore TODO: Wait for fix to bug of type guards in TypeScript
75
+ value: configSettings == null ? this.defaultValue : configSettings,
76
+ option: this.defaultOptions,
77
+ reason: undefined,
78
+ };
32
79
  }
33
- async verify(document, locale, globalRule, fix) {
80
+ async verify(document, locale, fix) {
34
81
  if (!tslib_1.__classPrivateFieldGet(this, _MLRule_v, "f")) {
35
82
  return [];
36
83
  }
37
84
  document.setRule(this);
38
- const context = new ml_rule_context_1.MLRuleContext(document, locale, globalRule);
85
+ const context = new ml_rule_context_1.MLRuleContext(document, locale);
39
86
  const providableContext = context.provide();
40
87
  await tslib_1.__classPrivateFieldGet(this, _MLRule_v, "f").call(this, providableContext);
41
88
  if (tslib_1.__classPrivateFieldGet(this, _MLRule_f, "f") && fix) {
@@ -46,7 +93,7 @@ class MLRule {
46
93
  let line = report.scope.startLine;
47
94
  let col = report.scope.startCol;
48
95
  let raw = report.scope.raw;
49
- if ('line' in report) {
96
+ if ('line' in report && report.line != null) {
50
97
  line = report.line;
51
98
  col = report.col;
52
99
  raw = report.raw;
@@ -59,79 +106,32 @@ class MLRule {
59
106
  raw,
60
107
  ruleId: this.name,
61
108
  };
62
- if (report.scope.rule.reason || globalRule.reason) {
63
- violation.reason = report.scope.rule.reason || globalRule.reason;
109
+ if (report.scope.rule.reason || document.rule.reason) {
110
+ violation.reason = report.scope.rule.reason || document.rule.reason;
64
111
  }
65
112
  return violation;
66
113
  }
67
114
  const violation = {
68
- severity: globalRule.severity,
115
+ severity: document.rule.severity,
69
116
  message: report.message,
70
117
  line: report.line,
71
118
  col: report.col,
72
119
  raw: report.raw,
73
120
  ruleId: this.name,
74
121
  };
75
- if (globalRule.reason) {
76
- violation.reason = globalRule.reason;
122
+ if (document.rule.reason) {
123
+ violation.reason = document.rule.reason;
77
124
  }
78
125
  return violation;
79
126
  });
80
127
  document.setRule(null);
81
128
  return violation;
82
129
  }
83
- getRuleInfo(ruleSet, ruleName) {
84
- const info = this._optimize(ruleSet.rules, ruleName);
85
- return {
86
- ...info,
87
- nodeRules: ruleSet.nodeRules.map(r => this._optimize(r.rules, ruleName)).filter(r => !r.disabled),
88
- childNodeRules: ruleSet.childNodeRules.map(r => this._optimize(r.rules, ruleName)).filter(r => !r.disabled),
89
- };
90
- }
91
130
  _optimize(rules, ruleName) {
92
131
  const rule = (rules && rules[ruleName]) || false;
93
132
  const info = this.optimizeOption(rule);
94
133
  return info;
95
134
  }
96
- optimizeOption(configSettings) {
97
- if (configSettings === undefined || typeof configSettings === 'boolean') {
98
- return {
99
- disabled: !configSettings,
100
- severity: this.defaultServerity,
101
- value: this.defaultValue,
102
- option: this.defaultOptions,
103
- reason: undefined,
104
- };
105
- }
106
- if (!Array.isArray(configSettings) && typeof configSettings === 'object' && configSettings !== null) {
107
- return {
108
- disabled: false,
109
- severity: configSettings.severity || this.defaultServerity,
110
- value: configSettings.value !== undefined ? configSettings.value : this.defaultValue,
111
- option: Array.isArray(this.defaultOptions)
112
- ? configSettings.option
113
- ? // prettier-ignore
114
- // @ts-ignore for "as" casting
115
- this.defaultOptions.concat(configSettings.option)
116
- : this.defaultOptions
117
- : this.defaultOptions !== null &&
118
- typeof this.defaultOptions === 'object' &&
119
- // for example `configSettings.option === true`
120
- (configSettings.option == null || typeof configSettings.option === 'object')
121
- ? { ...this.defaultOptions, ...(configSettings.option || {}) }
122
- : configSettings.option || this.defaultOptions,
123
- reason: configSettings.reason,
124
- };
125
- }
126
- return {
127
- disabled: false,
128
- severity: this.defaultServerity,
129
- // @ts-ignore TODO: Wait for fix to bug of type guards in TypeScript
130
- value: configSettings == null ? this.defaultValue : configSettings,
131
- option: this.defaultOptions,
132
- reason: undefined,
133
- };
134
- }
135
135
  }
136
136
  exports.MLRule = MLRule;
137
- _MLRule_v = new WeakMap(), _MLRule_f = new WeakMap();
137
+ _MLRule_f = new WeakMap(), _MLRule_v = new WeakMap();
@@ -1,10 +1,20 @@
1
+ import type { Attr, Element } from '../ml-dom';
1
2
  import type { MLRuleContext } from './ml-rule-context';
2
- import type { RuleConfigValue, Severity } from '@markuplint/ml-config';
3
+ import type { Translator } from '@markuplint/i18n';
4
+ import type { Report, RuleConfigValue, Severity } from '@markuplint/ml-config';
3
5
  export declare type RuleSeed<T extends RuleConfigValue = boolean, O = null> = {
4
- defaultServerity?: Severity;
6
+ defaultSeverity?: Severity;
5
7
  defaultValue?: T;
6
8
  defaultOptions?: O;
7
9
  verify(context: ReturnType<MLRuleContext<T, O>['provide']>): void | Promise<void>;
8
10
  fix?(context: ReturnType<MLRuleContext<T, O>['provide']>): void | Promise<void>;
9
11
  };
12
+ export declare type Checker<T extends RuleConfigValue, O = null, P extends Record<string, unknown> = {}> = (params: P) => CheckerReport<T, O>;
13
+ export declare type ElementChecker<T extends RuleConfigValue, O = null, P extends Record<string, unknown> = {}> = (params: P & {
14
+ el: Element<T, O>;
15
+ }) => CheckerReport<T, O>;
16
+ export declare type AttrChecker<T extends RuleConfigValue, O = null, P extends Record<string, unknown> = {}> = (params: P & {
17
+ attr: Attr<T, O>;
18
+ }) => CheckerReport<T, O>;
19
+ export declare type CheckerReport<T extends RuleConfigValue, O = null> = (t: Translator) => Report<T, O> | undefined | null;
10
20
  export declare type AnyRuleSeed = RuleSeed<any, any>;
@@ -1,7 +1,7 @@
1
1
  import type { ChildNodeRule, Config, NodeRule, Rules } from '@markuplint/ml-config';
2
2
  export default class Ruleset {
3
- readonly rules: Readonly<Rules>;
4
- readonly nodeRules: ReadonlyArray<NodeRule>;
5
3
  readonly childNodeRules: ReadonlyArray<ChildNodeRule>;
4
+ readonly nodeRules: ReadonlyArray<NodeRule>;
5
+ readonly rules: Readonly<Rules>;
6
6
  constructor(config: Config);
7
7
  }
@@ -5,9 +5,11 @@ 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").AnonymousNode<any, any>[];
11
+ export declare function createTestNodeList(sourceCode: string, options?: CreateTestOptions): readonly import("../ml-dom/node/node").MLNode<any, any, import("@markuplint/ml-ast").MLASTAbstractNode>[];
12
+ export declare function createTestTokenList(sourceCode: string, options?: CreateTestOptions): readonly import("../ml-dom/token/token").MLToken<import("@markuplint/ml-ast").MLToken>[];
11
13
  export declare function createTestElement(sourceCode: string, options?: CreateTestOptions): import("../ml-dom").Element<any, any>;
12
14
  /**
13
15
  * for test suite
package/lib/test/index.js CHANGED
@@ -1,13 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dummySchemas = exports.createTestElement = exports.createTestNodeList = exports.createTestDocument = void 0;
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;
@@ -16,10 +19,15 @@ function createTestNodeList(sourceCode, options) {
16
19
  return document.nodeList;
17
20
  }
18
21
  exports.createTestNodeList = createTestNodeList;
22
+ function createTestTokenList(sourceCode, options) {
23
+ const document = createTestDocument(sourceCode, options);
24
+ return document.getTokenList();
25
+ }
26
+ exports.createTestTokenList = createTestTokenList;
19
27
  function createTestElement(sourceCode, options) {
20
28
  const document = createTestDocument(sourceCode, options);
21
29
  const el = document.nodeList[0];
22
- if (el.type === 'Element') {
30
+ if (el.is(el.ELEMENT_NODE)) {
23
31
  return el;
24
32
  }
25
33
  throw TypeError(`Could not parse it to be an element from: ${sourceCode}`);
@@ -29,7 +37,6 @@ exports.createTestElement = createTestElement;
29
37
  * for test suite
30
38
  */
31
39
  function dummySchemas() {
32
- // @ts-ignore
33
- return [{}, {}];
40
+ return [html_spec_1.default];
34
41
  }
35
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": "2.3.3",
3
+ "version": "3.0.0-alpha.1",
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,19 +17,20 @@
17
17
  "clean": "tsc --build --clean"
18
18
  },
19
19
  "dependencies": {
20
- "@markuplint/i18n": "2.1.1",
21
- "@markuplint/ml-ast": "2.0.1-dev.20220307.0",
22
- "@markuplint/ml-config": "2.1.0",
23
- "@markuplint/ml-spec": "2.1.1",
24
- "@markuplint/parser-utils": "2.2.1",
20
+ "@markuplint/config-presets": "3.0.0-alpha.1",
21
+ "@markuplint/i18n": "3.0.0-alpha.1",
22
+ "@markuplint/ml-ast": "3.0.0-alpha.1",
23
+ "@markuplint/ml-config": "3.0.0-alpha.1",
24
+ "@markuplint/ml-spec": "3.0.0-alpha.1",
25
+ "@markuplint/parser-utils": "3.0.0-alpha.1",
26
+ "@markuplint/selector": "3.0.0-alpha.1",
25
27
  "debug": "^4.3.4",
26
- "dom-accessibility-api": "^0.5.13",
27
28
  "postcss-selector-parser": "^6.0.10",
28
- "tslib": "^2.3.1"
29
+ "tslib": "^2.4.0"
29
30
  },
30
31
  "devDependencies": {
31
- "@markuplint/html-parser": "2.2.2",
32
+ "@markuplint/html-parser": "3.0.0-alpha.1",
32
33
  "@types/debug": "^4.1.7"
33
34
  },
34
- "gitHead": "c28258b756d8c42890698e26c03cdc02c6833489"
35
+ "gitHead": "56de89456146a06777eb5b6d4e8ba456147dd18b"
35
36
  }