@markuplint/rules 3.15.0 → 4.0.0-alpha.10

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 (178) hide show
  1. package/.eslintrc +5 -0
  2. package/LICENSE +1 -1
  3. package/lib/attr-check.d.ts +8 -19
  4. package/lib/attr-check.js +16 -21
  5. package/lib/attr-duplication/index.d.ts +1 -3
  6. package/lib/attr-duplication/index.js +6 -6
  7. package/lib/attr-value-quotes/index.d.ts +2 -2
  8. package/lib/attr-value-quotes/index.js +8 -10
  9. package/lib/case-sensitive-attr-name/index.d.ts +1 -1
  10. package/lib/case-sensitive-attr-name/index.js +12 -13
  11. package/lib/case-sensitive-tag-name/index.d.ts +1 -1
  12. package/lib/case-sensitive-tag-name/index.js +5 -4
  13. package/lib/character-reference/index.d.ts +1 -1
  14. package/lib/character-reference/index.js +13 -12
  15. package/lib/class-naming/index.d.ts +1 -1
  16. package/lib/class-naming/index.js +14 -13
  17. package/lib/create-message.d.ts +2 -12
  18. package/lib/create-message.js +26 -26
  19. package/lib/debug.js +2 -6
  20. package/lib/deprecated-attr/index.d.ts +1 -3
  21. package/lib/deprecated-attr/index.js +9 -9
  22. package/lib/deprecated-element/index.d.ts +1 -3
  23. package/lib/deprecated-element/index.js +7 -6
  24. package/lib/disallowed-element/index.d.ts +1 -1
  25. package/lib/disallowed-element/index.js +9 -8
  26. package/lib/doctype/index.d.ts +2 -2
  27. package/lib/doctype/index.js +5 -4
  28. package/lib/end-tag/index.d.ts +1 -1
  29. package/lib/end-tag/index.js +8 -8
  30. package/lib/helpers.d.ts +17 -35
  31. package/lib/helpers.js +25 -32
  32. package/lib/id-duplication/index.d.ts +1 -3
  33. package/lib/id-duplication/index.js +5 -4
  34. package/lib/index.d.ts +21 -17
  35. package/lib/index.js +63 -66
  36. package/lib/ineffective-attr/index.d.ts +1 -3
  37. package/lib/ineffective-attr/index.js +8 -7
  38. package/lib/invalid-attr/index.d.ts +31 -38
  39. package/lib/invalid-attr/index.js +33 -33
  40. package/lib/label-has-control/index.d.ts +1 -3
  41. package/lib/label-has-control/index.js +5 -4
  42. package/lib/landmark-roles/index.d.ts +3 -3
  43. package/lib/landmark-roles/index.js +16 -18
  44. package/lib/no-boolean-attr-value/index.d.ts +1 -3
  45. package/lib/no-boolean-attr-value/index.js +9 -9
  46. package/lib/no-default-value/index.d.ts +1 -3
  47. package/lib/no-default-value/index.js +12 -12
  48. package/lib/no-empty-palpable-content/index.d.ts +3 -3
  49. package/lib/no-empty-palpable-content/index.js +9 -8
  50. package/lib/no-hard-code-id/index.d.ts +1 -3
  51. package/lib/no-hard-code-id/index.js +5 -4
  52. package/lib/no-refer-to-non-existent-id/index.d.ts +1 -1
  53. package/lib/no-refer-to-non-existent-id/index.js +37 -38
  54. package/lib/no-use-event-handler-attr/index.d.ts +2 -2
  55. package/lib/no-use-event-handler-attr/index.js +7 -6
  56. package/lib/permitted-contents/choice.d.ts +2 -8
  57. package/lib/permitted-contents/choice.js +14 -19
  58. package/lib/permitted-contents/complex-branch.d.ts +2 -8
  59. package/lib/permitted-contents/complex-branch.js +10 -14
  60. package/lib/permitted-contents/content-model.d.ts +1 -1
  61. package/lib/permitted-contents/content-model.js +10 -11
  62. package/lib/permitted-contents/count-pattern.d.ts +3 -18
  63. package/lib/permitted-contents/count-pattern.js +19 -24
  64. package/lib/permitted-contents/debug.browser.d.ts +16 -16
  65. package/lib/permitted-contents/debug.browser.js +9 -12
  66. package/lib/permitted-contents/debug.d.ts +10 -3
  67. package/lib/permitted-contents/debug.js +12 -13
  68. package/lib/permitted-contents/index.d.ts +2 -2
  69. package/lib/permitted-contents/index.js +13 -13
  70. package/lib/permitted-contents/matches-selector.d.ts +2 -7
  71. package/lib/permitted-contents/matches-selector.js +13 -18
  72. package/lib/permitted-contents/order.d.ts +2 -8
  73. package/lib/permitted-contents/order.js +19 -24
  74. package/lib/permitted-contents/recursive-branch.d.ts +3 -9
  75. package/lib/permitted-contents/recursive-branch.js +9 -13
  76. package/lib/permitted-contents/represent-transparent-nodes.d.ts +4 -8
  77. package/lib/permitted-contents/represent-transparent-nodes.js +15 -20
  78. package/lib/permitted-contents/start.d.ts +2 -7
  79. package/lib/permitted-contents/start.js +13 -21
  80. package/lib/permitted-contents/transparent.d.ts +1 -1
  81. package/lib/permitted-contents/transparent.js +6 -11
  82. package/lib/permitted-contents/types.d.ts +29 -29
  83. package/lib/permitted-contents/types.js +1 -2
  84. package/lib/permitted-contents/utils.d.ts +42 -79
  85. package/lib/permitted-contents/utils.js +72 -82
  86. package/lib/placeholder-label-option/index.d.ts +1 -1
  87. package/lib/placeholder-label-option/index.js +12 -13
  88. package/lib/require-accessible-name/index.d.ts +2 -2
  89. package/lib/require-accessible-name/index.js +12 -15
  90. package/lib/require-datetime/index.d.ts +3 -3
  91. package/lib/require-datetime/index.js +14 -13
  92. package/lib/require-datetime/types.d.ts +2 -2
  93. package/lib/require-datetime/types.js +1 -2
  94. package/lib/require-datetime/utils.d.ts +1 -1
  95. package/lib/require-datetime/utils.js +5 -12
  96. package/lib/required-attr/index.d.ts +3 -3
  97. package/lib/required-attr/index.js +11 -11
  98. package/lib/required-element/index.d.ts +2 -2
  99. package/lib/required-element/index.js +7 -7
  100. package/lib/required-h1/index.d.ts +3 -3
  101. package/lib/required-h1/index.js +6 -6
  102. package/lib/use-list/index.d.ts +6 -2
  103. package/lib/use-list/index.js +27 -11
  104. package/lib/wai-aria/checkings/abstract-role.d.ts +1 -1
  105. package/lib/wai-aria/checkings/abstract-role.js +5 -10
  106. package/lib/wai-aria/checkings/default-value.d.ts +4 -8
  107. package/lib/wai-aria/checkings/default-value.js +2 -6
  108. package/lib/wai-aria/checkings/deprecated-props.d.ts +5 -9
  109. package/lib/wai-aria/checkings/deprecated-props.js +3 -8
  110. package/lib/wai-aria/checkings/disallowed-prop.d.ts +5 -9
  111. package/lib/wai-aria/checkings/disallowed-prop.js +7 -12
  112. package/lib/wai-aria/checkings/implicit-props.d.ts +5 -9
  113. package/lib/wai-aria/checkings/implicit-props.js +12 -17
  114. package/lib/wai-aria/checkings/implicit-role.d.ts +1 -1
  115. package/lib/wai-aria/checkings/implicit-role.js +4 -9
  116. package/lib/wai-aria/checkings/interaction-in-hidden.d.ts +1 -1
  117. package/lib/wai-aria/checkings/interaction-in-hidden.js +4 -8
  118. package/lib/wai-aria/checkings/no-global-prop.d.ts +4 -8
  119. package/lib/wai-aria/checkings/no-global-prop.js +2 -7
  120. package/lib/wai-aria/checkings/non-existent-role.d.ts +1 -1
  121. package/lib/wai-aria/checkings/non-existent-role.js +4 -9
  122. package/lib/wai-aria/checkings/permitted-roles.d.ts +1 -1
  123. package/lib/wai-aria/checkings/permitted-roles.js +4 -9
  124. package/lib/wai-aria/checkings/presentational-children.d.ts +1 -1
  125. package/lib/wai-aria/checkings/presentational-children.js +5 -10
  126. package/lib/wai-aria/checkings/required-owned-elements.d.ts +4 -8
  127. package/lib/wai-aria/checkings/required-owned-elements.js +7 -11
  128. package/lib/wai-aria/checkings/required-prop.d.ts +7 -13
  129. package/lib/wai-aria/checkings/required-prop.js +2 -7
  130. package/lib/wai-aria/checkings/value.d.ts +7 -16
  131. package/lib/wai-aria/checkings/value.js +7 -13
  132. package/lib/wai-aria/index.d.ts +2 -2
  133. package/lib/wai-aria/index.js +41 -40
  134. package/lib/wai-aria/types.d.ts +10 -10
  135. package/lib/wai-aria/types.js +1 -2
  136. package/package.json +17 -13
  137. package/test/attr-check.spec.js +0 -77
  138. package/test/attr-duplication/index.spec.js +0 -159
  139. package/test/attr-value-quotes/index.spec.js +0 -133
  140. package/test/case-sensitive-attr-name/index.spec.js +0 -65
  141. package/test/case-sensitive-tag-name/index.spec.js +0 -80
  142. package/test/character-reference/index.spec.js +0 -72
  143. package/test/class-naming/index.spec.js +0 -470
  144. package/test/create-message.spec.js +0 -497
  145. package/test/deprecated-attr/index.spec.js +0 -48
  146. package/test/deprecated-element/index.spec.js +0 -35
  147. package/test/disallowed-element/index.spec.js +0 -90
  148. package/test/doctype/index.spec.js +0 -50
  149. package/test/end-tag/index.spec.js +0 -162
  150. package/test/id-duplication/index.spec.js +0 -47
  151. package/test/ineffective-attr/index.spec.js +0 -31
  152. package/test/invalid-attr/index.spec.js +0 -1631
  153. package/test/label-has-control/index.spec.js +0 -29
  154. package/test/landmark-roles/index.spec.js +0 -187
  155. package/test/no-boolean-attr-value/index.spec.js +0 -41
  156. package/test/no-default-value/index.spec.js +0 -74
  157. package/test/no-empty-palpable-content/index.spec.js +0 -115
  158. package/test/no-hard-code-id/index.spec.js +0 -100
  159. package/test/no-refer-to-non-existent-id/index.spec.js +0 -254
  160. package/test/no-use-event-handler-attr/index.spec.js +0 -57
  161. package/test/permitted-contents/choice.spec.js +0 -174
  162. package/test/permitted-contents/count-pattern.spec.js +0 -308
  163. package/test/permitted-contents/index.spec.js +0 -1395
  164. package/test/permitted-contents/matches-selector.spec.js +0 -59
  165. package/test/permitted-contents/order.spec.js +0 -351
  166. package/test/permitted-contents/recursive-branch.spec.js +0 -41
  167. package/test/permitted-contents/represent-transparent-nodes.spec.js +0 -24
  168. package/test/permitted-contents/start.spec.js +0 -67
  169. package/test/placeholder-label-option/index.spec.js +0 -113
  170. package/test/require-accessible-name/index.spec.js +0 -444
  171. package/test/require-datetime/index.spec.js +0 -54
  172. package/test/require-datetime/utils.spec.js +0 -52
  173. package/test/required-attr/index.spec.js +0 -414
  174. package/test/required-element/index.spec.js +0 -188
  175. package/test/required-h1/index.spec.js +0 -69
  176. package/test/use-list/index.spec.js +0 -109
  177. package/test/wai-aria/checkings/value.spec.js +0 -33
  178. package/test/wai-aria/index.spec.js +0 -1203
