@markuplint/ml-config 3.3.0 → 3.4.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/types.d.ts +124 -120
- package/lib/utils.d.ts +7 -2
- package/lib/utils.js +2 -1
- package/package.json +3 -3
package/lib/types.d.ts
CHANGED
|
@@ -2,92 +2,96 @@ import type { ParserOptions } from '@markuplint/ml-ast';
|
|
|
2
2
|
import type { RegexSelector } from '@markuplint/selector';
|
|
3
3
|
export type { RegexSelector } from '@markuplint/selector';
|
|
4
4
|
export interface Config {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
$schema?: string;
|
|
6
|
+
extends?: string | string[];
|
|
7
|
+
plugins?: (PluginConfig | string)[];
|
|
8
|
+
parser?: ParserConfig;
|
|
9
|
+
parserOptions?: ParserOptions;
|
|
10
|
+
specs?: SpecConfig;
|
|
11
|
+
excludeFiles?: string[];
|
|
12
|
+
pretenders?: Pretender[];
|
|
13
|
+
rules?: Rules;
|
|
14
|
+
nodeRules?: NodeRule[];
|
|
15
|
+
childNodeRules?: ChildNodeRule[];
|
|
16
|
+
overrides?: Record<string, Omit<Config, '$schema' | 'extends' | 'overrides'>>;
|
|
17
17
|
}
|
|
18
18
|
export type PluginConfig = {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
name: string;
|
|
20
|
+
settings: Record<string, any>;
|
|
21
21
|
};
|
|
22
22
|
export interface ParserConfig {
|
|
23
|
-
|
|
23
|
+
[extensionPattern: string]: string;
|
|
24
24
|
}
|
|
25
25
|
export type SpecConfig = {
|
|
26
|
-
|
|
26
|
+
[extensionPattern: string]: string;
|
|
27
27
|
};
|
|
28
28
|
export type Pretender = {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Target node selectors
|
|
31
|
+
*/
|
|
32
|
+
selector: string;
|
|
33
|
+
/**
|
|
34
|
+
* If it is a string, it is resolved as an element name.
|
|
35
|
+
* An element has the same attributes as the pretended custom element
|
|
36
|
+
* because attributes are just inherited.
|
|
37
|
+
*
|
|
38
|
+
* If it is an Object, It creates the element by that.
|
|
39
|
+
*/
|
|
40
|
+
as: string | OriginalNode;
|
|
41
41
|
};
|
|
42
42
|
export type OriginalNode = {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Element name
|
|
45
|
+
*/
|
|
46
|
+
element: string;
|
|
47
|
+
/**
|
|
48
|
+
* Namespace
|
|
49
|
+
*
|
|
50
|
+
* Supports `"svg"` and `undefined` only.
|
|
51
|
+
* If it is `undefined`, the namespace is HTML.
|
|
52
|
+
*/
|
|
53
|
+
namespace?: 'svg';
|
|
54
|
+
/**
|
|
55
|
+
* Attributes
|
|
56
|
+
*/
|
|
57
|
+
attrs?: {
|
|
58
|
+
/**
|
|
59
|
+
* Attribute name
|
|
60
|
+
*/
|
|
61
|
+
name: string;
|
|
62
|
+
/**
|
|
63
|
+
* If it omits this property, the attribute is resolved as a boolean.
|
|
64
|
+
*/
|
|
65
|
+
value?:
|
|
66
|
+
| string
|
|
67
|
+
| {
|
|
68
|
+
fromAttr: string;
|
|
69
|
+
};
|
|
70
|
+
}[];
|
|
71
|
+
/**
|
|
72
|
+
* To have attributes the defined element has.
|
|
73
|
+
*/
|
|
74
|
+
inheritAttrs?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* ARIA properties
|
|
77
|
+
*/
|
|
78
|
+
aria?: PretenderARIA;
|
|
77
79
|
};
|
|
78
80
|
/**
|
|
79
81
|
* Pretender Node ARIA properties
|
|
80
82
|
*/
|
|
81
83
|
export type PretenderARIA = {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Accessible name
|
|
86
|
+
*
|
|
87
|
+
* - If it is `true`, it assumes the element has any text on its accessible name.
|
|
88
|
+
* - If it specifies `fromAttr` property, it assumes the accessible name refers to the value of the attribute.
|
|
89
|
+
*/
|
|
90
|
+
name?:
|
|
91
|
+
| boolean
|
|
92
|
+
| {
|
|
93
|
+
fromAttr: string;
|
|
94
|
+
};
|
|
91
95
|
};
|
|
92
96
|
export type Rule<T extends RuleConfigValue, O = void> = RuleConfig<T, O> | T | boolean;
|
|
93
97
|
/**
|
|
@@ -100,80 +104,80 @@ export type AnyRule = Rule<RuleConfigValue, unknown>;
|
|
|
100
104
|
*/
|
|
101
105
|
export type AnyRuleV2 = RuleV2<RuleConfigValue, unknown>;
|
|
102
106
|
export interface Rules {
|
|
103
|
-
|
|
107
|
+
[ruleName: string]: AnyRule;
|
|
104
108
|
}
|
|
105
109
|
export type RuleConfig<T extends RuleConfigValue, O = void> = {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
severity?: Severity;
|
|
111
|
+
value?: T;
|
|
112
|
+
options?: O;
|
|
113
|
+
reason?: string;
|
|
110
114
|
};
|
|
111
115
|
/**
|
|
112
116
|
* @deprecated
|
|
113
117
|
*/
|
|
114
118
|
export type RuleConfigV2<T extends RuleConfigValue, O = void> = {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
severity?: Severity;
|
|
120
|
+
value?: T;
|
|
121
|
+
reason?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Old property
|
|
124
|
+
*
|
|
125
|
+
* @deprecated
|
|
126
|
+
* @see {this.options}
|
|
127
|
+
*/
|
|
128
|
+
option?: O;
|
|
125
129
|
};
|
|
126
130
|
export type Severity = 'error' | 'warning' | 'info';
|
|
127
131
|
export type RuleConfigValue = string | number | boolean | any[] | null;
|
|
128
132
|
export interface NodeRule {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
selector?: string;
|
|
134
|
+
regexSelector?: RegexSelector;
|
|
135
|
+
categories?: string[];
|
|
136
|
+
roles?: string[];
|
|
137
|
+
obsolete?: boolean;
|
|
138
|
+
rules?: Rules;
|
|
135
139
|
}
|
|
136
140
|
export interface ChildNodeRule {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
+
selector?: string;
|
|
142
|
+
regexSelector?: RegexSelector;
|
|
143
|
+
inheritance?: boolean;
|
|
144
|
+
rules?: Rules;
|
|
141
145
|
}
|
|
142
146
|
export type Report<T extends RuleConfigValue, O = null> = Report1<T, O> | Report2 | (Report1<T, O> & Report2);
|
|
143
147
|
export type Report1<T extends RuleConfigValue, O = null> = {
|
|
144
|
-
|
|
145
|
-
|
|
148
|
+
message: string;
|
|
149
|
+
scope: Scope<T, O>;
|
|
146
150
|
};
|
|
147
151
|
export type Report2 = {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
+
message: string;
|
|
153
|
+
line: number;
|
|
154
|
+
col: number;
|
|
155
|
+
raw: string;
|
|
152
156
|
};
|
|
153
157
|
export type Scope<T extends RuleConfigValue, O = null> = {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
+
rule: RuleInfo<T, O>;
|
|
159
|
+
startLine: number;
|
|
160
|
+
startCol: number;
|
|
161
|
+
raw: string;
|
|
158
162
|
};
|
|
159
163
|
export interface Violation {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
ruleId: string;
|
|
165
|
+
severity: Severity;
|
|
166
|
+
message: string;
|
|
167
|
+
reason?: string;
|
|
168
|
+
line: number;
|
|
169
|
+
col: number;
|
|
170
|
+
raw: string;
|
|
167
171
|
}
|
|
168
172
|
export interface RuleInfo<T extends RuleConfigValue, O = null> {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
173
|
+
disabled: boolean;
|
|
174
|
+
severity: Severity;
|
|
175
|
+
value: T;
|
|
176
|
+
options: O;
|
|
177
|
+
reason?: string;
|
|
174
178
|
}
|
|
175
179
|
export type GlobalRuleInfo<T extends RuleConfigValue, O = null> = RuleInfo<T, O> & {
|
|
176
|
-
|
|
177
|
-
|
|
180
|
+
nodeRules: RuleInfo<T, O>[];
|
|
181
|
+
childNodeRules: RuleInfo<T, O>[];
|
|
178
182
|
};
|
|
179
183
|
export type Nullable<T> = T | null | undefined;
|
package/lib/utils.d.ts
CHANGED
|
@@ -7,8 +7,13 @@ import type { AnyRule, AnyRuleV2, RuleConfig, RuleConfigV2, RuleConfigValue } fr
|
|
|
7
7
|
* @param data Captured string for replacement
|
|
8
8
|
*/
|
|
9
9
|
export declare function provideValue(template: string, data: Record<string, string>): string | undefined;
|
|
10
|
-
export declare function exchangeValueOnRule(
|
|
11
|
-
|
|
10
|
+
export declare function exchangeValueOnRule(
|
|
11
|
+
rule: AnyRule | AnyRuleV2,
|
|
12
|
+
data: Record<string, string>,
|
|
13
|
+
): AnyRule | undefined;
|
|
14
|
+
export declare function cleanOptions(
|
|
15
|
+
rule: RuleConfig<RuleConfigValue, unknown> | RuleConfigV2<RuleConfigValue, unknown>,
|
|
16
|
+
): RuleConfig<RuleConfigValue, unknown>;
|
|
12
17
|
export declare function isRuleConfigValue(v: any): v is RuleConfigValue;
|
|
13
18
|
/**
|
|
14
19
|
*
|
package/lib/utils.js
CHANGED
|
@@ -12,8 +12,9 @@ const mustache_1 = tslib_1.__importDefault(require("mustache"));
|
|
|
12
12
|
* @param data Captured string for replacement
|
|
13
13
|
*/
|
|
14
14
|
function provideValue(template, data) {
|
|
15
|
+
var _a;
|
|
15
16
|
const ast = mustache_1.default.parse(template);
|
|
16
|
-
if (ast.length === 1 && ast[0][0] === 'text') {
|
|
17
|
+
if (ast.length === 1 && ((_a = ast[0]) === null || _a === void 0 ? void 0 : _a[0]) === 'text') {
|
|
17
18
|
// It doesn't have a variable
|
|
18
19
|
return template;
|
|
19
20
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/ml-config",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "JSON Schema and TypeScript types of markuplint configure JSON",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"@types/mustache": "^4.2.2"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@markuplint/selector": "3.
|
|
26
|
+
"@markuplint/selector": "3.4.0",
|
|
27
27
|
"deepmerge": "^4.2.2",
|
|
28
28
|
"is-plain-object": "^5.0.0",
|
|
29
29
|
"mustache": "^4.2.0"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "a83e0f5f214a9bbcc0286b9e269074ddca6189e7"
|
|
32
32
|
}
|