@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
|
@@ -23,13 +23,13 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
23
23
|
}
|
|
24
24
|
const specType = node.ns === 'html' ? 'HTML' : node.ns === 'svg' ? 'SVG' : 'Any Language';
|
|
25
25
|
const childNodes = node.getChildElementsAndTextNodeWithoutWhitespaces();
|
|
26
|
-
const spec = !node.isCustomElement && ((_a = (0, helpers_1.htmlSpec)(node.nameWithNS)) === null || _a === void 0 ? void 0 : _a.permittedStructures);
|
|
26
|
+
const spec = !node.isCustomElement && ((_a = (0, helpers_1.htmlSpec)(document.specs, node.nameWithNS)) === null || _a === void 0 ? void 0 : _a.permittedStructures);
|
|
27
27
|
const expGen = new permitted_content_spec_to_regexp_1.default(idCounter++);
|
|
28
28
|
if (spec) {
|
|
29
29
|
if (spec.ancestor && !node.closest(spec.ancestor)) {
|
|
30
30
|
report({
|
|
31
31
|
scope: node,
|
|
32
|
-
message: t('{0} must be {1}', t('the "{0}" {1}', node.nodeName, 'element'), t('{0} of {1}', 'descendant', t('the "{0}" {1}', spec.ancestor, 'element'))),
|
|
32
|
+
message: t('{0} must be {1}', t('the "{0*}" {1}', node.nodeName, 'element'), t('{0} of {1}', 'descendant', t('the "{0*}" {1}', spec.ancestor, 'element'))),
|
|
33
33
|
});
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
@@ -45,11 +45,11 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
45
45
|
// console.log({ ...conditional, matched });
|
|
46
46
|
if (matched) {
|
|
47
47
|
try {
|
|
48
|
-
const parentExp = getRegExpFromParentNode(node, expGen);
|
|
48
|
+
const parentExp = getRegExpFromParentNode(document.specs, node, expGen);
|
|
49
49
|
const exp = expGen.specToRegExp(conditional.contents, parentExp, node.ns);
|
|
50
50
|
const conditionalResult = match(exp, childNodes, node.ns, false);
|
|
51
51
|
if (!conditionalResult) {
|
|
52
|
-
const message = t('{0} is {1:c}', t('{0} of {1}', t('the {0}', 'content'), t('the "{0}" {1}', node.nodeName, 'element')), 'invalid');
|
|
52
|
+
const message = t('{0} is {1:c}', t('{0} of {1}', t('the {0}', 'content'), t('the "{0*}" {1}', node.nodeName, 'element')), 'invalid');
|
|
53
53
|
report({
|
|
54
54
|
scope: node,
|
|
55
55
|
message: specType !== 'Any Language'
|
|
@@ -76,10 +76,10 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
76
76
|
}
|
|
77
77
|
if (!matched) {
|
|
78
78
|
try {
|
|
79
|
-
const exp = getRegExpFromNode(node, expGen);
|
|
79
|
+
const exp = getRegExpFromNode(document.specs, node, expGen);
|
|
80
80
|
const specResult = match(exp, childNodes, node.ns, false);
|
|
81
81
|
if (!specResult) {
|
|
82
|
-
const message = t('{0} is {1:c}', t('{0} of {1}', t('the {0}', 'content'), t('the "{0}" {1}', node.nodeName, 'element')), 'invalid');
|
|
82
|
+
const message = t('{0} is {1:c}', t('{0} of {1}', t('the {0}', 'content'), t('the "{0*}" {1}', node.nodeName, 'element')), 'invalid');
|
|
83
83
|
report({
|
|
84
84
|
scope: node,
|
|
85
85
|
message: specType !== 'Any Language'
|
|
@@ -103,7 +103,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
103
103
|
if (rule.tag.toLowerCase() !== node.nodeName.toLowerCase()) {
|
|
104
104
|
continue;
|
|
105
105
|
}
|
|
106
|
-
const parentExp = getRegExpFromParentNode(node, expGen);
|
|
106
|
+
const parentExp = getRegExpFromParentNode(document.specs, node, expGen);
|
|
107
107
|
try {
|
|
108
108
|
const exp = expGen.specToRegExp(rule.contents, parentExp, node.ns);
|
|
109
109
|
// Evaluate the custom element if the optional schema.
|
|
@@ -111,7 +111,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
111
111
|
if (!r) {
|
|
112
112
|
report({
|
|
113
113
|
scope: node,
|
|
114
|
-
message: t('{0} is {1:c}', t('{0} of {1}', t('the {0}', 'content'), t('the "{0}" {1}', node.nodeName, 'element')), 'invalid'),
|
|
114
|
+
message: t('{0} is {1:c}', t('{0} of {1}', t('the {0}', 'content'), t('the "{0*}" {1}', node.nodeName, 'element')), 'invalid'),
|
|
115
115
|
line: node.startLine,
|
|
116
116
|
col: node.startCol,
|
|
117
117
|
raw: node.raw,
|
|
@@ -148,22 +148,22 @@ function normalization(nodes, ownNS, evalCustomElement) {
|
|
|
148
148
|
})
|
|
149
149
|
.join('');
|
|
150
150
|
}
|
|
151
|
-
function getRegExpFromNode(node, expGen) {
|
|
151
|
+
function getRegExpFromNode(specs, node, expGen) {
|
|
152
152
|
var _a;
|
|
153
153
|
// console.log({ n: node.nodeName });
|
|
154
154
|
if (expMapOnNodeId.has(node.uuid)) {
|
|
155
155
|
return expMapOnNodeId.get(node.uuid);
|
|
156
156
|
}
|
|
157
|
-
const parentExp = node.parentNode ? getRegExpFromNode(node.parentNode, expGen) : null;
|
|
158
|
-
const spec = !node.isCustomElement && ((_a = (0, helpers_1.htmlSpec)(node.nameWithNS || node.nodeName.toLowerCase())) === null || _a === void 0 ? void 0 : _a.permittedStructures);
|
|
157
|
+
const parentExp = node.parentNode ? getRegExpFromNode(specs, node.parentNode, expGen) : null;
|
|
158
|
+
const spec = !node.isCustomElement && ((_a = (0, helpers_1.htmlSpec)(specs, node.nameWithNS || node.nodeName.toLowerCase())) === null || _a === void 0 ? void 0 : _a.permittedStructures);
|
|
159
159
|
const contentRule = spec ? spec.contents : true;
|
|
160
160
|
const exp = expGen.specToRegExp(contentRule, parentExp, node.ns || null);
|
|
161
161
|
expMapOnNodeId.set(node.uuid, exp);
|
|
162
162
|
return exp;
|
|
163
163
|
}
|
|
164
|
-
function getRegExpFromParentNode(node, expGen) {
|
|
164
|
+
function getRegExpFromParentNode(specs, node, expGen) {
|
|
165
165
|
// console.log({ p: node.nodeName });
|
|
166
|
-
const parentExp = node.parentNode ? getRegExpFromNode(node.parentNode, expGen) : null;
|
|
166
|
+
const parentExp = node.parentNode ? getRegExpFromNode(specs, node.parentNode, expGen) : null;
|
|
167
167
|
return parentExp;
|
|
168
168
|
}
|
|
169
169
|
const matchingCacheMap = new Map();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { PermittedContent } from '@markuplint/ml-spec';
|
|
2
2
|
export default class ExpGenerator {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
private _id;
|
|
4
|
+
private _idCounter;
|
|
5
|
+
constructor(_id: number);
|
|
6
|
+
specToRegExp(contentRule: PermittedContent[] | boolean, parentExp?: RegExp | null, ownNS?: string | null): RegExp;
|
|
7
|
+
private _toPattern;
|
|
8
|
+
private _interleavePattern;
|
|
9
|
+
private _targetTags;
|
|
10
|
+
private _resolveTags;
|
|
11
11
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import(
|
|
1
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<string[], null>;
|
|
2
2
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare type RequiredAttributes = string | (string | Attr)[];
|
|
2
2
|
declare type Attr = {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
name: string;
|
|
4
|
+
value: string | string[];
|
|
5
5
|
};
|
|
6
|
-
declare const _default: import(
|
|
6
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<RequiredAttributes, null>;
|
|
7
7
|
export default _default;
|
|
@@ -67,7 +67,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
if (invalid) {
|
|
70
|
-
const message = t('{0} expects {1}', t('the "{0}" {1}', node.nodeName, 'element'), t('the "{0}" {1}', spec.name, 'attribute'));
|
|
70
|
+
const message = t('{0} expects {1}', t('the "{0*}" {1}', node.nodeName, 'element'), t('the "{0*}" {1}', spec.name, 'attribute'));
|
|
71
71
|
report({
|
|
72
72
|
scope: node,
|
|
73
73
|
message,
|
|
@@ -78,7 +78,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
78
78
|
const matched = spec.values.some(pattern => (0, helpers_1.match)(value, pattern));
|
|
79
79
|
if (!matched) {
|
|
80
80
|
const expects = spec.values.length === 1 ? t(spec.values) : t('either {0}', t(spec.values));
|
|
81
|
-
const message = t('{0} expects {1}', t('the "{0}" {1}', spec.name, 'attribute'), expects);
|
|
81
|
+
const message = t('{0} expects {1}', t('the "{0*}" {1}', spec.name, 'attribute'), expects);
|
|
82
82
|
const attrToken = node.getAttributeToken(spec.name);
|
|
83
83
|
const valueToken = ((_a = attrToken[0]) === null || _a === void 0 ? void 0 : _a.attrType) === 'html-attr' ? attrToken[0].value : null;
|
|
84
84
|
const token = valueToken || attrToken[0];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare type Options = {
|
|
2
|
-
|
|
2
|
+
ignoreHasMutableContents?: boolean;
|
|
3
3
|
};
|
|
4
|
-
declare const _default: import(
|
|
4
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<string[], Options>;
|
|
5
5
|
export default _default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export interface Options {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
'expected-once'?: boolean;
|
|
3
|
+
'in-document-fragment'?: boolean;
|
|
4
4
|
}
|
|
5
|
-
declare const _default: import(
|
|
5
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, Options>;
|
|
6
6
|
export default _default;
|
package/lib/required-h1/index.js
CHANGED
|
@@ -20,7 +20,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
if (h1Stack.length === 0) {
|
|
23
|
-
const message = t('Require {0}', t('the "{0}" {1}', 'h1', 'element'));
|
|
23
|
+
const message = t('Require {0}', t('the "{0*}" {1}', 'h1', 'element'));
|
|
24
24
|
report({
|
|
25
25
|
message,
|
|
26
26
|
line: 1,
|
|
@@ -29,7 +29,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
else if (globalRule.option['expected-once'] && h1Stack.length > 1) {
|
|
32
|
-
const message = t('{0} is {1:c}', t('the "{0}" {1}', 'h1', 'element'), 'duplicated');
|
|
32
|
+
const message = t('{0} is {1:c}', t('the "{0*}" {1}', 'h1', 'element'), 'duplicated');
|
|
33
33
|
report({
|
|
34
34
|
message,
|
|
35
35
|
line: h1Stack[1].startLine,
|
package/lib/wai-aria/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
declare type Options = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
checkingValue?: boolean;
|
|
3
|
+
checkingDeprecatedProps?: boolean;
|
|
4
|
+
permittedAriaRoles?: boolean;
|
|
5
|
+
disallowSetImplicitRole?: boolean;
|
|
6
|
+
disallowSetImplicitProps?: boolean;
|
|
7
|
+
disallowDefaultValue?: boolean;
|
|
8
8
|
};
|
|
9
|
-
declare const _default: import(
|
|
9
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, Options>;
|
|
10
10
|
export default _default;
|
package/lib/wai-aria/index.js
CHANGED
|
@@ -14,8 +14,8 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
14
14
|
async verify({ document, report, t }) {
|
|
15
15
|
await document.walkOn('Element', async (node) => {
|
|
16
16
|
const attrSpecs = (0, ml_core_1.getAttrSpecs)(node.nameWithNS, document.specs);
|
|
17
|
-
const html = (0, helpers_1.htmlSpec)(node.nodeName);
|
|
18
|
-
const { roles, ariaAttrs } = (0, helpers_1.ariaSpec)();
|
|
17
|
+
const html = (0, helpers_1.htmlSpec)(document.specs, node.nodeName);
|
|
18
|
+
const { roles, ariaAttrs } = (0, helpers_1.ariaSpec)(document.specs);
|
|
19
19
|
if (!html || !attrSpecs) {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
@@ -29,7 +29,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
29
29
|
// Not exist
|
|
30
30
|
report({
|
|
31
31
|
scope: node,
|
|
32
|
-
message: t('{0} according to {1}', t('{0} does not exist', t('the "{0}" {1}', value, 'role')), 'the WAI-ARIA specification') + `This "${value}" role does not exist in WAI-ARIA.`,
|
|
32
|
+
message: t('{0} according to {1}', t('{0} does not exist', t('the "{0*}" {1}', value, 'role')), 'the WAI-ARIA specification') + `This "${value}" role does not exist in WAI-ARIA.`,
|
|
33
33
|
line: roleAttr.startLine,
|
|
34
34
|
col: roleAttr.startCol,
|
|
35
35
|
raw: roleAttr.raw,
|
|
@@ -39,7 +39,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
39
39
|
// the abstract role
|
|
40
40
|
report({
|
|
41
41
|
scope: node,
|
|
42
|
-
message: t('{0} is {1}', t('the "{0}" {1}', value, 'role'), 'the abstract role'),
|
|
42
|
+
message: t('{0} is {1}', t('the "{0*}" {1}', value, 'role'), 'the abstract role'),
|
|
43
43
|
line: roleAttr.startLine,
|
|
44
44
|
col: roleAttr.startCol,
|
|
45
45
|
raw: roleAttr.raw,
|
|
@@ -47,12 +47,12 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
47
47
|
}
|
|
48
48
|
// Set the implicit role explicitly
|
|
49
49
|
if (node.rule.option.disallowSetImplicitRole) {
|
|
50
|
-
const implictRole = (0, helpers_1.getImplicitRole)(node);
|
|
50
|
+
const implictRole = (0, helpers_1.getImplicitRole)(document.specs, node);
|
|
51
51
|
if (implictRole && implictRole === value) {
|
|
52
52
|
// the implicit role
|
|
53
53
|
report({
|
|
54
54
|
scope: node,
|
|
55
|
-
message: t('{0} is {1}', t('the "{0}" {1}', value, 'role'), t('{0} of {1}', 'the implicit role', t('the "{0}" {1}', node.nodeName, 'element'))),
|
|
55
|
+
message: t('{0} is {1}', t('the "{0*}" {1}', value, 'role'), t('{0} of {1}', 'the implicit role', t('the "{0*}" {1}', node.nodeName, 'element'))),
|
|
56
56
|
line: roleAttr.startLine,
|
|
57
57
|
col: roleAttr.startCol,
|
|
58
58
|
raw: roleAttr.raw,
|
|
@@ -61,11 +61,11 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
61
61
|
}
|
|
62
62
|
// Permitted ARIA Roles
|
|
63
63
|
if (node.rule.option.permittedAriaRoles) {
|
|
64
|
-
const permittedRoles = (0, helpers_1.getPermittedRoles)(node);
|
|
64
|
+
const permittedRoles = (0, helpers_1.getPermittedRoles)(document.specs, node);
|
|
65
65
|
if (permittedRoles === false) {
|
|
66
66
|
report({
|
|
67
67
|
scope: node,
|
|
68
|
-
message: t('{0} according to {1}', t('Cannot overwrite {0}', t('{0} of {1}', t('the {0}', 'role'), t('the "{0}" {1}', node.nodeName, 'element'))), 'ARIA in HTML specification'),
|
|
68
|
+
message: t('{0} according to {1}', t('Cannot overwrite {0}', t('{0} of {1}', t('the {0}', 'role'), t('the "{0*}" {1}', node.nodeName, 'element'))), 'ARIA in HTML specification'),
|
|
69
69
|
line: roleAttr.startLine,
|
|
70
70
|
col: roleAttr.startCol,
|
|
71
71
|
raw: roleAttr.raw,
|
|
@@ -74,7 +74,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
74
74
|
else if (Array.isArray(permittedRoles) && !permittedRoles.includes(value)) {
|
|
75
75
|
report({
|
|
76
76
|
scope: node,
|
|
77
|
-
message: t('{0} according to {1}', t('Cannot overwrite {0} to {1}', t('the "{0}" {1}', value, 'role'), t('the "{0}" {1}', node.nodeName, 'element')), 'ARIA in HTML specification'),
|
|
77
|
+
message: t('{0} according to {1}', t('Cannot overwrite {0} to {1}', t('the "{0*}" {1}', value, 'role'), t('the "{0*}" {1}', node.nodeName, 'element')), 'ARIA in HTML specification'),
|
|
78
78
|
line: roleAttr.startLine,
|
|
79
79
|
col: roleAttr.startCol,
|
|
80
80
|
raw: roleAttr.raw,
|
|
@@ -82,9 +82,9 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
const computedRole = (0, helpers_1.getComputedRole)(node);
|
|
85
|
+
const computedRole = (0, helpers_1.getComputedRole)(document.specs, node);
|
|
86
86
|
if (computedRole) {
|
|
87
|
-
const role = (0, helpers_1.getRoleSpec)(computedRole.name);
|
|
87
|
+
const role = (0, helpers_1.getRoleSpec)(document.specs, computedRole.name);
|
|
88
88
|
if (role) {
|
|
89
89
|
// Checking aria-* on the role
|
|
90
90
|
for (const attr of node.attributes) {
|
|
@@ -95,7 +95,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
95
95
|
if (node.rule.option.checkingDeprecatedProps && statesAndProp.deprecated) {
|
|
96
96
|
report({
|
|
97
97
|
scope: node,
|
|
98
|
-
message: t('{0:c} on {1}', t('{0} is {1:c}', t('the "{0}" {1}', attrName, 'ARIA state/property'), 'deprecated'), t('the "{0}" {1}', role.name, 'role')),
|
|
98
|
+
message: t('{0:c} on {1}', t('{0} is {1:c}', t('the "{0*}" {1}', attrName, 'ARIA state/property'), 'deprecated'), t('the "{0*}" {1}', role.name, 'role')),
|
|
99
99
|
line: attr.startLine,
|
|
100
100
|
col: attr.startCol,
|
|
101
101
|
raw: attr.raw,
|
|
@@ -105,7 +105,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
105
105
|
else {
|
|
106
106
|
report({
|
|
107
107
|
scope: node,
|
|
108
|
-
message: t('{0:c} on {1}', t('{0} is {1:c}', t('the "{0}" {1}', attrName, 'ARIA state/property'), 'disallowed'), t('the "{0}" {1}', role.name, 'role')),
|
|
108
|
+
message: t('{0:c} on {1}', t('{0} is {1:c}', t('the "{0*}" {1}', attrName, 'ARIA state/property'), 'disallowed'), t('the "{0*}" {1}', role.name, 'role')),
|
|
109
109
|
line: attr.startLine,
|
|
110
110
|
col: attr.startCol,
|
|
111
111
|
raw: attr.raw,
|
|
@@ -124,7 +124,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
124
124
|
if (!has) {
|
|
125
125
|
report({
|
|
126
126
|
scope: node,
|
|
127
|
-
message: t('{0:c} on {1}', t('Require {0}', t('the "{0}" {1}', requiredProp, 'ARIA state/property')), t('the "{0}" {1}', role.name, 'role')),
|
|
127
|
+
message: t('{0:c} on {1}', t('Require {0}', t('the "{0*}" {1}', requiredProp, 'ARIA state/property')), t('the "{0*}" {1}', role.name, 'role')),
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
130
|
}
|
|
@@ -133,7 +133,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
133
133
|
}
|
|
134
134
|
else {
|
|
135
135
|
// No role element
|
|
136
|
-
const { ariaAttrs } = (0, helpers_1.ariaSpec)();
|
|
136
|
+
const { ariaAttrs } = (0, helpers_1.ariaSpec)(document.specs);
|
|
137
137
|
for (const attr of node.attributes) {
|
|
138
138
|
const attrName = attr.getName().potential.trim().toLowerCase();
|
|
139
139
|
if (/^aria-/i.test(attrName)) {
|
|
@@ -141,7 +141,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
141
141
|
if (ariaAttr && !ariaAttr.isGlobal) {
|
|
142
142
|
report({
|
|
143
143
|
scope: node,
|
|
144
|
-
message: t('{0} is not {1}', t('the "{0}" {1}', attrName, 'ARIA state/property'), 'global state/property'),
|
|
144
|
+
message: t('{0} is not {1}', t('the "{0*}" {1}', attrName, 'ARIA state/property'), 'global state/property'),
|
|
145
145
|
line: attr.startLine,
|
|
146
146
|
col: attr.startCol,
|
|
147
147
|
raw: attr.raw,
|
|
@@ -160,11 +160,11 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
160
160
|
const propSpec = ariaAttrs.find(p => p.name === attrName);
|
|
161
161
|
// Checking ARIA Value
|
|
162
162
|
if (node.rule.option.checkingValue) {
|
|
163
|
-
const result = (0, helpers_1.checkAria)(attrName, value, computedRole === null || computedRole === void 0 ? void 0 : computedRole.name);
|
|
163
|
+
const result = (0, helpers_1.checkAria)(document.specs, attrName, value, computedRole === null || computedRole === void 0 ? void 0 : computedRole.name);
|
|
164
164
|
if (!result.isValid) {
|
|
165
165
|
report({
|
|
166
166
|
scope: node,
|
|
167
|
-
message: t('{0:c} on {1}', t('{0} is {1:c}', t('the "{0}"', value), 'disallowed'), t('the "{0}" {1}', attrName, 'ARIA state/property')) +
|
|
167
|
+
message: t('{0:c} on {1}', t('{0} is {1:c}', t('the "{0}"', value), 'disallowed'), t('the "{0*}" {1}', attrName, 'ARIA state/property')) +
|
|
168
168
|
('enum' in result && result.enum.length
|
|
169
169
|
? t('. ') + t('Allowed values are: {0}', t(result.enum))
|
|
170
170
|
: ''),
|
|
@@ -189,7 +189,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
189
189
|
equivalentHtmlAttr.value === value) {
|
|
190
190
|
report({
|
|
191
191
|
scope: node,
|
|
192
|
-
message: t('{0} has {1}', t('the "{0}" {1}', attrName, 'ARIA state/property'), t('the same {0} as {1}', 'semantics', t('{0} or {1}', t('the current "{0}" {1}', equivalentHtmlAttr.htmlAttrName, 'attribute'), t('the implicit "{0}" {1}', equivalentHtmlAttr.htmlAttrName, 'attribute')))),
|
|
192
|
+
message: t('{0} has {1}', t('the "{0*}" {1}', attrName, 'ARIA state/property'), t('the same {0} as {1}', 'semantics', t('{0} or {1}', t('the current "{0}" {1}', equivalentHtmlAttr.htmlAttrName, 'attribute'), t('the implicit "{0}" {1}', equivalentHtmlAttr.htmlAttrName, 'attribute')))),
|
|
193
193
|
line: attr.startLine,
|
|
194
194
|
col: attr.startCol,
|
|
195
195
|
raw: attr.raw,
|
|
@@ -201,7 +201,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
201
201
|
}
|
|
202
202
|
report({
|
|
203
203
|
scope: node,
|
|
204
|
-
message: t('{0} contradicts {1}', t('the "{0}" {1}', attrName, 'ARIA state/property'), t('the current "{0}" {1}', equivalentHtmlAttr.htmlAttrName, 'attribute')),
|
|
204
|
+
message: t('{0} contradicts {1}', t('the "{0*}" {1}', attrName, 'ARIA state/property'), t('the current "{0}" {1}', equivalentHtmlAttr.htmlAttrName, 'attribute')),
|
|
205
205
|
line: attr.startLine,
|
|
206
206
|
col: attr.startCol,
|
|
207
207
|
raw: attr.raw,
|
|
@@ -211,7 +211,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
211
211
|
if (!equivalentHtmlAttr.isNotStrictEquivalent && (htmlAttrSpec === null || htmlAttrSpec === void 0 ? void 0 : htmlAttrSpec.type) === 'Boolean') {
|
|
212
212
|
report({
|
|
213
213
|
scope: node,
|
|
214
|
-
message: t('{0} contradicts {1}', t('the "{0}" {1}', attrName, 'ARIA state/property'), t('the implicit "{0}" {1}', equivalentHtmlAttr.htmlAttrName, 'attribute')),
|
|
214
|
+
message: t('{0} contradicts {1}', t('the "{0*}" {1}', attrName, 'ARIA state/property'), t('the implicit "{0}" {1}', equivalentHtmlAttr.htmlAttrName, 'attribute')),
|
|
215
215
|
line: attr.startLine,
|
|
216
216
|
col: attr.startCol,
|
|
217
217
|
raw: attr.raw,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/rules",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Rules for markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
"clean": "tsc --build --clean"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@markuplint/html-spec": "2.0.0
|
|
21
|
-
"@markuplint/ml-core": "2.0.0
|
|
22
|
-
"@markuplint/ml-spec": "2.0.0
|
|
23
|
-
"@markuplint/types": "
|
|
24
|
-
"debug": "^4.3.
|
|
20
|
+
"@markuplint/html-spec": "2.0.0",
|
|
21
|
+
"@markuplint/ml-core": "2.0.0",
|
|
22
|
+
"@markuplint/ml-spec": "2.0.0",
|
|
23
|
+
"@markuplint/types": "2.0.0",
|
|
24
|
+
"debug": "^4.3.3",
|
|
25
25
|
"tslib": "^2.3.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/debug": "^4.1.7"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "de81fc514acdf472f87184e3499e9364258f9b66"
|
|
31
31
|
}
|
package/schema.json
CHANGED
|
@@ -48,6 +48,9 @@
|
|
|
48
48
|
"id-duplication": {
|
|
49
49
|
"$ref": "https://raw.githubusercontent.com/markuplint/markuplint/main/packages/%40markuplint/rules/src/id-duplication/schema.json"
|
|
50
50
|
},
|
|
51
|
+
"end-tag": {
|
|
52
|
+
"$ref": "https://raw.githubusercontent.com/markuplint/markuplint/main/packages/%40markuplint/rules/src/end-tag/schema.json"
|
|
53
|
+
},
|
|
51
54
|
"indentation": {
|
|
52
55
|
"$ref": "https://raw.githubusercontent.com/markuplint/markuplint/main/packages/%40markuplint/rules/src/indentation/schema.json"
|
|
53
56
|
},
|