@@ -4,49 +4,49 @@ import type { ReadonlyDeep } from 'type-fest';
4
4
  export type Element = _Element<TagRule[], Options>;
5
5
  export type ChildNode = _ChildNode<TagRule[], Options>;
6
6
  export type Specs = {
7
- readonly cites: MLMLSpec['cites'];
8
- readonly def: MLMLSpec['def'];
9
- readonly specs: readonly {
10
- readonly name: string;
11
- readonly contentModel: {
12
- readonly contents: MLMLSpec['specs'][0]['contentModel']['contents'];
13
- };
14
- }[];
7
+ readonly cites: MLMLSpec['cites'];
8
+ readonly def: MLMLSpec['def'];
9
+ readonly specs: readonly {
10
+ readonly name: string;
11
+ readonly contentModel: {
12
+ readonly contents: MLMLSpec['specs'][0]['contentModel']['contents'];
13
+ };
14
+ }[];
15
15
  };
16
16
  export type ContentModelResult = {
17
- type: MatchedReason | UnmatchedReason;
18
- scope: ChildNode;
19
- query: Result['query'];
20
- hint: Result['hint'];
17
+ type: MatchedReason | UnmatchedReason;
18
+ scope: ChildNode;
19
+ query: Result['query'];
20
+ hint: Result['hint'];
21
21
  };
