@markuplint/rules 3.0.0-alpha.66 → 3.0.0-dev.176

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 (211) hide show
  1. package/README.md +10 -44
  2. package/lib/attr-check.d.ts +22 -10
  3. package/lib/attr-check.js +32 -23
  4. package/lib/attr-duplication/index.d.ts +3 -1
  5. package/lib/attr-duplication/index.js +3 -2
  6. package/lib/attr-value-quotes/index.d.ts +5 -5
  7. package/lib/attr-value-quotes/index.js +1 -1
  8. package/lib/case-sensitive-attr-name/index.d.ts +2 -2
  9. package/lib/case-sensitive-attr-name/index.js +3 -3
  10. package/lib/case-sensitive-tag-name/index.d.ts +2 -2
  11. package/lib/case-sensitive-tag-name/index.js +3 -3
  12. package/lib/character-reference/index.d.ts +1 -1
  13. package/lib/character-reference/index.js +1 -1
  14. package/lib/class-naming/index.d.ts +2 -2
  15. package/lib/class-naming/index.js +3 -5
  16. package/lib/create-message.d.ts +13 -2
  17. package/lib/create-message.js +9 -8
  18. package/lib/debug.d.ts +1 -1
  19. package/lib/debug.js +1 -1
  20. package/lib/deprecated-attr/index.d.ts +3 -1
  21. package/lib/deprecated-element/index.d.ts +3 -1
  22. package/lib/deprecated-element/index.js +4 -4
  23. package/lib/disallowed-element/index.d.ts +1 -1
  24. package/lib/doctype/index.d.ts +3 -3
  25. package/lib/doctype/index.js +2 -2
  26. package/lib/end-tag/index.d.ts +1 -1
  27. package/lib/end-tag/index.js +3 -18
  28. package/lib/helpers.d.ts +38 -47
  29. package/lib/helpers.js +42 -93
  30. package/lib/id-duplication/index.d.ts +3 -1
  31. package/lib/index.d.ts +242 -62
  32. package/lib/index.js +10 -1
  33. package/lib/ineffective-attr/index.d.ts +3 -1
  34. package/lib/ineffective-attr/index.js +3 -6
  35. package/lib/invalid-attr/index.d.ts +40 -12
  36. package/lib/invalid-attr/index.js +159 -28
  37. package/lib/label-has-control/index.d.ts +4 -0
  38. package/lib/label-has-control/index.js +28 -0
  39. package/lib/landmark-roles/index.d.ts +6 -6
  40. package/lib/landmark-roles/index.js +10 -6
  41. package/lib/no-boolean-attr-value/index.d.ts +3 -1
  42. package/lib/no-boolean-attr-value/index.js +1 -1
  43. package/lib/no-default-value/index.d.ts +3 -1
  44. package/lib/no-default-value/index.js +1 -1
  45. package/lib/no-empty-palpable-content/index.d.ts +6 -0
  46. package/lib/no-empty-palpable-content/index.js +42 -0
  47. package/lib/no-hard-code-id/index.d.ts +3 -1
  48. package/lib/no-hard-code-id/index.js +1 -1
  49. package/lib/no-refer-to-non-existent-id/index.d.ts +9 -4
  50. package/lib/no-refer-to-non-existent-id/index.js +65 -5
  51. package/lib/no-use-event-handler-attr/index.d.ts +3 -3
  52. package/lib/no-use-event-handler-attr/index.js +6 -6
  53. package/lib/permitted-contents/choice.d.ts +10 -0
  54. package/lib/permitted-contents/choice.js +72 -0
  55. package/lib/permitted-contents/complex-branch.d.ts +20 -0
  56. package/lib/permitted-contents/complex-branch.js +29 -0
  57. package/lib/permitted-contents/content-model.d.ts +2 -0
  58. package/lib/permitted-contents/content-model.js +53 -0
  59. package/lib/permitted-contents/count-pattern.d.ts +29 -0
  60. package/lib/permitted-contents/count-pattern.js +162 -0
  61. package/lib/permitted-contents/debug.browser.d.ts +30 -0
  62. package/lib/permitted-contents/debug.browser.js +14 -0
  63. package/lib/permitted-contents/debug.d.ts +3 -0
  64. package/lib/permitted-contents/debug.js +13 -0
  65. package/lib/permitted-contents/index.d.ts +2 -8
  66. package/lib/permitted-contents/index.js +76 -249
  67. package/lib/permitted-contents/matches-selector.d.ts +8 -0
  68. package/lib/permitted-contents/matches-selector.js +187 -0
  69. package/lib/permitted-contents/order.d.ts +20 -0
  70. package/lib/permitted-contents/order.js +99 -0
  71. package/lib/permitted-contents/recursive-branch.d.ts +11 -0
  72. package/lib/permitted-contents/recursive-branch.js +45 -0
  73. package/lib/permitted-contents/represent-transparent-nodes.d.ts +10 -0
  74. package/lib/permitted-contents/represent-transparent-nodes.js +78 -0
  75. package/lib/permitted-contents/start.d.ts +18 -0
  76. package/lib/permitted-contents/start.js +73 -0
  77. package/lib/permitted-contents/transparent.d.ts +2 -0
  78. package/lib/permitted-contents/transparent.js +31 -0
  79. package/lib/permitted-contents/types.d.ts +52 -0
  80. package/lib/permitted-contents/types.js +2 -0
  81. package/lib/permitted-contents/utils.d.ts +100 -0
  82. package/lib/permitted-contents/utils.js +302 -0
  83. package/lib/placeholder-label-option/index.d.ts +2 -0
  84. package/lib/placeholder-label-option/index.js +88 -0
  85. package/lib/require-accessible-name/index.d.ts +3 -3
  86. package/lib/require-accessible-name/index.js +12 -4
  87. package/lib/require-datetime/index.d.ts +6 -0
  88. package/lib/require-datetime/index.js +34 -0
  89. package/lib/require-datetime/types.d.ts +10 -0
  90. package/lib/require-datetime/types.js +2 -0
  91. package/lib/require-datetime/utils.d.ts +11 -0
  92. package/lib/require-datetime/utils.js +137 -0
  93. package/lib/required-attr/index.d.ts +5 -5
  94. package/lib/required-attr/index.js +20 -17
  95. package/lib/required-element/index.d.ts +3 -3
  96. package/lib/required-element/index.js +3 -2
  97. package/lib/required-h1/index.d.ts +3 -3
  98. package/lib/required-h1/index.js +4 -3
  99. package/lib/use-list/index.d.ts +4 -4
  100. package/lib/use-list/index.js +9 -7
  101. package/lib/wai-aria/checkings/_.d.ts +15 -0
  102. package/lib/wai-aria/checkings/_.js +27 -0
  103. package/lib/wai-aria/checkings/abstract-role.js +1 -1
  104. package/lib/wai-aria/checkings/default-value.d.ts +7 -3
  105. package/lib/wai-aria/checkings/deprecated-props.d.ts +8 -4
  106. package/lib/wai-aria/checkings/disallowed-prop.d.ts +8 -4
  107. package/lib/wai-aria/checkings/disallowed-prop.js +27 -3
  108. package/lib/wai-aria/checkings/implicit-props.d.ts +8 -4
  109. package/lib/wai-aria/checkings/implicit-props.js +3 -2
  110. package/lib/wai-aria/checkings/implicit-role.js +2 -2
  111. package/lib/wai-aria/checkings/interaction-in-hidden.d.ts +11 -0
  112. package/lib/wai-aria/checkings/interaction-in-hidden.js +49 -0
  113. package/lib/wai-aria/checkings/no-global-prop.d.ts +7 -3
  114. package/lib/wai-aria/checkings/{non-existant-role.d.ts → non-existent-role.d.ts} +1 -1
  115. package/lib/wai-aria/checkings/{non-existant-role.js → non-existent-role.js} +4 -4
  116. package/lib/wai-aria/checkings/permitted-roles.js +1 -1
  117. package/lib/wai-aria/checkings/presentational-children.d.ts +29 -0
  118. package/lib/wai-aria/checkings/presentational-children.js +62 -0
  119. package/lib/wai-aria/checkings/{checking-required-owned-elements.d.ts → required-owned-elements.d.ts} +7 -3
  120. package/lib/wai-aria/checkings/required-owned-elements.js +103 -0
  121. package/lib/wai-aria/checkings/required-prop copy.d.ts +15 -0
  122. package/lib/wai-aria/checkings/required-prop copy.js +27 -0
  123. package/lib/wai-aria/checkings/required-prop.d.ts +12 -6
  124. package/lib/wai-aria/checkings/unadopted-explicit-roles.d.ts +15 -0
  125. package/lib/wai-aria/checkings/unadopted-explicit-roles.js +17 -0
  126. package/lib/wai-aria/checkings/value.d.ts +19 -4
  127. package/lib/wai-aria/checkings/value.js +77 -5
  128. package/lib/wai-aria/index.d.ts +1 -1
  129. package/lib/wai-aria/index.js +27 -16
  130. package/lib/wai-aria/types.d.ts +11 -9
  131. package/lib/xxx/index.d.ts +2 -0
  132. package/lib/xxx/index.js +32 -0
  133. package/package.json +18 -12
  134. package/schema.json +12 -0
  135. package/test/attr-check.spec.js +77 -0
  136. package/test/attr-duplication/index.spec.js +159 -0
  137. package/test/attr-value-quotes/index.spec.js +133 -0
  138. package/test/case-sensitive-attr-name/index.spec.js +65 -0
  139. package/test/case-sensitive-tag-name/index.spec.js +80 -0
  140. package/test/character-reference/index.spec.js +57 -0
  141. package/test/class-naming/index.spec.js +470 -0
  142. package/test/create-message.spec.js +497 -0
  143. package/test/deprecated-attr/index.spec.js +48 -0
  144. package/test/deprecated-element/index.spec.js +48 -0
  145. package/test/disallowed-element/index.spec.js +90 -0
  146. package/test/doctype/index.spec.js +50 -0
  147. package/test/end-tag/index.spec.js +162 -0
  148. package/test/id-duplication/index.spec.js +47 -0
  149. package/test/ineffective-attr/index.spec.js +31 -0
  150. package/test/invalid-attr/index.spec.js +1632 -0
  151. package/test/label-has-control/index.spec.js +29 -0
  152. package/test/landmark-roles/index.spec.js +187 -0
  153. package/test/no-boolean-attr-value/index.spec.js +41 -0
  154. package/test/no-default-value/index.spec.js +74 -0
  155. package/test/no-empty-palpable-content/index.spec.js +115 -0
  156. package/test/no-hard-code-id/index.spec.js +100 -0
  157. package/test/no-refer-to-non-existent-id/index.spec.js +254 -0
  158. package/test/no-use-event-handler-attr/index.spec.js +57 -0
  159. package/test/permitted-contents/choice.spec.js +174 -0
  160. package/test/permitted-contents/count-pattern.spec.js +308 -0
  161. package/test/permitted-contents/index.spec.js +1371 -0
  162. package/test/permitted-contents/matches-selector.spec.js +59 -0
  163. package/test/permitted-contents/order.spec.js +351 -0
  164. package/test/permitted-contents/recursive-branch.spec.js +41 -0
  165. package/test/permitted-contents/represent-transparent-nodes.spec.js +24 -0
  166. package/test/permitted-contents/start.spec.js +67 -0
  167. package/test/placeholder-label-option/index.spec.js +113 -0
  168. package/test/require-accessible-name/index.spec.js +446 -0
  169. package/test/require-datetime/index.spec.js +54 -0
  170. package/test/require-datetime/utils.spec.js +52 -0
  171. package/test/required-attr/index.spec.js +414 -0
  172. package/test/required-element/index.spec.js +188 -0
  173. package/test/required-h1/index.spec.js +69 -0
  174. package/test/use-list/index.spec.js +109 -0
  175. package/test/wai-aria/checkings/value.spec.js +33 -0
  176. package/test/wai-aria/index.spec.js +1173 -0
  177. package/lib/__foo/index.d.ts +0 -2
  178. package/lib/__foo/index.js +0 -46
  179. package/lib/attr-equal-space-after/index.d.ts +0 -3
  180. package/lib/attr-equal-space-after/index.js +0 -90
  181. package/lib/attr-equal-space-before/index.d.ts +0 -3
  182. package/lib/attr-equal-space-before/index.js +0 -90
  183. package/lib/attr-spacing/index.d.ts +0 -6
  184. package/lib/attr-spacing/index.js +0 -100
  185. package/lib/helper/aria/get-aria.d.ts +0 -7
  186. package/lib/helper/aria/get-aria.js +0 -53
  187. package/lib/helper/aria/get-computed-role.d.ts +0 -10
  188. package/lib/helper/aria/get-computed-role.js +0 -24
  189. package/lib/helper/aria/get-implicit-role.d.ts +0 -7
  190. package/lib/helper/aria/get-implicit-role.js +0 -12
  191. package/lib/helper/aria/get-permitted-roles.d.ts +0 -14
  192. package/lib/helper/aria/get-permitted-roles.js +0 -26
  193. package/lib/helper/aria/resolve-version.d.ts +0 -2
  194. package/lib/helper/aria/resolve-version.js +0 -21
  195. package/lib/helper/spec/aria-spec.d.ts +0 -5
  196. package/lib/helper/spec/aria-spec.js +0 -12
  197. package/lib/helper/spec/get-role-spec.d.ts +0 -11
  198. package/lib/helper/spec/get-role-spec.js +0 -39
  199. package/lib/helper/spec/html-spec.d.ts +0 -2
  200. package/lib/helper/spec/html-spec.js +0 -14
  201. package/lib/indentation/index.d.ts +0 -7
  202. package/lib/indentation/index.js +0 -208
  203. package/lib/permitted-contents/array.combination.d.ts +0 -1
  204. package/lib/permitted-contents/array.combination.js +0 -33
  205. package/lib/permitted-contents/permitted-content.spec-to-regexp.d.ts +0 -11
  206. package/lib/permitted-contents/permitted-content.spec-to-regexp.js +0 -230
  207. package/lib/permitted-contents/unfold-content-models-to-tags.d.ts +0 -2
  208. package/lib/permitted-contents/unfold-content-models-to-tags.js +0 -8
  209. package/lib/wai-aria/checkings/checking-required-owned-elements.js +0 -63
  210. package/tsconfig.test.json +0 -3
  211. package/tsconfig.tsbuildinfo +0 -1
