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