22
22
  export type Result<T extends string = MatchedReason> = {
23
- type: MatchedReason | UnmatchedReason | T;
24
- matched: ChildNode[];
25
- unmatched: ChildNode[];
26
- zeroMatch: boolean;
27
- query: string;
28
- hint: Hints;
23
+ type: MatchedReason | UnmatchedReason | T;
24
+ matched: ChildNode[];
25
+ unmatched: ChildNode[];
26
+ zeroMatch: boolean;
27
+ query: string;
28
+ hint: Hints;
29
29
  };
30
30
  export type Hints = {
31
- max?: number;
32
- not?: ChildNode;
33
- transparent?: Element;
34
- missing?: {
35
- barelyMatchedElements?: number;
36
- need?: string;
37
- };
31
+ max?: number;
32
+ not?: ChildNode;
33
+ transparent?: Element;
34
+ missing?: {
35
+ barelyMatchedElements?: number;
36
+ need?: string;
37
+ };
38
38
  };
39
39
  export type MatchedReason = 'MATCHED' | 'MATCHED_ZERO';
40
40
  export type UnmatchedReason = 'NOTHING' | 'UNEXPECTED_EXTRA_NODE' | 'TRANSPARENT_MODEL_DISALLOWS' | MissingNodeReason;
41
41
  export type MissingNodeReason = 'MISSING_NODE_REQUIRED' | 'MISSING_NODE_ONE_OR_MORE';
42
42
  export type RepeatSign = '' | '?' | '+' | '*' | `{${number},${number}}`;
43
43
  export type TransparentModel = {
44
- el: Element;
45
- additionalCondition: string;
44
+ el: Element;
45
+ additionalCondition: string;
46
46
  };
47
47
  export type TagRule = {
48
- readonly tag: string;
48
+ readonly tag: string;
49
49
  } & ReadonlyDeep<ContentModel>;
