@markuplint/rules 4.11.2 → 4.12.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/CHANGELOG.md +6 -3
- package/SKILL.md +76 -0
- package/lib/attr-check.d.ts +41 -5
- package/lib/attr-check.js +29 -5
- package/lib/attr-duplication/index.d.ts +7 -0
- package/lib/attr-duplication/index.js +7 -0
- package/lib/attr-duplication/meta.d.ts +1 -0
- package/lib/attr-duplication/meta.js +1 -0
- package/lib/attr-value-quotes/index.d.ts +10 -0
- package/lib/attr-value-quotes/index.js +10 -0
- package/lib/attr-value-quotes/meta.d.ts +1 -0
- package/lib/attr-value-quotes/meta.js +1 -0
- package/lib/case-sensitive-attr-name/index.d.ts +9 -0
- package/lib/case-sensitive-attr-name/index.js +8 -0
- package/lib/case-sensitive-attr-name/meta.d.ts +1 -0
- package/lib/case-sensitive-attr-name/meta.js +1 -0
- package/lib/case-sensitive-tag-name/index.d.ts +9 -0
- package/lib/case-sensitive-tag-name/index.js +8 -0
- package/lib/case-sensitive-tag-name/meta.d.ts +1 -0
- package/lib/case-sensitive-tag-name/meta.js +1 -0
- package/lib/character-reference/index.d.ts +8 -0
- package/lib/character-reference/index.js +16 -0
- package/lib/character-reference/meta.d.ts +1 -0
- package/lib/character-reference/meta.js +1 -0
- package/lib/class-naming/index.d.ts +9 -0
- package/lib/class-naming/index.js +8 -0
- package/lib/class-naming/meta.d.ts +1 -0
- package/lib/class-naming/meta.js +1 -0
- package/lib/create-message.d.ts +27 -0
- package/lib/create-message.js +56 -1
- package/lib/debug.d.ts +9 -0
- package/lib/debug.js +5 -0
- package/lib/deprecated-attr/index.d.ts +6 -0
- package/lib/deprecated-attr/index.js +6 -0
- package/lib/deprecated-attr/meta.d.ts +1 -0
- package/lib/deprecated-attr/meta.js +1 -0
- package/lib/deprecated-element/index.d.ts +8 -0
- package/lib/deprecated-element/index.js +8 -0
- package/lib/deprecated-element/meta.d.ts +1 -0
- package/lib/deprecated-element/meta.js +1 -0
- package/lib/disallowed-element/index.d.ts +7 -0
- package/lib/disallowed-element/index.js +7 -0
- package/lib/disallowed-element/meta.d.ts +1 -0
- package/lib/disallowed-element/meta.js +1 -0
- package/lib/doctype/index.d.ts +10 -0
- package/lib/doctype/index.js +8 -0
- package/lib/doctype/meta.d.ts +1 -0
- package/lib/doctype/meta.js +1 -0
- package/lib/end-tag/index.d.ts +7 -0
- package/lib/end-tag/index.js +7 -0
- package/lib/end-tag/meta.d.ts +1 -0
- package/lib/end-tag/meta.js +1 -0
- package/lib/heading-levels/index.d.ts +6 -0
- package/lib/heading-levels/index.js +6 -0
- package/lib/heading-levels/meta.d.ts +1 -0
- package/lib/heading-levels/meta.js +1 -0
- package/lib/helpers.d.ts +104 -0
- package/lib/helpers.js +105 -2
- package/lib/id-duplication/index.d.ts +7 -0
- package/lib/id-duplication/index.js +7 -0
- package/lib/id-duplication/meta.d.ts +1 -0
- package/lib/id-duplication/meta.js +1 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.js +12 -0
- package/lib/ineffective-attr/index.d.ts +7 -0
- package/lib/ineffective-attr/index.js +7 -0
- package/lib/ineffective-attr/meta.d.ts +1 -0
- package/lib/ineffective-attr/meta.js +1 -0
- package/lib/invalid-attr/index.d.ts +24 -0
- package/lib/invalid-attr/index.js +17 -0
- package/lib/invalid-attr/meta.d.ts +1 -0
- package/lib/invalid-attr/meta.js +1 -0
- package/lib/label-has-control/index.d.ts +7 -0
- package/lib/label-has-control/index.js +11 -0
- package/lib/label-has-control/meta.d.ts +1 -0
- package/lib/label-has-control/meta.js +1 -0
- package/lib/landmark-roles/index.d.ts +14 -0
- package/lib/landmark-roles/index.js +21 -0
- package/lib/landmark-roles/meta.d.ts +1 -0
- package/lib/landmark-roles/meta.js +1 -0
- package/lib/neighbor-popovers/index.d.ts +8 -0
- package/lib/neighbor-popovers/index.js +26 -2
- package/lib/neighbor-popovers/meta.d.ts +1 -0
- package/lib/neighbor-popovers/meta.js +1 -0
- package/lib/no-ambiguous-navigable-target-names/index.d.ts +8 -0
- package/lib/no-ambiguous-navigable-target-names/index.js +8 -0
- package/lib/no-ambiguous-navigable-target-names/meta.d.ts +1 -0
- package/lib/no-ambiguous-navigable-target-names/meta.js +1 -0
- package/lib/no-boolean-attr-value/index.d.ts +7 -0
- package/lib/no-boolean-attr-value/index.js +7 -0
- package/lib/no-boolean-attr-value/meta.d.ts +1 -0
- package/lib/no-boolean-attr-value/meta.js +1 -0
- package/lib/no-consecutive-br/index.d.ts +8 -0
- package/lib/no-consecutive-br/index.js +8 -0
- package/lib/no-consecutive-br/meta.d.ts +1 -0
- package/lib/no-consecutive-br/meta.js +1 -0
- package/lib/no-default-value/index.d.ts +7 -0
- package/lib/no-default-value/index.js +7 -0
- package/lib/no-default-value/meta.d.ts +1 -0
- package/lib/no-default-value/meta.js +1 -0
- package/lib/no-duplicate-dt/index.d.ts +6 -0
- package/lib/no-duplicate-dt/index.js +6 -0
- package/lib/no-duplicate-dt/meta.d.ts +1 -0
- package/lib/no-duplicate-dt/meta.js +1 -0
- package/lib/no-empty-palpable-content/index.d.ts +13 -0
- package/lib/no-empty-palpable-content/index.js +12 -0
- package/lib/no-empty-palpable-content/meta.d.ts +1 -0
- package/lib/no-empty-palpable-content/meta.js +1 -0
- package/lib/no-hard-code-id/index.d.ts +8 -0
- package/lib/no-hard-code-id/index.js +8 -0
- package/lib/no-hard-code-id/meta.d.ts +1 -0
- package/lib/no-hard-code-id/meta.js +1 -0
- package/lib/no-orphaned-end-tag/index.d.ts +7 -0
- package/lib/no-orphaned-end-tag/index.js +7 -0
- package/lib/no-orphaned-end-tag/meta.d.ts +1 -0
- package/lib/no-orphaned-end-tag/meta.js +1 -0
- package/lib/no-refer-to-non-existent-id/index.d.ts +8 -0
- package/lib/no-refer-to-non-existent-id/index.js +9 -0
- package/lib/no-refer-to-non-existent-id/meta.d.ts +1 -0
- package/lib/no-refer-to-non-existent-id/meta.js +1 -0
- package/lib/no-use-event-handler-attr/index.d.ts +10 -0
- package/lib/no-use-event-handler-attr/index.js +8 -0
- package/lib/no-use-event-handler-attr/meta.d.ts +1 -0
- package/lib/no-use-event-handler-attr/meta.js +1 -0
- package/lib/permitted-contents/choice.d.ts +17 -0
- package/lib/permitted-contents/choice.js +30 -0
- package/lib/permitted-contents/complex-branch.d.ts +11 -7
- package/lib/permitted-contents/complex-branch.js +11 -7
- package/lib/permitted-contents/content-model.d.ts +11 -0
- package/lib/permitted-contents/content-model.js +32 -0
- package/lib/permitted-contents/count-pattern.d.ts +13 -7
- package/lib/permitted-contents/count-pattern.js +23 -7
- package/lib/permitted-contents/debug.browser.d.ts +12 -0
- package/lib/permitted-contents/debug.browser.js +12 -0
- package/lib/permitted-contents/debug.d.ts +12 -0
- package/lib/permitted-contents/debug.js +12 -0
- package/lib/permitted-contents/index.d.ts +12 -0
- package/lib/permitted-contents/index.js +21 -0
- package/lib/permitted-contents/matches-selector.d.ts +19 -0
- package/lib/permitted-contents/matches-selector.js +33 -0
- package/lib/permitted-contents/meta.d.ts +1 -0
- package/lib/permitted-contents/meta.js +1 -0
- package/lib/permitted-contents/order.d.ts +14 -7
- package/lib/permitted-contents/order.js +14 -7
- package/lib/permitted-contents/recursive-branch.d.ts +17 -0
- package/lib/permitted-contents/recursive-branch.js +17 -0
- package/lib/permitted-contents/represent-transparent-nodes.d.ts +29 -0
- package/lib/permitted-contents/represent-transparent-nodes.js +24 -0
- package/lib/permitted-contents/start.d.ts +12 -6
- package/lib/permitted-contents/start.js +12 -6
- package/lib/permitted-contents/transparent.d.ts +12 -0
- package/lib/permitted-contents/transparent.js +12 -0
- package/lib/permitted-contents/types.d.ts +67 -0
- package/lib/permitted-contents/utils.d.ts +161 -1
- package/lib/permitted-contents/utils.js +194 -0
- package/lib/placeholder-label-option/index.d.ts +7 -0
- package/lib/placeholder-label-option/index.js +19 -15
- package/lib/placeholder-label-option/meta.d.ts +1 -0
- package/lib/placeholder-label-option/meta.js +1 -0
- package/lib/require-accessible-name/index.d.ts +11 -0
- package/lib/require-accessible-name/index.js +7 -0
- package/lib/require-accessible-name/meta.d.ts +1 -0
- package/lib/require-accessible-name/meta.js +1 -0
- package/lib/require-datetime/index.d.ts +12 -0
- package/lib/require-datetime/index.js +8 -0
- package/lib/require-datetime/meta.d.ts +1 -0
- package/lib/require-datetime/meta.js +1 -0
- package/lib/require-datetime/types.d.ts +7 -0
- package/lib/require-datetime/utils.d.ts +18 -5
- package/lib/require-datetime/utils.js +53 -9
- package/lib/required-attr/index.d.ts +13 -0
- package/lib/required-attr/index.js +7 -0
- package/lib/required-attr/meta.d.ts +1 -0
- package/lib/required-attr/meta.js +1 -0
- package/lib/required-element/index.d.ts +14 -0
- package/lib/required-element/index.js +14 -2
- package/lib/required-element/meta.d.ts +1 -0
- package/lib/required-element/meta.js +1 -0
- package/lib/required-h1/index.d.ts +12 -0
- package/lib/required-h1/index.js +7 -0
- package/lib/required-h1/meta.d.ts +1 -0
- package/lib/required-h1/meta.js +1 -0
- package/lib/table-row-column-alignment/find-children.d.ts +10 -0
- package/lib/table-row-column-alignment/find-children.js +11 -0
- package/lib/table-row-column-alignment/grid.d.ts +60 -0
- package/lib/table-row-column-alignment/grid.js +85 -0
- package/lib/table-row-column-alignment/index.d.ts +8 -0
- package/lib/table-row-column-alignment/index.js +8 -0
- package/lib/table-row-column-alignment/meta.d.ts +1 -0
- package/lib/table-row-column-alignment/meta.js +1 -0
- package/lib/table-row-column-alignment/types.d.ts +10 -0
- package/lib/use-list/index.d.ts +16 -0
- package/lib/use-list/index.js +20 -0
- package/lib/use-list/meta.d.ts +1 -0
- package/lib/use-list/meta.js +1 -0
- package/lib/wai-aria/checkings/abstract-role.d.ts +9 -0
- package/lib/wai-aria/checkings/abstract-role.js +9 -0
- package/lib/wai-aria/checkings/default-value.d.ts +11 -0
- package/lib/wai-aria/checkings/default-value.js +11 -0
- package/lib/wai-aria/checkings/deprecated-props.d.ts +11 -0
- package/lib/wai-aria/checkings/deprecated-props.js +11 -0
- package/lib/wai-aria/checkings/deprecated-role.d.ts +10 -0
- package/lib/wai-aria/checkings/deprecated-role.js +10 -0
- package/lib/wai-aria/checkings/disallowed-prop.d.ts +14 -0
- package/lib/wai-aria/checkings/disallowed-prop.js +14 -0
- package/lib/wai-aria/checkings/implicit-props.d.ts +13 -0
- package/lib/wai-aria/checkings/implicit-props.js +13 -0
- package/lib/wai-aria/checkings/implicit-role.d.ts +9 -0
- package/lib/wai-aria/checkings/implicit-role.js +9 -0
- package/lib/wai-aria/checkings/interaction-in-hidden.d.ts +9 -0
- package/lib/wai-aria/checkings/interaction-in-hidden.js +15 -4
- package/lib/wai-aria/checkings/no-global-prop.d.ts +10 -0
- package/lib/wai-aria/checkings/no-global-prop.js +10 -0
- package/lib/wai-aria/checkings/non-existent-role.d.ts +10 -0
- package/lib/wai-aria/checkings/non-existent-role.js +10 -0
- package/lib/wai-aria/checkings/permitted-roles.d.ts +10 -0
- package/lib/wai-aria/checkings/permitted-roles.js +10 -0
- package/lib/wai-aria/checkings/presentational-children.d.ts +7 -1
- package/lib/wai-aria/checkings/presentational-children.js +14 -1
- package/lib/wai-aria/checkings/required-owned-elements.d.ts +9 -1
- package/lib/wai-aria/checkings/required-owned-elements.js +16 -1
- package/lib/wai-aria/checkings/required-prop.d.ts +13 -0
- package/lib/wai-aria/checkings/required-prop.js +13 -0
- package/lib/wai-aria/checkings/value.d.ts +23 -0
- package/lib/wai-aria/checkings/value.js +32 -0
- package/lib/wai-aria/index.d.ts +10 -0
- package/lib/wai-aria/index.js +10 -0
- package/lib/wai-aria/meta.d.ts +1 -0
- package/lib/wai-aria/meta.js +1 -0
- package/lib/wai-aria/types.d.ts +17 -0
- package/package.json +9 -9
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether an ARIA property or state is deprecated for the element's computed role.
|
|
3
|
+
*
|
|
4
|
+
* Some ARIA properties become deprecated on specific roles across ARIA versions.
|
|
5
|
+
* This checker reports usage of such deprecated properties.
|
|
6
|
+
*
|
|
7
|
+
* @param attr - The ARIA attribute node to inspect.
|
|
8
|
+
* @param role - The computed ARIA role of the element.
|
|
9
|
+
* @param propSpecs - The list of ARIA property specifications for type lookup.
|
|
10
|
+
* @returns A violation if the property is deprecated on the given role.
|
|
11
|
+
*/
|
|
1
12
|
export const checkingDeprecatedProps = ({ attr, role, propSpecs }) => t => {
|
|
2
13
|
if (!role) {
|
|
3
14
|
return;
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import type { Options } from '../types.js';
|
|
2
2
|
import type { AttrChecker } from '@markuplint/ml-core';
|
|
3
3
|
import type { ARIARole } from '@markuplint/ml-spec';
|
|
4
|
+
/**
|
|
5
|
+
* Checks whether the element's computed ARIA role is deprecated in the specified ARIA version.
|
|
6
|
+
*
|
|
7
|
+
* Deprecated roles should be avoided as they may be removed in future ARIA versions
|
|
8
|
+
* and assistive technologies may not support them reliably.
|
|
9
|
+
*
|
|
10
|
+
* @param attr - The `role` attribute node to inspect.
|
|
11
|
+
* @param role - The computed ARIA role of the element.
|
|
12
|
+
* @returns A violation if the role is marked as deprecated.
|
|
13
|
+
*/
|
|
4
14
|
export declare const checkingDeprecatedRole: AttrChecker<boolean, Options, {
|
|
5
15
|
role: ARIARole | null;
|
|
6
16
|
}>;
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether the element's computed ARIA role is deprecated in the specified ARIA version.
|
|
3
|
+
*
|
|
4
|
+
* Deprecated roles should be avoided as they may be removed in future ARIA versions
|
|
5
|
+
* and assistive technologies may not support them reliably.
|
|
6
|
+
*
|
|
7
|
+
* @param attr - The `role` attribute node to inspect.
|
|
8
|
+
* @param role - The computed ARIA role of the element.
|
|
9
|
+
* @returns A violation if the role is marked as deprecated.
|
|
10
|
+
*/
|
|
1
11
|
export const checkingDeprecatedRole = ({ attr, role }) => t => {
|
|
2
12
|
if (!role) {
|
|
3
13
|
return;
|
|
@@ -1,6 +1,20 @@
|
|
|
1
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
|
+
/**
|
|
5
|
+
* Checks whether an ARIA property or state is disallowed on the element's computed role.
|
|
6
|
+
*
|
|
7
|
+
* Each ARIA role defines a set of supported states and properties. This checker reports
|
|
8
|
+
* usage of ARIA attributes that are not in that set. It also considers element-specific
|
|
9
|
+
* restrictions from the ARIA in HTML specification (e.g., properties that should not
|
|
10
|
+
* be used on certain native HTML elements).
|
|
11
|
+
*
|
|
12
|
+
* @param attr - The ARIA attribute node to inspect.
|
|
13
|
+
* @param role - The computed ARIA role of the element.
|
|
14
|
+
* @param propSpecs - The list of ARIA property specifications for type lookup.
|
|
15
|
+
* @param disallowSetImplicitProps - Whether to also enforce element-specific restrictions.
|
|
16
|
+
* @returns A violation if the property is not allowed on the given role or element.
|
|
17
|
+
*/
|
|
4
18
|
export declare const checkingDisallowedProp: AttrChecker<boolean, Options, {
|
|
5
19
|
role: ARIARole | null;
|
|
6
20
|
propSpecs: readonly ARIAProperty[];
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import { getARIA } from '@markuplint/ml-spec';
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether an ARIA property or state is disallowed on the element's computed role.
|
|
4
|
+
*
|
|
5
|
+
* Each ARIA role defines a set of supported states and properties. This checker reports
|
|
6
|
+
* usage of ARIA attributes that are not in that set. It also considers element-specific
|
|
7
|
+
* restrictions from the ARIA in HTML specification (e.g., properties that should not
|
|
8
|
+
* be used on certain native HTML elements).
|
|
9
|
+
*
|
|
10
|
+
* @param attr - The ARIA attribute node to inspect.
|
|
11
|
+
* @param role - The computed ARIA role of the element.
|
|
12
|
+
* @param propSpecs - The list of ARIA property specifications for type lookup.
|
|
13
|
+
* @param disallowSetImplicitProps - Whether to also enforce element-specific restrictions.
|
|
14
|
+
* @returns A violation if the property is not allowed on the given role or element.
|
|
15
|
+
*/
|
|
2
16
|
export const checkingDisallowedProp = ({ attr, role, propSpecs, disallowSetImplicitProps }) => t => {
|
|
3
17
|
if (!role) {
|
|
4
18
|
return;
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import type { Options } from '../types.js';
|
|
2
2
|
import type { AttrChecker } from '@markuplint/ml-core';
|
|
3
3
|
import type { ARIAProperty, Attribute } from '@markuplint/ml-spec';
|
|
4
|
+
/**
|
|
5
|
+
* Checks whether an ARIA property duplicates or contradicts semantics already
|
|
6
|
+
* provided by an equivalent native HTML attribute.
|
|
7
|
+
*
|
|
8
|
+
* Many ARIA properties have equivalent HTML attributes (e.g., `aria-required` and `required`).
|
|
9
|
+
* This checker reports when an ARIA property is redundant because the native attribute
|
|
10
|
+
* already conveys the same semantics, or when the ARIA value contradicts the native attribute.
|
|
11
|
+
*
|
|
12
|
+
* @param attr - The ARIA attribute node to inspect.
|
|
13
|
+
* @param propSpecs - The list of ARIA property specifications for equivalence lookup.
|
|
14
|
+
* @param attrSpecs - The HTML attribute specifications for the element.
|
|
15
|
+
* @returns A violation if the ARIA property duplicates or contradicts an equivalent HTML attribute.
|
|
16
|
+
*/
|
|
4
17
|
export declare const checkingImplicitProps: AttrChecker<boolean, Options, {
|
|
5
18
|
propSpecs: readonly ARIAProperty[];
|
|
6
19
|
attrSpecs: readonly Attribute[] | null;
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import { isValidAttr } from '../../helpers.js';
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether an ARIA property duplicates or contradicts semantics already
|
|
4
|
+
* provided by an equivalent native HTML attribute.
|
|
5
|
+
*
|
|
6
|
+
* Many ARIA properties have equivalent HTML attributes (e.g., `aria-required` and `required`).
|
|
7
|
+
* This checker reports when an ARIA property is redundant because the native attribute
|
|
8
|
+
* already conveys the same semantics, or when the ARIA value contradicts the native attribute.
|
|
9
|
+
*
|
|
10
|
+
* @param attr - The ARIA attribute node to inspect.
|
|
11
|
+
* @param propSpecs - The list of ARIA property specifications for equivalence lookup.
|
|
12
|
+
* @param attrSpecs - The HTML attribute specifications for the element.
|
|
13
|
+
* @returns A violation if the ARIA property duplicates or contradicts an equivalent HTML attribute.
|
|
14
|
+
*/
|
|
2
15
|
export const checkingImplicitProps = ({ attr, propSpecs, attrSpecs }) => t => {
|
|
3
16
|
if (!attrSpecs) {
|
|
4
17
|
return;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import type { Options } from '../types.js';
|
|
2
2
|
import type { AttrChecker } from '@markuplint/ml-core';
|
|
3
|
+
/**
|
|
4
|
+
* Checks whether the explicit `role` attribute duplicates the element's implicit (native) role.
|
|
5
|
+
*
|
|
6
|
+
* HTML elements have implicit ARIA roles (e.g., `<nav>` has an implicit role of `navigation`).
|
|
7
|
+
* Explicitly setting the same role is redundant and should be avoided.
|
|
8
|
+
*
|
|
9
|
+
* @param attr - The `role` attribute node to inspect.
|
|
10
|
+
* @returns A violation if any token in the role attribute matches the element's implicit role.
|
|
11
|
+
*/
|
|
3
12
|
export declare const checkingImplicitRole: AttrChecker<boolean, Options>;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { getImplicitRoleName } from '@markuplint/ml-spec';
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether the explicit `role` attribute duplicates the element's implicit (native) role.
|
|
4
|
+
*
|
|
5
|
+
* HTML elements have implicit ARIA roles (e.g., `<nav>` has an implicit role of `navigation`).
|
|
6
|
+
* Explicitly setting the same role is redundant and should be avoided.
|
|
7
|
+
*
|
|
8
|
+
* @param attr - The `role` attribute node to inspect.
|
|
9
|
+
* @returns A violation if any token in the role attribute matches the element's implicit role.
|
|
10
|
+
*/
|
|
2
11
|
export const checkingImplicitRole = ({ attr }) => t => {
|
|
3
12
|
const tokens = attr.tokenList?.allTokens();
|
|
4
13
|
if (!tokens) {
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import type { Options } from '../types.js';
|
|
2
2
|
import type { ElementChecker } from '@markuplint/ml-core';
|
|
3
3
|
/**
|
|
4
|
+
* Checks whether a focusable interactive element is inside an `aria-hidden=true` subtree.
|
|
5
|
+
*
|
|
4
6
|
* Including Elements in the Accessibility Tree
|
|
5
7
|
*
|
|
6
8
|
* @see https://w3c.github.io/aria/#tree_inclusion
|
|
7
9
|
* > Elements that are not hidden and may fire an accessibility API event, including:
|
|
8
10
|
* > - Elements that are currently focused, even if the element or one of its ancestor elements has its aria-hidden attribute set to true.
|
|
9
11
|
* > - Elements that are a valid target of an aria-activedescendant attribute.
|
|
12
|
+
*
|
|
13
|
+
* When a focused element exists within an `aria-hidden=true` ancestor, it is still
|
|
14
|
+
* exposed to the accessibility tree. This situation is almost always unintentional --
|
|
15
|
+
* while not strictly invalid per spec, it requires careful attention from the developer.
|
|
16
|
+
*
|
|
17
|
+
* @param el - The element node to inspect for focusability within a hidden context.
|
|
18
|
+
* @returns A violation if the element is focusable and has `aria-hidden=true` on itself or an ancestor.
|
|
10
19
|
*/
|
|
11
20
|
export declare const checkingInteractionInHidden: ElementChecker<boolean, Options>;
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { mayBeFocusable } from '@markuplint/ml-spec';
|
|
2
2
|
/**
|
|
3
|
+
* Checks whether a focusable interactive element is inside an `aria-hidden=true` subtree.
|
|
4
|
+
*
|
|
3
5
|
* Including Elements in the Accessibility Tree
|
|
4
6
|
*
|
|
5
7
|
* @see https://w3c.github.io/aria/#tree_inclusion
|
|
6
8
|
* > Elements that are not hidden and may fire an accessibility API event, including:
|
|
7
9
|
* > - Elements that are currently focused, even if the element or one of its ancestor elements has its aria-hidden attribute set to true.
|
|
8
10
|
* > - Elements that are a valid target of an aria-activedescendant attribute.
|
|
11
|
+
*
|
|
12
|
+
* When a focused element exists within an `aria-hidden=true` ancestor, it is still
|
|
13
|
+
* exposed to the accessibility tree. This situation is almost always unintentional --
|
|
14
|
+
* while not strictly invalid per spec, it requires careful attention from the developer.
|
|
15
|
+
*
|
|
16
|
+
* @param el - The element node to inspect for focusability within a hidden context.
|
|
17
|
+
* @returns A violation if the element is focusable and has `aria-hidden=true` on itself or an ancestor.
|
|
9
18
|
*/
|
|
10
|
-
// フォーカスがあたっている場合に限り、先祖がaria-hidden=trueでもアクセシビリティツリーに提示される
|
|
11
|
-
// なので、aria-hidden=trueの子孫要素で且つインタラクティブ要素である場合、
|
|
12
|
-
// それは開発者にとってはほとんどの場合、意図しないことが多いはずなので、
|
|
13
|
-
// 仕様上不正にはならないが、十分に注意しなければならない状態である。
|
|
14
19
|
export const checkingInteractionInHidden = ({ el }) => t => {
|
|
15
20
|
if (!mayBeFocusable(el, el.ownerMLDocument.specs)) {
|
|
16
21
|
return;
|
|
@@ -30,6 +35,12 @@ export const checkingInteractionInHidden = ({ el }) => t => {
|
|
|
30
35
|
message: t('It may be focusable in spite of it has the ancestor that has aria-hidden=true'),
|
|
31
36
|
};
|
|
32
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* Traverses the element's ancestor chain to find the closest element with `aria-hidden="true"`.
|
|
40
|
+
*
|
|
41
|
+
* @param el - The element to start searching from (inclusive).
|
|
42
|
+
* @returns The `aria-hidden` attribute node if found, or `null` if no ancestor is hidden.
|
|
43
|
+
*/
|
|
33
44
|
function getClosestAriaHidden(
|
|
34
45
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
35
46
|
el) {
|
|
@@ -1,6 +1,16 @@
|
|
|
1
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
|
+
/**
|
|
5
|
+
* Checks whether a non-global ARIA property is used on an element without an explicit role.
|
|
6
|
+
*
|
|
7
|
+
* When no role is computed for an element, only global ARIA properties (e.g., `aria-label`,
|
|
8
|
+
* `aria-hidden`) are allowed. This checker reports non-global properties used in that context.
|
|
9
|
+
*
|
|
10
|
+
* @param attr - The ARIA attribute node to inspect.
|
|
11
|
+
* @param propSpecs - The list of ARIA property specifications for global status lookup.
|
|
12
|
+
* @returns A violation if the property is not a global ARIA property.
|
|
13
|
+
*/
|
|
4
14
|
export declare const checkingNoGlobalProp: AttrChecker<boolean, Options, {
|
|
5
15
|
propSpecs: readonly ARIAProperty[];
|
|
6
16
|
}>;
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether a non-global ARIA property is used on an element without an explicit role.
|
|
3
|
+
*
|
|
4
|
+
* When no role is computed for an element, only global ARIA properties (e.g., `aria-label`,
|
|
5
|
+
* `aria-hidden`) are allowed. This checker reports non-global properties used in that context.
|
|
6
|
+
*
|
|
7
|
+
* @param attr - The ARIA attribute node to inspect.
|
|
8
|
+
* @param propSpecs - The list of ARIA property specifications for global status lookup.
|
|
9
|
+
* @returns A violation if the property is not a global ARIA property.
|
|
10
|
+
*/
|
|
1
11
|
export const checkingNoGlobalProp = ({ attr, propSpecs }) => t => {
|
|
2
12
|
const propSpec = propSpecs.find(prop => prop.name === attr.name);
|
|
3
13
|
if (propSpec && !propSpec.isGlobal) {
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
import type { Options } from '../types.js';
|
|
2
2
|
import type { AttrChecker } from '@markuplint/ml-core';
|
|
3
|
+
/**
|
|
4
|
+
* Checks whether the `role` attribute value refers to a role that does not exist
|
|
5
|
+
* in the WAI-ARIA specification.
|
|
6
|
+
*
|
|
7
|
+
* Validates each token in the role attribute against the known ARIA roles list.
|
|
8
|
+
* For SVG elements, the WAI-ARIA Graphics Module roles are also accepted.
|
|
9
|
+
*
|
|
10
|
+
* @param attr - The `role` attribute node to inspect.
|
|
11
|
+
* @returns A violation if any token does not correspond to a defined ARIA role.
|
|
12
|
+
*/
|
|
3
13
|
export declare const checkingNonExistentRole: AttrChecker<boolean, Options>;
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import { ariaSpecs } from '@markuplint/ml-spec';
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether the `role` attribute value refers to a role that does not exist
|
|
4
|
+
* in the WAI-ARIA specification.
|
|
5
|
+
*
|
|
6
|
+
* Validates each token in the role attribute against the known ARIA roles list.
|
|
7
|
+
* For SVG elements, the WAI-ARIA Graphics Module roles are also accepted.
|
|
8
|
+
*
|
|
9
|
+
* @param attr - The `role` attribute node to inspect.
|
|
10
|
+
* @returns A violation if any token does not correspond to a defined ARIA role.
|
|
11
|
+
*/
|
|
2
12
|
export const checkingNonExistentRole = ({ attr }) => t => {
|
|
3
13
|
const { roles, graphicsRoles } = ariaSpecs(attr.ownerMLDocument.specs, attr.rule.options.version);
|
|
4
14
|
const tokens = attr.tokenList?.allTokens();
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
import type { Options } from '../types.js';
|
|
2
2
|
import type { AttrChecker } from '@markuplint/ml-core';
|
|
3
|
+
/**
|
|
4
|
+
* Checks whether the explicit `role` attribute value is permitted on the element
|
|
5
|
+
* according to the ARIA in HTML specification.
|
|
6
|
+
*
|
|
7
|
+
* Each HTML element defines a set of roles that may be assigned to it. Some elements
|
|
8
|
+
* (e.g., `<meta>`) do not allow any role overrides. This checker enforces those constraints.
|
|
9
|
+
*
|
|
10
|
+
* @param attr - The `role` attribute node to inspect.
|
|
11
|
+
* @returns A violation if the role is not in the element's list of permitted roles.
|
|
12
|
+
*/
|
|
3
13
|
export declare const checkingPermittedRoles: AttrChecker<boolean, Options>;
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import { getPermittedRoles } from '@markuplint/ml-spec';
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether the explicit `role` attribute value is permitted on the element
|
|
4
|
+
* according to the ARIA in HTML specification.
|
|
5
|
+
*
|
|
6
|
+
* Each HTML element defines a set of roles that may be assigned to it. Some elements
|
|
7
|
+
* (e.g., `<meta>`) do not allow any role overrides. This checker enforces those constraints.
|
|
8
|
+
*
|
|
9
|
+
* @param attr - The `role` attribute node to inspect.
|
|
10
|
+
* @returns A violation if the role is not in the element's list of permitted roles.
|
|
11
|
+
*/
|
|
2
12
|
export const checkingPermittedRoles = ({ attr }) => t => {
|
|
3
13
|
const el = attr.ownerElement;
|
|
4
14
|
const permittedRoles = getPermittedRoles(el, el.rule.options.version, attr.ownerMLDocument.specs);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { Options } from '../types.js';
|
|
2
2
|
import type { ElementChecker } from '@markuplint/ml-core';
|
|
3
3
|
/**
|
|
4
|
+
* Checks whether ARIA attributes are applied to descendants of an element whose
|
|
5
|
+
* role has the `childrenArePresentational` characteristic.
|
|
6
|
+
*
|
|
4
7
|
* Presentational Children
|
|
5
8
|
*
|
|
6
9
|
* @see https://www.w3.org/TR/wai-aria/#childrenArePresentational
|
|
@@ -22,8 +25,11 @@ import type { ElementChecker } from '@markuplint/ml-core';
|
|
|
22
25
|
*
|
|
23
26
|
* @see https://w3c.github.io/aria/#tree_inclusion
|
|
24
27
|
*
|
|
25
|
-
*
|
|
28
|
+
* > Text equivalents for hidden referenced objects
|
|
26
29
|
* > may still be used in the name and description computation
|
|
27
30
|
* > even when not included in the accessibility tree.
|
|
31
|
+
*
|
|
32
|
+
* @param el - The element node to inspect for presentational ancestor context.
|
|
33
|
+
* @returns A violation if the element has ARIA attributes and an ancestor with presentational children.
|
|
28
34
|
*/
|
|
29
35
|
export declare const checkingPresentationalChildren: ElementChecker<boolean, Options>;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { getComputedRole } from '@markuplint/ml-spec';
|
|
2
2
|
/**
|
|
3
|
+
* Checks whether ARIA attributes are applied to descendants of an element whose
|
|
4
|
+
* role has the `childrenArePresentational` characteristic.
|
|
5
|
+
*
|
|
3
6
|
* Presentational Children
|
|
4
7
|
*
|
|
5
8
|
* @see https://www.w3.org/TR/wai-aria/#childrenArePresentational
|
|
@@ -21,9 +24,12 @@ import { getComputedRole } from '@markuplint/ml-spec';
|
|
|
21
24
|
*
|
|
22
25
|
* @see https://w3c.github.io/aria/#tree_inclusion
|
|
23
26
|
*
|
|
24
|
-
*
|
|
27
|
+
* > Text equivalents for hidden referenced objects
|
|
25
28
|
* > may still be used in the name and description computation
|
|
26
29
|
* > even when not included in the accessibility tree.
|
|
30
|
+
*
|
|
31
|
+
* @param el - The element node to inspect for presentational ancestor context.
|
|
32
|
+
* @returns A violation if the element has ARIA attributes and an ancestor with presentational children.
|
|
27
33
|
*/
|
|
28
34
|
export const checkingPresentationalChildren = ({ el }) => t => {
|
|
29
35
|
const ancestor = getAncestorHasPresentationalChildren(el);
|
|
@@ -42,6 +48,13 @@ export const checkingPresentationalChildren = ({ el }) => t => {
|
|
|
42
48
|
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'))),
|
|
43
49
|
};
|
|
44
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* Traverses the element's ancestor chain to find one whose computed role
|
|
53
|
+
* has the `childrenArePresentational` characteristic.
|
|
54
|
+
*
|
|
55
|
+
* @param el - The element to start searching from (exclusive, starts from parent).
|
|
56
|
+
* @returns The computed role of the ancestor with presentational children, or `null` if none found.
|
|
57
|
+
*/
|
|
45
58
|
function getAncestorHasPresentationalChildren(
|
|
46
59
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
47
60
|
el) {
|
|
@@ -2,9 +2,17 @@ import type { Options } from '../types.js';
|
|
|
2
2
|
import type { ElementChecker } from '@markuplint/ml-core';
|
|
3
3
|
import type { ARIARole } from '@markuplint/ml-spec';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Checks whether an element with a role that requires specific owned elements
|
|
6
|
+
* actually contains children with the expected roles.
|
|
7
|
+
*
|
|
8
|
+
* For example, a `list` role must own at least one element with the `listitem` role.
|
|
9
|
+
* This checker respects `aria-busy="true"` (which signals that content is still loading),
|
|
10
|
+
* preprocessor blocks, and mutable children from template engines.
|
|
6
11
|
*
|
|
7
12
|
* @see https://w3c.github.io/aria/#mustContain
|
|
13
|
+
* @param el - The element node to inspect for required owned elements.
|
|
14
|
+
* @param role - The computed ARIA role of the element, which defines required owned elements.
|
|
15
|
+
* @returns A violation if the role requires owned elements and none are found.
|
|
8
16
|
*/
|
|
9
17
|
export declare const checkingRequiredOwnedElements: ElementChecker<boolean, Options, {
|
|
10
18
|
role?: ARIARole | null;
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { getComputedRole, isRequiredOwnedElement } from '@markuplint/ml-spec';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Checks whether an element with a role that requires specific owned elements
|
|
4
|
+
* actually contains children with the expected roles.
|
|
5
|
+
*
|
|
6
|
+
* For example, a `list` role must own at least one element with the `listitem` role.
|
|
7
|
+
* This checker respects `aria-busy="true"` (which signals that content is still loading),
|
|
8
|
+
* preprocessor blocks, and mutable children from template engines.
|
|
4
9
|
*
|
|
5
10
|
* @see https://w3c.github.io/aria/#mustContain
|
|
11
|
+
* @param el - The element node to inspect for required owned elements.
|
|
12
|
+
* @param role - The computed ARIA role of the element, which defines required owned elements.
|
|
13
|
+
* @returns A violation if the role requires owned elements and none are found.
|
|
6
14
|
*/
|
|
7
15
|
export const checkingRequiredOwnedElements = ({ el, role }) => t => {
|
|
8
16
|
if (!role) {
|
|
@@ -87,6 +95,13 @@ export const checkingRequiredOwnedElements = ({ el, role }) => t => {
|
|
|
87
95
|
: t('the {0}', 'roles') + `: ${t(role.requiredOwnedElements)}`),
|
|
88
96
|
};
|
|
89
97
|
};
|
|
98
|
+
/**
|
|
99
|
+
* Determines whether the element's children may not yet exist (e.g., empty or
|
|
100
|
+
* containing only `<script>` / `<template>` elements that could dynamically create content).
|
|
101
|
+
*
|
|
102
|
+
* @param el - The element to inspect.
|
|
103
|
+
* @returns `true` if the element is empty or only contains script/template children.
|
|
104
|
+
*/
|
|
90
105
|
function mayBeBeforeCreated(
|
|
91
106
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
92
107
|
el) {
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import type { Options } from '../types.js';
|
|
2
2
|
import type { ElementChecker } from '@markuplint/ml-core';
|
|
3
3
|
import { type ARIAProperty, type ARIARole } from '@markuplint/ml-spec';
|
|
4
|
+
/**
|
|
5
|
+
* Checks whether all required ARIA properties for the element's computed role are present.
|
|
6
|
+
*
|
|
7
|
+
* Each ARIA role may define required states and properties (e.g., `slider` requires
|
|
8
|
+
* `aria-valuenow`). This checker verifies that explicitly-set roles have their required
|
|
9
|
+
* properties. Implicit roles are skipped since the browser provides default semantics.
|
|
10
|
+
* Alternative native HTML attributes that satisfy the requirement are also considered.
|
|
11
|
+
*
|
|
12
|
+
* @param el - The element node to inspect for required properties.
|
|
13
|
+
* @param role - The computed ARIA role (with an optional `isImplicit` flag).
|
|
14
|
+
* @param propSpecs - The list of ARIA property specifications for type lookup.
|
|
15
|
+
* @returns A violation if a required property is missing and no native alternative is present.
|
|
16
|
+
*/
|
|
4
17
|
export declare const checkingRequiredProp: ElementChecker<boolean, Options, {
|
|
5
18
|
role?: (ARIARole & {
|
|
6
19
|
isImplicit?: boolean;
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import { getARIA } from '@markuplint/ml-spec';
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether all required ARIA properties for the element's computed role are present.
|
|
4
|
+
*
|
|
5
|
+
* Each ARIA role may define required states and properties (e.g., `slider` requires
|
|
6
|
+
* `aria-valuenow`). This checker verifies that explicitly-set roles have their required
|
|
7
|
+
* properties. Implicit roles are skipped since the browser provides default semantics.
|
|
8
|
+
* Alternative native HTML attributes that satisfy the requirement are also considered.
|
|
9
|
+
*
|
|
10
|
+
* @param el - The element node to inspect for required properties.
|
|
11
|
+
* @param role - The computed ARIA role (with an optional `isImplicit` flag).
|
|
12
|
+
* @param propSpecs - The list of ARIA property specifications for type lookup.
|
|
13
|
+
* @returns A violation if a required property is missing and no native alternative is present.
|
|
14
|
+
*/
|
|
2
15
|
export const checkingRequiredProp = ({ el, role, propSpecs }) => t => {
|
|
3
16
|
if (!role) {
|
|
4
17
|
return;
|
|
@@ -1,13 +1,36 @@
|
|
|
1
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
|
+
/**
|
|
5
|
+
* Checks whether the value of an ARIA property or state conforms to its expected type.
|
|
6
|
+
*
|
|
7
|
+
* ARIA properties have specific value types (token, token list, true/false, tristate,
|
|
8
|
+
* integer, number, string, ID reference, etc.). This checker validates the attribute
|
|
9
|
+
* value against the property's expected type and allowed enum values.
|
|
10
|
+
* Role-specific conditional value types are also considered.
|
|
11
|
+
*
|
|
12
|
+
* @param attr - The ARIA attribute node to inspect.
|
|
13
|
+
* @param role - The computed ARIA role, used to resolve conditional value types.
|
|
14
|
+
* @param propSpecs - The list of ARIA property specifications for value type lookup.
|
|
15
|
+
* @param booleanish - Whether the document supports booleanish attribute values (e.g., JSX).
|
|
16
|
+
* @returns A violation if the attribute value does not match the expected type.
|
|
17
|
+
*/
|
|
4
18
|
export declare const checkingValue: AttrChecker<boolean, Options, {
|
|
5
19
|
role?: ARIARole | null;
|
|
6
20
|
propSpecs: readonly ARIAProperty[];
|
|
7
21
|
booleanish?: boolean;
|
|
8
22
|
}>;
|
|
9
23
|
/**
|
|
24
|
+
* Validates a raw ARIA value against the expected value type defined in the specification.
|
|
25
|
+
*
|
|
26
|
+
* Supports token, token list, string, ID reference, true/false, tristate,
|
|
27
|
+
* true/false/undefined, integer, and number value types.
|
|
10
28
|
*
|
|
11
29
|
* @see https://www.w3.org/TR/wai-aria-1.2/#propcharacteristic_value
|
|
30
|
+
* @param type - The ARIA value type (e.g., `"token"`, `"true/false"`, `"integer"`).
|
|
31
|
+
* @param value - The raw attribute value to validate.
|
|
32
|
+
* @param tokenEnum - The list of allowed token values for token-based types.
|
|
33
|
+
* @param booleanish - Whether empty string is accepted as a boolean `true` value.
|
|
34
|
+
* @returns `true` if the value is valid for the given type, `false` otherwise.
|
|
12
35
|
*/
|
|
13
36
|
export declare function checkAriaValue(type: string, value: string, tokenEnum: readonly string[], booleanish?: boolean): boolean;
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether the value of an ARIA property or state conforms to its expected type.
|
|
3
|
+
*
|
|
4
|
+
* ARIA properties have specific value types (token, token list, true/false, tristate,
|
|
5
|
+
* integer, number, string, ID reference, etc.). This checker validates the attribute
|
|
6
|
+
* value against the property's expected type and allowed enum values.
|
|
7
|
+
* Role-specific conditional value types are also considered.
|
|
8
|
+
*
|
|
9
|
+
* @param attr - The ARIA attribute node to inspect.
|
|
10
|
+
* @param role - The computed ARIA role, used to resolve conditional value types.
|
|
11
|
+
* @param propSpecs - The list of ARIA property specifications for value type lookup.
|
|
12
|
+
* @param booleanish - Whether the document supports booleanish attribute values (e.g., JSX).
|
|
13
|
+
* @returns A violation if the attribute value does not match the expected type.
|
|
14
|
+
*/
|
|
1
15
|
export const checkingValue = ({ attr, role, propSpecs, booleanish }) => t => {
|
|
2
16
|
if (attr.isDynamicValue) {
|
|
3
17
|
return;
|
|
@@ -15,6 +29,15 @@ export const checkingValue = ({ attr, role, propSpecs, booleanish }) => t => {
|
|
|
15
29
|
: ''),
|
|
16
30
|
};
|
|
17
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Validates an ARIA property value against its specification, considering role-specific conditional types.
|
|
34
|
+
*
|
|
35
|
+
* @param propSpec - The ARIA property specification, or `undefined` if the property is unknown.
|
|
36
|
+
* @param currentValue - The current attribute value to validate.
|
|
37
|
+
* @param role - The name of the computed role, used to resolve conditional value types.
|
|
38
|
+
* @param booleanish - Whether booleanish values (empty string as `true`) are accepted.
|
|
39
|
+
* @returns An object containing the validation result and, for enum types, the allowed values.
|
|
40
|
+
*/
|
|
18
41
|
function checkAria(propSpec, currentValue, role, booleanish) {
|
|
19
42
|
if (!propSpec) {
|
|
20
43
|
return {
|
|
@@ -40,8 +63,17 @@ function checkAria(propSpec, currentValue, role, booleanish) {
|
|
|
40
63
|
};
|
|
41
64
|
}
|
|
42
65
|
/**
|
|
66
|
+
* Validates a raw ARIA value against the expected value type defined in the specification.
|
|
67
|
+
*
|
|
68
|
+
* Supports token, token list, string, ID reference, true/false, tristate,
|
|
69
|
+
* true/false/undefined, integer, and number value types.
|
|
43
70
|
*
|
|
44
71
|
* @see https://www.w3.org/TR/wai-aria-1.2/#propcharacteristic_value
|
|
72
|
+
* @param type - The ARIA value type (e.g., `"token"`, `"true/false"`, `"integer"`).
|
|
73
|
+
* @param value - The raw attribute value to validate.
|
|
74
|
+
* @param tokenEnum - The list of allowed token values for token-based types.
|
|
75
|
+
* @param booleanish - Whether empty string is accepted as a boolean `true` value.
|
|
76
|
+
* @returns `true` if the value is valid for the given type, `false` otherwise.
|
|
45
77
|
*/
|
|
46
78
|
export function checkAriaValue(type, value, tokenEnum, booleanish) {
|
|
47
79
|
switch (type) {
|
package/lib/wai-aria/index.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
import type { Options } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* WAI-ARIA rule for markuplint.
|
|
4
|
+
*
|
|
5
|
+
* Validates the correct usage of WAI-ARIA roles, states, and properties
|
|
6
|
+
* on HTML elements. This rule performs a comprehensive set of checks including
|
|
7
|
+
* role validity, property values, required owned elements, and conformance
|
|
8
|
+
* with the ARIA in HTML specification.
|
|
9
|
+
*
|
|
10
|
+
* Individual checks can be toggled on or off via the rule's options.
|
|
11
|
+
*/
|
|
2
12
|
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<boolean, Options>>;
|
|
3
13
|
export default _default;
|
package/lib/wai-aria/index.js
CHANGED
|
@@ -17,6 +17,16 @@ import { checkingRequiredOwnedElements } from './checkings/required-owned-elemen
|
|
|
17
17
|
import { checkingRequiredProp } from './checkings/required-prop.js';
|
|
18
18
|
import { checkingValue } from './checkings/value.js';
|
|
19
19
|
import meta from './meta.js';
|
|
20
|
+
/**
|
|
21
|
+
* WAI-ARIA rule for markuplint.
|
|
22
|
+
*
|
|
23
|
+
* Validates the correct usage of WAI-ARIA roles, states, and properties
|
|
24
|
+
* on HTML elements. This rule performs a comprehensive set of checks including
|
|
25
|
+
* role validity, property values, required owned elements, and conformance
|
|
26
|
+
* with the ARIA in HTML specification.
|
|
27
|
+
*
|
|
28
|
+
* Individual checks can be toggled on or off via the rule's options.
|
|
29
|
+
*/
|
|
20
30
|
export default createRule({
|
|
21
31
|
meta: meta,
|
|
22
32
|
defaultOptions: {
|
package/lib/wai-aria/meta.d.ts
CHANGED
package/lib/wai-aria/meta.js
CHANGED
package/lib/wai-aria/types.d.ts
CHANGED
|
@@ -1,14 +1,31 @@
|
|
|
1
1
|
import type { ARIAVersion } from '@markuplint/ml-spec';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for the `wai-aria` rule.
|
|
4
|
+
*
|
|
5
|
+
* Each boolean flag enables or disables a specific WAI-ARIA validation check.
|
|
6
|
+
* The `version` field determines which ARIA specification version to validate against.
|
|
7
|
+
*/
|
|
2
8
|
export type Options = {
|
|
9
|
+
/** Whether to validate ARIA property and state values against their expected types. */
|
|
3
10
|
checkingValue: boolean;
|
|
11
|
+
/** Whether to report usage of deprecated ARIA properties and states. */
|
|
4
12
|
checkingDeprecatedProps: boolean;
|
|
13
|
+
/** Whether to report usage of deprecated ARIA roles. */
|
|
5
14
|
checkingDeprecatedRole: boolean;
|
|
15
|
+
/** Whether to enforce the list of permitted ARIA roles for each element. */
|
|
6
16
|
permittedAriaRoles: boolean;
|
|
17
|
+
/** Whether to verify that roles requiring specific owned elements contain them. */
|
|
7
18
|
checkingRequiredOwnedElements: boolean;
|
|
19
|
+
/** Whether to warn when ARIA attributes are set on descendants of presentational-children roles. */
|
|
8
20
|
checkingPresentationalChildren: boolean;
|
|
21
|
+
/** Whether to warn about focusable interactive elements hidden via `aria-hidden`. */
|
|
9
22
|
checkingInteractionInHidden: boolean;
|
|
23
|
+
/** Whether to disallow explicitly setting a role that matches the element's implicit role. */
|
|
10
24
|
disallowSetImplicitRole: boolean;
|
|
25
|
+
/** Whether to disallow explicitly setting ARIA properties that duplicate the element's native semantics. */
|
|
11
26
|
disallowSetImplicitProps: boolean;
|
|
27
|
+
/** Whether to disallow explicitly setting an ARIA property to its default value. */
|
|
12
28
|
disallowDefaultValue: boolean;
|
|
29
|
+
/** The WAI-ARIA specification version to validate against. */
|
|
13
30
|
version: ARIAVersion;
|
|
14
31
|
};
|