@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,6 +1,6 @@
|
|
|
1
|
-
import type { Options } from '../types';
|
|
1
|
+
import type { Options } from '../types.js';
|
|
2
2
|
import type { AttrChecker } from '@markuplint/ml-core';
|
|
3
3
|
import type { ARIAProperty } from '@markuplint/ml-spec';
|
|
4
4
|
export declare const checkingNoGlobalProp: AttrChecker<boolean, Options, {
|
|
5
|
-
propSpecs: ARIAProperty[];
|
|
5
|
+
propSpecs: readonly ARIAProperty[];
|
|
6
6
|
}>;
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkingNoGlobalProp = void 0;
|
|
4
|
-
const checkingNoGlobalProp = ({ attr, propSpecs }) => t => {
|
|
5
|
-
var _a, _b;
|
|
1
|
+
export const checkingNoGlobalProp = ({ attr, propSpecs }) => t => {
|
|
6
2
|
const propSpec = propSpecs.find(prop => prop.name === attr.name);
|
|
7
3
|
if (propSpec && !propSpec.isGlobal) {
|
|
8
4
|
return {
|
|
9
5
|
scope: attr,
|
|
10
|
-
message: t('{0} is not {1}', t('the "{0*}" {1}', attr.name, `ARIA ${
|
|
6
|
+
message: t('{0} is not {1}', t('the "{0*}" {1}', attr.name, `ARIA ${propSpec.type ?? 'property'}`), `global ${propSpec.type ?? 'property'}`),
|
|
11
7
|
};
|
|
12
8
|
}
|
|
13
9
|
};
|
|
14
|
-
exports.checkingNoGlobalProp = checkingNoGlobalProp;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const checkingNonExistentRole = ({ attr }) => t => {
|
|
6
|
-
var _a;
|
|
7
|
-
const { roles, graphicsRoles } = (0, ml_spec_1.ariaSpecs)(attr.ownerMLDocument.specs, attr.rule.options.version);
|
|
8
|
-
const tokens = (_a = attr.tokenList) === null || _a === void 0 ? void 0 : _a.allTokens();
|
|
1
|
+
import { ariaSpecs } from '@markuplint/ml-spec';
|
|
2
|
+
export const checkingNonExistentRole = ({ attr }) => t => {
|
|
3
|
+
const { roles, graphicsRoles } = ariaSpecs(attr.ownerMLDocument.specs, attr.rule.options.version);
|
|
4
|
+
const tokens = attr.tokenList?.allTokens();
|
|
9
5
|
if (!tokens) {
|
|
10
6
|
return;
|
|
11
7
|
}
|
|
@@ -25,4 +21,3 @@ const checkingNonExistentRole = ({ attr }) => t => {
|
|
|
25
21
|
}
|
|
26
22
|
}
|
|
27
23
|
};
|
|
28
|
-
exports.checkingNonExistentRole = checkingNonExistentRole;
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.checkingPermittedRoles = void 0;
|
|
4
|
-
const ml_spec_1 = require("@markuplint/ml-spec");
|
|
5
|
-
const checkingPermittedRoles = ({ attr }) => t => {
|
|
6
|
-
var _a;
|
|
1
|
+
import { getPermittedRoles } from '@markuplint/ml-spec';
|
|
2
|
+
export const checkingPermittedRoles = ({ attr }) => t => {
|
|
7
3
|
const el = attr.ownerElement;
|
|
8
|
-
const permittedRoles =
|
|
4
|
+
const permittedRoles = getPermittedRoles(el, el.rule.options.version, attr.ownerMLDocument.specs);
|
|
9
5
|
if (permittedRoles.length === 0) {
|
|
10
6
|
return {
|
|
11
7
|
scope: attr,
|
|
12
8
|
message: t('{0} according to {1}', t('Cannot overwrite {0}', t('{0} of {1}', t('the {0}', 'role'), t('the "{0*}" {1}', el.localName, 'element'))), 'ARIA in HTML specification'),
|
|
13
9
|
};
|
|
14
10
|
}
|
|
15
|
-
const tokens =
|
|
11
|
+
const tokens = attr.tokenList?.allTokens();
|
|
16
12
|
if (!tokens) {
|
|
17
13
|
return;
|
|
18
14
|
}
|
|
@@ -25,4 +21,3 @@ const checkingPermittedRoles = ({ attr }) => t => {
|
|
|
25
21
|
}
|
|
26
22
|
}
|
|
27
23
|
};
|
|
28
|
-
exports.checkingPermittedRoles = checkingPermittedRoles;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkingPresentationalChildren = void 0;
|
|
4
|
-
const ml_spec_1 = require("@markuplint/ml-spec");
|
|
1
|
+
import { getComputedRole } from '@markuplint/ml-spec';
|
|
5
2
|
/**
|
|
6
3
|
* Presentational Children
|
|
7
4
|
*
|
|
@@ -28,7 +25,7 @@ const ml_spec_1 = require("@markuplint/ml-spec");
|
|
|
28
25
|
* > may still be used in the name and description computation
|
|
29
26
|
* > even when not included in the accessibility tree.
|
|
30
27
|
*/
|
|
31
|
-
const checkingPresentationalChildren = ({ el }) => t => {
|
|
28
|
+
export const checkingPresentationalChildren = ({ el }) => t => {
|
|
32
29
|
const ancestor = getAncestorHasPresentationalChildren(el);
|
|
33
30
|
if (!ancestor) {
|
|
34
31
|
return;
|
|
@@ -45,13 +42,13 @@ const checkingPresentationalChildren = ({ el }) => t => {
|
|
|
45
42
|
message: t('it may be ineffective because {0}', t("it has {0} as an ancestor that doesn't expose its descendants to the accessibility tree", t('the "{0*}" {1}', ancestor.role.name, 'role'))),
|
|
46
43
|
};
|
|
47
44
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
function getAncestorHasPresentationalChildren(
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
47
|
+
el) {
|
|
51
48
|
let current = el.parentElement;
|
|
52
49
|
while (current) {
|
|
53
|
-
const computed =
|
|
54
|
-
if (
|
|
50
|
+
const computed = getComputedRole(el.ownerMLDocument.specs, current, el.rule.options.version);
|
|
51
|
+
if (computed.role?.childrenPresentational) {
|
|
55
52
|
return computed;
|
|
56
53
|
}
|
|
57
54
|
current = current.parentElement;
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkingRequiredOwnedElements = void 0;
|
|
4
|
-
const ml_spec_1 = require("@markuplint/ml-spec");
|
|
1
|
+
import { getComputedRole, isRequiredOwnedElement } from '@markuplint/ml-spec';
|
|
5
2
|
/**
|
|
6
3
|
* Required Owned Elements
|
|
7
4
|
*
|
|
8
5
|
* @see https://w3c.github.io/aria/#mustContain
|
|
9
6
|
*/
|
|
10
|
-
const checkingRequiredOwnedElements = ({ el, role }) => t => {
|
|
7
|
+
export const checkingRequiredOwnedElements = ({ el, role }) => t => {
|
|
11
8
|
if (!role) {
|
|
12
9
|
return;
|
|
13
10
|
}
|
|
14
|
-
if (
|
|
11
|
+
if (role.requiredOwnedElements.length === 0) {
|
|
15
12
|
return;
|
|
16
13
|
}
|
|
17
14
|
/**
|
|
@@ -33,8 +30,8 @@ const checkingRequiredOwnedElements = ({ el, role }) => t => {
|
|
|
33
30
|
if (child.matches('[aria-busy="true" i]')) {
|
|
34
31
|
return [child, 'BUSY'];
|
|
35
32
|
}
|
|
36
|
-
const computedChild =
|
|
37
|
-
if (role.requiredOwnedElements.some(ownedRole => (
|
|
33
|
+
const computedChild = getComputedRole(child.ownerMLDocument.specs, child, child.rule.options.version);
|
|
34
|
+
if (role.requiredOwnedElements.some(ownedRole => isRequiredOwnedElement(computedChild.el, computedChild.role, ownedRole, child.ownerMLDocument.specs, child.rule.options.version))) {
|
|
38
35
|
return [child, 'REQUIRED'];
|
|
39
36
|
}
|
|
40
37
|
return [child, 'OTHER'];
|
|
@@ -78,20 +75,21 @@ const checkingRequiredOwnedElements = ({ el, role }) => t => {
|
|
|
78
75
|
if (mayBeBeforeCreated(el)) {
|
|
79
76
|
return {
|
|
80
77
|
scope: el,
|
|
81
|
-
message: t('{0}. Or, {1}', t('require {0}', role.requiredOwnedElements.length === 1
|
|
78
|
+
message: t('{0}. Or, {1}', t('require {0}', role.requiredOwnedElements.length === 1 && role.requiredOwnedElements[0]
|
|
82
79
|
? t('the "{0*}" {1}', role.requiredOwnedElements[0], 'role')
|
|
83
80
|
: t('the {0}', 'roles') + `: ${t(role.requiredOwnedElements)}`), t('require {0}', 'aria-busy="true"')),
|
|
84
81
|
};
|
|
85
82
|
}
|
|
86
83
|
return {
|
|
87
84
|
scope: el,
|
|
88
|
-
message: t('{0} expects {1}', t('the "{0*}" {1}', role.name, 'role'), role.requiredOwnedElements.length === 1
|
|
85
|
+
message: t('{0} expects {1}', t('the "{0*}" {1}', role.name, 'role'), role.requiredOwnedElements.length === 1 && role.requiredOwnedElements[0]
|
|
89
86
|
? t('the "{0*}" {1}', role.requiredOwnedElements[0], 'role')
|
|
90
87
|
: t('the {0}', 'roles') + `: ${t(role.requiredOwnedElements)}`),
|
|
91
88
|
};
|
|
92
89
|
};
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
function mayBeBeforeCreated(
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
92
|
+
el) {
|
|
95
93
|
if (el.isEmpty()) {
|
|
96
94
|
return true;
|
|
97
95
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Options } from '../types';
|
|
1
|
+
import type { Options } from '../types.js';
|
|
2
2
|
import type { ElementChecker } from '@markuplint/ml-core';
|
|
3
3
|
import type { ARIAProperty, ARIARole } from '@markuplint/ml-spec';
|
|
4
4
|
export declare const checkingRequiredProp: ElementChecker<boolean, Options, {
|
|
5
5
|
role?: (ARIARole & {
|
|
6
6
|
isImplicit?: boolean;
|
|
7
7
|
}) | null;
|
|
8
|
-
propSpecs: ARIAProperty[];
|
|
8
|
+
propSpecs: readonly ARIAProperty[];
|
|
9
9
|
}>;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkingRequiredProp = void 0;
|
|
4
|
-
const checkingRequiredProp = ({ el, role, propSpecs }) => t => {
|
|
5
|
-
var _a;
|
|
1
|
+
export const checkingRequiredProp = ({ el, role, propSpecs }) => t => {
|
|
6
2
|
if (!role) {
|
|
7
3
|
return;
|
|
8
4
|
}
|
|
@@ -19,9 +15,8 @@ const checkingRequiredProp = ({ el, role, propSpecs }) => t => {
|
|
|
19
15
|
const propSpec = propSpecs.find(p => p.name === requiredProp);
|
|
20
16
|
return {
|
|
21
17
|
scope: el,
|
|
22
|
-
message: t('{0:c} on {1}', t('Require {0}', t('the "{0*}" {1}', requiredProp, `ARIA ${
|
|
18
|
+
message: t('{0:c} on {1}', t('Require {0}', t('the "{0*}" {1}', requiredProp, `ARIA ${propSpec?.type ?? 'property'}`)), t('the "{0*}" {1}', role.name, 'role')),
|
|
23
19
|
};
|
|
24
20
|
}
|
|
25
21
|
}
|
|
26
22
|
};
|
|
27
|
-
exports.checkingRequiredProp = checkingRequiredProp;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { Options } from '../types';
|
|
1
|
+
import type { Options } from '../types.js';
|
|
2
2
|
import type { AttrChecker } from '@markuplint/ml-core';
|
|
3
3
|
import type { ARIAProperty, ARIARole } from '@markuplint/ml-spec';
|
|
4
4
|
export declare const checkingValue: AttrChecker<boolean, Options, {
|
|
5
5
|
role?: ARIARole | null;
|
|
6
|
-
propSpecs: ARIAProperty[];
|
|
6
|
+
propSpecs: readonly ARIAProperty[];
|
|
7
7
|
booleanish?: boolean;
|
|
8
8
|
}>;
|
|
9
9
|
/**
|
|
10
10
|
*
|
|
11
11
|
* @see https://www.w3.org/TR/wai-aria-1.2/#propcharacteristic_value
|
|
12
12
|
*/
|
|
13
|
-
export declare function checkAriaValue(type: string, value: string, tokenEnum: string[], booleanish?: boolean): boolean;
|
|
13
|
+
export declare function checkAriaValue(type: string, value: string, tokenEnum: readonly string[], booleanish?: boolean): boolean;
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkAriaValue = exports.checkingValue = void 0;
|
|
4
|
-
const checkingValue = ({ attr, role, propSpecs, booleanish }) => t => {
|
|
5
|
-
var _a;
|
|
1
|
+
export const checkingValue = ({ attr, role, propSpecs, booleanish }) => t => {
|
|
6
2
|
if (attr.isDynamicValue) {
|
|
7
3
|
return;
|
|
8
4
|
}
|
|
9
5
|
const propSpec = propSpecs.find(p => p.name === attr.name);
|
|
10
|
-
const result = checkAria(propSpec, attr.value, role
|
|
6
|
+
const result = checkAria(propSpec, attr.value, role?.name, booleanish);
|
|
11
7
|
if (result.isValid) {
|
|
12
8
|
return;
|
|
13
9
|
}
|
|
14
10
|
return {
|
|
15
11
|
scope: attr,
|
|
16
|
-
message: t('{0:c} on {1}', t('{0} is {1:c}', t('the "{0}"', attr.value), 'disallowed'), t('the "{0*}" {1}', attr.name, `ARIA ${
|
|
17
|
-
('enum' in result && result.enum.length
|
|
12
|
+
message: t('{0:c} on {1}', t('{0} is {1:c}', t('the "{0}"', attr.value), 'disallowed'), t('the "{0*}" {1}', attr.name, `ARIA ${propSpec?.type ?? 'property'}`)) +
|
|
13
|
+
('enum' in result && result.enum.length > 0
|
|
14
|
+
? t('. ') + t('Allowed values are: {0}', t(result.enum))
|
|
15
|
+
: ''),
|
|
18
16
|
};
|
|
19
17
|
};
|
|
20
|
-
exports.checkingValue = checkingValue;
|
|
21
18
|
function checkAria(propSpec, currentValue, role, booleanish) {
|
|
22
19
|
if (!propSpec) {
|
|
23
20
|
return {
|
|
@@ -46,7 +43,7 @@ function checkAria(propSpec, currentValue, role, booleanish) {
|
|
|
46
43
|
*
|
|
47
44
|
* @see https://www.w3.org/TR/wai-aria-1.2/#propcharacteristic_value
|
|
48
45
|
*/
|
|
49
|
-
function checkAriaValue(type, value, tokenEnum, booleanish) {
|
|
46
|
+
export function checkAriaValue(type, value, tokenEnum, booleanish) {
|
|
50
47
|
switch (type) {
|
|
51
48
|
case 'token': {
|
|
52
49
|
return tokenEnum.includes(value);
|
|
@@ -88,4 +85,3 @@ function checkAriaValue(type, value, tokenEnum, booleanish) {
|
|
|
88
85
|
// For skipping checking
|
|
89
86
|
return true;
|
|
90
87
|
}
|
|
91
|
-
exports.checkAriaValue = checkAriaValue;
|
package/lib/wai-aria/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Options } from './types';
|
|
2
|
-
declare const _default: import("@markuplint/ml-core").RuleSeed<boolean, Options
|
|
1
|
+
import type { Options } from './types.js';
|
|
2
|
+
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<boolean, Options>>;
|
|
3
3
|
export default _default;
|
package/lib/wai-aria/index.js
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
exports.default = (0, ml_core_1.createRule)({
|
|
1
|
+
import { createRule, getAttrSpecs, getComputedRole, ariaSpecs, getSpec } from '@markuplint/ml-core';
|
|
2
|
+
import { ARIA_RECOMMENDED_VERSION } from '@markuplint/ml-spec';
|
|
3
|
+
import { Collection } from '../helpers.js';
|
|
4
|
+
import { checkingAbstractRole } from './checkings/abstract-role.js';
|
|
5
|
+
import { checkingDefaultValue } from './checkings/default-value.js';
|
|
6
|
+
import { checkingDeprecatedProps } from './checkings/deprecated-props.js';
|
|
7
|
+
import { checkingDisallowedProp } from './checkings/disallowed-prop.js';
|
|
8
|
+
import { checkingImplicitProps } from './checkings/implicit-props.js';
|
|
9
|
+
import { checkingImplicitRole } from './checkings/implicit-role.js';
|
|
10
|
+
import { checkingInteractionInHidden } from './checkings/interaction-in-hidden.js';
|
|
11
|
+
import { checkingNoGlobalProp } from './checkings/no-global-prop.js';
|
|
12
|
+
import { checkingNonExistentRole } from './checkings/non-existent-role.js';
|
|
13
|
+
import { checkingPermittedRoles } from './checkings/permitted-roles.js';
|
|
14
|
+
import { checkingPresentationalChildren } from './checkings/presentational-children.js';
|
|
15
|
+
import { checkingRequiredOwnedElements } from './checkings/required-owned-elements.js';
|
|
16
|
+
import { checkingRequiredProp } from './checkings/required-prop.js';
|
|
17
|
+
import { checkingValue } from './checkings/value.js';
|
|
18
|
+
export default createRule({
|
|
20
19
|
defaultOptions: {
|
|
21
20
|
checkingValue: true,
|
|
22
21
|
checkingDeprecatedProps: true,
|
|
@@ -27,14 +26,14 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
27
26
|
disallowSetImplicitRole: true,
|
|
28
27
|
disallowSetImplicitProps: true,
|
|
29
28
|
disallowDefaultValue: false,
|
|
30
|
-
version:
|
|
29
|
+
version: ARIA_RECOMMENDED_VERSION,
|
|
31
30
|
},
|
|
32
31
|
async verify({ document, report, t }) {
|
|
33
32
|
await document.walkOn('Element', el => {
|
|
34
33
|
const roleAttr = el.getAttributeNode('role');
|
|
35
34
|
const propAttrs = el.attributes.filter(attr => /^aria-/i.test(attr.name));
|
|
36
|
-
const ariaAttrs = new
|
|
37
|
-
const elSpec =
|
|
35
|
+
const ariaAttrs = new Collection(roleAttr, ...propAttrs);
|
|
36
|
+
const elSpec = getSpec(el, document.specs.specs);
|
|
38
37
|
if (!elSpec) {
|
|
39
38
|
return;
|
|
40
39
|
}
|
|
@@ -47,50 +46,50 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
47
46
|
}
|
|
48
47
|
return;
|
|
49
48
|
}
|
|
50
|
-
const computed =
|
|
51
|
-
const { props: propSpecs } =
|
|
49
|
+
const computed = getComputedRole(document.specs, el, el.rule.options.version);
|
|
50
|
+
const { props: propSpecs } = ariaSpecs(document.specs, el.rule.options.version);
|
|
52
51
|
if (roleAttr) {
|
|
53
|
-
if (report(
|
|
52
|
+
if (report(checkingNonExistentRole({ attr: roleAttr }))) {
|
|
54
53
|
return;
|
|
55
54
|
}
|
|
56
|
-
if (report(
|
|
55
|
+
if (report(checkingAbstractRole({ attr: roleAttr }))) {
|
|
57
56
|
return;
|
|
58
57
|
}
|
|
59
|
-
report(
|
|
58
|
+
report(checkingRequiredProp({ el, role: computed.role, propSpecs }));
|
|
60
59
|
if (el.rule.options.disallowSetImplicitRole) {
|
|
61
|
-
report(
|
|
60
|
+
report(checkingImplicitRole({ attr: roleAttr }));
|
|
62
61
|
}
|
|
63
62
|
if (el.rule.options.permittedAriaRoles) {
|
|
64
|
-
report(
|
|
63
|
+
report(checkingPermittedRoles({ attr: roleAttr }));
|
|
65
64
|
}
|
|
66
65
|
}
|
|
67
66
|
for (const attr of propAttrs) {
|
|
68
|
-
report(
|
|
67
|
+
report(checkingDisallowedProp({ attr, role: computed.role, propSpecs }));
|
|
69
68
|
if (el.rule.options.checkingDeprecatedProps) {
|
|
70
|
-
report(
|
|
69
|
+
report(checkingDeprecatedProps({ attr, role: computed.role, propSpecs }));
|
|
71
70
|
}
|
|
72
71
|
if (el.rule.options.disallowSetImplicitProps) {
|
|
73
|
-
const attrSpecs =
|
|
74
|
-
report(
|
|
72
|
+
const attrSpecs = getAttrSpecs(el, document.specs);
|
|
73
|
+
report(checkingImplicitProps({ attr, propSpecs, attrSpecs }));
|
|
75
74
|
}
|
|
76
75
|
if (el.rule.options.checkingValue) {
|
|
77
|
-
report(
|
|
76
|
+
report(checkingValue({ attr, role: computed.role, propSpecs, booleanish: document.booleanish }));
|
|
78
77
|
}
|
|
79
78
|
if (el.rule.options.disallowDefaultValue) {
|
|
80
|
-
report(
|
|
79
|
+
report(checkingDefaultValue({ attr, propSpecs }));
|
|
81
80
|
}
|
|
82
81
|
if (!computed.role) {
|
|
83
|
-
report(
|
|
82
|
+
report(checkingNoGlobalProp({ attr, propSpecs }));
|
|
84
83
|
}
|
|
85
84
|
}
|
|
86
85
|
if (el.rule.options.checkingRequiredOwnedElements) {
|
|
87
|
-
report(
|
|
86
|
+
report(checkingRequiredOwnedElements({ el, role: computed.role }));
|
|
88
87
|
}
|
|
89
88
|
if (el.rule.options.checkingPresentationalChildren) {
|
|
90
|
-
report(
|
|
89
|
+
report(checkingPresentationalChildren({ el }));
|
|
91
90
|
}
|
|
92
91
|
if (el.rule.options.checkingInteractionInHidden) {
|
|
93
|
-
report(
|
|
92
|
+
report(checkingInteractionInHidden({ el }));
|
|
94
93
|
}
|
|
95
94
|
});
|
|
96
95
|
},
|
package/lib/wai-aria/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/rules",
|
|
3
|
-
"version": "3.0.0-dev.
|
|
3
|
+
"version": "3.0.0-dev.290+af676442",
|
|
4
4
|
"description": "Built-in rules of markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"private": false,
|
|
9
|
-
"
|
|
10
|
-
"
|
|
9
|
+
"type": "module",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./lib/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"types": "./lib/index.d.ts",
|
|
11
16
|
"publishConfig": {
|
|
12
17
|
"access": "public"
|
|
13
18
|
},
|
|
@@ -20,17 +25,19 @@
|
|
|
20
25
|
"./lib/permitted-contents/debug.js": "./lib/permitted-contents/debug.browser.js"
|
|
21
26
|
},
|
|
22
27
|
"dependencies": {
|
|
23
|
-
"@markuplint/html-spec": "3.0.0-dev.
|
|
24
|
-
"@markuplint/ml-core": "3.0.0-dev.
|
|
25
|
-
"@markuplint/ml-spec": "3.0.0-dev.
|
|
26
|
-
"@markuplint/
|
|
27
|
-
"@
|
|
28
|
+
"@markuplint/html-spec": "3.0.0-dev.290+af676442",
|
|
29
|
+
"@markuplint/ml-core": "3.0.0-dev.290+af676442",
|
|
30
|
+
"@markuplint/ml-spec": "3.0.0-dev.290+af676442",
|
|
31
|
+
"@markuplint/selector": "3.0.0-dev.290+af676442",
|
|
32
|
+
"@markuplint/shared": "4.0.0-dev.3580+af676442",
|
|
33
|
+
"@markuplint/types": "3.0.0-dev.290+af676442",
|
|
34
|
+
"@types/debug": "^4.1.9",
|
|
35
|
+
"@ungap/structured-clone": "^1.2.0",
|
|
36
|
+
"ansi-colors": "^4.1.3",
|
|
37
|
+
"chrono-node": "^2.7.0",
|
|
28
38
|
"debug": "^4.3.4",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
},
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"@types/debug": "^4.1.7"
|
|
39
|
+
"tslib": "^2.6.2",
|
|
40
|
+
"type-fest": "^4.3.1"
|
|
34
41
|
},
|
|
35
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "af6764422feecb56d1d84659028f53daf685bb78"
|
|
36
43
|
}
|
package/schema.json
CHANGED
|
@@ -75,9 +75,15 @@
|
|
|
75
75
|
"permitted-contents": {
|
|
76
76
|
"$ref": "https://raw.githubusercontent.com/markuplint/markuplint/main/packages/%40markuplint/rules/src/permitted-contents/schema.json"
|
|
77
77
|
},
|
|
78
|
+
"placeholder-label-option": {
|
|
79
|
+
"$ref": "https://raw.githubusercontent.com/markuplint/markuplint/main/packages/%40markuplint/rules/src/placeholder-label-option/schema.json"
|
|
80
|
+
},
|
|
78
81
|
"require-accessible-name": {
|
|
79
82
|
"$ref": "https://raw.githubusercontent.com/markuplint/markuplint/main/packages/%40markuplint/rules/src/require-accessible-name/schema.json"
|
|
80
83
|
},
|
|
84
|
+
"require-datetime": {
|
|
85
|
+
"$ref": "https://raw.githubusercontent.com/markuplint/markuplint/main/packages/%40markuplint/rules/src/require-datetime/schema.json"
|
|
86
|
+
},
|
|
81
87
|
"required-attr": {
|
|
82
88
|
"$ref": "https://raw.githubusercontent.com/markuplint/markuplint/main/packages/%40markuplint/rules/src/required-attr/schema.json"
|
|
83
89
|
},
|
package/tsconfig.test.json
DELETED