50
50
  export type Options = {
51
- readonly ignoreHasMutableChildren: boolean;
51
+ readonly ignoreHasMutableChildren: boolean;
52
52
  };
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,88 +1,51 @@
1
- import type { ChildNode, Element, Hints, MissingNodeReason, RepeatSign, Specs } from './types';
2
- import type {
3
- PermittedContentPattern,
4
- PermittedContentChoice,
5
- PermittedContentOneOrMore,
6
- PermittedContentOptional,
7
- PermittedContentRequire,
8
- PermittedContentTransparent,
9
- PermittedContentZeroOrMore,
10
- Model,
11
- } from '@markuplint/ml-spec';
1
+ import type { ChildNode, Element, Hints, MissingNodeReason, RepeatSign, Specs } from './types.js';
2
+ import type { PermittedContentPattern, PermittedContentChoice, PermittedContentOneOrMore, PermittedContentOptional, PermittedContentRequire, PermittedContentTransparent, PermittedContentZeroOrMore, Model } from '@markuplint/ml-spec';
12
3
  import type { ReadonlyDeep } from 'type-fest';
13
4
  export declare function getChildNodesWithoutWhitespaces(el: Element): ChildNode[];
14
5
  export declare function isModel(model: ReadonlyDeep<Model | PermittedContentPattern[]>): model is ReadonlyDeep<Model>;
