@markuplint/ml-core 3.4.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/configs.js +1 -2
- package/lib/index.d.ts +1 -11
- package/lib/ml-core.d.ts +12 -23
- package/lib/ml-core.js +4 -4
- package/lib/ml-dom/helper/accname.js +15 -5
- package/lib/ml-dom/helper/create-node.d.ts +2 -5
- package/lib/ml-dom/helper/create-node.js +3 -1
- package/lib/ml-dom/helper/debug.js +6 -2
- package/lib/ml-dom/helper/getIndent.d.ts +7 -7
- package/lib/ml-dom/helper/getIndent.js +11 -3
- package/lib/ml-dom/helper/walkers.d.ts +5 -13
- package/lib/ml-dom/helper/walkers.js +3 -1
- package/lib/ml-dom/manipulations/child-node-methods.d.ts +7 -20
- package/lib/ml-dom/manipulations/child-node-methods.js +24 -6
- package/lib/ml-dom/manipulations/get-children.d.ts +2 -4
- package/lib/ml-dom/manipulations/get-children.js +3 -1
- package/lib/ml-dom/node/attr.d.ts +91 -91
- package/lib/ml-dom/node/attr.js +5 -1
- package/lib/ml-dom/node/block.d.ts +32 -32
- package/lib/ml-dom/node/block.js +14 -4
- package/lib/ml-dom/node/character-data.d.ts +53 -60
- package/lib/ml-dom/node/character-data.js +9 -3
- package/lib/ml-dom/node/child-node.d.ts +3 -8
- package/lib/ml-dom/node/child-node.js +3 -1
- package/lib/ml-dom/node/comment.d.ts +13 -16
- package/lib/ml-dom/node/document-fragment.d.ts +20 -23
- package/lib/ml-dom/node/document-type.d.ts +32 -35
- package/lib/ml-dom/node/document-type.js +14 -4
- package/lib/ml-dom/node/document.d.ts +1586 -1599
- package/lib/ml-dom/node/document.js +29 -7
- package/lib/ml-dom/node/dom-token-list.d.ts +26 -26
- package/lib/ml-dom/node/dom-token-list.js +3 -1
- package/lib/ml-dom/node/element.d.ts +1897 -1895
- package/lib/ml-dom/node/element.js +58 -14
- package/lib/ml-dom/node/named-node-map.d.ts +40 -45
- package/lib/ml-dom/node/named-node-map.js +9 -3
- package/lib/ml-dom/node/node-list.d.ts +4 -10
- package/lib/ml-dom/node/node-list.js +6 -2
- package/lib/ml-dom/node/node-store.d.ts +4 -4
- package/lib/ml-dom/node/node-store.js +8 -3
- package/lib/ml-dom/node/node.d.ts +472 -492
- package/lib/ml-dom/node/node.js +42 -14
- package/lib/ml-dom/node/parent-node.d.ts +58 -67
- package/lib/ml-dom/node/parent-node.js +9 -3
- package/lib/ml-dom/node/rule-mapper.d.ts +7 -7
- package/lib/ml-dom/node/rule-mapper.js +6 -2
- package/lib/ml-dom/node/text.d.ts +47 -50
- package/lib/ml-dom/node/types.d.ts +13 -69
- package/lib/ml-dom/node/unexpected-call-error.d.ts +2 -1
- package/lib/ml-dom/token/token.d.ts +44 -44
- package/lib/ml-rule/create-rule.d.ts +2 -2
- package/lib/ml-rule/create-test-rule.d.ts +4 -6
- package/lib/ml-rule/ml-rule-context.d.ts +49 -57
- package/lib/ml-rule/ml-rule-context.js +3 -1
- package/lib/ml-rule/ml-rule.d.ts +25 -27
- package/lib/ml-rule/ml-rule.js +30 -24
- package/lib/ml-rule/types.d.ts +16 -22
- package/lib/plugin/plugin.d.ts +1 -1
- package/lib/plugin/types.d.ts +7 -7
- package/lib/ruleset/index.d.ts +4 -4
- package/lib/ruleset/index.js +4 -4
- package/lib/test/index.d.ts +8 -20
- package/lib/types.d.ts +9 -8
- package/lib/utils/get-location-from-chars.d.ts +4 -9
- package/package.json +14 -12
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { RuleSeed } from './types';
|
|
2
|
-
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
3
|
-
export declare function createRule<T extends RuleConfigValue, O =
|
|
2
|
+
import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
|
|
3
|
+
export declare function createRule<T extends RuleConfigValue, O extends PlainData = undefined>(seed: Readonly<RuleSeed<T, O>>): Readonly<RuleSeed<T, O>>;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { RuleSeed } from './types';
|
|
2
|
-
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
2
|
+
import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
|
|
3
3
|
import { MLRule } from './ml-rule';
|
|
4
|
-
export declare function createRule<T extends RuleConfigValue, O =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
},
|
|
8
|
-
): MLRule<T, O>;
|
|
4
|
+
export declare function createRule<T extends RuleConfigValue, O extends PlainData = undefined>(seed: Readonly<RuleSeed<T, O>> & {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
}): MLRule<T, O>;
|
|
@@ -1,61 +1,53 @@
|
|
|
1
1
|
import type { CheckerReport } from './types';
|
|
2
2
|
import type { MLDocument } from '../ml-dom/node/document';
|
|
3
3
|
import type { LocaleSet, Translator } from '@markuplint/i18n';
|
|
4
|
-
import type { Report, RuleConfigValue } from '@markuplint/ml-config';
|
|
5
|
-
export declare class MLRuleContext<T extends RuleConfigValue, O =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
report: {
|
|
54
|
-
(report: Report<T, O>): undefined;
|
|
55
|
-
(report: CheckerReport<T, O>): boolean;
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
report(report: Report<T, O>): undefined;
|
|
59
|
-
report(report: CheckerReport<T, O>): boolean;
|
|
60
|
-
private _push;
|
|
4
|
+
import type { PlainData, Report, RuleConfigValue } from '@markuplint/ml-config';
|
|
5
|
+
export declare class MLRuleContext<T extends RuleConfigValue, O extends PlainData = undefined> {
|
|
6
|
+
#private;
|
|
7
|
+
readonly document: MLDocument<T, O>;
|
|
8
|
+
readonly locale: string;
|
|
9
|
+
readonly translate: Translator;
|
|
10
|
+
constructor(document: MLDocument<T, O>, locale: LocaleSet);
|
|
11
|
+
get reports(): ({
|
|
12
|
+
message: string;
|
|
13
|
+
line: number;
|
|
14
|
+
col: number;
|
|
15
|
+
raw: string;
|
|
16
|
+
} | {
|
|
17
|
+
message: string;
|
|
18
|
+
scope: import("@markuplint/ml-config").Scope<T, O>;
|
|
19
|
+
} | {
|
|
20
|
+
message: string;
|
|
21
|
+
scope: import("@markuplint/ml-config").Scope<T, O>;
|
|
22
|
+
line: number;
|
|
23
|
+
col: number;
|
|
24
|
+
raw: string;
|
|
25
|
+
})[];
|
|
26
|
+
provide(): {
|
|
27
|
+
document: MLDocument<T, O>;
|
|
28
|
+
translate: Translator;
|
|
29
|
+
t: Translator;
|
|
30
|
+
reports: ({
|
|
31
|
+
message: string;
|
|
32
|
+
line: number;
|
|
33
|
+
col: number;
|
|
34
|
+
raw: string;
|
|
35
|
+
} | {
|
|
36
|
+
message: string;
|
|
37
|
+
scope: import("@markuplint/ml-config").Scope<T, O>;
|
|
38
|
+
} | {
|
|
39
|
+
message: string;
|
|
40
|
+
scope: import("@markuplint/ml-config").Scope<T, O>;
|
|
41
|
+
line: number;
|
|
42
|
+
col: number;
|
|
43
|
+
raw: string;
|
|
44
|
+
})[];
|
|
45
|
+
report: {
|
|
46
|
+
(report: Report<T, O>): undefined;
|
|
47
|
+
(report: CheckerReport<T, O>): boolean;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
report(report: Report<T, O>): undefined;
|
|
51
|
+
report(report: CheckerReport<T, O>): boolean;
|
|
52
|
+
private _push;
|
|
61
53
|
}
|
|
@@ -5,7 +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(
|
|
8
|
+
constructor(
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
10
|
+
document, locale) {
|
|
9
11
|
_MLRuleContext_reports.set(this, []);
|
|
10
12
|
this.document = document;
|
|
11
13
|
this.translate = (0, i18n_1.translator)(locale);
|
package/lib/ml-rule/ml-rule.d.ts
CHANGED
|
@@ -2,31 +2,29 @@ import type { RuleSeed } from './types';
|
|
|
2
2
|
import type { Ruleset } from '..';
|
|
3
3
|
import type { MLDocument } from '../ml-dom/node/document';
|
|
4
4
|
import type { LocaleSet } from '@markuplint/i18n';
|
|
5
|
-
import type { GlobalRuleInfo,
|
|
6
|
-
export declare class MLRule<T extends RuleConfigValue, O =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
verify(document: MLDocument<T, O>, locale: LocaleSet, fix: boolean): Promise<Violation[]>;
|
|
30
|
-
private _optimize;
|
|
5
|
+
import type { GlobalRuleInfo, PlainData, Rule, RuleConfigValue, RuleInfo, Severity, Violation } from '@markuplint/ml-config';
|
|
6
|
+
export declare class MLRule<T extends RuleConfigValue, O extends PlainData = undefined> {
|
|
7
|
+
#private;
|
|
8
|
+
readonly defaultOptions: O;
|
|
9
|
+
readonly defaultSeverity: Severity;
|
|
10
|
+
readonly defaultValue: T;
|
|
11
|
+
readonly name: string;
|
|
12
|
+
constructor(o: Readonly<RuleSeed<T, O>> & {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* The following getter is unused internally,
|
|
17
|
+
* only for extending from 3rd party library
|
|
18
|
+
*/
|
|
19
|
+
protected get f(): RuleSeed<T, O>['fix'];
|
|
20
|
+
/**
|
|
21
|
+
* The following getter is unused internally,
|
|
22
|
+
* only for extending from 3rd party library
|
|
23
|
+
*/
|
|
24
|
+
protected get v(): RuleSeed<T, O>['verify'];
|
|
25
|
+
getRuleInfo(ruleSet: Ruleset, ruleName: string): GlobalRuleInfo<T, O>;
|
|
26
|
+
optimizeOption(configSettings: Rule<T, O> | null | undefined): RuleInfo<T, O>;
|
|
27
|
+
verify(document: MLDocument<T, O>, locale: LocaleSet, fix: boolean): Promise<Violation[]>;
|
|
28
|
+
private _optimize;
|
|
31
29
|
}
|
|
32
|
-
export type AnyMLRule = MLRule<RuleConfigValue,
|
|
30
|
+
export type AnyMLRule = MLRule<RuleConfigValue, PlainData>;
|
package/lib/ml-rule/ml-rule.js
CHANGED
|
@@ -3,6 +3,8 @@ 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");
|
|
6
|
+
const ml_config_1 = require("@markuplint/ml-config");
|
|
7
|
+
const is_plain_object_1 = require("is-plain-object");
|
|
6
8
|
const ml_rule_context_1 = require("./ml-rule-context");
|
|
7
9
|
class MLRule {
|
|
8
10
|
constructor(o) {
|
|
@@ -10,9 +12,9 @@ class MLRule {
|
|
|
10
12
|
_MLRule_f.set(this, void 0);
|
|
11
13
|
_MLRule_v.set(this, void 0);
|
|
12
14
|
this.name = o.name;
|
|
13
|
-
this.defaultSeverity = o.defaultSeverity
|
|
14
|
-
this.defaultValue = (
|
|
15
|
-
this.defaultOptions =
|
|
15
|
+
this.defaultSeverity = (_a = o.defaultSeverity) !== null && _a !== void 0 ? _a : 'error';
|
|
16
|
+
this.defaultValue = ((_b = o.defaultValue) !== null && _b !== void 0 ? _b : true);
|
|
17
|
+
this.defaultOptions = o.defaultOptions;
|
|
16
18
|
tslib_1.__classPrivateFieldSet(this, _MLRule_v, o.verify, "f");
|
|
17
19
|
tslib_1.__classPrivateFieldSet(this, _MLRule_f, o.fix, "f");
|
|
18
20
|
}
|
|
@@ -48,23 +50,12 @@ class MLRule {
|
|
|
48
50
|
reason: undefined,
|
|
49
51
|
};
|
|
50
52
|
}
|
|
51
|
-
if (
|
|
53
|
+
if (isRuleConfig(configSettings)) {
|
|
52
54
|
return {
|
|
53
55
|
disabled: false,
|
|
54
56
|
severity: configSettings.severity || this.defaultSeverity,
|
|
55
57
|
value: configSettings.value !== undefined ? configSettings.value : this.defaultValue,
|
|
56
|
-
options:
|
|
57
|
-
? configSettings.options
|
|
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.options == null || typeof configSettings.options === 'object')
|
|
66
|
-
? { ...this.defaultOptions, ...(configSettings.options || {}) }
|
|
67
|
-
: configSettings.options || this.defaultOptions,
|
|
58
|
+
options: mergeOptions(this.defaultOptions, configSettings.options),
|
|
68
59
|
reason: configSettings.reason,
|
|
69
60
|
};
|
|
70
61
|
}
|
|
@@ -76,7 +67,9 @@ class MLRule {
|
|
|
76
67
|
reason: undefined,
|
|
77
68
|
};
|
|
78
69
|
}
|
|
79
|
-
async verify(
|
|
70
|
+
async verify(
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
72
|
+
document, locale, fix) {
|
|
80
73
|
if (!tslib_1.__classPrivateFieldGet(this, _MLRule_v, "f")) {
|
|
81
74
|
return [];
|
|
82
75
|
}
|
|
@@ -104,10 +97,9 @@ class MLRule {
|
|
|
104
97
|
col,
|
|
105
98
|
raw,
|
|
106
99
|
ruleId: this.name,
|
|
100
|
+
reason: report.scope.rule.reason || document.rule.reason,
|
|
107
101
|
};
|
|
108
|
-
|
|
109
|
-
violation.reason = report.scope.rule.reason || document.rule.reason;
|
|
110
|
-
}
|
|
102
|
+
(0, ml_config_1.deleteUndefProp)(violation);
|
|
111
103
|
return violation;
|
|
112
104
|
}
|
|
113
105
|
const violation = {
|
|
@@ -117,20 +109,34 @@ class MLRule {
|
|
|
117
109
|
col: report.col,
|
|
118
110
|
raw: report.raw,
|
|
119
111
|
ruleId: this.name,
|
|
112
|
+
reason: document.rule.reason,
|
|
120
113
|
};
|
|
121
|
-
|
|
122
|
-
violation.reason = document.rule.reason;
|
|
123
|
-
}
|
|
114
|
+
(0, ml_config_1.deleteUndefProp)(violation);
|
|
124
115
|
return violation;
|
|
125
116
|
});
|
|
126
117
|
document.setRule(null);
|
|
127
118
|
return violation;
|
|
128
119
|
}
|
|
129
120
|
_optimize(rules, ruleName) {
|
|
130
|
-
|
|
121
|
+
var _a;
|
|
122
|
+
const rule = ((_a = rules === null || rules === void 0 ? void 0 : rules[ruleName]) !== null && _a !== void 0 ? _a : false);
|
|
131
123
|
const info = this.optimizeOption(rule);
|
|
132
124
|
return info;
|
|
133
125
|
}
|
|
134
126
|
}
|
|
135
127
|
exports.MLRule = MLRule;
|
|
136
128
|
_MLRule_f = new WeakMap(), _MLRule_v = new WeakMap();
|
|
129
|
+
function isRuleConfig(data) {
|
|
130
|
+
return (0, is_plain_object_1.isPlainObject)(data);
|
|
131
|
+
}
|
|
132
|
+
function mergeOptions(a, b) {
|
|
133
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
134
|
+
// @ts-ignore
|
|
135
|
+
return [...a, ...b];
|
|
136
|
+
}
|
|
137
|
+
if ((0, is_plain_object_1.isPlainObject)(a) && (0, is_plain_object_1.isPlainObject)(b)) {
|
|
138
|
+
// @ts-ignore
|
|
139
|
+
return { ...a, ...b };
|
|
140
|
+
}
|
|
141
|
+
return b !== null && b !== void 0 ? b : a;
|
|
142
|
+
}
|
package/lib/ml-rule/types.d.ts
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
import type { MLRuleContext } from './ml-rule-context';
|
|
2
2
|
import type { Attr, Element } from '../ml-dom';
|
|
3
3
|
import type { Translator } from '@markuplint/i18n';
|
|
4
|
-
import type { Report, RuleConfigValue, Severity } from '@markuplint/ml-config';
|
|
5
|
-
export type RuleSeed<T extends RuleConfigValue = boolean, O =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
import type { PlainData, Report, RuleConfigValue, Severity } from '@markuplint/ml-config';
|
|
5
|
+
export type RuleSeed<T extends RuleConfigValue = boolean, O extends PlainData = undefined> = {
|
|
6
|
+
readonly defaultSeverity?: Severity;
|
|
7
|
+
readonly defaultValue?: T;
|
|
8
|
+
readonly defaultOptions?: O;
|
|
9
|
+
verify(context: ReturnType<MLRuleContext<T, O>['provide']>): void | Promise<void>;
|
|
10
|
+
fix?(context: ReturnType<MLRuleContext<T, O>['provide']>): void | Promise<void>;
|
|
11
11
|
};
|
|
12
|
-
export type Checker<T extends RuleConfigValue, O =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
) =>
|
|
20
|
-
export type
|
|
21
|
-
params: P & {
|
|
22
|
-
attr: Attr<T, O>;
|
|
23
|
-
},
|
|
24
|
-
) => CheckerReport<T, O>;
|
|
25
|
-
export type CheckerReport<T extends RuleConfigValue, O = null> = (t: Translator) => Report<T, O> | undefined | null;
|
|
26
|
-
export type AnyRuleSeed = RuleSeed<any, any>;
|
|
12
|
+
export type Checker<T extends RuleConfigValue, O extends PlainData = undefined, P extends Record<string, unknown> = {}> = (params: P) => CheckerReport<T, O>;
|
|
13
|
+
export type ElementChecker<T extends RuleConfigValue, O extends PlainData = undefined, P extends Record<string, unknown> = {}> = (params: P & {
|
|
14
|
+
el: Element<T, O>;
|
|
15
|
+
}) => CheckerReport<T, O>;
|
|
16
|
+
export type AttrChecker<T extends RuleConfigValue, O extends PlainData = undefined, P extends Record<string, unknown> = {}> = (params: P & {
|
|
17
|
+
attr: Attr<T, O>;
|
|
18
|
+
}) => CheckerReport<T, O>;
|
|
19
|
+
export type CheckerReport<T extends RuleConfigValue, O extends PlainData = undefined> = (t: Translator) => Report<T, O> | undefined | null;
|
|
20
|
+
export type AnyRuleSeed<T extends RuleConfigValue = RuleConfigValue, O extends PlainData = PlainData> = RuleSeed<T, O>;
|
package/lib/plugin/plugin.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { PluginCreator, CreatePluginSettings } from './types';
|
|
2
|
-
export declare function createPlugin<S extends CreatePluginSettings>(fn: PluginCreator<S
|
|
2
|
+
export declare function createPlugin<S extends CreatePluginSettings>(fn: Readonly<PluginCreator<S>>): Readonly<PluginCreator<S>>;
|
package/lib/plugin/types.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RuleSeed } from '../ml-rule';
|
|
2
2
|
import type { Config } from '@markuplint/ml-config';
|
|
3
3
|
export type Plugin = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly rules?: Readonly<Record<string, Readonly<RuleSeed<any, any>>>>;
|
|
6
|
+
readonly configs?: Readonly<Record<string, Config>>;
|
|
7
7
|
};
|
|
8
8
|
export type PluginCreator<S extends CreatePluginSettings> = {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
readonly name: string;
|
|
10
|
+
create(setting: S): Omit<Plugin, 'name'>;
|
|
11
11
|
};
|
|
12
|
-
export type CreatePluginSettings = Record<string, unknown
|
|
12
|
+
export type CreatePluginSettings = Readonly<Record<string, unknown>>;
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
readonly childNodeRules: readonly ChildNodeRule[];
|
|
4
|
+
readonly nodeRules: readonly NodeRule[];
|
|
5
|
+
readonly rules: Rules;
|
|
6
|
+
constructor(config: Config);
|
|
7
7
|
}
|
package/lib/ruleset/index.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
class Ruleset {
|
|
4
4
|
constructor(config) {
|
|
5
|
-
|
|
6
|
-
this.rules =
|
|
7
|
-
this.nodeRules =
|
|
8
|
-
this.childNodeRules =
|
|
5
|
+
var _a, _b, _c;
|
|
6
|
+
this.rules = (_a = config.rules) !== null && _a !== void 0 ? _a : {};
|
|
7
|
+
this.nodeRules = (_b = config.nodeRules) !== null && _b !== void 0 ? _b : [];
|
|
8
|
+
this.childNodeRules = (_c = config.childNodeRules) !== null && _c !== void 0 ? _c : [];
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.default = Ruleset;
|
package/lib/test/index.d.ts
CHANGED
|
@@ -1,28 +1,16 @@
|
|
|
1
1
|
import type { MLMarkupLanguageParser } from '@markuplint/ml-ast';
|
|
2
|
-
import type { Config, RuleConfigValue } from '@markuplint/ml-config';
|
|
2
|
+
import type { Config, PlainData, RuleConfigValue } from '@markuplint/ml-config';
|
|
3
3
|
import type { ExtendedSpec, MLMLSpec } from '@markuplint/ml-spec';
|
|
4
4
|
import { Document } from '../ml-dom';
|
|
5
5
|
export type CreateTestOptions = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
readonly config?: Config;
|
|
7
|
+
readonly parser?: Readonly<MLMarkupLanguageParser>;
|
|
8
|
+
readonly specs?: MLMLSpec;
|
|
9
9
|
};
|
|
10
|
-
export declare function createTestDocument<T extends RuleConfigValue = any, O = any>(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
):
|
|
14
|
-
export declare function createTestNodeList(
|
|
15
|
-
sourceCode: string,
|
|
16
|
-
options?: CreateTestOptions,
|
|
17
|
-
): readonly import('../ml-dom/node/node').MLNode<any, any, import('@markuplint/ml-ast').MLASTAbstractNode>[];
|
|
18
|
-
export declare function createTestTokenList(
|
|
19
|
-
sourceCode: string,
|
|
20
|
-
options?: CreateTestOptions,
|
|
21
|
-
): readonly import('../ml-dom/token/token').MLToken<import('@markuplint/ml-ast').MLToken>[];
|
|
22
|
-
export declare function createTestElement(
|
|
23
|
-
sourceCode: string,
|
|
24
|
-
options?: CreateTestOptions,
|
|
25
|
-
): import('../ml-dom').Element<any, any>;
|
|
10
|
+
export declare function createTestDocument<T extends RuleConfigValue = any, O extends PlainData = any>(sourceCode: string, options?: CreateTestOptions): Document<T, O>;
|
|
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>[];
|
|
13
|
+
export declare function createTestElement(sourceCode: string, options?: CreateTestOptions): import("../ml-dom").Element<any, any>;
|
|
26
14
|
/**
|
|
27
15
|
* for test suite
|
|
28
16
|
*/
|
package/lib/types.d.ts
CHANGED
|
@@ -4,13 +4,14 @@ import type { LocaleSet } from '@markuplint/i18n';
|
|
|
4
4
|
import type { MLMarkupLanguageParser, ParserOptions } from '@markuplint/ml-ast';
|
|
5
5
|
import type { Pretender } from '@markuplint/ml-config';
|
|
6
6
|
import type { ExtendedSpec, MLMLSpec } from '@markuplint/ml-spec';
|
|
7
|
-
export type MLSchema =
|
|
7
|
+
export type MLSchema = readonly [MLMLSpec, ...ExtendedSpec[]];
|
|
8
8
|
export type MLFabric = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
readonly parser: Readonly<MLMarkupLanguageParser>;
|
|
10
|
+
readonly ruleset: Partial<Readonly<Ruleset>>;
|
|
11
|
+
readonly rules: readonly Readonly<AnyMLRule>[];
|
|
12
|
+
readonly locale: LocaleSet;
|
|
13
|
+
readonly schemas: MLSchema;
|
|
14
|
+
readonly parserOptions: ParserOptions;
|
|
15
|
+
readonly pretenders: readonly Pretender[];
|
|
16
|
+
readonly configErrors?: readonly Readonly<Error>[];
|
|
16
17
|
};
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
interface Location {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
line: number;
|
|
3
|
+
col: number;
|
|
4
|
+
raw: string;
|
|
5
5
|
}
|
|
6
|
-
export declare function getLocationFromChars(
|
|
7
|
-
searches: string[],
|
|
8
|
-
text: string,
|
|
9
|
-
currentLine: number,
|
|
10
|
-
currentCol: number,
|
|
11
|
-
): Location[];
|
|
6
|
+
export declare function getLocationFromChars(searches: readonly string[], text: string, currentLine: number, currentCol: number): Location[];
|
|
12
7
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/ml-core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
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>",
|
|
@@ -23,21 +23,23 @@
|
|
|
23
23
|
"./lib/configs.js": "./lib/configs.browser.js"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@markuplint/config-presets": "3.
|
|
27
|
-
"@markuplint/html-parser": "3.
|
|
28
|
-
"@markuplint/html-spec": "3.
|
|
29
|
-
"@markuplint/i18n": "3.
|
|
30
|
-
"@markuplint/ml-ast": "3.
|
|
31
|
-
"@markuplint/ml-config": "3.
|
|
32
|
-
"@markuplint/ml-spec": "3.
|
|
33
|
-
"@markuplint/parser-utils": "3.
|
|
34
|
-
"@markuplint/selector": "3.
|
|
26
|
+
"@markuplint/config-presets": "3.4.0",
|
|
27
|
+
"@markuplint/html-parser": "3.5.0",
|
|
28
|
+
"@markuplint/html-spec": "3.5.0",
|
|
29
|
+
"@markuplint/i18n": "3.5.0",
|
|
30
|
+
"@markuplint/ml-ast": "3.1.0",
|
|
31
|
+
"@markuplint/ml-config": "3.5.0",
|
|
32
|
+
"@markuplint/ml-spec": "3.5.0",
|
|
33
|
+
"@markuplint/parser-utils": "3.5.0",
|
|
34
|
+
"@markuplint/selector": "3.5.0",
|
|
35
35
|
"debug": "^4.3.4",
|
|
36
|
+
"is-plain-object": "^5.0.0",
|
|
36
37
|
"tslib": "^2.4.1"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@markuplint/html-parser": "3.3.0",
|
|
40
|
-
"@types/debug": "^4.1.7"
|
|
41
|
+
"@types/debug": "^4.1.7",
|
|
42
|
+
"type-fest": "^3.6.1"
|
|
41
43
|
},
|
|
42
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "0c47b2c2722f6823a17f36edbab98486275f8ab4"
|
|
43
45
|
}
|