@markuplint/rules 4.11.2 → 4.18.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.
Files changed (231) hide show
  1. package/CHANGELOG.md +12 -1
  2. package/SKILL.md +76 -0
  3. package/lib/attr-check.d.ts +41 -5
  4. package/lib/attr-check.js +29 -5
  5. package/lib/attr-duplication/index.d.ts +7 -0
  6. package/lib/attr-duplication/index.js +7 -0
  7. package/lib/attr-duplication/meta.d.ts +1 -0
  8. package/lib/attr-duplication/meta.js +1 -0
  9. package/lib/attr-value-quotes/index.d.ts +10 -0
  10. package/lib/attr-value-quotes/index.js +10 -0
  11. package/lib/attr-value-quotes/meta.d.ts +1 -0
  12. package/lib/attr-value-quotes/meta.js +1 -0
  13. package/lib/case-sensitive-attr-name/index.d.ts +9 -0
  14. package/lib/case-sensitive-attr-name/index.js +8 -0
  15. package/lib/case-sensitive-attr-name/meta.d.ts +1 -0
  16. package/lib/case-sensitive-attr-name/meta.js +1 -0
  17. package/lib/case-sensitive-tag-name/index.d.ts +9 -0
  18. package/lib/case-sensitive-tag-name/index.js +8 -0
  19. package/lib/case-sensitive-tag-name/meta.d.ts +1 -0
  20. package/lib/case-sensitive-tag-name/meta.js +1 -0
  21. package/lib/character-reference/index.d.ts +8 -0
  22. package/lib/character-reference/index.js +16 -0
  23. package/lib/character-reference/meta.d.ts +1 -0
  24. package/lib/character-reference/meta.js +1 -0
  25. package/lib/class-naming/index.d.ts +9 -0
  26. package/lib/class-naming/index.js +8 -0
  27. package/lib/class-naming/meta.d.ts +1 -0
  28. package/lib/class-naming/meta.js +1 -0
  29. package/lib/create-message.d.ts +27 -0
  30. package/lib/create-message.js +56 -1
  31. package/lib/debug.d.ts +9 -0
  32. package/lib/debug.js +5 -0
  33. package/lib/deprecated-attr/index.d.ts +6 -0
  34. package/lib/deprecated-attr/index.js +6 -0
  35. package/lib/deprecated-attr/meta.d.ts +1 -0
  36. package/lib/deprecated-attr/meta.js +1 -0
  37. package/lib/deprecated-element/index.d.ts +8 -0
  38. package/lib/deprecated-element/index.js +8 -0
  39. package/lib/deprecated-element/meta.d.ts +1 -0
  40. package/lib/deprecated-element/meta.js +1 -0
  41. package/lib/disallowed-element/index.d.ts +7 -0
  42. package/lib/disallowed-element/index.js +7 -0
  43. package/lib/disallowed-element/meta.d.ts +1 -0
  44. package/lib/disallowed-element/meta.js +1 -0
  45. package/lib/doctype/index.d.ts +10 -0
  46. package/lib/doctype/index.js +8 -0
  47. package/lib/doctype/meta.d.ts +1 -0
  48. package/lib/doctype/meta.js +1 -0
  49. package/lib/end-tag/index.d.ts +7 -0
  50. package/lib/end-tag/index.js +7 -0
  51. package/lib/end-tag/meta.d.ts +1 -0
  52. package/lib/end-tag/meta.js +1 -0
  53. package/lib/heading-levels/index.d.ts +6 -0
  54. package/lib/heading-levels/index.js +6 -0
  55. package/lib/heading-levels/meta.d.ts +1 -0
  56. package/lib/heading-levels/meta.js +1 -0
  57. package/lib/helpers.d.ts +104 -0
  58. package/lib/helpers.js +105 -2
  59. package/lib/id-duplication/index.d.ts +7 -0
  60. package/lib/id-duplication/index.js +7 -0
  61. package/lib/id-duplication/meta.d.ts +1 -0
  62. package/lib/id-duplication/meta.js +1 -0
  63. package/lib/index.d.ts +23 -10
  64. package/lib/index.js +12 -0
  65. package/lib/ineffective-attr/index.d.ts +7 -0
  66. package/lib/ineffective-attr/index.js +7 -0
  67. package/lib/ineffective-attr/meta.d.ts +1 -0
  68. package/lib/ineffective-attr/meta.js +1 -0
  69. package/lib/invalid-attr/index.d.ts +24 -0
  70. package/lib/invalid-attr/index.js +17 -0
  71. package/lib/invalid-attr/meta.d.ts +1 -0
  72. package/lib/invalid-attr/meta.js +1 -0
  73. package/lib/label-has-control/index.d.ts +7 -0
  74. package/lib/label-has-control/index.js +11 -0
  75. package/lib/label-has-control/meta.d.ts +1 -0
  76. package/lib/label-has-control/meta.js +1 -0
  77. package/lib/landmark-roles/index.d.ts +14 -0
  78. package/lib/landmark-roles/index.js +21 -0
  79. package/lib/landmark-roles/meta.d.ts +1 -0
  80. package/lib/landmark-roles/meta.js +1 -0
  81. package/lib/neighbor-popovers/index.d.ts +8 -0
  82. package/lib/neighbor-popovers/index.js +26 -2
  83. package/lib/neighbor-popovers/meta.d.ts +1 -0
  84. package/lib/neighbor-popovers/meta.js +1 -0
  85. package/lib/no-ambiguous-navigable-target-names/index.d.ts +8 -0
  86. package/lib/no-ambiguous-navigable-target-names/index.js +8 -0
  87. package/lib/no-ambiguous-navigable-target-names/meta.d.ts +1 -0
  88. package/lib/no-ambiguous-navigable-target-names/meta.js +1 -0
  89. package/lib/no-boolean-attr-value/index.d.ts +7 -0
  90. package/lib/no-boolean-attr-value/index.js +7 -0
  91. package/lib/no-boolean-attr-value/meta.d.ts +1 -0
  92. package/lib/no-boolean-attr-value/meta.js +1 -0
  93. package/lib/no-consecutive-br/index.d.ts +8 -0
  94. package/lib/no-consecutive-br/index.js +8 -0
  95. package/lib/no-consecutive-br/meta.d.ts +1 -0
  96. package/lib/no-consecutive-br/meta.js +1 -0
  97. package/lib/no-default-value/index.d.ts +7 -0
  98. package/lib/no-default-value/index.js +7 -0
  99. package/lib/no-default-value/meta.d.ts +1 -0
  100. package/lib/no-default-value/meta.js +1 -0
  101. package/lib/no-duplicate-dt/index.d.ts +6 -0
  102. package/lib/no-duplicate-dt/index.js +6 -0
  103. package/lib/no-duplicate-dt/meta.d.ts +1 -0
  104. package/lib/no-duplicate-dt/meta.js +1 -0
  105. package/lib/no-empty-palpable-content/index.d.ts +13 -0
  106. package/lib/no-empty-palpable-content/index.js +12 -0
  107. package/lib/no-empty-palpable-content/meta.d.ts +1 -0
  108. package/lib/no-empty-palpable-content/meta.js +1 -0
  109. package/lib/no-hard-code-id/index.d.ts +8 -0
  110. package/lib/no-hard-code-id/index.js +8 -0
  111. package/lib/no-hard-code-id/meta.d.ts +1 -0
  112. package/lib/no-hard-code-id/meta.js +1 -0
  113. package/lib/no-orphaned-end-tag/index.d.ts +7 -0
  114. package/lib/no-orphaned-end-tag/index.js +7 -0
  115. package/lib/no-orphaned-end-tag/meta.d.ts +1 -0
  116. package/lib/no-orphaned-end-tag/meta.js +1 -0
  117. package/lib/no-refer-to-non-existent-id/index.d.ts +8 -0
  118. package/lib/no-refer-to-non-existent-id/index.js +9 -0
  119. package/lib/no-refer-to-non-existent-id/meta.d.ts +1 -0
  120. package/lib/no-refer-to-non-existent-id/meta.js +1 -0
  121. package/lib/no-use-event-handler-attr/index.d.ts +10 -0
  122. package/lib/no-use-event-handler-attr/index.js +8 -0
  123. package/lib/no-use-event-handler-attr/meta.d.ts +1 -0
  124. package/lib/no-use-event-handler-attr/meta.js +1 -0
  125. package/lib/permitted-contents/choice.d.ts +17 -0
  126. package/lib/permitted-contents/choice.js +30 -0
  127. package/lib/permitted-contents/complex-branch.d.ts +11 -7
  128. package/lib/permitted-contents/complex-branch.js +11 -7
  129. package/lib/permitted-contents/content-model.d.ts +11 -0
  130. package/lib/permitted-contents/content-model.js +32 -0
  131. package/lib/permitted-contents/count-pattern.d.ts +13 -7
  132. package/lib/permitted-contents/count-pattern.js +23 -7
  133. package/lib/permitted-contents/debug.browser.d.ts +12 -0
  134. package/lib/permitted-contents/debug.browser.js +12 -0
  135. package/lib/permitted-contents/debug.d.ts +12 -0
  136. package/lib/permitted-contents/debug.js +12 -0
  137. package/lib/permitted-contents/index.d.ts +12 -0
  138. package/lib/permitted-contents/index.js +21 -0
  139. package/lib/permitted-contents/matches-selector.d.ts +19 -0
  140. package/lib/permitted-contents/matches-selector.js +33 -0
  141. package/lib/permitted-contents/meta.d.ts +1 -0
  142. package/lib/permitted-contents/meta.js +1 -0
  143. package/lib/permitted-contents/order.d.ts +14 -7
  144. package/lib/permitted-contents/order.js +14 -7
  145. package/lib/permitted-contents/recursive-branch.d.ts +17 -0
  146. package/lib/permitted-contents/recursive-branch.js +17 -0
  147. package/lib/permitted-contents/represent-transparent-nodes.d.ts +29 -0
  148. package/lib/permitted-contents/represent-transparent-nodes.js +24 -0
  149. package/lib/permitted-contents/start.d.ts +12 -6
  150. package/lib/permitted-contents/start.js +12 -6
  151. package/lib/permitted-contents/transparent.d.ts +12 -0
  152. package/lib/permitted-contents/transparent.js +12 -0
  153. package/lib/permitted-contents/types.d.ts +67 -0
  154. package/lib/permitted-contents/utils.d.ts +160 -0
  155. package/lib/permitted-contents/utils.js +194 -0
  156. package/lib/placeholder-label-option/index.d.ts +7 -0
  157. package/lib/placeholder-label-option/index.js +19 -15
  158. package/lib/placeholder-label-option/meta.d.ts +1 -0
  159. package/lib/placeholder-label-option/meta.js +1 -0
  160. package/lib/require-accessible-name/index.d.ts +11 -0
  161. package/lib/require-accessible-name/index.js +7 -0
  162. package/lib/require-accessible-name/meta.d.ts +1 -0
  163. package/lib/require-accessible-name/meta.js +1 -0
  164. package/lib/require-datetime/index.d.ts +12 -0
  165. package/lib/require-datetime/index.js +8 -0
  166. package/lib/require-datetime/meta.d.ts +1 -0
  167. package/lib/require-datetime/meta.js +1 -0
  168. package/lib/require-datetime/types.d.ts +7 -0
  169. package/lib/require-datetime/utils.d.ts +18 -5
  170. package/lib/require-datetime/utils.js +53 -9
  171. package/lib/required-attr/index.d.ts +13 -0
  172. package/lib/required-attr/index.js +7 -0
  173. package/lib/required-attr/meta.d.ts +1 -0
  174. package/lib/required-attr/meta.js +1 -0
  175. package/lib/required-element/index.d.ts +14 -0
  176. package/lib/required-element/index.js +14 -2
  177. package/lib/required-element/meta.d.ts +1 -0
  178. package/lib/required-element/meta.js +1 -0
  179. package/lib/required-h1/index.d.ts +12 -0
  180. package/lib/required-h1/index.js +7 -0
  181. package/lib/required-h1/meta.d.ts +1 -0
  182. package/lib/required-h1/meta.js +1 -0
  183. package/lib/table-row-column-alignment/find-children.d.ts +10 -0
  184. package/lib/table-row-column-alignment/find-children.js +11 -0
  185. package/lib/table-row-column-alignment/grid.d.ts +60 -0
  186. package/lib/table-row-column-alignment/grid.js +85 -0
  187. package/lib/table-row-column-alignment/index.d.ts +8 -0
  188. package/lib/table-row-column-alignment/index.js +8 -0
  189. package/lib/table-row-column-alignment/meta.d.ts +1 -0
  190. package/lib/table-row-column-alignment/meta.js +1 -0
  191. package/lib/table-row-column-alignment/types.d.ts +10 -0
  192. package/lib/use-list/index.d.ts +16 -0
  193. package/lib/use-list/index.js +20 -0
  194. package/lib/use-list/meta.d.ts +1 -0
  195. package/lib/use-list/meta.js +1 -0
  196. package/lib/wai-aria/checkings/abstract-role.d.ts +9 -0
  197. package/lib/wai-aria/checkings/abstract-role.js +9 -0
  198. package/lib/wai-aria/checkings/default-value.d.ts +11 -0
  199. package/lib/wai-aria/checkings/default-value.js +11 -0
  200. package/lib/wai-aria/checkings/deprecated-props.d.ts +11 -0
  201. package/lib/wai-aria/checkings/deprecated-props.js +11 -0
  202. package/lib/wai-aria/checkings/deprecated-role.d.ts +10 -0
  203. package/lib/wai-aria/checkings/deprecated-role.js +10 -0
  204. package/lib/wai-aria/checkings/disallowed-prop.d.ts +14 -0
  205. package/lib/wai-aria/checkings/disallowed-prop.js +14 -0
  206. package/lib/wai-aria/checkings/implicit-props.d.ts +13 -0
  207. package/lib/wai-aria/checkings/implicit-props.js +13 -0
  208. package/lib/wai-aria/checkings/implicit-role.d.ts +9 -0
  209. package/lib/wai-aria/checkings/implicit-role.js +9 -0
  210. package/lib/wai-aria/checkings/interaction-in-hidden.d.ts +9 -0
  211. package/lib/wai-aria/checkings/interaction-in-hidden.js +15 -4
  212. package/lib/wai-aria/checkings/no-global-prop.d.ts +10 -0
  213. package/lib/wai-aria/checkings/no-global-prop.js +10 -0
  214. package/lib/wai-aria/checkings/non-existent-role.d.ts +10 -0
  215. package/lib/wai-aria/checkings/non-existent-role.js +10 -0
  216. package/lib/wai-aria/checkings/permitted-roles.d.ts +10 -0
  217. package/lib/wai-aria/checkings/permitted-roles.js +10 -0
  218. package/lib/wai-aria/checkings/presentational-children.d.ts +7 -1
  219. package/lib/wai-aria/checkings/presentational-children.js +14 -1
  220. package/lib/wai-aria/checkings/required-owned-elements.d.ts +9 -1
  221. package/lib/wai-aria/checkings/required-owned-elements.js +16 -1
  222. package/lib/wai-aria/checkings/required-prop.d.ts +13 -0
  223. package/lib/wai-aria/checkings/required-prop.js +13 -0
  224. package/lib/wai-aria/checkings/value.d.ts +23 -0
  225. package/lib/wai-aria/checkings/value.js +32 -0
  226. package/lib/wai-aria/index.d.ts +10 -0
  227. package/lib/wai-aria/index.js +10 -0
  228. package/lib/wai-aria/meta.d.ts +1 -0
  229. package/lib/wai-aria/meta.js +1 -0
  230. package/lib/wai-aria/types.d.ts +17 -0
  231. package/package.json +11 -11