15
- export declare function matches(
16
- selector: string,
17
- node: ChildNode,
18
- specs: Specs,
19
- ):
20
- | {
21
- matched: boolean;
22
- not?: undefined;
23
- }
24
- | {
25
- matched: boolean;
26
- not: ChildNode | undefined;
27
- };
28
- export declare function isRequire(
29
- content: ReadonlyDeep<PermittedContentPattern>,
30
- ): content is ReadonlyDeep<PermittedContentRequire>;
31
- export declare function isOptional(
32
- content: ReadonlyDeep<PermittedContentPattern>,
33
- ): content is ReadonlyDeep<PermittedContentOptional>;
34
- export declare function isOneOrMore(
35
- content: ReadonlyDeep<PermittedContentPattern>,
36
- ): content is ReadonlyDeep<PermittedContentOneOrMore>;
37
- export declare function isZeroOrMore(
38
- content: ReadonlyDeep<PermittedContentPattern>,
39
- ): content is ReadonlyDeep<PermittedContentZeroOrMore>;
40
- export declare function isChoice(
41
- content: ReadonlyDeep<PermittedContentPattern>,
42
- ): content is ReadonlyDeep<PermittedContentChoice>;
43
- export declare function isTransparent(
44
- content: ReadonlyDeep<PermittedContentPattern>,
45
- ): content is ReadonlyDeep<PermittedContentTransparent>;
46
- export declare function normalizeModel(
47
- pattern:
48
- | ReadonlyDeep<PermittedContentRequire>
49
- | ReadonlyDeep<PermittedContentOptional>
50
- | ReadonlyDeep<PermittedContentOneOrMore>
51
- | ReadonlyDeep<PermittedContentZeroOrMore>,
52
- ): {
53
- model: ReadonlyDeep<PermittedContentPattern[] | Model>;
54
- min: number;
55
- max: number;
56
- repeat: RepeatSign;
57
- missingType: MissingNodeReason | undefined;
6
+ export declare function matches(selector: string, node: ChildNode, specs: Specs): {
7
+ matched: boolean;
8
+ not?: undefined;
9
+ } | {
10
+ matched: boolean;
11
+ not: ChildNode | undefined;
58
12
  };
59
- export declare function mergeHints(
60
- a: Readonly<Hints>,
61
- b: Readonly<Hints>,
62
- ): Partial<{
63
- missing:
64
- | Partial<{
65
- barelyMatchedElements?: number | undefined;
66
- need?: string | undefined;
67
- }>
68
- | undefined;
69
- max?: number | undefined;
70
- not?: ChildNode | undefined;
71
- transparent?: Element | undefined;
13
+ export declare function isRequire(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentRequire>;
14
+ export declare function isOptional(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentOptional>;
15
+ export declare function isOneOrMore(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentOneOrMore>;
16
+ export declare function isZeroOrMore(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentZeroOrMore>;
17
+ export declare function isChoice(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentChoice>;
18
+ export declare function isTransparent(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentTransparent>;
19
+ export declare function normalizeModel(pattern: ReadonlyDeep<PermittedContentRequire> | ReadonlyDeep<PermittedContentOptional> | ReadonlyDeep<PermittedContentOneOrMore> | ReadonlyDeep<PermittedContentZeroOrMore>): {
20
+ model: ReadonlyDeep<PermittedContentPattern[] | Model>;
21
+ min: number;
22
+ max: number;
23
+ repeat: RepeatSign;
24
+ missingType: MissingNodeReason | undefined;
25
+ };
26
+ export declare function mergeHints(a: Readonly<Hints>, b: Readonly<Hints>): Partial<{
27
+ missing: Partial<{
28
+ barelyMatchedElements?: number | undefined;
29
+ need?: string | undefined;
30
+ }> | undefined;
31
+ max?: number | undefined;
32
+ not?: ChildNode | undefined;
33
+ transparent?: Element | undefined;
72
34
  }>;
73
35
  export declare function cleanObject<T extends Object>(object: T): Partial<T>;
74
36
  export declare class Collection {
75
- #private;
76
- constructor(origin: readonly ChildNode[]);
77
- get matched(): ChildNode[];
78
- get matchedCount(): number;
79
- get nodes(): ChildNode[];
80
- get unmatched(): ChildNode[];
81
- addMatched(nodes: ChildNode[]): boolean;
82
- back(): void;
83
- lock(): void;
84
- max(max: number): void;
85
- toString(highlightExtraNodes?: boolean): string;
37
+ #private;
38
+ constructor(origin: readonly ChildNode[]);
39
+ get matched(): ChildNode[];
40
+ get matchedCount(): number;
41
+ get nodes(): ChildNode[];
42
+ get unmatched(): ChildNode[];
43
+ addMatched(nodes: ChildNode[]): boolean;
44
+ back(): void;
45
+ lock(): void;
46
+ max(max: number): void;
47
+ toString(highlightExtraNodes?: boolean): string;
48
+ }
49
+ export declare class UnsupportedError extends Error {
86
50
  }
87
- export declare class UnsupportedError extends Error {}
88
51
  export declare function modelLog(model: ReadonlyDeep<Model | PermittedContentPattern[]>, repeat: RepeatSign): string;
@@ -1,27 +1,33 @@
1
- "use strict";
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
2
12
  var _Collection_locked, _Collection_matched, _Collection_nodes, _Collection_origin;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.modelLog = exports.UnsupportedError = exports.Collection = exports.cleanObject = exports.mergeHints = exports.normalizeModel = exports.isTransparent = exports.isChoice = exports.isZeroOrMore = exports.isOneOrMore = exports.isOptional = exports.isRequire = exports.matches = exports.isModel = exports.getChildNodesWithoutWhitespaces = void 0;
5
- const tslib_1 = require("tslib");
6
- const selector_1 = require("@markuplint/selector");
7
- const debug_1 = require("./debug");
8
- const represent_transparent_nodes_1 = require("./represent-transparent-nodes");
13
+ import { createSelector } from '@markuplint/selector';
14
+ import { bgGreen, green, bgRed, bgBlue, blue, bgMagenta, cyan } from './debug.js';
15
+ import { transparentMode } from './represent-transparent-nodes.js';
9
16
  const getChildNodesWithoutWhitespacesCaches = new Map();
10
- function getChildNodesWithoutWhitespaces(
17
+ export function getChildNodesWithoutWhitespaces(
11
18
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
12
19
  el) {
13
20
  let nodes = getChildNodesWithoutWhitespacesCaches.get(el);
14
21
  if (nodes) {
15
22
  return nodes;
16
23
  }
17
- nodes = Array.from(el.childNodes).filter(node => {
24
+ nodes = [...el.childNodes].filter(node => {
18
25
  return !(node.is(node.TEXT_NODE) && node.isWhitespace());
19
26
  });
20
27
  getChildNodesWithoutWhitespacesCaches.set(el, nodes);
21
28
  return nodes;
22
29
  }
23
- exports.getChildNodesWithoutWhitespaces = getChildNodesWithoutWhitespaces;
24
- function isModel(model) {
30
+ export function isModel(model) {
25
31
  if (typeof model === 'string') {
26
32
  return true;
27
33
  }
@@ -37,11 +43,10 @@ function isModel(model) {
37
43
  }
38
44
  return modelMode;
39
45
  }
40
- exports.isModel = isModel;
41
- function matches(selector,
46
+ export function matches(selector,
42
47
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
43
48
  node, specs) {
44
- const selectorResult = (0, selector_1.createSelector)(selector, specs).search(node);
49
+ const selectorResult = createSelector(selector, specs).search(node);
45
50
  const matched = selectorResult.filter((r) => r.matched);
46
51
  if (matched.length > 0) {
47
52
  return {
@@ -49,21 +54,18 @@ node, specs) {
49
54
  };
50
55
  }
51
56
  const not = selectorResult
52
- .map(r => { var _a; return (r.matched ? [] : (_a = r.not) !== null && _a !== void 0 ? _a : []); })
53
- .flat()
54
- .map(descendants)
55
- .flat()
57
+ .flatMap(r => (r.matched ? [] : r.not ?? []))
58
+ .flatMap(descendants)
56
59
  .shift();
57
60
  return {
58
61
  matched: false,
59
62
  not,
60
63
  };
61
64
  }
62
- exports.matches = matches;
63
65
  function descendants(
64
66
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
65
67
  selectorResult) {
66
- let nodes = selectorResult.nodes.slice();
68
+ let nodes = [...selectorResult.nodes];
67
69
  while (selectorResult.has.length > 0) {
68
70
  for (const dep of selectorResult.has) {
69
71
  if (dep.has.length === 0) {
@@ -77,32 +79,25 @@ selectorResult) {
77
79
  }
78
80
  return nodes;
79
81
  }
80
- function isRequire(content) {
82
+ export function isRequire(content) {
81
83
  return 'require' in content;
82
84
  }
83
- exports.isRequire = isRequire;
84
- function isOptional(content) {
85
+ export function isOptional(content) {
85
86
  return 'optional' in content;
86
87
  }
87
- exports.isOptional = isOptional;
88
- function isOneOrMore(content) {
88
+ export function isOneOrMore(content) {
89
89
  return 'oneOrMore' in content;
90
90
  }
91
- exports.isOneOrMore = isOneOrMore;
92
- function isZeroOrMore(content) {
91
+ export function isZeroOrMore(content) {
93
92
  return 'zeroOrMore' in content;
94
93
  }
95
- exports.isZeroOrMore = isZeroOrMore;
96
- function isChoice(content) {
94
+ export function isChoice(content) {
97
95
  return 'choice' in content;
98
96
  }
99
- exports.isChoice = isChoice;
100
- function isTransparent(content) {
97
+ export function isTransparent(content) {
101
98
  return 'transparent' in content;
102
99
  }
103
- exports.isTransparent = isTransparent;
104
- function normalizeModel(pattern) {
105
- var _a, _b, _c, _d, _e;
100
+ export function normalizeModel(pattern) {
106
101
  let model;
107
102
  let min;
108
103
  let max;
@@ -110,25 +105,25 @@ function normalizeModel(pattern) {
110
105
  let missingType;
111
106
  if (isRequire(pattern)) {
112
107
  model = pattern.require;
113
- min = (_a = pattern.min) !== null && _a !== void 0 ? _a : 1;
114
- max = Math.max((_b = pattern.max) !== null && _b !== void 0 ? _b : 1, min);
108
+ min = pattern.min ?? 1;
109
+ max = Math.max(pattern.max ?? 1, min);
115
110
  missingType = 'MISSING_NODE_REQUIRED';
116
111
  }
117
112
  else if (isOptional(pattern)) {
118
113
  model = pattern.optional;
119
114
  min = 0;
120
- max = Math.max((_c = pattern.max) !== null && _c !== void 0 ? _c : 1, 1);
115
+ max = Math.max(pattern.max ?? 1, 1);
121
116
  }
122
117
  else if (isOneOrMore(pattern)) {
123
118
  model = pattern.oneOrMore;
124
119
  min = 1;
125
- max = Math.max((_d = pattern.max) !== null && _d !== void 0 ? _d : Infinity, 1);
120
+ max = Math.max(pattern.max ?? Number.POSITIVE_INFINITY, 1);
126
121
  missingType = 'MISSING_NODE_ONE_OR_MORE';
127
122
  }
128
123
  else if (isZeroOrMore(pattern)) {
129
124
  model = pattern.zeroOrMore;
130
125
  min = 0;
131
- max = Math.max((_e = pattern.max) !== null && _e !== void 0 ? _e : Infinity, 1);
126
+ max = Math.max(pattern.max ?? Number.POSITIVE_INFINITY, 1);
132
127
  }
133
128
  else {
134
129
  throw new Error('Unreachable code');
@@ -156,31 +151,28 @@ function normalizeModel(pattern) {
156
151
  missingType,
157
152
  };
158
153
  }
159
- exports.normalizeModel = normalizeModel;
160
- function mergeHints(
154
+ export function mergeHints(
161
155
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
162
156
  a,
163
157
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
164
158
  b) {
165
- const missing = [a.missing, b.missing].sort((a, b) => { var _a, _b; return ((_a = b === null || b === void 0 ? void 0 : b.barelyMatchedElements) !== null && _a !== void 0 ? _a : 0) - ((_b = a === null || a === void 0 ? void 0 : a.barelyMatchedElements) !== null && _b !== void 0 ? _b : 0); })[0];
159
+ const missing = [a.missing, b.missing].sort((a, b) => (b?.barelyMatchedElements ?? 0) - (a?.barelyMatchedElements ?? 0))[0];
166
160
  return cleanObject({
167
161
  ...a,
168
162
  ...b,
169
163
  missing: missing && cleanObject(missing),
170
164
  });
171
165
  }
172
- exports.mergeHints = mergeHints;
173
- function cleanObject(object) {
166
+ export function cleanObject(object) {
174
167
  const newObject = {};
175
- Object.entries(object).forEach(([key, value]) => {
168
+ for (const [key, value] of Object.entries(object)) {
176
169
  if (value !== undefined) {
177
170
  newObject[key] = value;
178
171
  }
179
- });
172
+ }
180
173
  return newObject;
181
174
  }
182
- exports.cleanObject = cleanObject;
183
- class Collection {
175
+ export class Collection {
184
176
  constructor(
185
177
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
186
178
  origin) {
@@ -188,76 +180,77 @@ class Collection {
188
180
  _Collection_matched.set(this, new Set());
189
181
  _Collection_nodes.set(this, void 0);
190
182
  _Collection_origin.set(this, void 0);
191
- tslib_1.__classPrivateFieldSet(this, _Collection_origin, origin.slice(), "f");
192
- tslib_1.__classPrivateFieldSet(this, _Collection_nodes, new Set(tslib_1.__classPrivateFieldGet(this, _Collection_origin, "f")), "f");
183
+ __classPrivateFieldSet(this, _Collection_origin, [...origin], "f");
184
+ __classPrivateFieldSet(this, _Collection_nodes, new Set(__classPrivateFieldGet(this, _Collection_origin, "f")), "f");
193
185
  }
194
186
  get matched() {
195
- return Array.from(tslib_1.__classPrivateFieldGet(this, _Collection_matched, "f"));
187
+ return [...__classPrivateFieldGet(this, _Collection_matched, "f")];
196
188
  }
197
189
  get matchedCount() {
198
- return tslib_1.__classPrivateFieldGet(this, _Collection_matched, "f").size;
190
+ return __classPrivateFieldGet(this, _Collection_matched, "f").size;
199
191
  }
200
192
  get nodes() {
201
- return tslib_1.__classPrivateFieldGet(this, _Collection_origin, "f").slice();
193
+ return [...__classPrivateFieldGet(this, _Collection_origin, "f")];
202
194
  }
203
195
  get unmatched() {
204
- return Array.from(tslib_1.__classPrivateFieldGet(this, _Collection_nodes, "f")).filter(n => !tslib_1.__classPrivateFieldGet(this, _Collection_matched, "f").has(n));
196
+ return [...__classPrivateFieldGet(this, _Collection_nodes, "f")].filter(n => !__classPrivateFieldGet(this, _Collection_matched, "f").has(n));
205
197
  }
206
198
  addMatched(
207
199
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
208
200
  nodes) {
209
- const i = tslib_1.__classPrivateFieldGet(this, _Collection_matched, "f").size;
201
+ const i = __classPrivateFieldGet(this, _Collection_matched, "f").size;
210
202
  for (const node of nodes) {
211
- if (!tslib_1.__classPrivateFieldGet(this, _Collection_nodes, "f").has(node)) {
203
+ if (!__classPrivateFieldGet(this, _Collection_nodes, "f").has(node)) {
212
204
  throw new ReferenceError(`External Node: ${node.nodeName}`);
213
205
  }
214
- tslib_1.__classPrivateFieldGet(this, _Collection_matched, "f").add(node);
206
+ __classPrivateFieldGet(this, _Collection_matched, "f").add(node);
215
207
  }
216
- return i < tslib_1.__classPrivateFieldGet(this, _Collection_matched, "f").size;
208
+ return i < __classPrivateFieldGet(this, _Collection_matched, "f").size;
217
209
  }
218
210
  back() {
219
- tslib_1.__classPrivateFieldSet(this, _Collection_matched, new Set(tslib_1.__classPrivateFieldGet(this, _Collection_locked, "f")), "f");
211
+ __classPrivateFieldSet(this, _Collection_matched, new Set(__classPrivateFieldGet(this, _Collection_locked, "f")), "f");
220
212
  }
221
213
  lock() {
222
- tslib_1.__classPrivateFieldSet(this, _Collection_locked, new Set(tslib_1.__classPrivateFieldGet(this, _Collection_matched, "f")), "f");
214
+ __classPrivateFieldSet(this, _Collection_locked, new Set(__classPrivateFieldGet(this, _Collection_matched, "f")), "f");
223
215
  }
224
216
  max(max) {
225
- const sliced = Array.from(tslib_1.__classPrivateFieldGet(this, _Collection_matched, "f")).slice(max);
226
- sliced.forEach(n => tslib_1.__classPrivateFieldGet(this, _Collection_matched, "f").delete(n));
217
+ const sliced = [...__classPrivateFieldGet(this, _Collection_matched, "f")].slice(max);
218
+ for (const n of sliced)
219
+ __classPrivateFieldGet(this, _Collection_matched, "f").delete(n);
227
220
  }
228
221
  toString(highlightExtraNodes = false) {
229
222
  const out = [];
230
- for (const n of tslib_1.__classPrivateFieldGet(this, _Collection_origin, "f")) {
231
- const raw = n.is(n.TEXT_NODE) ? `:text(${n.raw.replace(/\n/g, '\\n')})` : n.raw;
232
- if (tslib_1.__classPrivateFieldGet(this, _Collection_locked, "f").has(n)) {
233
- if (represent_transparent_nodes_1.transparentMode.has(n)) {
234
- out.push(debug_1.bgBlue.bold(raw));
223
+ for (const n of __classPrivateFieldGet(this, _Collection_origin, "f")) {
224
+ const raw = n.is(n.TEXT_NODE) ? `:text(${n.raw.replaceAll('\n', '\\n')})` : n.raw;
225
+ if (__classPrivateFieldGet(this, _Collection_locked, "f").has(n)) {
226
+ if (transparentMode.has(n)) {
227
+ out.push(bgBlue.bold(raw));
235
228
  }
236
229
  else {
237
- out.push(debug_1.bgGreen.bold(raw));
230
+ out.push(bgGreen.bold(raw));
238
231
  }
239
232
  continue;
240
233
  }
241
- if (tslib_1.__classPrivateFieldGet(this, _Collection_matched, "f").has(n)) {
242
- if (represent_transparent_nodes_1.transparentMode.has(n)) {
243
- out.push(debug_1.blue.bold(raw));
234
+ if (__classPrivateFieldGet(this, _Collection_matched, "f").has(n)) {
235
+ if (transparentMode.has(n)) {
236
+ out.push(blue.bold(raw));
244
237
  }
245
238
  else {
246
- out.push(debug_1.green.bold(raw));
239
+ out.push(green.bold(raw));
247
240
  }
248
241
  continue;
249
242
  }
250
243
  if (highlightExtraNodes) {
251
- if (represent_transparent_nodes_1.transparentMode.has(n)) {
252
- out.push(debug_1.bgMagenta.bold(raw));
244
+ if (transparentMode.has(n)) {
245
+ out.push(bgMagenta.bold(raw));
253
246
  }
254
247
  else {
255
- out.push(debug_1.bgRed.bold(raw));
248
+ out.push(bgRed.bold(raw));
256
249
  }
257
250
  continue;
258
251
  }
259
- if (represent_transparent_nodes_1.transparentMode.has(n)) {
260
- out.push((0, debug_1.cyan)(raw));
252
+ if (transparentMode.has(n)) {
253
+ out.push(cyan(raw));
261
254
  }
262
255
  else {
263
256
  out.push(raw);
@@ -266,12 +259,10 @@ class Collection {
266
259
  return `[ ${out.join(', ')} ]`;
267
260
  }
268
261
  }
269
- exports.Collection = Collection;
270
262
  _Collection_locked = new WeakMap(), _Collection_matched = new WeakMap(), _Collection_nodes = new WeakMap(), _Collection_origin = new WeakMap();
271
- class UnsupportedError extends Error {
263
+ export class UnsupportedError extends Error {
272
264
  }
273
- exports.UnsupportedError = UnsupportedError;
274
- function modelLog(model, repeat) {
265
+ export function modelLog(model, repeat) {
275
266
  if (!isModel(model)) {
276
267
  return orderLog(model, repeat);
277
268
  }
@@ -280,7 +271,6 @@ function modelLog(model, repeat) {
280
271
  }
281
272
  return `(<${model.join('>|<')}>)${repeat}`;
282
273
  }
283
- exports.modelLog = modelLog;
284
274
  function orderLog(order, repeat) {
285
275
  return order.length === 1 && order[0]
286
276
  ? markRepeat(patternLog(order[0]), repeat)
@@ -1,2 +1,2 @@
1
- declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<boolean, undefined>>;
1
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<boolean, undefined>>;
2
2
  export default _default;
@@ -1,20 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ml_core_1 = require("@markuplint/ml-core");
4
- exports.default = (0, ml_core_1.createRule)({
1
+ import { createRule } from '@markuplint/ml-core';
2
+ export default createRule({
3
+ meta: {
4
+ category: 'validation',
5
+ },
5
6
  verify({ document, report, t }) {
6
- document.querySelectorAll('select').forEach(select => {
7
+ for (const select of document.querySelectorAll('select')) {
7
8
  if (hasPlaceholderLabelOption(select)) {
8
- return;
9
+ continue;
9
10
  }
10
11
  if (!needPlaceholderLabelOption(select)) {
11
- return;
12
+ continue;
12
13
  }
13
14
  report({
14
15
  scope: select,
15
16
  message: t('need {0}', t('the {0}', 'placeholder label option')),
16
17
  });
17
- });
18
+ }
18
19
  },
19
20
  });
20
21
  /**
@@ -29,7 +30,6 @@ exports.default = (0, ml_core_1.createRule)({
29
30
  function needPlaceholderLabelOption(
30
31
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
31
32
  select) {
32
- var _a;
33
33
  const hasRequired = select.hasAttribute('required');
34
34
  if (!hasRequired) {
35
35
  return false;
@@ -38,7 +38,7 @@ select) {
38
38
  if (hasMultiple) {
39
39
  return false;
40
40
  }
41
- const size = (_a = select.getAttribute('size')) !== null && _a !== void 0 ? _a : '1';
41
+ const size = select.getAttribute('size') ?? '1';
42
42
  if (size !== '1') {
43
43
  return false;
44
44
  }
@@ -59,7 +59,6 @@ select) {
59
59
  function hasPlaceholderLabelOption(
60
60
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
61
61
  select) {
62
- var _a, _b;
63
62
  // > has a required attribute specified
64
63
  if (!select.hasAttribute('required')) {
65
64
  return false;
@@ -69,7 +68,7 @@ select) {
69
68
  return false;
70
69
  }
71
70
  // > has a display size of 1
72
- const size = (_a = select.getAttribute('size')) !== null && _a !== void 0 ? _a : '1';
71
+ const size = select.getAttribute('size') ?? '1';
73
72
  if (size !== '1') {
74
73
  return false;
75
74
  }
@@ -80,7 +79,7 @@ select) {
80
79
  return true;
81
80
  }
82
81
  // > that option element's parent node is the select element (and not an optgroup element)
83
- if (((_b = firstOption.parentElement) === null || _b === void 0 ? void 0 : _b.localName) === 'optgroup') {
82
+ if (firstOption.parentElement?.localName === 'optgroup') {
84
83
  return false;
85
84
  }
86
85
  const value = firstOption.getAttribute('value');
@@ -1,6 +1,6 @@
1
1
  import type { ARIAVersion } from '@markuplint/ml-spec';
2
2
  type Option = {
3
- ariaVersion: ARIAVersion;
3
+ ariaVersion: ARIAVersion;
4
4
  };
5
- declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<boolean, Option>>;
5
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<boolean, Option>>;
6
6
  export default _default;