@markuplint/rules 2.0.0-rc.1 → 2.0.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/README.md +34 -66
- package/lib/attr-check.d.ts +19 -8
- package/lib/attr-check.js +2 -2
- package/lib/attr-duplication/index.d.ts +1 -1
- package/lib/attr-equal-space-after/index.d.ts +1 -1
- package/lib/attr-equal-space-before/index.d.ts +1 -1
- package/lib/attr-spacing/index.d.ts +3 -3
- package/lib/attr-value-quotes/index.d.ts +2 -2
- package/lib/case-sensitive-attr-name/index.d.ts +6 -2
- package/lib/case-sensitive-attr-name/index.js +28 -4
- package/lib/case-sensitive-tag-name/index.d.ts +1 -1
- package/lib/character-reference/index.d.ts +1 -1
- package/lib/class-naming/index.d.ts +1 -1
- package/lib/class-naming/index.js +1 -1
- package/lib/create-message.d.ts +12 -2
- package/lib/deprecated-attr/index.d.ts +1 -1
- package/lib/deprecated-attr/index.js +1 -1
- package/lib/deprecated-element/index.d.ts +1 -1
- package/lib/deprecated-element/index.js +1 -1
- package/lib/disallowed-element/index.d.ts +1 -1
- package/lib/doctype/index.d.ts +2 -2
- package/lib/end-tag/index.d.ts +2 -0
- package/lib/end-tag/index.js +43 -0
- package/lib/helpers.d.ts +78 -45
- package/lib/helpers.js +26 -27
- package/lib/id-duplication/index.d.ts +1 -1
- package/lib/id-duplication/index.js +1 -1
- package/lib/indentation/index.d.ts +3 -3
- package/lib/index.d.ts +147 -60
- package/lib/index.js +2 -0
- package/lib/ineffective-attr/index.d.ts +1 -1
- package/lib/ineffective-attr/index.js +1 -1
- package/lib/invalid-attr/index.d.ts +16 -12
- package/lib/invalid-attr/index.js +10 -3
- package/lib/landmark-roles/index.d.ts +3 -3
- package/lib/landmark-roles/index.js +1 -1
- package/lib/no-boolean-attr-value/index.d.ts +1 -1
- package/lib/no-boolean-attr-value/index.js +2 -2
- package/lib/no-default-value/index.d.ts +1 -1
- package/lib/no-hard-code-id/index.d.ts +1 -1
- package/lib/no-refer-to-non-existent-id/index.d.ts +1 -1
- package/lib/no-refer-to-non-existent-id/index.js +2 -2
- package/lib/no-use-event-handler-attr/index.d.ts +2 -2
- package/lib/no-use-event-handler-attr/index.js +1 -1
- package/lib/permitted-contents/index.d.ts +2 -2
- package/lib/permitted-contents/index.js +13 -13
- package/lib/permitted-contents/permitted-content.spec-to-regexp.d.ts +8 -8
- package/lib/permitted-contents/types.d.ts +8 -0
- package/lib/permitted-contents/types.js +2 -0
- package/lib/require-element/index.d.ts +1 -1
- package/lib/required-attr/index.d.ts +3 -3
- package/lib/required-attr/index.js +2 -2
- package/lib/required-element/index.d.ts +2 -2
- package/lib/required-h1/index.d.ts +3 -3
- package/lib/required-h1/index.js +2 -2
- package/lib/wai-aria/index.d.ts +7 -7
- package/lib/wai-aria/index.js +21 -21
- package/package.json +7 -7
- package/schema.json +3 -0
- package/tsconfig.tsbuildinfo +1 -1
package/lib/helpers.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.checkAria = exports.checkAriaValue = exports.getComputedRole = exports.getImplicitRole = exports.getPermittedRoles = exports.getRoleSpec = exports.ariaSpec = exports.toNormalizedValue = exports.isValidAttr = exports.htmlSpec = exports.rePCENChar = exports.match = exports.attrMatches = void 0;
|
|
4
|
-
const html_spec_1 = require("@markuplint/html-spec");
|
|
5
4
|
const attr_check_1 = require("./attr-check");
|
|
6
5
|
function attrMatches(node, condition) {
|
|
7
6
|
if (!condition) {
|
|
@@ -75,8 +74,8 @@ exports.rePCENChar = [
|
|
|
75
74
|
'[\uFDF0-\uFFFD]',
|
|
76
75
|
'[\uD800-\uDBFF][\uDC00-\uDFFF]',
|
|
77
76
|
].join('|');
|
|
78
|
-
function htmlSpec(nameWithNS) {
|
|
79
|
-
const spec =
|
|
77
|
+
function htmlSpec(specs, nameWithNS) {
|
|
78
|
+
const spec = specs.specs.find(spec => spec.name === nameWithNS);
|
|
80
79
|
return spec || null;
|
|
81
80
|
}
|
|
82
81
|
exports.htmlSpec = htmlSpec;
|
|
@@ -88,7 +87,7 @@ function isValidAttr(t, name, value, isDynamicValue, node, attrSpecs, log) {
|
|
|
88
87
|
if (!invalid && spec && spec.condition && !node.hasSpreadAttr && !attrMatches(node, spec.condition)) {
|
|
89
88
|
invalid = {
|
|
90
89
|
invalidType: 'non-existent',
|
|
91
|
-
message: t('{0} is {1}', t('the "{0}" {1}', name, 'attribute'), 'disallowed'),
|
|
90
|
+
message: t('{0} is {1}', t('the "{0*}" {1}', name, 'attribute'), 'disallowed'),
|
|
92
91
|
};
|
|
93
92
|
}
|
|
94
93
|
if (invalid && invalid.invalidType === 'invalid-value' && isDynamicValue) {
|
|
@@ -126,21 +125,21 @@ function toNormalizedValue(value, spec) {
|
|
|
126
125
|
return normalized;
|
|
127
126
|
}
|
|
128
127
|
exports.toNormalizedValue = toNormalizedValue;
|
|
129
|
-
function ariaSpec() {
|
|
130
|
-
const roles =
|
|
131
|
-
const ariaAttrs =
|
|
128
|
+
function ariaSpec(specs) {
|
|
129
|
+
const roles = specs.def['#roles'];
|
|
130
|
+
const ariaAttrs = specs.def['#ariaAttrs'];
|
|
132
131
|
return {
|
|
133
132
|
roles,
|
|
134
133
|
ariaAttrs,
|
|
135
134
|
};
|
|
136
135
|
}
|
|
137
136
|
exports.ariaSpec = ariaSpec;
|
|
138
|
-
function getRoleSpec(roleName) {
|
|
139
|
-
const role = getRoleByName(roleName);
|
|
137
|
+
function getRoleSpec(specs, roleName) {
|
|
138
|
+
const role = getRoleByName(specs, roleName);
|
|
140
139
|
if (!role) {
|
|
141
140
|
return null;
|
|
142
141
|
}
|
|
143
|
-
const superClassRoles = recursiveTraverseSuperClassRoles(roleName);
|
|
142
|
+
const superClassRoles = recursiveTraverseSuperClassRoles(specs, roleName);
|
|
144
143
|
return {
|
|
145
144
|
name: role.name,
|
|
146
145
|
isAbstract: !!role.isAbstract,
|
|
@@ -149,22 +148,22 @@ function getRoleSpec(roleName) {
|
|
|
149
148
|
};
|
|
150
149
|
}
|
|
151
150
|
exports.getRoleSpec = getRoleSpec;
|
|
152
|
-
function getRoleByName(roleName) {
|
|
153
|
-
const roles =
|
|
151
|
+
function getRoleByName(specs, roleName) {
|
|
152
|
+
const roles = specs.def['#roles'];
|
|
154
153
|
const role = roles.find(r => r.name === roleName);
|
|
155
154
|
return role;
|
|
156
155
|
}
|
|
157
|
-
function getSuperClassRoles(roleName) {
|
|
158
|
-
const role = getRoleByName(roleName);
|
|
159
|
-
return ((role === null || role === void 0 ? void 0 : role.generalization.map(roleName => getRoleByName(roleName)).filter((role) => !!role)) || null);
|
|
156
|
+
function getSuperClassRoles(specs, roleName) {
|
|
157
|
+
const role = getRoleByName(specs, roleName);
|
|
158
|
+
return ((role === null || role === void 0 ? void 0 : role.generalization.map(roleName => getRoleByName(specs, roleName)).filter((role) => !!role)) || null);
|
|
160
159
|
}
|
|
161
|
-
function recursiveTraverseSuperClassRoles(roleName) {
|
|
160
|
+
function recursiveTraverseSuperClassRoles(specs, roleName) {
|
|
162
161
|
const roles = [];
|
|
163
|
-
const superClassRoles = getSuperClassRoles(roleName);
|
|
162
|
+
const superClassRoles = getSuperClassRoles(specs, roleName);
|
|
164
163
|
if (superClassRoles) {
|
|
165
164
|
roles.push(...superClassRoles);
|
|
166
165
|
for (const superClassRole of superClassRoles) {
|
|
167
|
-
const ancestorRoles = recursiveTraverseSuperClassRoles(superClassRole.name);
|
|
166
|
+
const ancestorRoles = recursiveTraverseSuperClassRoles(specs, superClassRole.name);
|
|
168
167
|
roles.push(...ancestorRoles);
|
|
169
168
|
}
|
|
170
169
|
}
|
|
@@ -177,10 +176,10 @@ function recursiveTraverseSuperClassRoles(roleName) {
|
|
|
177
176
|
* - If `true`, this mean is "Any".
|
|
178
177
|
* - If `false`, this mean is "No".
|
|
179
178
|
*/
|
|
180
|
-
function getPermittedRoles(el) {
|
|
179
|
+
function getPermittedRoles(specs, el) {
|
|
181
180
|
var _a;
|
|
182
|
-
const implicitRole = getImplicitRole(el);
|
|
183
|
-
const spec = (_a = htmlSpec(el.nodeName)) === null || _a === void 0 ? void 0 : _a.permittedRoles;
|
|
181
|
+
const implicitRole = getImplicitRole(specs, el);
|
|
182
|
+
const spec = (_a = htmlSpec(specs, el.nodeName)) === null || _a === void 0 ? void 0 : _a.permittedRoles;
|
|
184
183
|
if (!spec) {
|
|
185
184
|
return true;
|
|
186
185
|
}
|
|
@@ -209,9 +208,9 @@ function mergeRoleList(implicitRole, permittedRoles) {
|
|
|
209
208
|
}
|
|
210
209
|
return permittedRoles;
|
|
211
210
|
}
|
|
212
|
-
function getImplicitRole(el) {
|
|
211
|
+
function getImplicitRole(specs, el) {
|
|
213
212
|
var _a;
|
|
214
|
-
const implicitRole = (_a = htmlSpec(el.nodeName)) === null || _a === void 0 ? void 0 : _a.implicitRole;
|
|
213
|
+
const implicitRole = (_a = htmlSpec(specs, el.nodeName)) === null || _a === void 0 ? void 0 : _a.implicitRole;
|
|
215
214
|
if (!implicitRole) {
|
|
216
215
|
return false;
|
|
217
216
|
}
|
|
@@ -225,7 +224,7 @@ function getImplicitRole(el) {
|
|
|
225
224
|
return implicitRole.role;
|
|
226
225
|
}
|
|
227
226
|
exports.getImplicitRole = getImplicitRole;
|
|
228
|
-
function getComputedRole(el) {
|
|
227
|
+
function getComputedRole(specs, el) {
|
|
229
228
|
const roleAttrTokens = el.getAttributeToken('role');
|
|
230
229
|
const roleAttr = roleAttrTokens[0];
|
|
231
230
|
if (roleAttr) {
|
|
@@ -235,7 +234,7 @@ function getComputedRole(el) {
|
|
|
235
234
|
isImplicit: false,
|
|
236
235
|
};
|
|
237
236
|
}
|
|
238
|
-
const implicitRole = getImplicitRole(el);
|
|
237
|
+
const implicitRole = getImplicitRole(specs, el);
|
|
239
238
|
if (implicitRole) {
|
|
240
239
|
return {
|
|
241
240
|
name: implicitRole,
|
|
@@ -287,8 +286,8 @@ function checkAriaValue(type, value, tokenEnum) {
|
|
|
287
286
|
return true;
|
|
288
287
|
}
|
|
289
288
|
exports.checkAriaValue = checkAriaValue;
|
|
290
|
-
function checkAria(attrName, currentValue, role) {
|
|
291
|
-
const ariaAttrs =
|
|
289
|
+
function checkAria(specs, attrName, currentValue, role) {
|
|
290
|
+
const ariaAttrs = specs.def['#ariaAttrs'];
|
|
292
291
|
const aria = ariaAttrs.find(a => a.name === attrName);
|
|
293
292
|
if (!aria) {
|
|
294
293
|
return {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import(
|
|
1
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, null>;
|
|
2
2
|
export default _default;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const ml_core_1 = require("@markuplint/ml-core");
|
|
4
4
|
exports.default = (0, ml_core_1.createRule)({
|
|
5
5
|
async verify({ document, report, t }) {
|
|
6
|
-
const message = t('{0} is {1:c}', t('{0} of {1}', t('the {0}', 'value'), t('the "{0}" {1}', 'id', 'attribute')), 'duplicated');
|
|
6
|
+
const message = t('{0} is {1:c}', t('{0} of {1}', t('the {0}', 'value'), t('the "{0*}" {1}', 'id', 'attribute')), 'duplicated');
|
|
7
7
|
const idStack = [];
|
|
8
8
|
await document.walkOn('Element', async (node) => {
|
|
9
9
|
const idAttrs = node.getAttributeToken('id');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare type Value = 'tab' | number;
|
|
2
2
|
export interface IndentationOptions {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
alignment?: boolean;
|
|
4
|
+
'indent-nested-nodes'?: boolean | 'always' | 'never';
|
|
5
5
|
}
|
|
6
|
-
declare const _default: import(
|
|
6
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<Value, IndentationOptions>;
|
|
7
7
|
export default _default;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,63 +1,150 @@
|
|
|
1
1
|
declare const _default: {
|
|
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
|
-
|
|
2
|
+
'attr-duplication': import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
3
|
+
import('packages/@markuplint/ml-config/src').RuleConfigValue,
|
|
4
|
+
null
|
|
5
|
+
>;
|
|
6
|
+
'attr-equal-space-after': import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
7
|
+
'always' | 'never' | 'always-single-line' | 'never-single-line',
|
|
8
|
+
null
|
|
9
|
+
>;
|
|
10
|
+
'attr-equal-space-before': import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
11
|
+
'always' | 'never' | 'always-single-line' | 'never-single-line',
|
|
12
|
+
null
|
|
13
|
+
>;
|
|
14
|
+
'attr-spacing': import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
15
|
+
boolean,
|
|
16
|
+
import('./attr-spacing').AttrSpasingOptions
|
|
17
|
+
>;
|
|
18
|
+
'attr-value-quotes': import('packages/@markuplint/ml-core/lib').RuleSeed<import('./attr-value-quotes').Type, null>;
|
|
19
|
+
'case-sensitive-attr-name': import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
20
|
+
import('./case-sensitive-attr-name').Value | import('./case-sensitive-attr-name').Value_v1,
|
|
21
|
+
null
|
|
22
|
+
>;
|
|
23
|
+
'case-sensitive-tag-name': import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
24
|
+
import('./case-sensitive-tag-name').Value,
|
|
25
|
+
null
|
|
26
|
+
>;
|
|
27
|
+
'character-reference': import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
28
|
+
import('packages/@markuplint/ml-config/src').RuleConfigValue,
|
|
29
|
+
null
|
|
30
|
+
>;
|
|
31
|
+
'class-naming': import('packages/@markuplint/ml-core/lib').RuleSeed<import('./class-naming').Value, null>;
|
|
32
|
+
'deprecated-attr': import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
33
|
+
import('packages/@markuplint/ml-config/src').RuleConfigValue,
|
|
34
|
+
null
|
|
35
|
+
>;
|
|
36
|
+
'deprecated-element': import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
37
|
+
import('packages/@markuplint/ml-config/src').RuleConfigValue,
|
|
38
|
+
null
|
|
39
|
+
>;
|
|
40
|
+
'disallowed-element': import('packages/@markuplint/ml-core/lib').RuleSeed<string[], null>;
|
|
41
|
+
doctype: import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
42
|
+
'always',
|
|
43
|
+
{
|
|
44
|
+
denyObsolateType: boolean;
|
|
45
|
+
}
|
|
46
|
+
>;
|
|
47
|
+
'end-tag': import('packages/@markuplint/ml-core/lib').RuleSeed<boolean, null>;
|
|
48
|
+
'id-duplication': import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
49
|
+
import('packages/@markuplint/ml-config/src').RuleConfigValue,
|
|
50
|
+
null
|
|
51
|
+
>;
|
|
52
|
+
indentation: import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
53
|
+
import('./indentation').Value,
|
|
54
|
+
import('./indentation').IndentationOptions
|
|
55
|
+
>;
|
|
56
|
+
'ineffective-attr': import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
57
|
+
import('packages/@markuplint/ml-config/src').RuleConfigValue,
|
|
58
|
+
null
|
|
59
|
+
>;
|
|
60
|
+
'invalid-attr': import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
61
|
+
boolean,
|
|
62
|
+
{
|
|
63
|
+
attrs?:
|
|
64
|
+
| Record<
|
|
65
|
+
string,
|
|
66
|
+
| {
|
|
67
|
+
enum: [string, ...string[]];
|
|
68
|
+
}
|
|
69
|
+
| {
|
|
70
|
+
pattern: string;
|
|
71
|
+
}
|
|
72
|
+
| {
|
|
73
|
+
type: import('packages/@markuplint/ml-spec/lib').AttributeType;
|
|
74
|
+
}
|
|
75
|
+
| {
|
|
76
|
+
disallowed: true;
|
|
77
|
+
}
|
|
78
|
+
>
|
|
79
|
+
| undefined;
|
|
80
|
+
ignoreAttrNamePrefix?: string | string[] | undefined;
|
|
81
|
+
}
|
|
82
|
+
>;
|
|
83
|
+
'landmark-roles': import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
84
|
+
boolean,
|
|
85
|
+
{
|
|
86
|
+
ignoreRoles?:
|
|
87
|
+
| (('banner' | 'main' | 'complementary' | 'contentinfo') | 'form' | 'navigation' | 'region')[]
|
|
88
|
+
| undefined;
|
|
89
|
+
labelEachArea?: boolean | undefined;
|
|
90
|
+
}
|
|
91
|
+
>;
|
|
92
|
+
'no-boolean-attr-value': import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
93
|
+
import('packages/@markuplint/ml-config/src').RuleConfigValue,
|
|
94
|
+
null
|
|
95
|
+
>;
|
|
96
|
+
'no-default-value': import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
97
|
+
import('packages/@markuplint/ml-config/src').RuleConfigValue,
|
|
98
|
+
null
|
|
99
|
+
>;
|
|
100
|
+
'no-hard-code-id': import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
101
|
+
import('packages/@markuplint/ml-config/src').RuleConfigValue,
|
|
102
|
+
null
|
|
103
|
+
>;
|
|
104
|
+
'no-refer-to-non-existent-id': import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
105
|
+
import('packages/@markuplint/ml-config/src').RuleConfigValue,
|
|
106
|
+
null
|
|
107
|
+
>;
|
|
108
|
+
'no-use-event-handler-attr': import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
109
|
+
boolean,
|
|
110
|
+
{
|
|
111
|
+
ignore?: string | string[] | undefined;
|
|
112
|
+
}
|
|
113
|
+
>;
|
|
114
|
+
'permitted-contents': import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
115
|
+
import('packages/@markuplint/ml-spec/lib').PermittedStructuresSchema[],
|
|
116
|
+
{
|
|
117
|
+
ignoreHasMutableChildren: boolean;
|
|
118
|
+
}
|
|
119
|
+
>;
|
|
120
|
+
'required-attr': import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
121
|
+
| string
|
|
122
|
+
| (
|
|
123
|
+
| string
|
|
124
|
+
| {
|
|
125
|
+
name: string;
|
|
126
|
+
value: string | string[];
|
|
127
|
+
}
|
|
128
|
+
)[],
|
|
129
|
+
null
|
|
130
|
+
>;
|
|
131
|
+
'required-element': import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
132
|
+
string[],
|
|
133
|
+
{
|
|
134
|
+
ignoreHasMutableContents?: boolean | undefined;
|
|
135
|
+
}
|
|
136
|
+
>;
|
|
137
|
+
'required-h1': import('packages/@markuplint/ml-core/lib').RuleSeed<boolean, import('./required-h1').Options>;
|
|
138
|
+
'wai-aria': import('packages/@markuplint/ml-core/lib').RuleSeed<
|
|
139
|
+
boolean,
|
|
140
|
+
{
|
|
141
|
+
checkingValue?: boolean | undefined;
|
|
142
|
+
checkingDeprecatedProps?: boolean | undefined;
|
|
143
|
+
permittedAriaRoles?: boolean | undefined;
|
|
144
|
+
disallowSetImplicitRole?: boolean | undefined;
|
|
145
|
+
disallowSetImplicitProps?: boolean | undefined;
|
|
146
|
+
disallowDefaultValue?: boolean | undefined;
|
|
147
|
+
}
|
|
148
|
+
>;
|
|
62
149
|
};
|
|
63
150
|
export default _default;
|
package/lib/index.js
CHANGED
|
@@ -14,6 +14,7 @@ const deprecated_attr_1 = (0, tslib_1.__importDefault)(require("./deprecated-att
|
|
|
14
14
|
const deprecated_element_1 = (0, tslib_1.__importDefault)(require("./deprecated-element"));
|
|
15
15
|
const disallowed_element_1 = (0, tslib_1.__importDefault)(require("./disallowed-element"));
|
|
16
16
|
const doctype_1 = (0, tslib_1.__importDefault)(require("./doctype"));
|
|
17
|
+
const end_tag_1 = (0, tslib_1.__importDefault)(require("./end-tag"));
|
|
17
18
|
const id_duplication_1 = (0, tslib_1.__importDefault)(require("./id-duplication"));
|
|
18
19
|
const indentation_1 = (0, tslib_1.__importDefault)(require("./indentation"));
|
|
19
20
|
const ineffective_attr_1 = (0, tslib_1.__importDefault)(require("./ineffective-attr"));
|
|
@@ -43,6 +44,7 @@ exports.default = {
|
|
|
43
44
|
'deprecated-element': deprecated_element_1.default,
|
|
44
45
|
'disallowed-element': disallowed_element_1.default,
|
|
45
46
|
doctype: doctype_1.default,
|
|
47
|
+
'end-tag': end_tag_1.default,
|
|
46
48
|
'id-duplication': id_duplication_1.default,
|
|
47
49
|
indentation: indentation_1.default,
|
|
48
50
|
'ineffective-attr': ineffective_attr_1.default,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import(
|
|
1
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, null>;
|
|
2
2
|
export default _default;
|
|
@@ -29,7 +29,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
29
29
|
raw: attr.raw,
|
|
30
30
|
line: attr.startLine,
|
|
31
31
|
col: attr.startCol,
|
|
32
|
-
message: t('{0} is {1:c}', t('the "{0}" {1}', name, 'attribute'), 'ineffective') +
|
|
32
|
+
message: t('{0} is {1:c}', t('the "{0*}" {1}', name, 'attribute'), 'ineffective') +
|
|
33
33
|
t('. ') +
|
|
34
34
|
t("It doesn't need {0}", t('the {0}', 'attribute')),
|
|
35
35
|
});
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import type { AttributeType } from '@markuplint/ml-spec';
|
|
2
2
|
declare type Option = {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
attrs?: Record<string, Rule>;
|
|
4
|
+
ignoreAttrNamePrefix?: string | string[];
|
|
5
5
|
};
|
|
6
|
-
declare type Rule =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
declare type Rule =
|
|
7
|
+
| {
|
|
8
|
+
enum: [string, ...string[]];
|
|
9
|
+
}
|
|
10
|
+
| {
|
|
11
|
+
pattern: string;
|
|
12
|
+
}
|
|
13
|
+
| {
|
|
14
|
+
type: AttributeType;
|
|
15
|
+
}
|
|
16
|
+
| {
|
|
17
|
+
disallowed: true;
|
|
18
|
+
};
|
|
19
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, Option>;
|
|
16
20
|
export default _default;
|
|
@@ -18,7 +18,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
18
18
|
const attrName = attr.getName();
|
|
19
19
|
const name = attrName.potential;
|
|
20
20
|
if (!node.isCustomElement && attr.attrType === 'html-attr' && attr.candidate) {
|
|
21
|
-
const message = t('{0} is {1:c}', t('the "{0}" {1}', attrName.raw, 'attribute'), 'disallowed') +
|
|
21
|
+
const message = t('{0} is {1:c}', t('the "{0*}" {1}', attrName.raw, 'attribute'), 'disallowed') +
|
|
22
22
|
t('. ') +
|
|
23
23
|
t('Did you mean "{0}"?', attr.candidate);
|
|
24
24
|
report({
|
|
@@ -43,6 +43,9 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
43
43
|
let invalid = false;
|
|
44
44
|
const customRule = node.rule.option.attrs ? node.rule.option.attrs[name] : null;
|
|
45
45
|
if (customRule) {
|
|
46
|
+
if (attr.attrType === 'html-attr' && attr.isDynamicValue) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
46
49
|
if ('enum' in customRule) {
|
|
47
50
|
invalid = (0, attr_check_1.attrCheck)(t, name.toLowerCase(), value, true, {
|
|
48
51
|
name,
|
|
@@ -56,7 +59,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
56
59
|
if (!(0, helpers_1.match)(value, customRule.pattern)) {
|
|
57
60
|
invalid = {
|
|
58
61
|
invalidType: 'invalid-value',
|
|
59
|
-
message: t('{0} is unmatched with the below patterns: {1}', t('the "{0}" {1}', name, 'attribute'), customRule.pattern),
|
|
62
|
+
message: t('{0} is unmatched with the below patterns: {1}', t('the "{0*}" {1}', name, 'attribute'), customRule.pattern),
|
|
60
63
|
};
|
|
61
64
|
}
|
|
62
65
|
}
|
|
@@ -66,7 +69,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
66
69
|
else if ('disallowed' in customRule && customRule.disallowed) {
|
|
67
70
|
invalid = {
|
|
68
71
|
invalidType: 'non-existent',
|
|
69
|
-
message: t('{0} is disallowed', t('the "{0}" {1}', name, 'attribute')),
|
|
72
|
+
message: t('{0} is disallowed', t('the "{0*}" {1}', name, 'attribute')),
|
|
70
73
|
};
|
|
71
74
|
}
|
|
72
75
|
}
|
|
@@ -87,6 +90,10 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
87
90
|
break;
|
|
88
91
|
}
|
|
89
92
|
case 'non-existent': {
|
|
93
|
+
const spec = (0, helpers_1.htmlSpec)(document.specs, node.nameWithNS);
|
|
94
|
+
if (spec === null || spec === void 0 ? void 0 : spec.possibleToAddProperties) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
90
97
|
report({
|
|
91
98
|
scope: node,
|
|
92
99
|
message: invalid.message,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
declare type Options = {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
ignoreRoles?: Roles[];
|
|
3
|
+
labelEachArea?: boolean;
|
|
4
4
|
};
|
|
5
5
|
declare type TopLevelRoles = 'banner' | 'main' | 'complementary' | 'contentinfo';
|
|
6
6
|
declare type Roles = TopLevelRoles | 'form' | 'navigation' | 'region';
|
|
7
|
-
declare const _default: import(
|
|
7
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, Options>;
|
|
8
8
|
export default _default;
|
|
@@ -78,7 +78,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
78
78
|
if (el.isDescendantByUUIDList(uuidList)) {
|
|
79
79
|
report({
|
|
80
80
|
scope: el,
|
|
81
|
-
message: t('{0} should be {1}', t('the "{0}" {1}', role, 'role'), 'top level'),
|
|
81
|
+
message: t('{0} should be {1}', t('the "{0*}" {1}', role, 'role'), 'top level'),
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import(
|
|
1
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, null>;
|
|
2
2
|
export default _default;
|
|
@@ -10,7 +10,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
12
|
for (const attr of el.attributes) {
|
|
13
|
-
if (attr.attrType === 'ps-attr') {
|
|
13
|
+
if (attr.attrType === 'ps-attr' || attr.isDynamicValue) {
|
|
14
14
|
continue;
|
|
15
15
|
}
|
|
16
16
|
const name = attr.getName().potential;
|
|
@@ -36,7 +36,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
36
36
|
raw: extraRaw,
|
|
37
37
|
line: attr.spacesBeforeEqual.startLine,
|
|
38
38
|
col: attr.spacesBeforeEqual.startCol,
|
|
39
|
-
message: t('{0} is {1}', t('the "{0}" {1}', name, 'attribute'), t('a {0}', 'boolean attribute')) +
|
|
39
|
+
message: t('{0} is {1}', t('the "{0*}" {1}', name, 'attribute'), t('a {0}', 'boolean attribute')) +
|
|
40
40
|
t('. ') +
|
|
41
41
|
t("It doesn't need {0}", t('the {0}', 'value')),
|
|
42
42
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import(
|
|
1
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, null>;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import(
|
|
1
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, null>;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import(
|
|
1
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, null>;
|
|
2
2
|
export default _default;
|
|
@@ -4,7 +4,7 @@ const ml_core_1 = require("@markuplint/ml-core");
|
|
|
4
4
|
const helpers_1 = require("../helpers");
|
|
5
5
|
exports.default = (0, ml_core_1.createRule)({
|
|
6
6
|
async verify({ document, report, t }) {
|
|
7
|
-
const { ariaAttrs } = (0, helpers_1.ariaSpec)();
|
|
7
|
+
const { ariaAttrs } = (0, helpers_1.ariaSpec)(document.specs);
|
|
8
8
|
const idList = new Set();
|
|
9
9
|
let hasDynamicId = false;
|
|
10
10
|
await document.walkOn('Element', el => {
|
|
@@ -34,7 +34,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
for (const attr of el.attributes) {
|
|
37
|
-
if (attr.attrType !== 'html-attr') {
|
|
37
|
+
if (attr.attrType !== 'html-attr' || attr.isDynamicValue) {
|
|
38
38
|
continue;
|
|
39
39
|
}
|
|
40
40
|
const name = attr.getName().potential;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare type Options = {
|
|
2
|
-
|
|
2
|
+
ignore?: string | string[];
|
|
3
3
|
};
|
|
4
|
-
declare const _default: import(
|
|
4
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, Options>;
|
|
5
5
|
export default _default;
|
|
@@ -28,7 +28,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
28
28
|
raw: attr.raw,
|
|
29
29
|
line: attr.startLine,
|
|
30
30
|
col: attr.startCol,
|
|
31
|
-
message: t('{0} is disallowed', t('the "{0}" {1}', name, 'attribute')),
|
|
31
|
+
message: t('{0} is disallowed', t('the "{0*}" {1}', name, 'attribute')),
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PermittedStructuresSchema } from '@markuplint/ml-spec';
|
|
2
2
|
declare type Options = {
|
|
3
|
-
|
|
3
|
+
ignoreHasMutableChildren: boolean;
|
|
4
4
|
};
|
|
5
|
-
declare const _default: import(
|
|
5
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<PermittedStructuresSchema[], Options>;
|
|
6
6
|
export default _default;
|