@@ -1,2 +1,12 @@
1
+ /** A grid cell coordinate key in "row:column" format. */
1
2
  export type Key = `${number}:${number}`;
3
+ /**
4
+ * Represents the type of a cell in the table grid model.
5
+ *
6
+ * - `'●'` - A regular cell (single-span).
7
+ * - `'◎'` - The origin cell of a colspan or rowspan.
8
+ * - `'↓'` - A cell occupied by a rowspan from a row above.
9
+ * - `'→'` - A cell occupied by a colspan from a column to the left.
10
+ * - `'x'` - An overlapping cell caused by conflicting spans.
11
+ */
2
12
  export type CellType = '●' | '◎' | '↓' | '→' | 'x';
@@ -1,10 +1,26 @@
1
+ /** An array of characters recognized as bullet-like symbols indicating list items. */
1
2
  type Bullets = readonly string[];
3
+ /**
4
+ * Configuration options for the use-list rule.
5
+ */
2
6
  type Options = {
7
+ /** Bullet characters that require a space after them to be considered list items. */
3
8
  spaceNeededBullets?: string[];
9
+ /** Whether to report text nodes with no preceding sibling. */
4
10
  noPrev?: boolean;
11
+ /** Whether to report text nodes preceded by an element node. */
5
12
  prevElement?: boolean;
13
+ /** Whether to report text nodes preceded by a comment node. */
6
14
  prevComment?: boolean;
15
+ /** Whether to report text nodes preceded by a preprocessor block. */
7
16
  prevCodeBlock?: boolean;
8
17
  };
