@markuplint/rules 3.7.0 → 3.9.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/helpers.d.ts +2 -5
- package/lib/index.d.ts +240 -99
- package/lib/invalid-attr/index.d.ts +38 -31
- package/lib/no-refer-to-non-existent-id/index.d.ts +1 -2
- package/lib/no-refer-to-non-existent-id/index.js +2 -1
- package/lib/require-accessible-name/index.js +1 -1
- package/lib/required-attr/index.d.ts +1 -1
- package/lib/required-attr/index.js +1 -1
- package/lib/wai-aria/checkings/_.d.ts +15 -0
- package/lib/wai-aria/checkings/_.js +27 -0
- package/lib/wai-aria/checkings/required-prop copy.d.ts +15 -0
- package/lib/wai-aria/checkings/required-prop copy.js +27 -0
- package/lib/wai-aria/checkings/unadopted-explicit-roles.d.ts +15 -0
- package/lib/wai-aria/checkings/unadopted-explicit-roles.js +17 -0
- package/lib/wai-aria/index.js +2 -1
- package/lib/xxx/index.d.ts +2 -0
- package/lib/xxx/index.js +32 -0
- package/package.json +11 -13
- package/test/attr-check.spec.js +77 -0
- package/test/attr-duplication/index.spec.js +159 -0
- package/test/attr-value-quotes/index.spec.js +133 -0
- package/test/case-sensitive-attr-name/index.spec.js +65 -0
- package/test/case-sensitive-tag-name/index.spec.js +80 -0
- package/test/character-reference/index.spec.js +57 -0
- package/test/class-naming/index.spec.js +470 -0
- package/test/create-message.spec.js +497 -0
- package/test/deprecated-attr/index.spec.js +48 -0
- package/test/deprecated-element/index.spec.js +48 -0
- package/test/disallowed-element/index.spec.js +90 -0
- package/test/doctype/index.spec.js +50 -0
- package/test/end-tag/index.spec.js +162 -0
- package/test/id-duplication/index.spec.js +47 -0
- package/test/ineffective-attr/index.spec.js +31 -0
- package/test/invalid-attr/index.spec.js +1632 -0
- package/test/label-has-control/index.spec.js +29 -0
- package/test/landmark-roles/index.spec.js +187 -0
- package/test/no-boolean-attr-value/index.spec.js +41 -0
- package/test/no-default-value/index.spec.js +74 -0
- package/test/no-empty-palpable-content/index.spec.js +115 -0
- package/test/no-hard-code-id/index.spec.js +100 -0
- package/test/no-refer-to-non-existent-id/index.spec.js +254 -0
- package/test/no-use-event-handler-attr/index.spec.js +57 -0
- package/test/permitted-contents/choice.spec.js +174 -0
- package/test/permitted-contents/count-pattern.spec.js +308 -0
- package/test/permitted-contents/index.spec.js +1371 -0
- package/test/permitted-contents/matches-selector.spec.js +59 -0
- package/test/permitted-contents/order.spec.js +351 -0
- package/test/permitted-contents/recursive-branch.spec.js +41 -0
- package/test/permitted-contents/represent-transparent-nodes.spec.js +24 -0
- package/test/permitted-contents/start.spec.js +67 -0
- package/test/placeholder-label-option/index.spec.js +113 -0
- package/test/require-accessible-name/index.spec.js +446 -0
- package/test/require-datetime/index.spec.js +54 -0
- package/test/require-datetime/utils.spec.js +52 -0
- package/test/required-attr/index.spec.js +414 -0
- package/test/required-element/index.spec.js +188 -0
- package/test/required-h1/index.spec.js +69 -0
- package/test/use-list/index.spec.js +109 -0
- package/test/wai-aria/checkings/value.spec.js +33 -0
- package/test/wai-aria/index.spec.js +1173 -0
package/lib/helpers.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { Translator } from '@markuplint/i18n';
|
|
|
3
3
|
import type { PlainData } from '@markuplint/ml-config';
|
|
4
4
|
import type { Element, RuleConfigValue, Document } from '@markuplint/ml-core';
|
|
5
5
|
import type { Attribute } from '@markuplint/ml-spec';
|
|
6
|
+
import type { WritableDeep } from 'type-fest';
|
|
6
7
|
export declare function attrMatches<T extends RuleConfigValue, O extends PlainData>(
|
|
7
8
|
node: Element<T, O>,
|
|
8
9
|
condition: Attribute['condition'],
|
|
@@ -58,8 +59,4 @@ export declare class Collection<T> {
|
|
|
58
59
|
add(...items: readonly (T | null | undefined)[]): void;
|
|
59
60
|
toArray(): readonly T[];
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
-
-readonly [P in keyof T]: T[P];
|
|
63
|
-
};
|
|
64
|
-
export declare function deepCopy<T>(value: T): Writeable<T>;
|
|
65
|
-
export {};
|
|
62
|
+
export declare function deepCopy<T>(value: T): WritableDeep<T>;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,102 +1,243 @@
|
|
|
1
1
|
declare const rules: {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
2
|
+
readonly 'attr-duplication': Readonly<
|
|
3
|
+
import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
|
|
4
|
+
>;
|
|
5
|
+
readonly 'attr-value-quotes': Readonly<
|
|
6
|
+
import('@markuplint/ml-core').RuleSeed<import('./attr-value-quotes').Type, undefined>
|
|
7
|
+
>;
|
|
8
|
+
readonly 'case-sensitive-attr-name': Readonly<
|
|
9
|
+
import('@markuplint/ml-core').RuleSeed<import('./case-sensitive-attr-name').Value, undefined>
|
|
10
|
+
>;
|
|
11
|
+
readonly 'case-sensitive-tag-name': Readonly<
|
|
12
|
+
import('@markuplint/ml-core').RuleSeed<import('./case-sensitive-tag-name').Value, undefined>
|
|
13
|
+
>;
|
|
14
|
+
readonly 'character-reference': Readonly<
|
|
15
|
+
import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
|
|
16
|
+
>;
|
|
17
|
+
readonly 'class-naming': Readonly<
|
|
18
|
+
import('@markuplint/ml-core').RuleSeed<import('./class-naming').Value, undefined>
|
|
19
|
+
>;
|
|
20
|
+
readonly 'deprecated-attr': Readonly<
|
|
21
|
+
import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
|
|
22
|
+
>;
|
|
23
|
+
readonly 'deprecated-element': Readonly<
|
|
24
|
+
import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
|
|
25
|
+
>;
|
|
26
|
+
readonly 'disallowed-element': Readonly<import('@markuplint/ml-core').RuleSeed<string[], undefined>>;
|
|
27
|
+
readonly doctype: Readonly<
|
|
28
|
+
import('@markuplint/ml-core').RuleSeed<
|
|
29
|
+
'always',
|
|
30
|
+
{
|
|
31
|
+
denyObsoleteType: boolean;
|
|
32
|
+
}
|
|
33
|
+
>
|
|
34
|
+
>;
|
|
35
|
+
readonly 'end-tag': Readonly<import('@markuplint/ml-core').RuleSeed<boolean, undefined>>;
|
|
36
|
+
readonly 'id-duplication': Readonly<
|
|
37
|
+
import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
|
|
38
|
+
>;
|
|
39
|
+
readonly 'ineffective-attr': Readonly<
|
|
40
|
+
import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
|
|
41
|
+
>;
|
|
42
|
+
readonly 'invalid-attr': Readonly<
|
|
43
|
+
import('@markuplint/ml-core').RuleSeed<
|
|
44
|
+
boolean,
|
|
45
|
+
{
|
|
46
|
+
allowAttrs?:
|
|
47
|
+
| Record<
|
|
48
|
+
string,
|
|
49
|
+
| {
|
|
50
|
+
enum: [string, ...string[]];
|
|
51
|
+
}
|
|
52
|
+
| {
|
|
53
|
+
pattern: string;
|
|
54
|
+
}
|
|
55
|
+
| {
|
|
56
|
+
type: import('packages/@markuplint/ml-spec/lib').AttributeType;
|
|
57
|
+
}
|
|
58
|
+
>
|
|
59
|
+
| (
|
|
60
|
+
| string
|
|
61
|
+
| {
|
|
62
|
+
name: string;
|
|
63
|
+
value:
|
|
64
|
+
| import('packages/@markuplint/ml-spec/lib').AttributeType
|
|
65
|
+
| (
|
|
66
|
+
| {
|
|
67
|
+
enum: [string, ...string[]];
|
|
68
|
+
}
|
|
69
|
+
| {
|
|
70
|
+
pattern: string;
|
|
71
|
+
}
|
|
72
|
+
| {
|
|
73
|
+
type: import('packages/@markuplint/ml-spec/lib').AttributeType;
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
)[]
|
|
78
|
+
| undefined;
|
|
79
|
+
disallowAttrs?:
|
|
80
|
+
| Record<
|
|
81
|
+
string,
|
|
82
|
+
| {
|
|
83
|
+
enum: [string, ...string[]];
|
|
84
|
+
}
|
|
85
|
+
| {
|
|
86
|
+
pattern: string;
|
|
87
|
+
}
|
|
88
|
+
| {
|
|
89
|
+
type: import('packages/@markuplint/ml-spec/lib').AttributeType;
|
|
90
|
+
}
|
|
91
|
+
>
|
|
92
|
+
| (
|
|
93
|
+
| string
|
|
94
|
+
| {
|
|
95
|
+
name: string;
|
|
96
|
+
value:
|
|
97
|
+
| import('packages/@markuplint/ml-spec/lib').AttributeType
|
|
98
|
+
| (
|
|
99
|
+
| {
|
|
100
|
+
enum: [string, ...string[]];
|
|
101
|
+
}
|
|
102
|
+
| {
|
|
103
|
+
pattern: string;
|
|
104
|
+
}
|
|
105
|
+
| {
|
|
106
|
+
type: import('packages/@markuplint/ml-spec/lib').AttributeType;
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
)[]
|
|
111
|
+
| undefined;
|
|
112
|
+
ignoreAttrNamePrefix?: string | string[] | undefined;
|
|
113
|
+
allowToAddPropertiesForPretender?: boolean | undefined;
|
|
114
|
+
attrs?:
|
|
115
|
+
| Record<
|
|
116
|
+
string,
|
|
117
|
+
| (
|
|
118
|
+
| {
|
|
119
|
+
enum: [string, ...string[]];
|
|
120
|
+
}
|
|
121
|
+
| {
|
|
122
|
+
pattern: string;
|
|
123
|
+
}
|
|
124
|
+
| {
|
|
125
|
+
type: import('packages/@markuplint/ml-spec/lib').AttributeType;
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
| {
|
|
129
|
+
disallowed: true;
|
|
130
|
+
}
|
|
131
|
+
>
|
|
132
|
+
| undefined;
|
|
133
|
+
}
|
|
134
|
+
>
|
|
135
|
+
>;
|
|
136
|
+
readonly 'label-has-control': Readonly<
|
|
137
|
+
import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
|
|
138
|
+
>;
|
|
139
|
+
readonly 'landmark-roles': Readonly<
|
|
140
|
+
import('@markuplint/ml-core').RuleSeed<
|
|
141
|
+
boolean,
|
|
142
|
+
{
|
|
143
|
+
ignoreRoles: (
|
|
144
|
+
| ('banner' | 'main' | 'complementary' | 'contentinfo')
|
|
145
|
+
| 'form'
|
|
146
|
+
| 'navigation'
|
|
147
|
+
| 'region'
|
|
148
|
+
)[];
|
|
149
|
+
labelEachArea: boolean;
|
|
150
|
+
}
|
|
151
|
+
>
|
|
152
|
+
>;
|
|
153
|
+
readonly 'no-boolean-attr-value': Readonly<
|
|
154
|
+
import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
|
|
155
|
+
>;
|
|
156
|
+
readonly 'no-default-value': Readonly<
|
|
157
|
+
import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
|
|
158
|
+
>;
|
|
159
|
+
readonly 'no-empty-palpable-content': Readonly<
|
|
160
|
+
import('@markuplint/ml-core').RuleSeed<
|
|
161
|
+
boolean,
|
|
162
|
+
{
|
|
163
|
+
extendsExposableElements?: boolean | undefined;
|
|
164
|
+
ignoreIfAriaBusy?: boolean | undefined;
|
|
165
|
+
}
|
|
166
|
+
>
|
|
167
|
+
>;
|
|
168
|
+
readonly 'no-hard-code-id': Readonly<
|
|
169
|
+
import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
|
|
170
|
+
>;
|
|
171
|
+
readonly 'no-refer-to-non-existent-id': Readonly<
|
|
172
|
+
import('@markuplint/ml-core').RuleSeed<
|
|
173
|
+
import('@markuplint/ml-core').RuleConfigValue,
|
|
174
|
+
{
|
|
175
|
+
ariaVersion: '1.1' | '1.2' | '1.3';
|
|
176
|
+
fragmentRefersNameAttr: boolean;
|
|
177
|
+
}
|
|
178
|
+
>
|
|
179
|
+
>;
|
|
180
|
+
readonly 'no-use-event-handler-attr': Readonly<
|
|
181
|
+
import('@markuplint/ml-core').RuleSeed<
|
|
182
|
+
boolean,
|
|
183
|
+
{
|
|
184
|
+
ignore?: string | string[] | undefined;
|
|
185
|
+
}
|
|
186
|
+
>
|
|
187
|
+
>;
|
|
188
|
+
readonly 'permitted-contents': Readonly<
|
|
189
|
+
import('@markuplint/ml-core').RuleSeed<
|
|
190
|
+
import('./permitted-contents/types').TagRule[],
|
|
191
|
+
import('./permitted-contents/types').Options
|
|
192
|
+
>
|
|
193
|
+
>;
|
|
194
|
+
readonly 'placeholder-label-option': Readonly<import('@markuplint/ml-core').RuleSeed<boolean, undefined>>;
|
|
195
|
+
readonly 'require-accessible-name': Readonly<
|
|
196
|
+
import('@markuplint/ml-core').RuleSeed<
|
|
197
|
+
boolean,
|
|
198
|
+
{
|
|
199
|
+
ariaVersion: '1.1' | '1.2' | '1.3';
|
|
200
|
+
}
|
|
201
|
+
>
|
|
202
|
+
>;
|
|
203
|
+
readonly 'require-datetime': Readonly<
|
|
204
|
+
import('@markuplint/ml-core').RuleSeed<
|
|
205
|
+
boolean,
|
|
206
|
+
{
|
|
207
|
+
langs?: import('./require-datetime/types').Lang[] | undefined;
|
|
208
|
+
}
|
|
209
|
+
>
|
|
210
|
+
>;
|
|
211
|
+
readonly 'required-attr': Readonly<
|
|
212
|
+
import('@markuplint/ml-core').RuleSeed<
|
|
213
|
+
| string
|
|
214
|
+
| (
|
|
215
|
+
| string
|
|
216
|
+
| {
|
|
217
|
+
name: string;
|
|
218
|
+
value?: string | string[] | undefined;
|
|
219
|
+
}
|
|
220
|
+
)[],
|
|
221
|
+
undefined
|
|
222
|
+
>
|
|
223
|
+
>;
|
|
224
|
+
readonly 'required-element': Readonly<
|
|
225
|
+
import('@markuplint/ml-core').RuleSeed<
|
|
226
|
+
string[],
|
|
227
|
+
{
|
|
228
|
+
ignoreHasMutableContents: boolean;
|
|
229
|
+
}
|
|
230
|
+
>
|
|
231
|
+
>;
|
|
232
|
+
readonly 'required-h1': Readonly<import('@markuplint/ml-core').RuleSeed<boolean, import('./required-h1').Options>>;
|
|
233
|
+
readonly 'use-list': Readonly<
|
|
234
|
+
import('@markuplint/ml-core').RuleSeed<
|
|
235
|
+
readonly string[],
|
|
236
|
+
{
|
|
237
|
+
spaceNeededBullets?: string[] | undefined;
|
|
238
|
+
}
|
|
239
|
+
>
|
|
240
|
+
>;
|
|
241
|
+
readonly 'wai-aria': Readonly<import('@markuplint/ml-core').RuleSeed<boolean, import('./wai-aria/types').Options>>;
|
|
101
242
|
};
|
|
102
243
|
export default rules;
|
|
@@ -1,37 +1,44 @@
|
|
|
1
1
|
import type { AttributeType } from '@markuplint/ml-spec';
|
|
2
2
|
type Option = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @since 3.7.0
|
|
5
|
+
*/
|
|
6
|
+
allowAttrs?: (string | Attr)[] | Record<string, ValueRule>;
|
|
7
|
+
/**
|
|
8
|
+
* @since 3.7.0
|
|
9
|
+
*/
|
|
10
|
+
disallowAttrs?: (string | Attr)[] | Record<string, ValueRule>;
|
|
11
|
+
ignoreAttrNamePrefix?: string | string[];
|
|
12
|
+
allowToAddPropertiesForPretender?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Since version 3.7.0. Use `allowAttrs` or `disallowAttrs` instead.
|
|
15
|
+
* This option (`attr`) is now considered ambiguous and may lead to confusion.
|
|
16
|
+
* Please use the more explicit `allowAttrs` or `disallowAttrs` option
|
|
17
|
+
* to specify allowed attributes for the `invalid-attr` rule.
|
|
18
|
+
* @see {@link Option.allowAttrs}
|
|
19
|
+
* @see {@link Option.disallowAttrs}
|
|
20
|
+
*/
|
|
21
|
+
attrs?: Record<
|
|
22
|
+
string,
|
|
23
|
+
| ValueRule
|
|
24
|
+
| {
|
|
25
|
+
disallowed: true;
|
|
26
|
+
}
|
|
27
|
+
>;
|
|
24
28
|
};
|
|
25
29
|
type Attr = {
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
name: string;
|
|
31
|
+
value: AttributeType | ValueRule;
|
|
28
32
|
};
|
|
29
|
-
type ValueRule =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
33
|
+
type ValueRule =
|
|
34
|
+
| {
|
|
35
|
+
enum: [string, ...string[]];
|
|
36
|
+
}
|
|
37
|
+
| {
|
|
38
|
+
pattern: string;
|
|
39
|
+
}
|
|
40
|
+
| {
|
|
41
|
+
type: AttributeType;
|
|
42
|
+
};
|
|
43
|
+
declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<boolean, Option>>;
|
|
37
44
|
export default _default;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { ARIAVersion } from '@markuplint/ml-spec';
|
|
2
1
|
declare const _default: Readonly<
|
|
3
2
|
import('@markuplint/ml-core').RuleSeed<
|
|
4
3
|
import('@markuplint/ml-core').RuleConfigValue,
|
|
5
4
|
{
|
|
6
|
-
ariaVersion:
|
|
5
|
+
ariaVersion: '1.1' | '1.2' | '1.3';
|
|
7
6
|
fragmentRefersNameAttr: boolean;
|
|
8
7
|
}
|
|
9
8
|
>
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ml_core_1 = require("@markuplint/ml-core");
|
|
4
|
+
const ml_spec_1 = require("@markuplint/ml-spec");
|
|
4
5
|
const shared_1 = require("@markuplint/shared");
|
|
5
6
|
const HYPERLINK_SELECTOR = 'a[href], area[href]';
|
|
6
7
|
exports.default = (0, ml_core_1.createRule)({
|
|
7
8
|
defaultOptions: {
|
|
8
|
-
ariaVersion:
|
|
9
|
+
ariaVersion: ml_spec_1.ARIA_RECOMMENDED_VERSION,
|
|
9
10
|
fragmentRefersNameAttr: false,
|
|
10
11
|
},
|
|
11
12
|
async verify({ document, report, t }) {
|
|
@@ -5,7 +5,7 @@ const ml_spec_1 = require("@markuplint/ml-spec");
|
|
|
5
5
|
const helpers_1 = require("../helpers");
|
|
6
6
|
exports.default = (0, ml_core_1.createRule)({
|
|
7
7
|
defaultOptions: {
|
|
8
|
-
ariaVersion:
|
|
8
|
+
ariaVersion: ml_spec_1.ARIA_RECOMMENDED_VERSION,
|
|
9
9
|
},
|
|
10
10
|
async verify({ document, report, t }) {
|
|
11
11
|
await document.walkOn('Element', el => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
type RequiredAttributes = string | (string | Attr)[];
|
|
2
2
|
type Attr = {
|
|
3
3
|
name: string;
|
|
4
|
-
value
|
|
4
|
+
value?: string | string[];
|
|
5
5
|
};
|
|
6
6
|
declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<RequiredAttributes, undefined>>;
|
|
7
7
|
export default _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Options } from '../types';
|
|
2
|
+
import type { ElementChecker } from '@markuplint/ml-core';
|
|
3
|
+
import type { ARIAProperty, ARIARole } from '@markuplint/ml-spec';
|
|
4
|
+
export declare const checkingRequiredProp: ElementChecker<
|
|
5
|
+
boolean,
|
|
6
|
+
Options,
|
|
7
|
+
{
|
|
8
|
+
role?:
|
|
9
|
+
| (ARIARole & {
|
|
10
|
+
isImplicit?: boolean;
|
|
11
|
+
})
|
|
12
|
+
| null;
|
|
13
|
+
propSpecs: readonly ARIAProperty[];
|
|
14
|
+
}
|
|
15
|
+
>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkingRequiredProp = void 0;
|
|
4
|
+
const checkingRequiredProp = ({ el, role, propSpecs }) => t => {
|
|
5
|
+
var _a;
|
|
6
|
+
if (!role) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (role.isImplicit) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const requiredProps = role.ownedProperties.filter(s => s.required).map(s => s.name);
|
|
13
|
+
for (const requiredProp of requiredProps) {
|
|
14
|
+
const has = el.attributes.some(attr => {
|
|
15
|
+
const attrName = attr.name.toLowerCase();
|
|
16
|
+
return attrName === requiredProp;
|
|
17
|
+
});
|
|
18
|
+
if (!has) {
|
|
19
|
+
const propSpec = propSpecs.find(p => p.name === requiredProp);
|
|
20
|
+
return {
|
|
21
|
+
scope: el,
|
|
22
|
+
message: t('{0:c} on {1}', t('Require {0}', t('the "{0*}" {1}', requiredProp, `ARIA ${(_a = propSpec === null || propSpec === void 0 ? void 0 : propSpec.type) !== null && _a !== void 0 ? _a : 'property'}`)), t('the "{0*}" {1}', role.name, 'role')),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.checkingRequiredProp = checkingRequiredProp;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Options } from '../types';
|
|
2
|
+
import type { ElementChecker } from '@markuplint/ml-core';
|
|
3
|
+
import type { ARIAProperty, ARIARole } from '@markuplint/ml-spec';
|
|
4
|
+
export declare const checkingRequiredProp: ElementChecker<
|
|
5
|
+
boolean,
|
|
6
|
+
Options,
|
|
7
|
+
{
|
|
8
|
+
role?:
|
|
9
|
+
| (ARIARole & {
|
|
10
|
+
isImplicit?: boolean;
|
|
11
|
+
})
|
|
12
|
+
| null;
|
|
13
|
+
propSpecs: readonly ARIAProperty[];
|
|
14
|
+
}
|
|
15
|
+
>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkingRequiredProp = void 0;
|
|
4
|
+
const checkingRequiredProp = ({ el, role, propSpecs }) => t => {
|
|
5
|
+
var _a;
|
|
6
|
+
if (!role) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (role.isImplicit) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const requiredProps = role.ownedProperties.filter(s => s.required).map(s => s.name);
|
|
13
|
+
for (const requiredProp of requiredProps) {
|
|
14
|
+
const has = el.attributes.some(attr => {
|
|
15
|
+
const attrName = attr.name.toLowerCase();
|
|
16
|
+
return attrName === requiredProp;
|
|
17
|
+
});
|
|
18
|
+
if (!has) {
|
|
19
|
+
const propSpec = propSpecs.find(p => p.name === requiredProp);
|
|
20
|
+
return {
|
|
21
|
+
scope: el,
|
|
22
|
+
message: t('{0:c} on {1}', t('Require {0}', t('the "{0*}" {1}', requiredProp, `ARIA ${(_a = propSpec === null || propSpec === void 0 ? void 0 : propSpec.type) !== null && _a !== void 0 ? _a : 'property'}`)), t('the "{0*}" {1}', role.name, 'role')),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.checkingRequiredProp = checkingRequiredProp;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Options } from '../types';
|
|
2
|
+
import type { ElementChecker } from '@markuplint/ml-core';
|
|
3
|
+
import type { ARIAProperty, ARIARole } from '@markuplint/ml-spec';
|
|
4
|
+
export declare const checkingUnadoptedExplicitRoles: ElementChecker<
|
|
5
|
+
boolean,
|
|
6
|
+
Options,
|
|
7
|
+
{
|
|
8
|
+
role?:
|
|
9
|
+
| (ARIARole & {
|
|
10
|
+
isImplicit?: boolean;
|
|
11
|
+
})
|
|
12
|
+
| null;
|
|
13
|
+
propSpecs: readonly ARIAProperty[];
|
|
14
|
+
}
|
|
15
|
+
>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkingUnadoptedExplicitRoles = void 0;
|
|
4
|
+
const checkingUnadoptedExplicitRoles = ({ el, role, propSpecs }) => t => {
|
|
5
|
+
if (!role) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
if (role.name) {
|
|
9
|
+
console.log(el.localName, role.name);
|
|
10
|
+
return {
|
|
11
|
+
scope: el,
|
|
12
|
+
message: '',
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
return;
|
|
16
|
+
};
|
|
17
|
+
exports.checkingUnadoptedExplicitRoles = checkingUnadoptedExplicitRoles;
|
package/lib/wai-aria/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ml_core_1 = require("@markuplint/ml-core");
|
|
4
|
+
const ml_spec_1 = require("@markuplint/ml-spec");
|
|
4
5
|
const helpers_1 = require("../helpers");
|
|
5
6
|
const abstract_role_1 = require("./checkings/abstract-role");
|
|
6
7
|
const default_value_1 = require("./checkings/default-value");
|
|
@@ -27,7 +28,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
27
28
|
disallowSetImplicitRole: true,
|
|
28
29
|
disallowSetImplicitProps: true,
|
|
29
30
|
disallowDefaultValue: false,
|
|
30
|
-
version:
|
|
31
|
+
version: ml_spec_1.ARIA_RECOMMENDED_VERSION,
|
|
31
32
|
},
|
|
32
33
|
async verify({ document, report, t }) {
|
|
33
34
|
await document.walkOn('Element', el => {
|