package/lib/helpers.d.ts CHANGED
@@ -1,8 +1,13 @@
1
1
  import type { Log } from './debug';
2
2
  import type { Translator } from '@markuplint/i18n';
3
+ import type { PlainData } from '@markuplint/ml-config';
3
4
  import type { Element, RuleConfigValue, Document } from '@markuplint/ml-core';
4
- import type { ARIAVersion, Attribute, MLMLSpec } from '@markuplint/ml-spec';
5
- export declare function attrMatches<T extends RuleConfigValue, R>(node: Element<T, R>, condition: Attribute['condition']): boolean;
5
+ import type { Attribute } from '@markuplint/ml-spec';
6
+ import type { WritableDeep } from 'type-fest';
7
+ export declare function attrMatches<T extends RuleConfigValue, O extends PlainData>(
8
+ node: Element<T, O>,
9
+ condition: Attribute['condition'],
10
+ ): boolean;
6
11
  export declare function match(needle: string, pattern: string): boolean;
7
12
  /**
8
13
  * PotentialCustomElementName
@@ -20,52 +25,38 @@ export declare function match(needle: string, pattern: string): boolean;
20
25
  * Originally, it is not possible to define a name including ASCII upper alphas in the custom element, but it is not treated as illegal by the HTML parser.
21
26
  */