18
+ /**
19
+ * Rule that suggests using `<li>` elements instead of text with bullet characters.
20
+ *
21
+ * Detects text nodes that start with bullet-like characters (Unicode bullets,
22
+ * markdown-style dashes/asterisks, etc.) and recommends converting them into
23
+ * proper list markup using `<li>` elements.
24
+ */
9
25
  declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<Bullets, Options>>;
10
26
  export default _default;
@@ -1,6 +1,13 @@
1
1
  import { createRule } from '@markuplint/ml-core';
2
2
  import { decodeEntities } from '@markuplint/shared';
3
3
  import meta from './meta.js';
4
+ /**
5
+ * Rule that suggests using `<li>` elements instead of text with bullet characters.
6
+ *
7
+ * Detects text nodes that start with bullet-like characters (Unicode bullets,
8
+ * markdown-style dashes/asterisks, etc.) and recommends converting them into
9
+ * proper list markup using `<li>` elements.
10
+ */
4
11
  export default createRule({
5
12
  meta: meta,
6
13
  defaultValue: [
@@ -94,6 +101,19 @@ export default createRule({
94
101
  });
95
102
  },
96
103
  });
104
+ /**
105
+ * Determines whether a text string appears to be a list item based on its first character.
106
+ *
107
+ * Checks if the text starts with a recognized bullet character. For bullets
108
+ * that require a trailing space (e.g., `-`, `*`, `+`), also verifies that the
109
+ * second character is whitespace. Consecutive identical characters are not
110
+ * treated as bullets (e.g., `--` is not a list item).
111
+ *
112
+ * @param text - The text content to evaluate.
113
+ * @param bullets - Characters recognized as bullet symbols.
114
+ * @param spaceNeededBullets - Bullet characters that require a following space.
115
+ * @returns `true` if the text appears to be a list item.
116
+ */
97
117
  function isMayListItem(text, bullets, spaceNeededBullets) {
98
118
  const textArray = [...text];
99
119
  const firstLetter = textArray[0] ?? '';
@@ -1,3 +1,4 @@
1
+ /** Rule metadata for the `use-list` rule, categorized as accessibility. */
1
2
  declare const _default: {
2
3
  readonly category: "a11y";
3
4
  };
@@ -1,3 +1,4 @@
1
+ /** Rule metadata for the `use-list` rule, categorized as accessibility. */
1
2
  export default {
2
3
  category: 'a11y',
3
4
  };
@@ -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 `role` attribute value refers to an abstract WAI-ARIA role.
5
+ *
6
+ * Abstract roles (e.g., `widget`, `landmark`) are used for ontological purposes
7
+ * in the ARIA taxonomy and must not be used directly in content.
8
+ *
9
+ * @param attr - The `role` attribute node to inspect.
10
+ * @returns A violation if any token in the role attribute is an abstract role.
11
+ */
3
12
  export declare const checkingAbstractRole: AttrChecker<boolean, Options>;
@@ -1,4 +1,13 @@
1
1
  import { ariaSpecs } from '@markuplint/ml-spec';
2
+ /**
3
+ * Checks whether the `role` attribute value refers to an abstract WAI-ARIA role.
4
+ *
5
+ * Abstract roles (e.g., `widget`, `landmark`) are used for ontological purposes
6
+ * in the ARIA taxonomy and must not be used directly in content.
7
+ *
8
+ * @param attr - The `role` attribute node to inspect.
9
+ * @returns A violation if any token in the role attribute is an abstract role.
10
+ */
2
11
  export const checkingAbstractRole = ({ attr }) => t => {
3
12
  const { roles } = ariaSpecs(attr.ownerMLDocument.specs, attr.rule.options.version);
4
13
  const tokens = attr.tokenList?.allTokens();
@@ -1,6 +1,17 @@
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 an ARIA property is explicitly set to its spec-defined default value.
6
+ *
7
+ * Setting an ARIA property to its default value is redundant and may indicate
8
+ * a misunderstanding of the property's behavior. This checker reports such cases
9
+ * when the `disallowDefaultValue` option is enabled.
10
+ *
11
+ * @param attr - The ARIA attribute node to inspect.
12
+ * @param propSpecs - The list of ARIA property specifications for value lookup.
13
+ * @returns A violation if the attribute value matches the property's default value.
14
+ */
4
15
  export declare const checkingDefaultValue: AttrChecker<boolean, Options, {
5
16
  propSpecs: readonly ARIAProperty[];
6
17
  }>;
@@ -1,3 +1,14 @@
1
+ /**
2
+ * Checks whether an ARIA property is explicitly set to its spec-defined default value.
3
+ *
4
+ * Setting an ARIA property to its default value is redundant and may indicate
5
+ * a misunderstanding of the property's behavior. This checker reports such cases
6
+ * when the `disallowDefaultValue` option is enabled.
7
+ *
8
+ * @param attr - The ARIA attribute node to inspect.
9
+ * @param propSpecs - The list of ARIA property specifications for value lookup.
10
+ * @returns A violation if the attribute value matches the property's default value.
11
+ */
1
12
  export const checkingDefaultValue = ({ attr, propSpecs }) => t => {
2
13
  if (attr.isDynamicValue) {
3
14
  return;
@@ -1,6 +1,17 @@
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 deprecated for the element's computed role.
6
+ *
7
+ * Some ARIA properties become deprecated on specific roles across ARIA versions.
8
+ * This checker reports usage of such deprecated properties.
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
+ * @returns A violation if the property is deprecated on the given role.
14
+ */
4
15
  export declare const checkingDeprecatedProps: AttrChecker<boolean, Options, {
5
16
  role: ARIARole | null;
6
17
  propSpecs: readonly ARIAProperty[];
@@ -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
- * > Text equivalents for hidden referenced objects
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
- * > Text equivalents for hidden referenced objects
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
- * Required Owned Elements
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
- * Required Owned Elements
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;