@markuplint/rules 2.4.2 → 3.0.0-alpha.66
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 +1 -5
- package/lib/attr-duplication/index.js +10 -7
- 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.js +21 -25
- package/lib/case-sensitive-attr-name/index.d.ts +1 -5
- package/lib/case-sensitive-attr-name/index.js +51 -81
- package/lib/case-sensitive-tag-name/index.js +38 -30
- package/lib/character-reference/index.d.ts +2 -1
- package/lib/character-reference/index.js +5 -7
- package/lib/class-naming/index.js +11 -11
- package/lib/deprecated-attr/index.js +17 -18
- package/lib/deprecated-element/index.js +5 -7
- package/lib/disallowed-element/index.js +8 -9
- package/lib/doctype/index.js +7 -7
- package/lib/end-tag/index.js +4 -1
- package/lib/helper/aria/get-aria.d.ts +7 -0
- package/lib/helper/aria/get-aria.js +53 -0
- package/lib/helper/aria/get-computed-role.d.ts +10 -0
- package/lib/helper/aria/get-computed-role.js +24 -0
- package/lib/helper/aria/get-implicit-role.d.ts +7 -0
- package/lib/helper/aria/get-implicit-role.js +12 -0
- package/lib/helper/aria/get-permitted-roles.d.ts +14 -0
- package/lib/helper/aria/get-permitted-roles.js +26 -0
- package/lib/helper/aria/resolve-version.d.ts +2 -0
- package/lib/helper/aria/resolve-version.js +21 -0
- package/lib/helper/spec/aria-spec.d.ts +5 -0
- package/lib/helper/spec/aria-spec.js +12 -0
- package/lib/helper/spec/get-role-spec.d.ts +11 -0
- package/lib/helper/spec/get-role-spec.js +39 -0
- package/lib/helper/spec/html-spec.d.ts +2 -0
- package/lib/helper/spec/html-spec.js +14 -0
- package/lib/helpers.d.ts +10 -28
- package/lib/helpers.js +29 -149
- package/lib/id-duplication/index.js +4 -6
- package/lib/indentation/index.d.ts +3 -3
- package/lib/index.d.ts +14 -19
- package/lib/index.js +0 -8
- package/lib/ineffective-attr/index.js +19 -27
- package/lib/invalid-attr/index.js +83 -83
- package/lib/landmark-roles/index.d.ts +2 -2
- package/lib/landmark-roles/index.js +9 -9
- package/lib/no-boolean-attr-value/index.js +33 -34
- package/lib/no-default-value/index.js +20 -24
- package/lib/no-hard-code-id/index.js +9 -13
- package/lib/no-refer-to-non-existent-id/index.d.ts +4 -1
- package/lib/no-refer-to-non-existent-id/index.js +77 -83
- package/lib/no-use-event-handler-attr/index.js +20 -22
- package/lib/permitted-contents/index.d.ts +5 -2
- package/lib/permitted-contents/index.js +67 -68
- package/lib/permitted-contents/permitted-content.spec-to-regexp.d.ts +5 -5
- package/lib/permitted-contents/permitted-content.spec-to-regexp.js +19 -14
- package/lib/permitted-contents/unfold-content-models-to-tags.d.ts +2 -2
- package/lib/require-accessible-name/index.d.ts +5 -1
- package/lib/require-accessible-name/index.js +6 -3
- package/lib/required-attr/index.js +16 -25
- package/lib/required-element/index.d.ts +1 -1
- package/lib/required-element/index.js +6 -6
- package/lib/required-h1/index.d.ts +2 -2
- package/lib/required-h1/index.js +3 -3
- package/lib/wai-aria/checkings/abstract-role.d.ts +3 -0
- package/lib/wai-aria/checkings/abstract-role.js +22 -0
- package/lib/wai-aria/checkings/checking-required-owned-elements.d.ts +11 -0
- package/lib/wai-aria/checkings/checking-required-owned-elements.js +63 -0
- package/lib/wai-aria/checkings/default-value.d.ts +6 -0
- package/lib/wai-aria/checkings/default-value.js +17 -0
- package/lib/wai-aria/checkings/deprecated-props.d.ts +7 -0
- package/lib/wai-aria/checkings/deprecated-props.js +18 -0
- package/lib/wai-aria/checkings/disallowed-prop.d.ts +7 -0
- package/lib/wai-aria/checkings/disallowed-prop.js +22 -0
- package/lib/wai-aria/checkings/implicit-props.d.ts +7 -0
- package/lib/wai-aria/checkings/implicit-props.js +50 -0
- package/lib/wai-aria/checkings/implicit-role.d.ts +3 -0
- package/lib/wai-aria/checkings/implicit-role.js +21 -0
- package/lib/wai-aria/checkings/no-global-prop.d.ts +6 -0
- package/lib/wai-aria/checkings/no-global-prop.js +14 -0
- package/lib/wai-aria/checkings/non-existant-role.d.ts +3 -0
- package/lib/wai-aria/checkings/non-existant-role.js +28 -0
- package/lib/wai-aria/checkings/permitted-roles.d.ts +3 -0
- package/lib/wai-aria/checkings/permitted-roles.js +28 -0
- package/lib/wai-aria/checkings/required-prop.d.ts +9 -0
- package/lib/wai-aria/checkings/required-prop.js +27 -0
- package/lib/wai-aria/checkings/value.d.ts +7 -0
- package/lib/wai-aria/checkings/value.js +21 -0
- package/lib/wai-aria/index.d.ts +1 -8
- package/lib/wai-aria/index.js +56 -207
- package/lib/wai-aria/types.d.ts +11 -0
- package/lib/wai-aria/types.js +2 -0
- package/package.json +5 -5
- package/schema.json +0 -12
- package/tsconfig.tsbuildinfo +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
2
|
'attr-duplication': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
|
|
3
|
-
'attr-equal-space-after': import("packages/@markuplint/ml-core/lib").RuleSeed<"always" | "never" | "always-single-line" | "never-single-line", null>;
|
|
4
|
-
'attr-equal-space-before': import("packages/@markuplint/ml-core/lib").RuleSeed<"always" | "never" | "always-single-line" | "never-single-line", null>;
|
|
5
|
-
'attr-spacing': import("packages/@markuplint/ml-core/lib").RuleSeed<boolean, import("./attr-spacing").AttrSpasingOptions>;
|
|
6
3
|
'attr-value-quotes': import("packages/@markuplint/ml-core/lib").RuleSeed<import("./attr-value-quotes").Type, null>;
|
|
7
|
-
'case-sensitive-attr-name': import("packages/@markuplint/ml-core/lib").RuleSeed<import("./case-sensitive-attr-name").Value
|
|
4
|
+
'case-sensitive-attr-name': import("packages/@markuplint/ml-core/lib").RuleSeed<import("./case-sensitive-attr-name").Value, null>;
|
|
8
5
|
'case-sensitive-tag-name': import("packages/@markuplint/ml-core/lib").RuleSeed<import("./case-sensitive-tag-name").Value, null>;
|
|
9
6
|
'character-reference': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
|
|
10
7
|
'class-naming': import("packages/@markuplint/ml-core/lib").RuleSeed<import("./class-naming").Value, null>;
|
|
@@ -16,7 +13,6 @@ declare const _default: {
|
|
|
16
13
|
}>;
|
|
17
14
|
'end-tag': import("packages/@markuplint/ml-core/lib").RuleSeed<boolean, null>;
|
|
18
15
|
'id-duplication': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
|
|
19
|
-
indentation: import("packages/@markuplint/ml-core/lib").RuleSeed<import("./indentation").Value, import("./indentation").IndentationOptions>;
|
|
20
16
|
'ineffective-attr': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
|
|
21
17
|
'invalid-attr': import("packages/@markuplint/ml-core/lib").RuleSeed<boolean, {
|
|
22
18
|
attrs?: Record<string, {
|
|
@@ -31,38 +27,37 @@ declare const _default: {
|
|
|
31
27
|
ignoreAttrNamePrefix?: string | string[] | undefined;
|
|
32
28
|
}>;
|
|
33
29
|
'landmark-roles': import("packages/@markuplint/ml-core/lib").RuleSeed<boolean, {
|
|
34
|
-
ignoreRoles
|
|
35
|
-
labelEachArea
|
|
30
|
+
ignoreRoles: (("banner" | "main" | "complementary" | "contentinfo") | "form" | "navigation" | "region")[];
|
|
31
|
+
labelEachArea: boolean;
|
|
36
32
|
}>;
|
|
37
33
|
'no-boolean-attr-value': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
|
|
38
34
|
'no-default-value': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
|
|
39
35
|
'no-hard-code-id': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
|
|
40
|
-
'no-refer-to-non-existent-id': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue,
|
|
36
|
+
'no-refer-to-non-existent-id': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, {
|
|
37
|
+
ariaVersion: import("packages/@markuplint/ml-spec/lib").ARIAVersion;
|
|
38
|
+
}>;
|
|
41
39
|
'no-use-event-handler-attr': import("packages/@markuplint/ml-core/lib").RuleSeed<boolean, {
|
|
42
40
|
ignore?: string | string[] | undefined;
|
|
43
41
|
}>;
|
|
44
|
-
'permitted-contents': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-spec/lib").
|
|
42
|
+
'permitted-contents': import("packages/@markuplint/ml-core/lib").RuleSeed<(import("packages/@markuplint/ml-spec/lib").ContentModel & {
|
|
43
|
+
tag: string;
|
|
44
|
+
})[], {
|
|
45
45
|
ignoreHasMutableChildren: boolean;
|
|
46
46
|
}>;
|
|
47
|
-
'require-accessible-name': import("packages/@markuplint/ml-core/lib").RuleSeed<boolean,
|
|
47
|
+
'require-accessible-name': import("packages/@markuplint/ml-core/lib").RuleSeed<boolean, {
|
|
48
|
+
ariaVersion: import("packages/@markuplint/ml-spec/lib").ARIAVersion;
|
|
49
|
+
}>;
|
|
48
50
|
'required-attr': import("packages/@markuplint/ml-core/lib").RuleSeed<string | (string | {
|
|
49
51
|
name: string;
|
|
50
52
|
value: string | string[];
|
|
51
53
|
})[], null>;
|
|
52
54
|
'required-element': import("packages/@markuplint/ml-core/lib").RuleSeed<string[], {
|
|
53
|
-
ignoreHasMutableContents
|
|
55
|
+
ignoreHasMutableContents: boolean;
|
|
54
56
|
}>;
|
|
55
57
|
'required-h1': import("packages/@markuplint/ml-core/lib").RuleSeed<boolean, import("./required-h1").Options>;
|
|
56
58
|
'use-list': import("packages/@markuplint/ml-core/lib").RuleSeed<string[], {
|
|
57
59
|
spaceNeededBullets?: string[] | undefined;
|
|
58
60
|
}>;
|
|
59
|
-
'wai-aria': import("packages/@markuplint/ml-core/lib").RuleSeed<boolean,
|
|
60
|
-
checkingValue?: boolean | undefined;
|
|
61
|
-
checkingDeprecatedProps?: boolean | undefined;
|
|
62
|
-
permittedAriaRoles?: boolean | undefined;
|
|
63
|
-
disallowSetImplicitRole?: boolean | undefined;
|
|
64
|
-
disallowSetImplicitProps?: boolean | undefined;
|
|
65
|
-
disallowDefaultValue?: boolean | undefined;
|
|
66
|
-
}>;
|
|
61
|
+
'wai-aria': import("packages/@markuplint/ml-core/lib").RuleSeed<boolean, import("./wai-aria/types").Options>;
|
|
67
62
|
};
|
|
68
63
|
export default _default;
|
package/lib/index.js
CHANGED
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const attr_duplication_1 = tslib_1.__importDefault(require("./attr-duplication"));
|
|
5
|
-
const attr_equal_space_after_1 = tslib_1.__importDefault(require("./attr-equal-space-after"));
|
|
6
|
-
const attr_equal_space_before_1 = tslib_1.__importDefault(require("./attr-equal-space-before"));
|
|
7
|
-
const attr_spacing_1 = tslib_1.__importDefault(require("./attr-spacing"));
|
|
8
5
|
const attr_value_quotes_1 = tslib_1.__importDefault(require("./attr-value-quotes"));
|
|
9
6
|
const case_sensitive_attr_name_1 = tslib_1.__importDefault(require("./case-sensitive-attr-name"));
|
|
10
7
|
const case_sensitive_tag_name_1 = tslib_1.__importDefault(require("./case-sensitive-tag-name"));
|
|
@@ -16,7 +13,6 @@ const disallowed_element_1 = tslib_1.__importDefault(require("./disallowed-eleme
|
|
|
16
13
|
const doctype_1 = tslib_1.__importDefault(require("./doctype"));
|
|
17
14
|
const end_tag_1 = tslib_1.__importDefault(require("./end-tag"));
|
|
18
15
|
const id_duplication_1 = tslib_1.__importDefault(require("./id-duplication"));
|
|
19
|
-
const indentation_1 = tslib_1.__importDefault(require("./indentation"));
|
|
20
16
|
const ineffective_attr_1 = tslib_1.__importDefault(require("./ineffective-attr"));
|
|
21
17
|
const invalid_attr_1 = tslib_1.__importDefault(require("./invalid-attr"));
|
|
22
18
|
const landmark_roles_1 = tslib_1.__importDefault(require("./landmark-roles"));
|
|
@@ -34,9 +30,6 @@ const use_list_1 = tslib_1.__importDefault(require("./use-list"));
|
|
|
34
30
|
const wai_aria_1 = tslib_1.__importDefault(require("./wai-aria"));
|
|
35
31
|
exports.default = {
|
|
36
32
|
'attr-duplication': attr_duplication_1.default,
|
|
37
|
-
'attr-equal-space-after': attr_equal_space_after_1.default,
|
|
38
|
-
'attr-equal-space-before': attr_equal_space_before_1.default,
|
|
39
|
-
'attr-spacing': attr_spacing_1.default,
|
|
40
33
|
'attr-value-quotes': attr_value_quotes_1.default,
|
|
41
34
|
'case-sensitive-attr-name': case_sensitive_attr_name_1.default,
|
|
42
35
|
'case-sensitive-tag-name': case_sensitive_tag_name_1.default,
|
|
@@ -48,7 +41,6 @@ exports.default = {
|
|
|
48
41
|
doctype: doctype_1.default,
|
|
49
42
|
'end-tag': end_tag_1.default,
|
|
50
43
|
'id-duplication': id_duplication_1.default,
|
|
51
|
-
indentation: indentation_1.default,
|
|
52
44
|
'ineffective-attr': ineffective_attr_1.default,
|
|
53
45
|
'invalid-attr': invalid_attr_1.default,
|
|
54
46
|
'landmark-roles': landmark_roles_1.default,
|
|
@@ -4,36 +4,28 @@ const ml_core_1 = require("@markuplint/ml-core");
|
|
|
4
4
|
exports.default = (0, ml_core_1.createRule)({
|
|
5
5
|
defaultServerity: 'warning',
|
|
6
6
|
async verify({ document, report, t }) {
|
|
7
|
-
await document.walkOn('
|
|
8
|
-
const attrSpec = (0, ml_core_1.getAttrSpecs)(
|
|
7
|
+
await document.walkOn('Attr', attr => {
|
|
8
|
+
const attrSpec = (0, ml_core_1.getAttrSpecs)(attr.ownerElement, document.specs);
|
|
9
9
|
if (!attrSpec) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
raw: attr.raw,
|
|
30
|
-
line: attr.startLine,
|
|
31
|
-
col: attr.startCol,
|
|
32
|
-
message: t('{0} is {1:c}', t('the "{0*}" {1}', name, 'attribute'), 'ineffective') +
|
|
33
|
-
t('. ') +
|
|
34
|
-
t("It doesn't need {0}", t('the {0}', 'attribute')),
|
|
35
|
-
});
|
|
36
|
-
}
|
|
12
|
+
const name = attr.name;
|
|
13
|
+
const spec = attrSpec.find(s => s.name === name);
|
|
14
|
+
if (!spec) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const ineffectiveConditions = spec.ineffective
|
|
18
|
+
? Array.isArray(spec.ineffective)
|
|
19
|
+
? spec.ineffective
|
|
20
|
+
: [spec.ineffective]
|
|
21
|
+
: [];
|
|
22
|
+
if (ineffectiveConditions.some(selector => attr.ownerElement.matches(selector))) {
|
|
23
|
+
report({
|
|
24
|
+
scope: attr,
|
|
25
|
+
message: t('{0} is {1:c}', t('the "{0*}" {1}', name, 'attribute'), 'ineffective') +
|
|
26
|
+
t('. ') +
|
|
27
|
+
t("It doesn't need {0}", t('the {0}', 'attribute')),
|
|
28
|
+
});
|
|
37
29
|
}
|
|
38
30
|
});
|
|
39
31
|
},
|
|
@@ -8,100 +8,100 @@ const log = debug_1.log.extend('invalid-attr');
|
|
|
8
8
|
exports.default = (0, ml_core_1.createRule)({
|
|
9
9
|
defaultOptions: {},
|
|
10
10
|
async verify({ document, report, t }) {
|
|
11
|
-
await document.walkOn('
|
|
12
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
await document.walkOn('Attr', attr => {
|
|
12
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
13
|
+
if (attr.isDirective) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const attrSpecs = (0, ml_core_1.getAttrSpecs)(attr.ownerElement, document.specs);
|
|
17
|
+
const attrName = attr.nameNode;
|
|
18
|
+
const name = attr.name;
|
|
19
|
+
if (!attr.ownerElement.isCustomElement && attr.candidate) {
|
|
20
|
+
const message = t('{0} is {1:c}', t('the "{0*}" {1}', name, 'attribute'), 'disallowed') +
|
|
21
|
+
t('. ') +
|
|
22
|
+
t('Did you mean "{0}"?', attr.candidate);
|
|
23
|
+
report({
|
|
24
|
+
scope: attr,
|
|
25
|
+
line: attrName === null || attrName === void 0 ? void 0 : attrName.startLine,
|
|
26
|
+
col: attrName === null || attrName === void 0 ? void 0 : attrName.startCol,
|
|
27
|
+
raw: attrName === null || attrName === void 0 ? void 0 : attrName.raw,
|
|
28
|
+
message: message,
|
|
29
|
+
});
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const valueNode = attr.valueNode;
|
|
33
|
+
const value = attr.value;
|
|
34
|
+
if (attr.rule.option.ignoreAttrNamePrefix) {
|
|
35
|
+
const ignoreAttrNamePrefixes = Array.isArray(attr.rule.option.ignoreAttrNamePrefix)
|
|
36
|
+
? attr.rule.option.ignoreAttrNamePrefix
|
|
37
|
+
: [attr.rule.option.ignoreAttrNamePrefix];
|
|
38
|
+
if (ignoreAttrNamePrefixes.some(prefix => name.indexOf(prefix) === 0)) {
|
|
39
|
+
return;
|
|
17
40
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
raw: attrName.raw,
|
|
41
|
+
}
|
|
42
|
+
let invalid = false;
|
|
43
|
+
const customRule = attr.rule.option.attrs ? attr.rule.option.attrs[name] : null;
|
|
44
|
+
if (customRule) {
|
|
45
|
+
if ('enum' in customRule) {
|
|
46
|
+
invalid = (0, attr_check_1.attrCheck)(t, name.toLowerCase(), value, true, {
|
|
47
|
+
name,
|
|
48
|
+
type: {
|
|
49
|
+
enum: customRule.enum,
|
|
50
|
+
},
|
|
51
|
+
description: '',
|
|
30
52
|
});
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
const attrValue = attr.getValue();
|
|
34
|
-
const value = attrValue.potential;
|
|
35
|
-
if (node.rule.option.ignoreAttrNamePrefix) {
|
|
36
|
-
const ignoreAttrNamePrefixes = Array.isArray(node.rule.option.ignoreAttrNamePrefix)
|
|
37
|
-
? node.rule.option.ignoreAttrNamePrefix
|
|
38
|
-
: [node.rule.option.ignoreAttrNamePrefix];
|
|
39
|
-
if (ignoreAttrNamePrefixes.some(prefix => name.indexOf(prefix) === 0)) {
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
53
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (customRule) {
|
|
46
|
-
if (attr.attrType === 'html-attr' && attr.isDynamicValue) {
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
if ('enum' in customRule) {
|
|
50
|
-
invalid = (0, attr_check_1.attrCheck)(t, name.toLowerCase(), value, true, {
|
|
51
|
-
name,
|
|
52
|
-
type: {
|
|
53
|
-
enum: customRule.enum,
|
|
54
|
-
},
|
|
55
|
-
description: '',
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
else if ('pattern' in customRule) {
|
|
59
|
-
if (!(0, helpers_1.match)(value, customRule.pattern)) {
|
|
60
|
-
invalid = {
|
|
61
|
-
invalidType: 'invalid-value',
|
|
62
|
-
message: t('{0} is unmatched with the below patterns: {1}', t('the "{0*}" {1}', name, 'attribute'), customRule.pattern),
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
else if ('type' in customRule) {
|
|
67
|
-
invalid = (0, attr_check_1.attrCheck)(t, name, value, true, { name, type: customRule.type, description: '' });
|
|
68
|
-
}
|
|
69
|
-
else if ('disallowed' in customRule && customRule.disallowed) {
|
|
54
|
+
else if ('pattern' in customRule) {
|
|
55
|
+
if (!(0, helpers_1.match)(value, customRule.pattern)) {
|
|
70
56
|
invalid = {
|
|
71
|
-
invalidType: '
|
|
72
|
-
message: t('{0} is
|
|
57
|
+
invalidType: 'invalid-value',
|
|
58
|
+
message: t('{0} is unmatched with the below patterns: {1}', t('the "{0*}" {1}', name, 'attribute'), customRule.pattern),
|
|
73
59
|
};
|
|
74
60
|
}
|
|
75
61
|
}
|
|
76
|
-
else if (
|
|
77
|
-
|
|
78
|
-
invalid = (0, helpers_1.isValidAttr)(t, name, value, (attr.attrType === 'html-attr' && attr.isDynamicValue) || false, node, attrSpecs, log);
|
|
62
|
+
else if ('type' in customRule) {
|
|
63
|
+
invalid = (0, attr_check_1.attrCheck)(t, name, value, true, { name, type: customRule.type, description: '' });
|
|
79
64
|
}
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
65
|
+
else if ('disallowed' in customRule && customRule.disallowed) {
|
|
66
|
+
invalid = {
|
|
67
|
+
invalidType: 'non-existent',
|
|
68
|
+
message: t('{0} is disallowed', t('the "{0*}" {1}', name, 'attribute')),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else if (!attr.ownerElement.isCustomElement && attrSpecs) {
|
|
73
|
+
log('Checking %s[%s="%s"]', attr.nodeName, name, value);
|
|
74
|
+
invalid = (0, helpers_1.isValidAttr)(t, name, value, attr.isDynamicValue || false, attr.ownerElement, attrSpecs, log);
|
|
75
|
+
}
|
|
76
|
+
if (invalid) {
|
|
77
|
+
switch (invalid.invalidType) {
|
|
78
|
+
case 'invalid-value': {
|
|
79
|
+
if (attr.isDynamicValue) {
|
|
90
80
|
break;
|
|
91
81
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
82
|
+
report({
|
|
83
|
+
scope: attr,
|
|
84
|
+
message: invalid.message,
|
|
85
|
+
line: ((_a = valueNode === null || valueNode === void 0 ? void 0 : valueNode.startLine) !== null && _a !== void 0 ? _a : 0) + ((_c = (_b = invalid.loc) === null || _b === void 0 ? void 0 : _b.line) !== null && _c !== void 0 ? _c : 0),
|
|
86
|
+
col: ((_d = invalid.loc) === null || _d === void 0 ? void 0 : _d.line)
|
|
87
|
+
? ((_e = invalid.loc) === null || _e === void 0 ? void 0 : _e.col) + 1
|
|
88
|
+
: ((_f = valueNode === null || valueNode === void 0 ? void 0 : valueNode.startCol) !== null && _f !== void 0 ? _f : 0) + ((_h = (_g = invalid.loc) === null || _g === void 0 ? void 0 : _g.col) !== null && _h !== void 0 ? _h : 0),
|
|
89
|
+
raw: (_k = (_j = invalid.loc) === null || _j === void 0 ? void 0 : _j.raw) !== null && _k !== void 0 ? _k : value,
|
|
90
|
+
});
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
case 'non-existent': {
|
|
94
|
+
const spec = (0, ml_core_1.getSpec)(attr.ownerElement, document.specs);
|
|
95
|
+
if (spec === null || spec === void 0 ? void 0 : spec.possibleToAddProperties) {
|
|
96
|
+
return;
|
|
104
97
|
}
|
|
98
|
+
report({
|
|
99
|
+
scope: attr,
|
|
100
|
+
message: invalid.message,
|
|
101
|
+
line: attrName === null || attrName === void 0 ? void 0 : attrName.startLine,
|
|
102
|
+
col: attrName === null || attrName === void 0 ? void 0 : attrName.startCol,
|
|
103
|
+
raw: attrName === null || attrName === void 0 ? void 0 : attrName.raw,
|
|
104
|
+
});
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare type Options = {
|
|
2
|
-
ignoreRoles
|
|
3
|
-
labelEachArea
|
|
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';
|
|
@@ -23,13 +23,13 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
const roles = {
|
|
26
|
-
complementary: document.
|
|
27
|
-
contentinfo: document.
|
|
28
|
-
form: document.
|
|
29
|
-
banner: document.
|
|
30
|
-
main: document.
|
|
31
|
-
navigation: document.
|
|
32
|
-
region: document.
|
|
26
|
+
complementary: Array.from(document.querySelectorAll(selectors.complementary.join(','))),
|
|
27
|
+
contentinfo: Array.from(document.querySelectorAll(selectors.contentinfo.join(','))),
|
|
28
|
+
form: Array.from(document.querySelectorAll(selectors.form.join(','))),
|
|
29
|
+
banner: Array.from(document.querySelectorAll(selectors.banner.join(','))),
|
|
30
|
+
main: Array.from(document.querySelectorAll(selectors.main.join(','))),
|
|
31
|
+
navigation: Array.from(document.querySelectorAll(selectors.navigation.join(','))),
|
|
32
|
+
region: Array.from(document.querySelectorAll(selectors.region.join(','))),
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
35
35
|
* `<header>`
|
|
@@ -43,7 +43,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
43
43
|
* > - nav
|
|
44
44
|
* > - section
|
|
45
45
|
*/
|
|
46
|
-
const headers = document.
|
|
46
|
+
const headers = Array.from(document.querySelectorAll('header')).filter(header => {
|
|
47
47
|
return !header.closest('article, aside, main, nav, section');
|
|
48
48
|
});
|
|
49
49
|
roles.banner.push(...headers);
|
|
@@ -59,7 +59,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
59
59
|
* > - nav
|
|
60
60
|
* > - section
|
|
61
61
|
*/
|
|
62
|
-
const footers = document.
|
|
62
|
+
const footers = Array.from(document.querySelectorAll('footer')).filter(footer => {
|
|
63
63
|
return !footer.closest('article, aside, main, nav, section');
|
|
64
64
|
});
|
|
65
65
|
roles.contentinfo.push(...footers);
|
|
@@ -4,43 +4,42 @@ const ml_core_1 = require("@markuplint/ml-core");
|
|
|
4
4
|
exports.default = (0, ml_core_1.createRule)({
|
|
5
5
|
defaultServerity: 'warning',
|
|
6
6
|
async verify({ document, report, t }) {
|
|
7
|
-
await document.walkOn('
|
|
8
|
-
|
|
7
|
+
await document.walkOn('Attr', attr => {
|
|
8
|
+
var _a, _b;
|
|
9
|
+
const attrSpec = (0, ml_core_1.getAttrSpecs)(attr.ownerElement, document.specs);
|
|
9
10
|
if (!attrSpec) {
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
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
|
-
}
|
|
13
|
+
if (attr.isDynamicValue) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const name = attr.name;
|
|
17
|
+
const spec = attrSpec.find(s => s.name === name);
|
|
18
|
+
if (!spec) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (spec.type !== 'Boolean') {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const extraTokens = [
|
|
25
|
+
attr.spacesBeforeEqual,
|
|
26
|
+
attr.equal,
|
|
27
|
+
attr.spacesAfterEqual,
|
|
28
|
+
attr.startQuote,
|
|
29
|
+
attr.valueNode,
|
|
30
|
+
attr.endQuote,
|
|
31
|
+
];
|
|
32
|
+
const extraRaw = extraTokens.reduce((raw, t) => { var _a; return raw + ((_a = t === null || t === void 0 ? void 0 : t.raw) !== null && _a !== void 0 ? _a : ''); }, '');
|
|
33
|
+
if (extraRaw) {
|
|
34
|
+
report({
|
|
35
|
+
scope: attr,
|
|
36
|
+
line: (_a = attr.spacesBeforeEqual) === null || _a === void 0 ? void 0 : _a.startLine,
|
|
37
|
+
col: (_b = attr.spacesBeforeEqual) === null || _b === void 0 ? void 0 : _b.startCol,
|
|
38
|
+
raw: extraRaw,
|
|
39
|
+
message: t('{0} is {1}', t('the "{0*}" {1}', name, 'attribute'), t('a {0}', 'boolean attribute')) +
|
|
40
|
+
t('. ') +
|
|
41
|
+
t("It doesn't need {0}", t('the {0}', 'value')),
|
|
42
|
+
});
|
|
44
43
|
}
|
|
45
44
|
});
|
|
46
45
|
},
|
|
@@ -5,33 +5,29 @@ const helpers_1 = require("../helpers");
|
|
|
5
5
|
exports.default = (0, ml_core_1.createRule)({
|
|
6
6
|
defaultServerity: 'warning',
|
|
7
7
|
async verify({ document, report, t }) {
|
|
8
|
-
await document.walkOn('
|
|
9
|
-
|
|
8
|
+
await document.walkOn('Attr', attr => {
|
|
9
|
+
var _a, _b, _c;
|
|
10
|
+
const attrSpec = (0, ml_core_1.getAttrSpecs)(attr.ownerElement, document.specs);
|
|
10
11
|
if (!attrSpec) {
|
|
11
12
|
return;
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
col: attr.valueNode.startCol,
|
|
31
|
-
raw: attr.valueNode.raw,
|
|
32
|
-
message: t('It is {0}', t('the {0}', 'default value')),
|
|
33
|
-
});
|
|
34
|
-
}
|
|
14
|
+
const spec = attrSpec.find(s => s.name === attr.name);
|
|
15
|
+
if (!spec) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (!spec.defaultValue) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const normalizedValue = (0, helpers_1.toNormalizedValue)(attr.value, spec);
|
|
22
|
+
const defaultValue = (0, helpers_1.toNormalizedValue)(spec.defaultValue, spec);
|
|
23
|
+
if (defaultValue === normalizedValue) {
|
|
24
|
+
report({
|
|
25
|
+
scope: attr,
|
|
26
|
+
line: (_a = attr.valueNode) === null || _a === void 0 ? void 0 : _a.startLine,
|
|
27
|
+
col: (_b = attr.valueNode) === null || _b === void 0 ? void 0 : _b.startCol,
|
|
28
|
+
raw: (_c = attr.valueNode) === null || _c === void 0 ? void 0 : _c.raw,
|
|
29
|
+
message: t('It is {0}', t('the {0}', 'default value')),
|
|
30
|
+
});
|
|
35
31
|
}
|
|
36
32
|
});
|
|
37
33
|
},
|
|
@@ -7,19 +7,15 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
7
7
|
if (!document.isFragment) {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
|
-
await document.walkOn('
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
raw: attr.raw,
|
|
20
|
-
message: t('It is {0:c}', 'hard-coded'),
|
|
21
|
-
});
|
|
22
|
-
}
|
|
10
|
+
await document.walkOn('Attr', attr => {
|
|
11
|
+
if (attr.name.toLowerCase() === 'id' && !attr.isDynamicValue && attr.valueType !== 'code') {
|
|
12
|
+
report({
|
|
13
|
+
scope: attr,
|
|
14
|
+
line: attr.startLine,
|
|
15
|
+
col: attr.startCol,
|
|
16
|
+
raw: attr.raw,
|
|
17
|
+
message: t('It is {0:c}', 'hard-coded'),
|
|
18
|
+
});
|
|
23
19
|
}
|
|
24
20
|
});
|
|
25
21
|
},
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ARIAVersion } from '@markuplint/ml-spec';
|
|
2
|
+
declare const _default: import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, {
|
|
3
|
+
ariaVersion: ARIAVersion;
|
|
4
|
+
}>;
|
|
2
5
|
export default _default;
|