22
27
  export declare const rePCENChar: string;
23
- export declare function isValidAttr(t: Translator, name: string, value: string, isDynamicValue: boolean, node: Element<any, any>, attrSpecs: Attribute[], log?: Log): false | {
24
- invalidType: "non-existent" | "invalid-value";
25
- message: string;
26
- loc?: {
27
- raw: string;
28
- line: number;
29
- col: number;
30
- } | undefined;
31
- };
28
+ export declare function isValidAttr(
29
+ t: Translator,
30
+ name: string,
31
+ value: string,
32
+ isDynamicValue: boolean,
33
+ node: Element<any, any>,
34
+ attrSpecs: readonly Attribute[],
35
+ log?: Log,
36
+ ):
37
+ | false
38
+ | {
39
+ invalidType: 'non-existent' | 'invalid-value' | 'disallowed-attr';
40
+ message: string;
41
+ loc?:
42
+ | {
43
+ raw: string;
44
+ line: number;
45
+ col: number;
46
+ }
47
+ | undefined;
48
+ };
32
49
  export declare function toNormalizedValue(value: string, spec: Attribute): string;
33
- /**
34
- *
35
- * @see https://www.w3.org/TR/wai-aria-1.2/#propcharacteristic_value
36
- *
37
- * @param type
38
- * @param value
39
- * @param tokenEnum
40
- */
41
- export declare function checkAriaValue(type: string, value: string, tokenEnum: string[]): boolean;
42
- export declare function checkAria(specs: Readonly<MLMLSpec>, attrName: string, currentValue: string, version: ARIAVersion, role?: string): {
43
- currentValue: string;
44
- isValid: boolean;
45
- } | {
46
- currentValue: string;
47
- isValid: boolean;
48
- name: string;
49
- type: "property" | "state";
50
- deprecated?: true | undefined;
51
- isGlobal?: true | undefined;
52
- value: import("@markuplint/ml-spec").ARIAAttributeValue;
53
- conditionalValue?: {
54
- role: string[];
55
- value: import("@markuplint/ml-spec").ARIAAttributeValue;
56
- }[] | undefined;
57
- enum: string[];
58
- defaultValue?: string | undefined;
59
- equivalentHtmlAttrs?: import("@markuplint/ml-spec").EquivalentHtmlAttr[] | undefined;
60
- valueDescriptions?: Record<string, string> | undefined;
61
- };
62
50
  export declare function accnameMayBeMutable(el: Element<any, any>, document: Document<any, any>): boolean;
