@markuplint/ml-core 2.3.2 → 3.0.0-alpha.66
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/configs.d.ts +1 -1
- package/lib/configs.js +29 -9
- package/lib/index.d.ts +8 -8
- package/lib/index.js +18 -10
- package/lib/ml-core.d.ts +3 -3
- package/lib/ml-core.js +41 -42
- package/lib/ml-dom/document.d.ts +79 -70
- package/lib/ml-dom/helper/accname.d.ts +2 -2
- package/lib/ml-dom/helper/accname.js +2 -3
- package/lib/ml-dom/helper/create-node.d.ts +3 -4
- package/lib/ml-dom/helper/create-node.js +11 -15
- package/lib/ml-dom/helper/debug.d.ts +2 -2
- package/lib/ml-dom/helper/debug.js +35 -21
- package/lib/ml-dom/helper/getIndent.d.ts +5 -5
- package/lib/ml-dom/helper/getIndent.js +14 -14
- package/lib/ml-dom/helper/mapped-nodes.d.ts +51 -3
- package/lib/ml-dom/helper/match-selector.d.ts +10 -6
- package/lib/ml-dom/helper/node-store.d.ts +6 -3
- package/lib/ml-dom/helper/selector.d.ts +3 -3
- package/lib/ml-dom/helper/walkers.d.ts +5 -4
- package/lib/ml-dom/helper/walkers.js +39 -3
- package/lib/ml-dom/index.d.ts +8 -3
- package/lib/ml-dom/index.js +3 -15
- package/lib/ml-dom/node/attr.d.ts +5 -0
- package/lib/ml-dom/node/attr.js +7 -0
- package/lib/ml-dom/node/document.js +1 -1
- package/lib/ml-dom/node/dom-token-list.d.ts +20 -2
- package/lib/ml-dom/node/dom-token-list.js +85 -9
- package/lib/ml-dom/node/element.d.ts +4 -11
- package/lib/ml-dom/node/element.js +12 -33
- package/lib/ml-dom/node/node.js +2 -8
- package/lib/ml-dom/rule-mapper.d.ts +7 -7
- package/lib/ml-dom/tokens/abstract-element.d.ts +47 -42
- package/lib/ml-dom/tokens/attribute.d.ts +38 -38
- package/lib/ml-dom/tokens/comment.d.ts +7 -4
- package/lib/ml-dom/tokens/doctype.d.ts +12 -9
- package/lib/ml-dom/tokens/element-close-tag.d.ts +20 -17
- package/lib/ml-dom/tokens/element.d.ts +18 -15
- package/lib/ml-dom/tokens/node.d.ts +38 -31
- package/lib/ml-dom/tokens/omitted-element.d.ts +7 -4
- package/lib/ml-dom/tokens/preprocessor-specific-attribute.d.ts +20 -20
- package/lib/ml-dom/tokens/preprocessor-specific-block.d.ts +8 -5
- package/lib/ml-dom/tokens/text.d.ts +13 -9
- package/lib/ml-dom/tokens/token.d.ts +13 -13
- package/lib/ml-dom/types.d.ts +35 -13
- package/lib/ml-rule/ml-rule-context.d.ts +13 -10
- package/lib/ml-rule/ml-rule-context.js +12 -6
- package/lib/ml-rule/ml-rule.d.ts +8 -8
- package/lib/ml-rule/ml-rule.js +62 -62
- package/lib/ml-rule/types.d.ts +11 -1
- package/lib/ruleset/index.d.ts +2 -2
- package/lib/selector/match-selector.d.ts +5 -5
- package/lib/test/index.d.ts +2 -1
- package/lib/test/index.js +7 -2
- package/package.json +6 -5
- package/tsconfig.tsbuildinfo +1 -1
- package/markuplint-recommended.json +0 -196
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { MLDocument } from '../ml-dom/node/document';
|
|
2
|
+
import type { CheckerReport } from './types';
|
|
2
3
|
import type { LocaleSet, Translator } from '@markuplint/i18n';
|
|
3
|
-
import type { Report, RuleConfigValue
|
|
4
|
+
import type { Report, RuleConfigValue } from '@markuplint/ml-config';
|
|
4
5
|
export declare class MLRuleContext<T extends RuleConfigValue, O = null> {
|
|
5
6
|
#private;
|
|
6
|
-
readonly document:
|
|
7
|
-
readonly globalRule: RuleInfo<T, O>;
|
|
8
|
-
readonly translate: Translator;
|
|
7
|
+
readonly document: MLDocument<T, O>;
|
|
9
8
|
readonly locale: string;
|
|
10
|
-
|
|
9
|
+
readonly translate: Translator;
|
|
11
10
|
get reports(): ({
|
|
12
11
|
message: string;
|
|
13
12
|
line: number;
|
|
@@ -23,12 +22,11 @@ export declare class MLRuleContext<T extends RuleConfigValue, O = null> {
|
|
|
23
22
|
col: number;
|
|
24
23
|
raw: string;
|
|
25
24
|
})[];
|
|
26
|
-
|
|
25
|
+
constructor(document: MLDocument<T, O>, locale: LocaleSet);
|
|
27
26
|
provide(): {
|
|
28
|
-
document:
|
|
27
|
+
document: MLDocument<T, O>;
|
|
29
28
|
translate: Translator;
|
|
30
29
|
t: Translator;
|
|
31
|
-
globalRule: RuleInfo<T, O>;
|
|
32
30
|
reports: ({
|
|
33
31
|
message: string;
|
|
34
32
|
line: number;
|
|
@@ -44,6 +42,11 @@ export declare class MLRuleContext<T extends RuleConfigValue, O = null> {
|
|
|
44
42
|
col: number;
|
|
45
43
|
raw: string;
|
|
46
44
|
})[];
|
|
47
|
-
report:
|
|
45
|
+
report: {
|
|
46
|
+
(report: Report<T, O>): undefined;
|
|
47
|
+
(report: CheckerReport<T, O>): boolean;
|
|
48
|
+
};
|
|
48
49
|
};
|
|
50
|
+
report(report: Report<T, O>): undefined;
|
|
51
|
+
report(report: CheckerReport<T, O>): boolean;
|
|
49
52
|
}
|
|
@@ -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
|
|
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,26 @@ 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
|
+
tslib_1.__classPrivateFieldGet(this, _MLRuleContext_reports, "f").push(r);
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
tslib_1.__classPrivateFieldGet(this, _MLRuleContext_reports, "f").push(report);
|
|
39
|
+
}
|
|
34
40
|
}
|
|
35
41
|
exports.MLRuleContext = MLRuleContext;
|
|
36
42
|
_MLRuleContext_reports = new WeakMap();
|
package/lib/ml-rule/ml-rule.d.ts
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import type { Ruleset } from '..';
|
|
2
|
-
import type
|
|
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,
|
|
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
|
|
8
|
+
readonly defaultOptions: O;
|
|
9
9
|
readonly defaultServerity: Severity;
|
|
10
10
|
readonly defaultValue: T;
|
|
11
|
-
readonly
|
|
11
|
+
readonly name: string;
|
|
12
12
|
/**
|
|
13
13
|
* The following getter is unused internally,
|
|
14
14
|
* only for extending from 3rd party library
|
|
15
15
|
*/
|
|
16
|
-
protected get
|
|
16
|
+
protected get f(): RuleSeed<T, O>['fix'];
|
|
17
17
|
/**
|
|
18
18
|
* The following getter is unused internally,
|
|
19
19
|
* only for extending from 3rd party library
|
|
20
20
|
*/
|
|
21
|
-
protected get
|
|
21
|
+
protected get v(): RuleSeed<T, O>['verify'];
|
|
22
22
|
constructor(o: RuleSeed<T, O> & {
|
|
23
23
|
name: string;
|
|
24
24
|
});
|
|
25
|
-
verify(document: Document<T, O>, locale: LocaleSet, globalRule: RuleInfo<T, O>, fix: boolean): Promise<Violation[]>;
|
|
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>;
|
package/lib/ml-rule/ml-rule.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
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,8 +7,8 @@ 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
13
|
this.defaultServerity = o.defaultServerity || 'error';
|
|
14
14
|
this.defaultValue = (_a = o.defaultValue) !== null && _a !== void 0 ? _a : true;
|
|
@@ -20,65 +20,15 @@ class MLRule {
|
|
|
20
20
|
* The following getter is unused internally,
|
|
21
21
|
* only for extending from 3rd party library
|
|
22
22
|
*/
|
|
23
|
-
get
|
|
24
|
-
return tslib_1.__classPrivateFieldGet(this,
|
|
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
|
|
31
|
-
return tslib_1.__classPrivateFieldGet(this,
|
|
32
|
-
}
|
|
33
|
-
async verify(document, locale, globalRule, fix) {
|
|
34
|
-
if (!tslib_1.__classPrivateFieldGet(this, _MLRule_v, "f")) {
|
|
35
|
-
return [];
|
|
36
|
-
}
|
|
37
|
-
document.setRule(this);
|
|
38
|
-
const context = new ml_rule_context_1.MLRuleContext(document, locale, globalRule);
|
|
39
|
-
const providableContext = context.provide();
|
|
40
|
-
await tslib_1.__classPrivateFieldGet(this, _MLRule_v, "f").call(this, providableContext);
|
|
41
|
-
if (tslib_1.__classPrivateFieldGet(this, _MLRule_f, "f") && fix) {
|
|
42
|
-
await tslib_1.__classPrivateFieldGet(this, _MLRule_f, "f").call(this, providableContext);
|
|
43
|
-
}
|
|
44
|
-
const violation = context.reports.map(report => {
|
|
45
|
-
if ('scope' in report) {
|
|
46
|
-
let line = report.scope.startLine;
|
|
47
|
-
let col = report.scope.startCol;
|
|
48
|
-
let raw = report.scope.raw;
|
|
49
|
-
if ('line' in report) {
|
|
50
|
-
line = report.line;
|
|
51
|
-
col = report.col;
|
|
52
|
-
raw = report.raw;
|
|
53
|
-
}
|
|
54
|
-
const violation = {
|
|
55
|
-
severity: report.scope.rule.severity,
|
|
56
|
-
message: report.message,
|
|
57
|
-
line,
|
|
58
|
-
col,
|
|
59
|
-
raw,
|
|
60
|
-
ruleId: this.name,
|
|
61
|
-
};
|
|
62
|
-
if (report.scope.rule.reason || globalRule.reason) {
|
|
63
|
-
violation.reason = report.scope.rule.reason || globalRule.reason;
|
|
64
|
-
}
|
|
65
|
-
return violation;
|
|
66
|
-
}
|
|
67
|
-
const violation = {
|
|
68
|
-
severity: globalRule.severity,
|
|
69
|
-
message: report.message,
|
|
70
|
-
line: report.line,
|
|
71
|
-
col: report.col,
|
|
72
|
-
raw: report.raw,
|
|
73
|
-
ruleId: this.name,
|
|
74
|
-
};
|
|
75
|
-
if (globalRule.reason) {
|
|
76
|
-
violation.reason = globalRule.reason;
|
|
77
|
-
}
|
|
78
|
-
return violation;
|
|
79
|
-
});
|
|
80
|
-
document.setRule(null);
|
|
81
|
-
return violation;
|
|
30
|
+
get v() {
|
|
31
|
+
return tslib_1.__classPrivateFieldGet(this, _MLRule_v, "f");
|
|
82
32
|
}
|
|
83
33
|
getRuleInfo(ruleSet, ruleName) {
|
|
84
34
|
const info = this._optimize(ruleSet.rules, ruleName);
|
|
@@ -88,11 +38,6 @@ class MLRule {
|
|
|
88
38
|
childNodeRules: ruleSet.childNodeRules.map(r => this._optimize(r.rules, ruleName)).filter(r => !r.disabled),
|
|
89
39
|
};
|
|
90
40
|
}
|
|
91
|
-
_optimize(rules, ruleName) {
|
|
92
|
-
const rule = (rules && rules[ruleName]) || false;
|
|
93
|
-
const info = this.optimizeOption(rule);
|
|
94
|
-
return info;
|
|
95
|
-
}
|
|
96
41
|
optimizeOption(configSettings) {
|
|
97
42
|
if (configSettings === undefined || typeof configSettings === 'boolean') {
|
|
98
43
|
return {
|
|
@@ -132,6 +77,61 @@ class MLRule {
|
|
|
132
77
|
reason: undefined,
|
|
133
78
|
};
|
|
134
79
|
}
|
|
80
|
+
async verify(document, locale, fix) {
|
|
81
|
+
if (!tslib_1.__classPrivateFieldGet(this, _MLRule_v, "f")) {
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
document.setRule(this);
|
|
85
|
+
const context = new ml_rule_context_1.MLRuleContext(document, locale);
|
|
86
|
+
const providableContext = context.provide();
|
|
87
|
+
await tslib_1.__classPrivateFieldGet(this, _MLRule_v, "f").call(this, providableContext);
|
|
88
|
+
if (tslib_1.__classPrivateFieldGet(this, _MLRule_f, "f") && fix) {
|
|
89
|
+
await tslib_1.__classPrivateFieldGet(this, _MLRule_f, "f").call(this, providableContext);
|
|
90
|
+
}
|
|
91
|
+
const violation = context.reports.map(report => {
|
|
92
|
+
if ('scope' in report) {
|
|
93
|
+
let line = report.scope.startLine;
|
|
94
|
+
let col = report.scope.startCol;
|
|
95
|
+
let raw = report.scope.raw;
|
|
96
|
+
if ('line' in report && report.line != null) {
|
|
97
|
+
line = report.line;
|
|
98
|
+
col = report.col;
|
|
99
|
+
raw = report.raw;
|
|
100
|
+
}
|
|
101
|
+
const violation = {
|
|
102
|
+
severity: report.scope.rule.severity,
|
|
103
|
+
message: report.message,
|
|
104
|
+
line,
|
|
105
|
+
col,
|
|
106
|
+
raw,
|
|
107
|
+
ruleId: this.name,
|
|
108
|
+
};
|
|
109
|
+
if (report.scope.rule.reason || document.rule.reason) {
|
|
110
|
+
violation.reason = report.scope.rule.reason || document.rule.reason;
|
|
111
|
+
}
|
|
112
|
+
return violation;
|
|
113
|
+
}
|
|
114
|
+
const violation = {
|
|
115
|
+
severity: document.rule.severity,
|
|
116
|
+
message: report.message,
|
|
117
|
+
line: report.line,
|
|
118
|
+
col: report.col,
|
|
119
|
+
raw: report.raw,
|
|
120
|
+
ruleId: this.name,
|
|
121
|
+
};
|
|
122
|
+
if (document.rule.reason) {
|
|
123
|
+
violation.reason = document.rule.reason;
|
|
124
|
+
}
|
|
125
|
+
return violation;
|
|
126
|
+
});
|
|
127
|
+
document.setRule(null);
|
|
128
|
+
return violation;
|
|
129
|
+
}
|
|
130
|
+
_optimize(rules, ruleName) {
|
|
131
|
+
const rule = (rules && rules[ruleName]) || false;
|
|
132
|
+
const info = this.optimizeOption(rule);
|
|
133
|
+
return info;
|
|
134
|
+
}
|
|
135
135
|
}
|
|
136
136
|
exports.MLRule = MLRule;
|
|
137
|
-
|
|
137
|
+
_MLRule_f = new WeakMap(), _MLRule_v = new WeakMap();
|
package/lib/ml-rule/types.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { Attr, Element } from '../ml-dom';
|
|
1
2
|
import type { MLRuleContext } from './ml-rule-context';
|
|
2
|
-
import type {
|
|
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
6
|
defaultServerity?: Severity;
|
|
5
7
|
defaultValue?: T;
|
|
@@ -7,4 +9,12 @@ export declare type RuleSeed<T extends RuleConfigValue = boolean, O = null> = {
|
|
|
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>;
|
package/lib/ruleset/index.d.ts
CHANGED
|
@@ -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
|
}
|
|
@@ -2,13 +2,13 @@ import type { Specificity } from './selector';
|
|
|
2
2
|
import type { RegexSelector } from '@markuplint/ml-config';
|
|
3
3
|
export declare type SelectorMatches = SelectorMatched | SelectorUnmatched;
|
|
4
4
|
declare type SelectorMatched = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
matched: true;
|
|
6
|
+
selector: string;
|
|
7
|
+
specificity: Specificity;
|
|
8
|
+
data?: Record<string, string>;
|
|
9
9
|
};
|
|
10
10
|
declare type SelectorUnmatched = {
|
|
11
|
-
|
|
11
|
+
matched: false;
|
|
12
12
|
};
|
|
13
13
|
export declare function matchSelector(el: Element, selector: string | RegexSelector | undefined): SelectorMatches;
|
|
14
14
|
export {};
|
package/lib/test/index.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ export declare type CreateTestOptions = {
|
|
|
7
7
|
parser?: MLMarkupLanguageParser;
|
|
8
8
|
};
|
|
9
9
|
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").
|
|
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 createTestTokenList(sourceCode: string, options?: CreateTestOptions): readonly import("../ml-dom/token/token").MLToken<import("@markuplint/ml-ast").MLToken>[];
|
|
11
12
|
export declare function createTestElement(sourceCode: string, options?: CreateTestOptions): import("../ml-dom").Element<any, any>;
|
|
12
13
|
/**
|
|
13
14
|
* for test suite
|
package/lib/test/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
4
|
const html_parser_1 = require("@markuplint/html-parser");
|
|
5
5
|
const convert_ruleset_1 = require("../convert-ruleset");
|
|
6
6
|
const ml_dom_1 = require("../ml-dom");
|
|
@@ -16,10 +16,15 @@ function createTestNodeList(sourceCode, options) {
|
|
|
16
16
|
return document.nodeList;
|
|
17
17
|
}
|
|
18
18
|
exports.createTestNodeList = createTestNodeList;
|
|
19
|
+
function createTestTokenList(sourceCode, options) {
|
|
20
|
+
const document = createTestDocument(sourceCode, options);
|
|
21
|
+
return document.getTokenList();
|
|
22
|
+
}
|
|
23
|
+
exports.createTestTokenList = createTestTokenList;
|
|
19
24
|
function createTestElement(sourceCode, options) {
|
|
20
25
|
const document = createTestDocument(sourceCode, options);
|
|
21
26
|
const el = document.nodeList[0];
|
|
22
|
-
if (el.
|
|
27
|
+
if (el.is(el.ELEMENT_NODE)) {
|
|
23
28
|
return el;
|
|
24
29
|
}
|
|
25
30
|
throw TypeError(`Could not parse it to be an element from: ${sourceCode}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/ml-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.66+6cde1134",
|
|
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,13 +17,14 @@
|
|
|
17
17
|
"clean": "tsc --build --clean"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
+
"@markuplint/config-presets": "3.0.0-alpha",
|
|
20
21
|
"@markuplint/i18n": "2.1.1",
|
|
21
22
|
"@markuplint/ml-ast": "2.0.1-dev.20220307.0",
|
|
22
|
-
"@markuplint/ml-config": "
|
|
23
|
-
"@markuplint/ml-spec": "
|
|
23
|
+
"@markuplint/ml-config": "3.0.0-alpha.66+6cde1134",
|
|
24
|
+
"@markuplint/ml-spec": "3.0.0-alpha.82+6cde1134",
|
|
24
25
|
"@markuplint/parser-utils": "2.2.0",
|
|
26
|
+
"@markuplint/selector": "3.0.0-alpha.2105+6cde1134",
|
|
25
27
|
"debug": "^4.3.4",
|
|
26
|
-
"dom-accessibility-api": "^0.5.13",
|
|
27
28
|
"postcss-selector-parser": "^6.0.10",
|
|
28
29
|
"tslib": "^2.3.1"
|
|
29
30
|
},
|
|
@@ -31,5 +32,5 @@
|
|
|
31
32
|
"@markuplint/html-parser": "2.2.1",
|
|
32
33
|
"@types/debug": "^4.1.7"
|
|
33
34
|
},
|
|
34
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "6cde113402758a8fdbd6a0fcf98e78efd2cdb778"
|
|
35
36
|
}
|