@markuplint/rules 3.0.0-dev.25 → 3.0.0-dev.290
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/attr-check.d.ts +3 -2
- package/lib/attr-check.js +42 -38
- package/lib/attr-duplication/index.d.ts +1 -1
- package/lib/attr-duplication/index.js +3 -5
- package/lib/attr-value-quotes/index.d.ts +1 -1
- package/lib/attr-value-quotes/index.js +5 -9
- package/lib/case-sensitive-attr-name/index.d.ts +1 -1
- package/lib/case-sensitive-attr-name/index.js +9 -13
- package/lib/case-sensitive-tag-name/index.d.ts +1 -1
- package/lib/case-sensitive-tag-name/index.js +2 -4
- package/lib/character-reference/index.d.ts +1 -1
- package/lib/character-reference/index.js +7 -9
- package/lib/class-naming/index.d.ts +1 -1
- package/lib/class-naming/index.js +9 -13
- package/lib/create-message.d.ts +3 -2
- package/lib/create-message.js +15 -17
- package/lib/debug.js +2 -6
- package/lib/deprecated-attr/index.d.ts +1 -1
- package/lib/deprecated-attr/index.js +6 -9
- package/lib/deprecated-element/index.d.ts +1 -1
- package/lib/deprecated-element/index.js +5 -7
- package/lib/disallowed-element/index.d.ts +1 -1
- package/lib/disallowed-element/index.js +2 -4
- package/lib/doctype/index.d.ts +1 -1
- package/lib/doctype/index.js +2 -4
- package/lib/end-tag/index.d.ts +1 -1
- package/lib/end-tag/index.js +5 -8
- package/lib/helpers.d.ts +10 -13
- package/lib/helpers.js +39 -37
- package/lib/id-duplication/index.d.ts +1 -1
- package/lib/id-duplication/index.js +2 -4
- package/lib/index.d.ts +102 -3
- package/lib/index.js +64 -62
- package/lib/ineffective-attr/index.d.ts +1 -1
- package/lib/ineffective-attr/index.js +5 -10
- package/lib/invalid-attr/index.d.ts +25 -5
- package/lib/invalid-attr/index.js +166 -43
- package/lib/label-has-control/index.d.ts +1 -1
- package/lib/label-has-control/index.js +2 -4
- package/lib/landmark-roles/index.d.ts +1 -1
- package/lib/landmark-roles/index.js +10 -9
- package/lib/no-boolean-attr-value/index.d.ts +1 -1
- package/lib/no-boolean-attr-value/index.js +6 -9
- package/lib/no-default-value/index.d.ts +1 -1
- package/lib/no-default-value/index.js +9 -12
- package/lib/no-empty-palpable-content/index.d.ts +1 -1
- package/lib/no-empty-palpable-content/index.js +13 -7
- package/lib/no-hard-code-id/index.d.ts +1 -1
- package/lib/no-hard-code-id/index.js +2 -4
- package/lib/no-refer-to-non-existent-id/index.d.ts +4 -4
- package/lib/no-refer-to-non-existent-id/index.js +79 -23
- package/lib/no-use-event-handler-attr/index.d.ts +1 -1
- package/lib/no-use-event-handler-attr/index.js +4 -6
- package/lib/permitted-contents/choice.d.ts +3 -2
- package/lib/permitted-contents/choice.js +54 -14
- package/lib/permitted-contents/complex-branch.d.ts +3 -2
- package/lib/permitted-contents/complex-branch.js +12 -14
- package/lib/permitted-contents/content-model.d.ts +2 -2
- package/lib/permitted-contents/content-model.js +11 -11
- package/lib/permitted-contents/count-pattern.d.ts +3 -2
- package/lib/permitted-contents/count-pattern.js +76 -74
- package/lib/permitted-contents/debug.browser.js +9 -12
- package/lib/permitted-contents/debug.d.ts +8 -1
- package/lib/permitted-contents/debug.js +12 -13
- package/lib/permitted-contents/index.d.ts +2 -2
- package/lib/permitted-contents/index.js +18 -24
- package/lib/permitted-contents/matches-selector.d.ts +2 -2
- package/lib/permitted-contents/matches-selector.js +17 -20
- package/lib/permitted-contents/order.d.ts +3 -2
- package/lib/permitted-contents/order.js +33 -28
- package/lib/permitted-contents/recursive-branch.d.ts +4 -3
- package/lib/permitted-contents/recursive-branch.js +11 -13
- package/lib/permitted-contents/represent-transparent-nodes.d.ts +1 -1
- package/lib/permitted-contents/represent-transparent-nodes.js +18 -21
- package/lib/permitted-contents/start.d.ts +3 -2
- package/lib/permitted-contents/start.js +16 -22
- package/lib/permitted-contents/transparent.d.ts +2 -2
- package/lib/permitted-contents/transparent.js +6 -9
- package/lib/permitted-contents/types.d.ts +20 -13
- package/lib/permitted-contents/types.js +1 -2
- package/lib/permitted-contents/utils.d.ts +27 -8
- package/lib/permitted-contents/utils.js +164 -65
- package/lib/placeholder-label-option/index.d.ts +2 -0
- package/lib/placeholder-label-option/index.js +84 -0
- package/lib/require-accessible-name/index.d.ts +1 -1
- package/lib/require-accessible-name/index.js +10 -13
- package/lib/require-datetime/index.d.ts +6 -0
- package/lib/require-datetime/index.js +32 -0
- package/lib/require-datetime/types.d.ts +10 -0
- package/lib/require-datetime/types.js +1 -0
- package/lib/require-datetime/utils.d.ts +11 -0
- package/lib/require-datetime/utils.js +130 -0
- package/lib/required-attr/index.d.ts +2 -2
- package/lib/required-attr/index.js +24 -24
- package/lib/required-element/index.d.ts +1 -1
- package/lib/required-element/index.js +3 -5
- package/lib/required-h1/index.d.ts +1 -1
- package/lib/required-h1/index.js +4 -6
- package/lib/use-list/index.d.ts +2 -2
- package/lib/use-list/index.js +7 -9
- package/lib/wai-aria/checkings/abstract-role.d.ts +1 -1
- package/lib/wai-aria/checkings/abstract-role.js +5 -10
- package/lib/wai-aria/checkings/default-value.d.ts +2 -2
- package/lib/wai-aria/checkings/default-value.js +2 -6
- package/lib/wai-aria/checkings/deprecated-props.d.ts +2 -2
- package/lib/wai-aria/checkings/deprecated-props.js +3 -8
- package/lib/wai-aria/checkings/disallowed-prop.d.ts +2 -2
- package/lib/wai-aria/checkings/disallowed-prop.js +27 -8
- package/lib/wai-aria/checkings/implicit-props.d.ts +3 -3
- package/lib/wai-aria/checkings/implicit-props.js +7 -11
- package/lib/wai-aria/checkings/implicit-role.d.ts +1 -1
- package/lib/wai-aria/checkings/implicit-role.js +4 -9
- package/lib/wai-aria/checkings/interaction-in-hidden.d.ts +1 -1
- package/lib/wai-aria/checkings/interaction-in-hidden.js +7 -9
- package/lib/wai-aria/checkings/no-global-prop.d.ts +2 -2
- package/lib/wai-aria/checkings/no-global-prop.js +2 -7
- package/lib/wai-aria/checkings/non-existent-role.d.ts +1 -1
- package/lib/wai-aria/checkings/non-existent-role.js +4 -9
- package/lib/wai-aria/checkings/permitted-roles.d.ts +1 -1
- package/lib/wai-aria/checkings/permitted-roles.js +4 -9
- package/lib/wai-aria/checkings/presentational-children.d.ts +1 -1
- package/lib/wai-aria/checkings/presentational-children.js +7 -10
- package/lib/wai-aria/checkings/required-owned-elements.d.ts +1 -1
- package/lib/wai-aria/checkings/required-owned-elements.js +10 -12
- package/lib/wai-aria/checkings/required-prop.d.ts +2 -2
- package/lib/wai-aria/checkings/required-prop.js +2 -7
- package/lib/wai-aria/checkings/value.d.ts +3 -3
- package/lib/wai-aria/checkings/value.js +7 -11
- package/lib/wai-aria/index.d.ts +2 -2
- package/lib/wai-aria/index.js +38 -39
- package/lib/wai-aria/types.js +1 -2
- package/package.json +21 -14
- package/schema.json +6 -0
- package/tsconfig.test.json +0 -3
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const log = debug_1.log.extend('invalid-attr');
|
|
8
|
-
exports.default = (0, ml_core_1.createRule)({
|
|
1
|
+
import { createRule, getAttrSpecs, getSpec } from '@markuplint/ml-core';
|
|
2
|
+
import { attrCheck } from '../attr-check.js';
|
|
3
|
+
import { log as ruleLog } from '../debug.js';
|
|
4
|
+
import { isValidAttr, match } from '../helpers.js';
|
|
5
|
+
const log = ruleLog.extend('invalid-attr');
|
|
6
|
+
export default createRule({
|
|
9
7
|
defaultOptions: {},
|
|
10
8
|
async verify({ document, report, t }) {
|
|
11
9
|
await document.walkOn('Attr', attr => {
|
|
12
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
13
10
|
// Default
|
|
14
|
-
const allowToAddPropertiesForPretender =
|
|
11
|
+
const allowToAddPropertiesForPretender = attr.rule.options.allowToAddPropertiesForPretender ?? true;
|
|
15
12
|
if (attr.isDirective) {
|
|
16
13
|
return;
|
|
17
14
|
}
|
|
18
|
-
const attrSpecs =
|
|
15
|
+
const attrSpecs = getAttrSpecs(attr.ownerElement, document.specs);
|
|
19
16
|
const attrName = attr.nameNode;
|
|
20
17
|
const name = attr.name;
|
|
21
18
|
if (attr.ownerElement.elementType === 'html' && attr.candidate) {
|
|
@@ -24,16 +21,16 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
24
21
|
t('Did you mean "{0}"?', attr.candidate);
|
|
25
22
|
report({
|
|
26
23
|
scope: attr,
|
|
27
|
-
line: attrName
|
|
28
|
-
col: attrName
|
|
29
|
-
raw: attrName
|
|
24
|
+
line: attrName?.startLine,
|
|
25
|
+
col: attrName?.startCol,
|
|
26
|
+
raw: attrName?.raw,
|
|
30
27
|
message: message,
|
|
31
28
|
});
|
|
32
29
|
return;
|
|
33
30
|
}
|
|
34
31
|
const valueNode = attr.valueNode;
|
|
35
32
|
const value = attr.value;
|
|
36
|
-
if (attr.rule.options.ignoreAttrNamePrefix) {
|
|
33
|
+
if (attr.rule.options.ignoreAttrNamePrefix != null) {
|
|
37
34
|
const ignoreAttrNamePrefixes = Array.isArray(attr.rule.options.ignoreAttrNamePrefix)
|
|
38
35
|
? attr.rule.options.ignoreAttrNamePrefix
|
|
39
36
|
: [attr.rule.options.ignoreAttrNamePrefix];
|
|
@@ -42,41 +39,141 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
41
|
let invalid = false;
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
const allowAttrs = {};
|
|
43
|
+
const disallowAttrs = {};
|
|
44
|
+
if (attr.rule.options.allowAttrs) {
|
|
45
|
+
if (Array.isArray(attr.rule.options.allowAttrs)) {
|
|
46
|
+
for (const allowAttr of attr.rule.options.allowAttrs) {
|
|
47
|
+
if (typeof allowAttr === 'string') {
|
|
48
|
+
allowAttrs[allowAttr] = { type: 'Any' };
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (isValueRule(allowAttr.value)) {
|
|
52
|
+
allowAttrs[allowAttr.name] = allowAttr.value;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
allowAttrs[allowAttr.name] = { type: allowAttr.value };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
for (const [attrName, valueRule] of Object.entries(attr.rule.options.allowAttrs)) {
|
|
60
|
+
allowAttrs[attrName] = valueRule;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (attr.rule.options.disallowAttrs) {
|
|
65
|
+
if (Array.isArray(attr.rule.options.disallowAttrs)) {
|
|
66
|
+
for (const disallowAttr of attr.rule.options.disallowAttrs) {
|
|
67
|
+
if (typeof disallowAttr === 'string') {
|
|
68
|
+
disallowAttrs[disallowAttr] = { type: 'Any' };
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (isValueRule(disallowAttr.value)) {
|
|
72
|
+
disallowAttrs[disallowAttr.name] = disallowAttr.value;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
disallowAttrs[disallowAttr.name] = { type: disallowAttr.value };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
for (const [attrName, valueRule] of Object.entries(attr.rule.options.disallowAttrs)) {
|
|
80
|
+
disallowAttrs[attrName] = valueRule;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (attr.rule.options.attrs) {
|
|
85
|
+
for (const [attrName, valueRule] of Object.entries(attr.rule.options.attrs)) {
|
|
86
|
+
if ('disallowed' in valueRule) {
|
|
87
|
+
disallowAttrs[attrName] = { type: 'Any' };
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
allowAttrs[attrName] = valueRule;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const allowValue = allowAttrs[name] ?? null;
|
|
95
|
+
const disallowValue = disallowAttrs[name] ?? null;
|
|
96
|
+
if (allowValue) {
|
|
97
|
+
if ('enum' in allowValue) {
|
|
98
|
+
invalid = attrCheck(t, name.toLowerCase(), value, true, {
|
|
49
99
|
name,
|
|
50
100
|
type: {
|
|
51
|
-
enum:
|
|
101
|
+
enum: allowValue.enum,
|
|
52
102
|
},
|
|
53
103
|
description: '',
|
|
54
104
|
});
|
|
55
105
|
}
|
|
56
|
-
else if ('pattern' in
|
|
57
|
-
if (!
|
|
106
|
+
else if ('pattern' in allowValue) {
|
|
107
|
+
if (!match(value, allowValue.pattern)) {
|
|
108
|
+
invalid = {
|
|
109
|
+
invalidType: 'invalid-value',
|
|
110
|
+
message: t('{0} is unmatched with the below patterns: {1}', t('the "{0*}" {1}', name, 'attribute'), allowValue.pattern),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else if ('type' in allowValue) {
|
|
115
|
+
invalid = attrCheck(t, name, value, true, { name, type: allowValue.type, description: '' });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else if (disallowValue) {
|
|
119
|
+
if ('enum' in disallowValue) {
|
|
120
|
+
const checkResult = attrCheck(t, name.toLowerCase(), value, true, {
|
|
121
|
+
name,
|
|
122
|
+
type: {
|
|
123
|
+
enum: disallowValue.enum,
|
|
124
|
+
},
|
|
125
|
+
description: '',
|
|
126
|
+
});
|
|
127
|
+
if (checkResult === false) {
|
|
58
128
|
invalid = {
|
|
59
129
|
invalidType: 'invalid-value',
|
|
60
|
-
message: t('{0} is
|
|
130
|
+
message: t('{0} is disallowed to accept the following values: {1}', t('the "{0*}" {1}', name, 'attribute'), t(disallowValue.enum)),
|
|
61
131
|
};
|
|
62
132
|
}
|
|
63
133
|
}
|
|
64
|
-
else if ('
|
|
65
|
-
|
|
134
|
+
else if ('pattern' in disallowValue) {
|
|
135
|
+
if (match(value, disallowValue.pattern)) {
|
|
136
|
+
invalid = {
|
|
137
|
+
invalidType: 'invalid-value',
|
|
138
|
+
message: t('{0} is matched with the below disallowed patterns: {1}', t('the "{0*}" {1}', name, 'attribute'), disallowValue.pattern),
|
|
139
|
+
};
|
|
140
|
+
}
|
|
66
141
|
}
|
|
67
|
-
else if ('
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
142
|
+
else if ('type' in disallowValue) {
|
|
143
|
+
if (disallowValue.type === 'Any') {
|
|
144
|
+
invalid = {
|
|
145
|
+
invalidType: 'non-existent',
|
|
146
|
+
message: t('{0} is disallowed', t('the "{0*}" {1}', name, 'attribute')),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
const checkResult = attrCheck(t, name, value, true, {
|
|
151
|
+
name,
|
|
152
|
+
type: disallowValue.type,
|
|
153
|
+
description: '',
|
|
154
|
+
});
|
|
155
|
+
if (checkResult === false) {
|
|
156
|
+
invalid = {
|
|
157
|
+
invalidType: 'invalid-value',
|
|
158
|
+
message: t('{0} is disallowed', t('{0} of {1}', t('the {0}', 'type'), t('the "{0*}" {1}', name, 'attribute'))),
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}
|
|
72
162
|
}
|
|
73
163
|
}
|
|
74
164
|
else if (attr.ownerElement.elementType === 'html' && attrSpecs) {
|
|
75
165
|
log('Checking %s[%s="%s"]', attr.nodeName, name, value);
|
|
76
|
-
invalid =
|
|
166
|
+
invalid = isValidAttr(t, name, value, attr.isDynamicValue || false, attr.ownerElement, attrSpecs, log);
|
|
77
167
|
}
|
|
78
|
-
if (invalid) {
|
|
168
|
+
if (invalid !== false) {
|
|
79
169
|
switch (invalid.invalidType) {
|
|
170
|
+
case 'disallowed-attr': {
|
|
171
|
+
report({
|
|
172
|
+
scope: attr,
|
|
173
|
+
message: invalid.message,
|
|
174
|
+
});
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
80
177
|
case 'invalid-value': {
|
|
81
178
|
if (attr.isDynamicValue) {
|
|
82
179
|
break;
|
|
@@ -84,28 +181,28 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
84
181
|
report({
|
|
85
182
|
scope: attr,
|
|
86
183
|
message: invalid.message,
|
|
87
|
-
line: (
|
|
88
|
-
col:
|
|
89
|
-
?
|
|
90
|
-
: (
|
|
91
|
-
raw:
|
|
184
|
+
line: (valueNode?.startLine ?? 0) + (invalid.loc?.line ?? 0),
|
|
185
|
+
col: invalid.loc && invalid.loc.line > 0
|
|
186
|
+
? invalid.loc?.col + 1
|
|
187
|
+
: (valueNode?.startCol ?? 0) + (invalid.loc?.col ?? 0),
|
|
188
|
+
raw: invalid.loc?.raw ?? value,
|
|
92
189
|
});
|
|
93
190
|
break;
|
|
94
191
|
}
|
|
95
192
|
case 'non-existent': {
|
|
96
|
-
if (allowToAddPropertiesForPretender &&
|
|
193
|
+
if (allowToAddPropertiesForPretender && attr.ownerElement.pretenderContext?.type === 'origin') {
|
|
97
194
|
return;
|
|
98
195
|
}
|
|
99
|
-
const spec =
|
|
100
|
-
if (spec
|
|
196
|
+
const spec = getSpec(attr.ownerElement, document.specs.specs);
|
|
197
|
+
if (spec?.possibleToAddProperties) {
|
|
101
198
|
return;
|
|
102
199
|
}
|
|
103
200
|
report({
|
|
104
201
|
scope: attr,
|
|
105
202
|
message: invalid.message,
|
|
106
|
-
line: attrName
|
|
107
|
-
col: attrName
|
|
108
|
-
raw: attrName
|
|
203
|
+
line: attrName?.startLine,
|
|
204
|
+
col: attrName?.startCol,
|
|
205
|
+
raw: attrName?.raw,
|
|
109
206
|
});
|
|
110
207
|
}
|
|
111
208
|
}
|
|
@@ -113,3 +210,29 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
113
210
|
});
|
|
114
211
|
},
|
|
115
212
|
});
|
|
213
|
+
function isValueRule(
|
|
214
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
215
|
+
value) {
|
|
216
|
+
if (typeof value === 'string') {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
if ('enum' in value) {
|
|
220
|
+
if (Object.keys(value).length > 1) {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
if ('token' in value) {
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
if ('pattern' in value) {
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
if (value.type === 'integer' || value.type === 'float') {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
if (Object.keys(value).length > 1) {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
return true;
|
|
238
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue,
|
|
1
|
+
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
2
2
|
export default _default;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ml_core_1 = require("@markuplint/ml-core");
|
|
1
|
+
import { createRule } from '@markuplint/ml-core';
|
|
4
2
|
const controlSelector = ["input:not([type='hidden' i])", 'select', 'textarea'].join(',');
|
|
5
|
-
|
|
3
|
+
export default createRule({
|
|
6
4
|
defaultSeverity: 'warning',
|
|
7
5
|
async verify({ document, report, t }) {
|
|
8
6
|
await document.walkOn('Element', el => {
|
|
@@ -4,5 +4,5 @@ type Options = {
|
|
|
4
4
|
};
|
|
5
5
|
type TopLevelRoles = 'banner' | 'main' | 'complementary' | 'contentinfo';
|
|
6
6
|
type Roles = TopLevelRoles | 'form' | 'navigation' | 'region';
|
|
7
|
-
declare const _default: import("@markuplint/ml-core").RuleSeed<boolean, Options
|
|
7
|
+
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<boolean, Options>>;
|
|
8
8
|
export default _default;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ml_core_1 = require("@markuplint/ml-core");
|
|
1
|
+
import { createRule } from '@markuplint/ml-core';
|
|
4
2
|
const selectors = {
|
|
5
3
|
complementary: ['[role="complementary"]', 'aside'],
|
|
6
4
|
contentinfo: ['[role="contentinfo"]'],
|
|
@@ -11,14 +9,13 @@ const selectors = {
|
|
|
11
9
|
region: ['[role="region"]', 'section[aria-labelledby]', 'section[aria-label]', 'section[title]'],
|
|
12
10
|
};
|
|
13
11
|
const topLevelRoles = ['banner', 'main', 'complementary', 'contentinfo'];
|
|
14
|
-
|
|
12
|
+
export default createRule({
|
|
15
13
|
defaultSeverity: 'warning',
|
|
16
14
|
defaultOptions: {
|
|
17
15
|
ignoreRoles: [],
|
|
18
16
|
labelEachArea: true,
|
|
19
17
|
},
|
|
20
18
|
verify({ document, report, t }) {
|
|
21
|
-
var _a;
|
|
22
19
|
if (document.isFragment) {
|
|
23
20
|
return;
|
|
24
21
|
}
|
|
@@ -72,7 +69,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
72
69
|
if (el.rule.disabled) {
|
|
73
70
|
continue;
|
|
74
71
|
}
|
|
75
|
-
if (
|
|
72
|
+
if (el.rule.options.ignoreRoles?.includes(role)) {
|
|
76
73
|
continue;
|
|
77
74
|
}
|
|
78
75
|
if (el.isDescendantByUUIDList(uuidList)) {
|
|
@@ -106,13 +103,17 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
106
103
|
}
|
|
107
104
|
},
|
|
108
105
|
});
|
|
109
|
-
function landmarkRoleElementUUIDList(
|
|
106
|
+
function landmarkRoleElementUUIDList(
|
|
107
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
108
|
+
roleset) {
|
|
110
109
|
return Object.values(roleset)
|
|
111
110
|
.map(elements => elements.map(element => element.uuid))
|
|
112
111
|
.flat();
|
|
113
112
|
}
|
|
114
|
-
function hasLabel(
|
|
115
|
-
|
|
113
|
+
function hasLabel(
|
|
114
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
115
|
+
el) {
|
|
116
|
+
const hasHeading = el.querySelectorAll('h1, h2, h3, h4, h5, h6').length > 0;
|
|
116
117
|
if (hasHeading && el.matches('[aria-labelledby]')) {
|
|
117
118
|
return true;
|
|
118
119
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue,
|
|
1
|
+
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
2
2
|
export default _default;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const ml_core_1 = require("@markuplint/ml-core");
|
|
4
|
-
exports.default = (0, ml_core_1.createRule)({
|
|
1
|
+
import { createRule, getAttrSpecs } from '@markuplint/ml-core';
|
|
2
|
+
export default createRule({
|
|
5
3
|
defaultSeverity: 'warning',
|
|
6
4
|
async verify({ document, report, t }) {
|
|
7
5
|
await document.walkOn('Attr', attr => {
|
|
8
|
-
|
|
9
|
-
const attrSpec = (0, ml_core_1.getAttrSpecs)(attr.ownerElement, document.specs);
|
|
6
|
+
const attrSpec = getAttrSpecs(attr.ownerElement, document.specs);
|
|
10
7
|
if (!attrSpec) {
|
|
11
8
|
return;
|
|
12
9
|
}
|
|
@@ -29,12 +26,12 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
29
26
|
attr.valueNode,
|
|
30
27
|
attr.endQuote,
|
|
31
28
|
];
|
|
32
|
-
const extraRaw = extraTokens.reduce((raw, t) =>
|
|
29
|
+
const extraRaw = extraTokens.reduce((raw, t) => raw + (t?.raw ?? ''), '');
|
|
33
30
|
if (extraRaw) {
|
|
34
31
|
report({
|
|
35
32
|
scope: attr,
|
|
36
|
-
line:
|
|
37
|
-
col:
|
|
33
|
+
line: attr.spacesBeforeEqual?.startLine,
|
|
34
|
+
col: attr.spacesBeforeEqual?.startCol,
|
|
38
35
|
raw: extraRaw,
|
|
39
36
|
message: t('{0} is {1}', t('the "{0*}" {1}', name, 'attribute'), t('a {0}', 'boolean attribute')) +
|
|
40
37
|
t('. ') +
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue,
|
|
1
|
+
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
2
2
|
export default _default;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const helpers_1 = require("../helpers");
|
|
5
|
-
exports.default = (0, ml_core_1.createRule)({
|
|
1
|
+
import { createRule, getAttrSpecs } from '@markuplint/ml-core';
|
|
2
|
+
import { toNormalizedValue } from '../helpers.js';
|
|
3
|
+
export default createRule({
|
|
6
4
|
defaultSeverity: 'warning',
|
|
7
5
|
async verify({ document, report, t }) {
|
|
8
6
|
await document.walkOn('Attr', attr => {
|
|
9
|
-
|
|
10
|
-
const attrSpec = (0, ml_core_1.getAttrSpecs)(attr.ownerElement, document.specs);
|
|
7
|
+
const attrSpec = getAttrSpecs(attr.ownerElement, document.specs);
|
|
11
8
|
if (!attrSpec) {
|
|
12
9
|
return;
|
|
13
10
|
}
|
|
@@ -18,14 +15,14 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
18
15
|
if (!spec.defaultValue) {
|
|
19
16
|
return;
|
|
20
17
|
}
|
|
21
|
-
const normalizedValue =
|
|
22
|
-
const defaultValue =
|
|
18
|
+
const normalizedValue = toNormalizedValue(attr.value, spec);
|
|
19
|
+
const defaultValue = toNormalizedValue(spec.defaultValue, spec);
|
|
23
20
|
if (defaultValue === normalizedValue) {
|
|
24
21
|
report({
|
|
25
22
|
scope: attr,
|
|
26
|
-
line:
|
|
27
|
-
col:
|
|
28
|
-
raw:
|
|
23
|
+
line: attr.valueNode?.startLine,
|
|
24
|
+
col: attr.valueNode?.startCol,
|
|
25
|
+
raw: attr.valueNode?.raw,
|
|
29
26
|
message: t('It is {0}', t('the {0}', 'default value')),
|
|
30
27
|
});
|
|
31
28
|
}
|
|
@@ -2,5 +2,5 @@ type Options = {
|
|
|
2
2
|
extendsExposableElements?: boolean;
|
|
3
3
|
ignoreIfAriaBusy?: boolean;
|
|
4
4
|
};
|
|
5
|
-
declare const _default: import("@markuplint/ml-core").RuleSeed<boolean, Options
|
|
5
|
+
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<boolean, Options>>;
|
|
6
6
|
export default _default;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const ml_spec_1 = require("@markuplint/ml-spec");
|
|
5
|
-
exports.default = (0, ml_core_1.createRule)({
|
|
1
|
+
import { createRule } from '@markuplint/ml-core';
|
|
2
|
+
import { isNothingContentModel, isPalpableElement } from '@markuplint/ml-spec';
|
|
3
|
+
export default createRule({
|
|
6
4
|
defaultSeverity: 'warning',
|
|
7
5
|
defaultOptions: {
|
|
8
6
|
extendsExposableElements: true,
|
|
@@ -10,13 +8,21 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
10
8
|
},
|
|
11
9
|
async verify({ document, report, t }) {
|
|
12
10
|
await document.walkOn('Element', el => {
|
|
13
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Exception
|
|
13
|
+
*
|
|
14
|
+
* - The `textarea` element is possibly empty because a user inputs it.
|
|
15
|
+
*/
|
|
16
|
+
if (el.localName === 'textarea') {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (!isPalpableElement(el, el.ownerMLDocument.specs, {
|
|
14
20
|
extendsSvg: false,
|
|
15
21
|
extendsExposableElements: el.rule.options.extendsExposableElements,
|
|
16
22
|
})) {
|
|
17
23
|
return;
|
|
18
24
|
}
|
|
19
|
-
if (
|
|
25
|
+
if (isNothingContentModel(el)) {
|
|
20
26
|
return;
|
|
21
27
|
}
|
|
22
28
|
if (el.rule.options.ignoreIfAriaBusy && el.getAttribute('aria-busy') === 'true') {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue,
|
|
1
|
+
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
2
2
|
export default _default;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const ml_core_1 = require("@markuplint/ml-core");
|
|
4
|
-
exports.default = (0, ml_core_1.createRule)({
|
|
1
|
+
import { createRule } from '@markuplint/ml-core';
|
|
2
|
+
export default createRule({
|
|
5
3
|
defaultSeverity: 'warning',
|
|
6
4
|
async verify({ document, report, t }) {
|
|
7
5
|
if (!document.isFragment) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
1
|
+
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, {
|
|
2
|
+
ariaVersion: "1.1" | "1.2" | "1.3";
|
|
3
|
+
fragmentRefersNameAttr: boolean;
|
|
4
|
+
}>>;
|
|
5
5
|
export default _default;
|