63
- export declare function getOwnedLabel<V extends RuleConfigValue, O>(el: Element<V, O>, docuemnt: Document<V, O>): Element<V, O> | null;
64
- export declare function decodeCharRef(characterReference: string): string;
51
+ export declare function getOwnedLabel<V extends RuleConfigValue, O extends PlainData>(
52
+ el: Element<V, O>,
53
+ document: Document<V, O>,
54
+ ): Element<V, O> | null;
65
55
  export declare class Collection<T> {
66
- #private;
67
- constructor(...items: (T | null | undefined)[]);
68
- add(...items: (T | null | undefined)[]): void;
69
- toArray(): readonly T[];
70
- [Symbol.iterator](): Iterator<T>;
56
+ #private;
57
+ constructor(...items: readonly (T | null | undefined)[]);
58
+ [Symbol.iterator](): Iterator<T>;
59
+ add(...items: readonly (T | null | undefined)[]): void;
60
+ toArray(): readonly T[];
71
61
  }
62
+ export declare function deepCopy<T>(value: T): WritableDeep<T>;
package/lib/helpers.js CHANGED
@@ -1,16 +1,18 @@
1
1
  "use strict";
2
2
  var _Collection_items;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Collection = exports.decodeCharRef = exports.getOwnedLabel = exports.accnameMayBeMutable = exports.checkAria = exports.checkAriaValue = exports.toNormalizedValue = exports.isValidAttr = exports.rePCENChar = exports.match = exports.attrMatches = void 0;
4
+ exports.deepCopy = exports.Collection = exports.getOwnedLabel = exports.accnameMayBeMutable = exports.toNormalizedValue = exports.isValidAttr = exports.rePCENChar = exports.match = exports.attrMatches = void 0;
5
5
  const tslib_1 = require("tslib");
6
- const ml_core_1 = require("@markuplint/ml-core");
7
- const html_entities_1 = require("html-entities");
6
+ // @ts-ignore
7
+ const structured_clone_1 = tslib_1.__importDefault(require("@ungap/structured-clone"));
8
8
  const attr_check_1 = require("./attr-check");
9
- function attrMatches(node, condition) {
10
- if (!condition) {
9
+ function attrMatches(
10
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
11
+ node, condition) {
12
+ if (condition == null) {
11
13
  return true;
12
14
  }
13
- const condSelector = Array.isArray(condition) ? condition.join(',') : condition;
15
+ const condSelector = typeof condition === 'string' ? condition : condition.join(',');
14
16
  return node.matches(condSelector);
15
17
  }
16
18
  exports.attrMatches = attrMatches;
@@ -59,18 +61,26 @@ exports.rePCENChar = [
59
61
  '[\uFDF0-\uFFFD]',
60
62
  '[\uD800-\uDBFF][\uDC00-\uDFFF]',
61
63
  ].join('|');
62
- function isValidAttr(t, name, value, isDynamicValue, node, attrSpecs, log) {
64
+ function isValidAttr(t, name, value, isDynamicValue,
65
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
66
+ node, attrSpecs,
67
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
68
+ log) {
63
69
  let invalid = false;
64
70
  const spec = attrSpecs.find(s => s.name.toLowerCase() === name.toLowerCase());
65
71
  log && log('Spec of the %s attr: %o', name, spec);
66
72
  invalid = (0, attr_check_1.attrCheck)(t, name, value, false, spec);
67
- if (!invalid && spec && spec.condition && !node.hasSpreadAttr && !attrMatches(node, spec.condition)) {
73
+ if (invalid === false &&
74
+ spec &&
75
+ spec.condition != null &&
76
+ !node.hasSpreadAttr &&
77
+ !attrMatches(node, spec.condition)) {
68
78
  invalid = {
69
79
  invalidType: 'non-existent',
70
80
  message: t('{0} is {1}', t('the "{0*}" {1}', name, 'attribute'), 'disallowed'),
71
81
  };
72
82
  }
73
- if (invalid && invalid.invalidType === 'invalid-value' && isDynamicValue) {
83
+ if (invalid !== false && invalid.invalidType === 'invalid-value' && isDynamicValue) {
74
84
  invalid = false;
75
85
  }
76
86
  return invalid;
@@ -105,110 +115,48 @@ function toNormalizedValue(value, spec) {
105
115
  return normalized;
106
116
  }
107
117
  exports.toNormalizedValue = toNormalizedValue;
108
- /**
109
- *
110
- * @see https://www.w3.org/TR/wai-aria-1.2/#propcharacteristic_value
111
- *
112
- * @param type
113
- * @param value
114
- * @param tokenEnum
115
- */
116
- function checkAriaValue(type, value, tokenEnum) {
117
- switch (type) {
118
- case 'token': {
119
- return tokenEnum.includes(value);
120
- }
121
- case 'token list': {
122
- const list = value.split(/\s+/g).map(s => s.trim());
123
- return list.every(token => tokenEnum.includes(token));
124
- }
125
- case 'string':
126
- case 'ID reference':
127
- case 'ID reference list': {
128
- return true;
129
- }
130
- case 'true/false': {
131
- return ['true', 'false'].includes(value);
132
- }
133
- case 'tristate': {
134
- return ['mixed', 'true', 'false', 'undefined'].includes(value);
135
- }
136
- case 'true/false/undefined': {
137
- return ['true', 'false', 'undefined'].includes(value);
138
- }
139
- case 'integer': {
140
- return parseInt(value).toString() === value;
141
- }
142
- case 'number': {
143
- return parseFloat(value).toString() === value;
144
- }
145
- }
146
- // For skipping checking
147
- return true;
148
- }
149
- exports.checkAriaValue = checkAriaValue;
150
- function checkAria(specs, attrName, currentValue, version, role) {
151
- const ariaAttrs = (0, ml_core_1.ariaSpecs)(specs, version).props;
152
- const aria = ariaAttrs.find(a => a.name === attrName);
153
- if (!aria) {
154
- return {
155
- currentValue,
156
- // For skipping checking
157
- isValid: true,
158
- };
159
- }
160
- let valueType = aria.value;
161
- if (role && aria.conditionalValue) {
162
- for (const cond of aria.conditionalValue) {
163
- if (cond.role.includes(role)) {
164
- valueType = cond.value;
165
- break;
166
- }
167
- }
168
- }
169
- const isValid = checkAriaValue(valueType, currentValue, aria.enum);
170
- return {
171
- ...aria,
172
- currentValue,
173
- isValid,
174
- };
175
- }
176
- exports.checkAria = checkAria;
177
- function accnameMayBeMutable(el, document) {
118
+ function accnameMayBeMutable(
119
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
120
+ el,
121
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
122
+ document) {
178
123
  if (el.hasMutableAttributes() || el.hasMutableChildren(true)) {
179
124
  return true;
180
125
  }
181
- const ownedLable = getOwnedLabel(el, document);
182
- if (ownedLable && (ownedLable.hasMutableAttributes() || ownedLable.hasMutableChildren(true))) {
126
+ const ownedLabel = getOwnedLabel(el, document);
127
+ if (ownedLabel && (ownedLabel.hasMutableAttributes() || ownedLabel.hasMutableChildren(true))) {
183
128
  return true;
184
129
  }
185
130
  return false;
186
131
  }
187
132
  exports.accnameMayBeMutable = accnameMayBeMutable;
188
133
  const labelable = ['button', 'input:not([type=hidden])', 'meter', 'output', 'progress', 'select', 'textarea'];
189
- function getOwnedLabel(el, docuemnt) {
134
+ function getOwnedLabel(
135
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
136
+ el,
137
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
138
+ document) {
190
139
  if (!labelable.some(cond => el.matches(cond))) {
191
140
  return null;
192
141
  }
193
- let ownedLable = el.closest('label');
194
- if (!ownedLable) {
142
+ let ownedLabel = el.closest('label');
143
+ if (!ownedLabel) {
195
144
  const id = el.getAttribute('id');
196
145
  if (id) {
197
- ownedLable = docuemnt.querySelector(`label[for="${id}"]`);
146
+ ownedLabel = document.querySelector(`label[for="${id}"]`);
198
147
  }
199
148
  }
200
- return ownedLable;
149
+ return ownedLabel;
201
150
  }
202
151
  exports.getOwnedLabel = getOwnedLabel;
203
- function decodeCharRef(characterReference) {
204
- return (0, html_entities_1.decode)(characterReference);
205
- }
206
- exports.decodeCharRef = decodeCharRef;
207
152
  class Collection {
208
153
  constructor(...items) {
209
154
  _Collection_items.set(this, new Set());
210
155
  this.add(...items);
211
156
  }
157
+ [(_Collection_items = new WeakMap(), Symbol.iterator)]() {
158
+ return tslib_1.__classPrivateFieldGet(this, _Collection_items, "f").values();
159
+ }
212
160
  add(...items) {
213
161
  for (const item of items) {
214
162
  if (item == null) {
@@ -220,8 +168,9 @@ class Collection {
220
168
  toArray() {
221
169
  return Object.freeze(Array.from(tslib_1.__classPrivateFieldGet(this, _Collection_items, "f")));
222
170
  }
223
- [(_Collection_items = new WeakMap(), Symbol.iterator)]() {
224
- return tslib_1.__classPrivateFieldGet(this, _Collection_items, "f").values();
225
- }
226
171
  }
227
172
  exports.Collection = Collection;
173
+ function deepCopy(value) {
174
+ return (0, structured_clone_1.default)(value);
175
+ }
176
+ exports.deepCopy = deepCopy;
@@ -1,2 +1,4 @@
1
- declare const _default: import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, null>;
1
+ declare const _default: Readonly<
2
+ import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
3
+ >;
2
4
  export default _default;
package/lib/index.d.ts CHANGED
@@ -1,63 +1,243 @@
1
- declare const _default: {
2
- 'attr-duplication': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
3
- 'attr-value-quotes': import("packages/@markuplint/ml-core/lib").RuleSeed<import("./attr-value-quotes").Type, null>;
4
- 'case-sensitive-attr-name': import("packages/@markuplint/ml-core/lib").RuleSeed<import("./case-sensitive-attr-name").Value, null>;
5
- 'case-sensitive-tag-name': import("packages/@markuplint/ml-core/lib").RuleSeed<import("./case-sensitive-tag-name").Value, null>;
6
- 'character-reference': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
7
- 'class-naming': import("packages/@markuplint/ml-core/lib").RuleSeed<import("./class-naming").Value, null>;
8
- 'deprecated-attr': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
9
- 'deprecated-element': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
10
- 'disallowed-element': import("packages/@markuplint/ml-core/lib").RuleSeed<string[], null>;
11
- doctype: import("packages/@markuplint/ml-core/lib").RuleSeed<"always", {
12
- denyObsolateType: boolean;
13
- }>;
14
- 'end-tag': import("packages/@markuplint/ml-core/lib").RuleSeed<boolean, null>;
15
- 'id-duplication': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
16
- 'ineffective-attr': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
17
- 'invalid-attr': import("packages/@markuplint/ml-core/lib").RuleSeed<boolean, {
18
- attrs?: Record<string, {
19
- enum: [string, ...string[]];
20
- } | {
21
- pattern: string;
22
- } | {
23
- type: import("packages/@markuplint/ml-spec/lib").AttributeType;
24
- } | {
25
- disallowed: true;
26
- }> | undefined;
27
- ignoreAttrNamePrefix?: string | string[] | undefined;
28
- }>;
29
- 'landmark-roles': import("packages/@markuplint/ml-core/lib").RuleSeed<boolean, {
30
- ignoreRoles: (("banner" | "main" | "complementary" | "contentinfo") | "form" | "navigation" | "region")[];
31
- labelEachArea: boolean;
32
- }>;
33
- 'no-boolean-attr-value': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
34
- 'no-default-value': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
35
- 'no-hard-code-id': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
36
- 'no-refer-to-non-existent-id': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, {
37
- ariaVersion: import("packages/@markuplint/ml-spec/lib").ARIAVersion;
38
- }>;
39
- 'no-use-event-handler-attr': import("packages/@markuplint/ml-core/lib").RuleSeed<boolean, {
40
- ignore?: string | string[] | undefined;
41
- }>;
42
- 'permitted-contents': import("packages/@markuplint/ml-core/lib").RuleSeed<(import("packages/@markuplint/ml-spec/lib").ContentModel & {
43
- tag: string;
44
- })[], {
45
- ignoreHasMutableChildren: boolean;
46
- }>;
47
- 'require-accessible-name': import("packages/@markuplint/ml-core/lib").RuleSeed<boolean, {
48
- ariaVersion: import("packages/@markuplint/ml-spec/lib").ARIAVersion;
49
- }>;
50
- 'required-attr': import("packages/@markuplint/ml-core/lib").RuleSeed<string | (string | {
51
- name: string;
52
- value: string | string[];
53
- })[], null>;
54
- 'required-element': import("packages/@markuplint/ml-core/lib").RuleSeed<string[], {
55
- ignoreHasMutableContents: boolean;
56
- }>;
57
- 'required-h1': import("packages/@markuplint/ml-core/lib").RuleSeed<boolean, import("./required-h1").Options>;
58
- 'use-list': import("packages/@markuplint/ml-core/lib").RuleSeed<string[], {
59
- spaceNeededBullets?: string[] | undefined;
60
- }>;
61
- 'wai-aria': import("packages/@markuplint/ml-core/lib").RuleSeed<boolean, import("./wai-aria/types").Options>;
1
+ declare const rules: {
2
+ readonly 'attr-duplication': Readonly<
3
+ import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
4
+ >;
5
+ readonly 'attr-value-quotes': Readonly<
6
+ import('@markuplint/ml-core').RuleSeed<import('./attr-value-quotes').Type, undefined>
7
+ >;
8
+ readonly 'case-sensitive-attr-name': Readonly<
9
+ import('@markuplint/ml-core').RuleSeed<import('./case-sensitive-attr-name').Value, undefined>
10
+ >;
11
+ readonly 'case-sensitive-tag-name': Readonly<
12
+ import('@markuplint/ml-core').RuleSeed<import('./case-sensitive-tag-name').Value, undefined>
13
+ >;
14
+ readonly 'character-reference': Readonly<
15
+ import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
16
+ >;
17
+ readonly 'class-naming': Readonly<
18
+ import('@markuplint/ml-core').RuleSeed<import('./class-naming').Value, undefined>
19
+ >;
20
+ readonly 'deprecated-attr': Readonly<
21
+ import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
22
+ >;
23
+ readonly 'deprecated-element': Readonly<
24
+ import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
25
+ >;
26
+ readonly 'disallowed-element': Readonly<import('@markuplint/ml-core').RuleSeed<string[], undefined>>;
27
+ readonly doctype: Readonly<
28
+ import('@markuplint/ml-core').RuleSeed<
29
+ 'always',
30
+ {
31
+ denyObsoleteType: boolean;
32
+ }
33
+ >
34
+ >;
35
+ readonly 'end-tag': Readonly<import('@markuplint/ml-core').RuleSeed<boolean, undefined>>;
36
+ readonly 'id-duplication': Readonly<
37
+ import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
38
+ >;
39
+ readonly 'ineffective-attr': Readonly<
40
+ import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
41
+ >;
42
+ readonly 'invalid-attr': Readonly<
43
+ import('@markuplint/ml-core').RuleSeed<
44
+ boolean,
45
+ {
46
+ allowAttrs?:
47
+ | Record<
48
+ string,
49
+ | {
50
+ enum: [string, ...string[]];
51
+ }
52
+ | {
53
+ pattern: string;
54
+ }
55
+ | {
56
+ type: import('packages/@markuplint/ml-spec/lib').AttributeType;
57
+ }
58
+ >
59
+ | (
60
+ | string
61
+ | {
62
+ name: string;
63
+ value:
64
+ | import('packages/@markuplint/ml-spec/lib').AttributeType
65
+ | (
66
+ | {
67
+ enum: [string, ...string[]];
68
+ }
69
+ | {
70
+ pattern: string;
71
+ }
72
+ | {
73
+ type: import('packages/@markuplint/ml-spec/lib').AttributeType;
74
+ }
75
+ );
76
+ }
77
+ )[]
78
+ | undefined;
79
+ disallowAttrs?:
80
+ | Record<
81
+ string,
82
+ | {
83
+ enum: [string, ...string[]];
84
+ }
85
+ | {
86
+ pattern: string;
87
+ }
88
+ | {
89
+ type: import('packages/@markuplint/ml-spec/lib').AttributeType;
90
+ }
91
+ >
92
+ | (
93
+ | string
94
+ | {
95
+ name: string;
96
+ value:
97
+ | import('packages/@markuplint/ml-spec/lib').AttributeType
98
+ | (
99
+ | {
100
+ enum: [string, ...string[]];
101
+ }
102
+ | {
103
+ pattern: string;
104
+ }
105
+ | {
106
+ type: import('packages/@markuplint/ml-spec/lib').AttributeType;
107
+ }
108
+ );
109
+ }
110
+ )[]
111
+ | undefined;
112
+ ignoreAttrNamePrefix?: string | string[] | undefined;
113
+ allowToAddPropertiesForPretender?: boolean | undefined;
114
+ attrs?:
115
+ | Record<
116
+ string,
117
+ | (
118
+ | {
119
+ enum: [string, ...string[]];
120
+ }
121
+ | {
122
+ pattern: string;
123
+ }
124
+ | {
125
+ type: import('packages/@markuplint/ml-spec/lib').AttributeType;
126
+ }
127
+ )
128
+ | {
129
+ disallowed: true;
130
+ }
131
+ >
132
+ | undefined;
133
+ }
134
+ >
135
+ >;
136
+ readonly 'label-has-control': Readonly<
137
+ import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
138
+ >;
139
+ readonly 'landmark-roles': Readonly<
140
+ import('@markuplint/ml-core').RuleSeed<
141
+ boolean,
142
+ {
143
+ ignoreRoles: (
144
+ | ('banner' | 'main' | 'complementary' | 'contentinfo')
145
+ | 'form'
146
+ | 'navigation'
147
+ | 'region'
148
+ )[];
149
+ labelEachArea: boolean;
150
+ }
151
+ >
152
+ >;
153
+ readonly 'no-boolean-attr-value': Readonly<
154
+ import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
155
+ >;
156
+ readonly 'no-default-value': Readonly<
157
+ import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
158
+ >;
159
+ readonly 'no-empty-palpable-content': Readonly<
160
+ import('@markuplint/ml-core').RuleSeed<
161
+ boolean,
162
+ {
163
+ extendsExposableElements?: boolean | undefined;
164
+ ignoreIfAriaBusy?: boolean | undefined;
165
+ }
166
+ >
167
+ >;
168
+ readonly 'no-hard-code-id': Readonly<
169
+ import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
170
+ >;
171
+ readonly 'no-refer-to-non-existent-id': Readonly<
172
+ import('@markuplint/ml-core').RuleSeed<
173
+ import('@markuplint/ml-core').RuleConfigValue,
174
+ {
175
+ ariaVersion: '1.1' | '1.2' | '1.3';
176
+ fragmentRefersNameAttr: boolean;
177
+ }
178
+ >
179
+ >;
180
+ readonly 'no-use-event-handler-attr': Readonly<
181
+ import('@markuplint/ml-core').RuleSeed<
182
+ boolean,
183
+ {
184
+ ignore?: string | string[] | undefined;
185
+ }
186
+ >
187
+ >;
188
+ readonly 'permitted-contents': Readonly<
189
+ import('@markuplint/ml-core').RuleSeed<
190
+ import('./permitted-contents/types').TagRule[],
191
+ import('./permitted-contents/types').Options
192
+ >
193
+ >;
194
+ readonly 'placeholder-label-option': Readonly<import('@markuplint/ml-core').RuleSeed<boolean, undefined>>;
195
+ readonly 'require-accessible-name': Readonly<
196
+ import('@markuplint/ml-core').RuleSeed<
197
+ boolean,
198
+ {
199
+ ariaVersion: '1.1' | '1.2' | '1.3';
200
+ }
201
+ >
202
+ >;
203
+ readonly 'require-datetime': Readonly<
204
+ import('@markuplint/ml-core').RuleSeed<
205
+ boolean,
206
+ {
207
+ langs?: import('./require-datetime/types').Lang[] | undefined;
208
+ }
209
+ >
210
+ >;
211
+ readonly 'required-attr': Readonly<
212
+ import('@markuplint/ml-core').RuleSeed<
213
+ | string
214
+ | (
215
+ | string
216
+ | {
217
+ name: string;
218
+ value?: string | string[] | undefined;
219
+ }
220
+ )[],
221
+ undefined
222
+ >
223
+ >;
224
+ readonly 'required-element': Readonly<
225
+ import('@markuplint/ml-core').RuleSeed<
226
+ string[],
227
+ {
228
+ ignoreHasMutableContents: boolean;
229
+ }
230
+ >
231
+ >;
232
+ readonly 'required-h1': Readonly<import('@markuplint/ml-core').RuleSeed<boolean, import('./required-h1').Options>>;
233
+ readonly 'use-list': Readonly<
234
+ import('@markuplint/ml-core').RuleSeed<
235
+ readonly string[],
236
+ {
237
+ spaceNeededBullets?: string[] | undefined;
238
+ }
239
+ >
240
+ >;
241
+ readonly 'wai-aria': Readonly<import('@markuplint/ml-core').RuleSeed<boolean, import('./wai-aria/types').Options>>;
62
242
  };
63
- export default _default;
243
+ export default rules;
package/lib/index.js CHANGED
@@ -15,20 +15,24 @@ const end_tag_1 = tslib_1.__importDefault(require("./end-tag"));
15
15
  const id_duplication_1 = tslib_1.__importDefault(require("./id-duplication"));
16
16
  const ineffective_attr_1 = tslib_1.__importDefault(require("./ineffective-attr"));
17
17
  const invalid_attr_1 = tslib_1.__importDefault(require("./invalid-attr"));
18
+ const label_has_control_1 = tslib_1.__importDefault(require("./label-has-control"));
18
19
  const landmark_roles_1 = tslib_1.__importDefault(require("./landmark-roles"));
19
20
  const no_boolean_attr_value_1 = tslib_1.__importDefault(require("./no-boolean-attr-value"));
20
21
  const no_default_value_1 = tslib_1.__importDefault(require("./no-default-value"));
22
+ const no_empty_palpable_content_1 = tslib_1.__importDefault(require("./no-empty-palpable-content"));
21
23
  const no_hard_code_id_1 = tslib_1.__importDefault(require("./no-hard-code-id"));
22
24
  const no_refer_to_non_existent_id_1 = tslib_1.__importDefault(require("./no-refer-to-non-existent-id"));
23
25
  const no_use_event_handler_attr_1 = tslib_1.__importDefault(require("./no-use-event-handler-attr"));
24
26
  const permitted_contents_1 = tslib_1.__importDefault(require("./permitted-contents"));
27
+ const placeholder_label_option_1 = tslib_1.__importDefault(require("./placeholder-label-option"));
25
28
  const require_accessible_name_1 = tslib_1.__importDefault(require("./require-accessible-name"));
29
+ const require_datetime_1 = tslib_1.__importDefault(require("./require-datetime"));
26
30
  const required_attr_1 = tslib_1.__importDefault(require("./required-attr"));
27
31
  const required_element_1 = tslib_1.__importDefault(require("./required-element"));
28
32
  const required_h1_1 = tslib_1.__importDefault(require("./required-h1"));
29
33
  const use_list_1 = tslib_1.__importDefault(require("./use-list"));
30
34
  const wai_aria_1 = tslib_1.__importDefault(require("./wai-aria"));
31
- exports.default = {
35
+ const rules = {
32
36
  'attr-duplication': attr_duplication_1.default,
33
37
  'attr-value-quotes': attr_value_quotes_1.default,
34
38
  'case-sensitive-attr-name': case_sensitive_attr_name_1.default,
@@ -43,17 +47,22 @@ exports.default = {
43
47
  'id-duplication': id_duplication_1.default,
44
48
  'ineffective-attr': ineffective_attr_1.default,
45
49
  'invalid-attr': invalid_attr_1.default,
50
+ 'label-has-control': label_has_control_1.default,
46
51
  'landmark-roles': landmark_roles_1.default,
47
52
  'no-boolean-attr-value': no_boolean_attr_value_1.default,
48
53
  'no-default-value': no_default_value_1.default,
54
+ 'no-empty-palpable-content': no_empty_palpable_content_1.default,
49
55
  'no-hard-code-id': no_hard_code_id_1.default,
50
56
  'no-refer-to-non-existent-id': no_refer_to_non_existent_id_1.default,
51
57
  'no-use-event-handler-attr': no_use_event_handler_attr_1.default,
52
58
  'permitted-contents': permitted_contents_1.default,
59
+ 'placeholder-label-option': placeholder_label_option_1.default,
53
60
  'require-accessible-name': require_accessible_name_1.default,
61
+ 'require-datetime': require_datetime_1.default,
54
62
  'required-attr': required_attr_1.default,
55
63
  'required-element': required_element_1.default,
56
64
  'required-h1': required_h1_1.default,
57
65
  'use-list': use_list_1.default,
58
66
  'wai-aria': wai_aria_1.default,
59
67
  };
68
+ exports.default = rules;