@markuplint/rules 3.12.0 → 4.0.0-alpha.1

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 (142) hide show
  1. package/lib/attr-check.js +14 -19
  2. package/lib/attr-duplication/index.js +3 -6
  3. package/lib/attr-value-quotes/index.js +5 -9
  4. package/lib/case-sensitive-attr-name/index.js +9 -13
  5. package/lib/case-sensitive-tag-name/index.js +2 -4
  6. package/lib/character-reference/index.js +6 -8
  7. package/lib/class-naming/index.js +9 -11
  8. package/lib/create-message.js +9 -16
  9. package/lib/debug.js +2 -6
  10. package/lib/deprecated-attr/index.js +6 -9
  11. package/lib/deprecated-element/index.js +3 -5
  12. package/lib/disallowed-element/index.js +2 -4
  13. package/lib/doctype/index.js +2 -4
  14. package/lib/end-tag/index.js +5 -8
  15. package/lib/helpers.d.ts +1 -1
  16. package/lib/helpers.js +17 -28
  17. package/lib/id-duplication/index.js +2 -4
  18. package/lib/index.d.ts +15 -15
  19. package/lib/index.js +63 -66
  20. package/lib/ineffective-attr/index.js +5 -7
  21. package/lib/invalid-attr/index.js +30 -33
  22. package/lib/label-has-control/index.js +2 -4
  23. package/lib/landmark-roles/index.js +3 -6
  24. package/lib/no-boolean-attr-value/index.js +6 -9
  25. package/lib/no-default-value/index.js +9 -12
  26. package/lib/no-empty-palpable-content/index.js +5 -7
  27. package/lib/no-hard-code-id/index.js +2 -4
  28. package/lib/no-refer-to-non-existent-id/index.js +26 -30
  29. package/lib/no-use-event-handler-attr/index.js +4 -6
  30. package/lib/permitted-contents/choice.d.ts +1 -1
  31. package/lib/permitted-contents/choice.js +13 -18
  32. package/lib/permitted-contents/complex-branch.d.ts +1 -1
  33. package/lib/permitted-contents/complex-branch.js +10 -14
  34. package/lib/permitted-contents/content-model.d.ts +1 -1
  35. package/lib/permitted-contents/content-model.js +5 -9
  36. package/lib/permitted-contents/count-pattern.d.ts +1 -1
  37. package/lib/permitted-contents/count-pattern.js +19 -24
  38. package/lib/permitted-contents/debug.browser.js +9 -12
  39. package/lib/permitted-contents/debug.d.ts +8 -1
  40. package/lib/permitted-contents/debug.js +12 -13
  41. package/lib/permitted-contents/index.d.ts +1 -1
  42. package/lib/permitted-contents/index.js +10 -13
  43. package/lib/permitted-contents/matches-selector.d.ts +1 -1
  44. package/lib/permitted-contents/matches-selector.js +12 -17
  45. package/lib/permitted-contents/order.d.ts +1 -1
  46. package/lib/permitted-contents/order.js +17 -22
  47. package/lib/permitted-contents/recursive-branch.d.ts +2 -2
  48. package/lib/permitted-contents/recursive-branch.js +9 -13
  49. package/lib/permitted-contents/represent-transparent-nodes.d.ts +1 -1
  50. package/lib/permitted-contents/represent-transparent-nodes.js +15 -20
  51. package/lib/permitted-contents/start.d.ts +1 -1
  52. package/lib/permitted-contents/start.js +13 -21
  53. package/lib/permitted-contents/transparent.d.ts +1 -1
  54. package/lib/permitted-contents/transparent.js +4 -9
  55. package/lib/permitted-contents/types.js +1 -2
  56. package/lib/permitted-contents/utils.d.ts +1 -1
  57. package/lib/permitted-contents/utils.js +55 -74
  58. package/lib/placeholder-label-option/index.js +5 -9
  59. package/lib/require-accessible-name/index.js +10 -13
  60. package/lib/require-datetime/index.d.ts +1 -1
  61. package/lib/require-datetime/index.js +6 -8
  62. package/lib/require-datetime/types.js +1 -2
  63. package/lib/require-datetime/utils.d.ts +1 -1
  64. package/lib/require-datetime/utils.js +4 -11
  65. package/lib/required-attr/index.js +8 -11
  66. package/lib/required-element/index.js +3 -6
  67. package/lib/required-h1/index.js +3 -6
  68. package/lib/use-list/index.js +6 -10
  69. package/lib/wai-aria/checkings/abstract-role.d.ts +1 -1
  70. package/lib/wai-aria/checkings/abstract-role.js +5 -10
  71. package/lib/wai-aria/checkings/default-value.d.ts +1 -1
  72. package/lib/wai-aria/checkings/default-value.js +2 -6
  73. package/lib/wai-aria/checkings/deprecated-props.d.ts +1 -1
  74. package/lib/wai-aria/checkings/deprecated-props.js +3 -8
  75. package/lib/wai-aria/checkings/disallowed-prop.d.ts +1 -1
  76. package/lib/wai-aria/checkings/disallowed-prop.js +7 -12
  77. package/lib/wai-aria/checkings/implicit-props.d.ts +1 -1
  78. package/lib/wai-aria/checkings/implicit-props.js +6 -11
  79. package/lib/wai-aria/checkings/implicit-role.d.ts +1 -1
  80. package/lib/wai-aria/checkings/implicit-role.js +4 -9
  81. package/lib/wai-aria/checkings/interaction-in-hidden.d.ts +1 -1
  82. package/lib/wai-aria/checkings/interaction-in-hidden.js +4 -8
  83. package/lib/wai-aria/checkings/no-global-prop.d.ts +1 -1
  84. package/lib/wai-aria/checkings/no-global-prop.js +2 -7
  85. package/lib/wai-aria/checkings/non-existent-role.d.ts +1 -1
  86. package/lib/wai-aria/checkings/non-existent-role.js +4 -9
  87. package/lib/wai-aria/checkings/permitted-roles.d.ts +1 -1
  88. package/lib/wai-aria/checkings/permitted-roles.js +4 -9
  89. package/lib/wai-aria/checkings/presentational-children.d.ts +1 -1
  90. package/lib/wai-aria/checkings/presentational-children.js +4 -9
  91. package/lib/wai-aria/checkings/required-owned-elements.d.ts +1 -1
  92. package/lib/wai-aria/checkings/required-owned-elements.js +4 -8
  93. package/lib/wai-aria/checkings/required-prop.d.ts +1 -1
  94. package/lib/wai-aria/checkings/required-prop.js +2 -7
  95. package/lib/wai-aria/checkings/value.d.ts +1 -1
  96. package/lib/wai-aria/checkings/value.js +4 -10
  97. package/lib/wai-aria/index.d.ts +1 -1
  98. package/lib/wai-aria/index.js +38 -40
  99. package/lib/wai-aria/types.js +1 -2
  100. package/package.json +17 -12
  101. package/test/attr-check.spec.js +0 -77
  102. package/test/attr-duplication/index.spec.js +0 -159
  103. package/test/attr-value-quotes/index.spec.js +0 -133
  104. package/test/case-sensitive-attr-name/index.spec.js +0 -65
  105. package/test/case-sensitive-tag-name/index.spec.js +0 -80
  106. package/test/character-reference/index.spec.js +0 -72
  107. package/test/class-naming/index.spec.js +0 -470
  108. package/test/create-message.spec.js +0 -497
  109. package/test/deprecated-attr/index.spec.js +0 -48
  110. package/test/deprecated-element/index.spec.js +0 -35
  111. package/test/disallowed-element/index.spec.js +0 -90
  112. package/test/doctype/index.spec.js +0 -50
  113. package/test/end-tag/index.spec.js +0 -162
  114. package/test/id-duplication/index.spec.js +0 -47
  115. package/test/ineffective-attr/index.spec.js +0 -31
  116. package/test/invalid-attr/index.spec.js +0 -1641
  117. package/test/label-has-control/index.spec.js +0 -29
  118. package/test/landmark-roles/index.spec.js +0 -187
  119. package/test/no-boolean-attr-value/index.spec.js +0 -41
  120. package/test/no-default-value/index.spec.js +0 -74
  121. package/test/no-empty-palpable-content/index.spec.js +0 -115
  122. package/test/no-hard-code-id/index.spec.js +0 -100
  123. package/test/no-refer-to-non-existent-id/index.spec.js +0 -254
  124. package/test/no-use-event-handler-attr/index.spec.js +0 -57
  125. package/test/permitted-contents/choice.spec.js +0 -174
  126. package/test/permitted-contents/count-pattern.spec.js +0 -308
  127. package/test/permitted-contents/index.spec.js +0 -1395
  128. package/test/permitted-contents/matches-selector.spec.js +0 -59
  129. package/test/permitted-contents/order.spec.js +0 -351
  130. package/test/permitted-contents/recursive-branch.spec.js +0 -41
  131. package/test/permitted-contents/represent-transparent-nodes.spec.js +0 -24
  132. package/test/permitted-contents/start.spec.js +0 -67
  133. package/test/placeholder-label-option/index.spec.js +0 -113
  134. package/test/require-accessible-name/index.spec.js +0 -444
  135. package/test/require-datetime/index.spec.js +0 -54
  136. package/test/require-datetime/utils.spec.js +0 -52
  137. package/test/required-attr/index.spec.js +0 -414
  138. package/test/required-element/index.spec.js +0 -188
  139. package/test/required-h1/index.spec.js +0 -69
  140. package/test/use-list/index.spec.js +0 -109
  141. package/test/wai-aria/checkings/value.spec.js +0 -33
  142. package/test/wai-aria/index.spec.js +0 -1203
@@ -1,13 +1,10 @@
1
- "use strict";
2
1
  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");
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
+ import { createSelector } from '@markuplint/selector';
4
+ import { bgGreen, green, bgRed, bgBlue, blue, bgMagenta, cyan } from './debug.js';
5
+ import { transparentMode } from './represent-transparent-nodes.js';
9
6
  const getChildNodesWithoutWhitespacesCaches = new Map();
10
- function getChildNodesWithoutWhitespaces(
7
+ export function getChildNodesWithoutWhitespaces(
11
8
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
12
9
  el) {
13
10
  let nodes = getChildNodesWithoutWhitespacesCaches.get(el);
@@ -20,8 +17,7 @@ el) {
20
17
  getChildNodesWithoutWhitespacesCaches.set(el, nodes);
21
18
  return nodes;
22
19
  }
23
- exports.getChildNodesWithoutWhitespaces = getChildNodesWithoutWhitespaces;
24
- function isModel(model) {
20
+ export function isModel(model) {
25
21
  if (typeof model === 'string') {
26
22
  return true;
27
23
  }
@@ -37,11 +33,10 @@ function isModel(model) {
37
33
  }
38
34
  return modelMode;
39
35
  }
40
- exports.isModel = isModel;
41
- function matches(selector,
36
+ export function matches(selector,
42
37
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
43
38
  node, specs) {
44
- const selectorResult = (0, selector_1.createSelector)(selector, specs).search(node);
39
+ const selectorResult = createSelector(selector, specs).search(node);
45
40
  const matched = selectorResult.filter((r) => r.matched);
46
41
  if (matched.length > 0) {
47
42
  return {
@@ -49,7 +44,7 @@ node, specs) {
49
44
  };
50
45
  }
51
46
  const not = selectorResult
52
- .map(r => { var _a; return (r.matched ? [] : (_a = r.not) !== null && _a !== void 0 ? _a : []); })
47
+ .map(r => (r.matched ? [] : r.not ?? []))
53
48
  .flat()
54
49
  .map(descendants)
55
50
  .flat()
@@ -59,7 +54,6 @@ node, specs) {
59
54
  not,
60
55
  };
61
56
  }
62
- exports.matches = matches;
63
57
  function descendants(
64
58
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
65
59
  selectorResult) {
@@ -77,32 +71,25 @@ selectorResult) {
77
71
  }
78
72
  return nodes;
79
73
  }
80
- function isRequire(content) {
74
+ export function isRequire(content) {
81
75
  return 'require' in content;
82
76
  }
83
- exports.isRequire = isRequire;
84
- function isOptional(content) {
77
+ export function isOptional(content) {
85
78
  return 'optional' in content;
86
79
  }
87
- exports.isOptional = isOptional;
88
- function isOneOrMore(content) {
80
+ export function isOneOrMore(content) {
89
81
  return 'oneOrMore' in content;
90
82
  }
91
- exports.isOneOrMore = isOneOrMore;
92
- function isZeroOrMore(content) {
83
+ export function isZeroOrMore(content) {
93
84
  return 'zeroOrMore' in content;
94
85
  }
95
- exports.isZeroOrMore = isZeroOrMore;
96
- function isChoice(content) {
86
+ export function isChoice(content) {
97
87
  return 'choice' in content;
98
88
  }
99
- exports.isChoice = isChoice;
100
- function isTransparent(content) {
89
+ export function isTransparent(content) {
101
90
  return 'transparent' in content;
102
91
  }
103
- exports.isTransparent = isTransparent;
104
- function normalizeModel(pattern) {
105
- var _a, _b, _c, _d, _e;
92
+ export function normalizeModel(pattern) {
106
93
  let model;
107
94
  let min;
108
95
  let max;
@@ -110,25 +97,25 @@ function normalizeModel(pattern) {
110
97
  let missingType;
111
98
  if (isRequire(pattern)) {
112
99
  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);
100
+ min = pattern.min ?? 1;
101
+ max = Math.max(pattern.max ?? 1, min);
115
102
  missingType = 'MISSING_NODE_REQUIRED';
116
103
  }
117
104
  else if (isOptional(pattern)) {
118
105
  model = pattern.optional;
119
106
  min = 0;
120
- max = Math.max((_c = pattern.max) !== null && _c !== void 0 ? _c : 1, 1);
107
+ max = Math.max(pattern.max ?? 1, 1);
121
108
  }
122
109
  else if (isOneOrMore(pattern)) {
123
110
  model = pattern.oneOrMore;
124
111
  min = 1;
125
- max = Math.max((_d = pattern.max) !== null && _d !== void 0 ? _d : Infinity, 1);
112
+ max = Math.max(pattern.max ?? Infinity, 1);
126
113
  missingType = 'MISSING_NODE_ONE_OR_MORE';
127
114
  }
128
115
  else if (isZeroOrMore(pattern)) {
129
116
  model = pattern.zeroOrMore;
130
117
  min = 0;
131
- max = Math.max((_e = pattern.max) !== null && _e !== void 0 ? _e : Infinity, 1);
118
+ max = Math.max(pattern.max ?? Infinity, 1);
132
119
  }
133
120
  else {
134
121
  throw new Error('Unreachable code');
@@ -156,21 +143,19 @@ function normalizeModel(pattern) {
156
143
  missingType,
157
144
  };
158
145
  }
159
- exports.normalizeModel = normalizeModel;
160
- function mergeHints(
146
+ export function mergeHints(
161
147
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
162
148
  a,
163
149
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
164
150
  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];
151
+ const missing = [a.missing, b.missing].sort((a, b) => (b?.barelyMatchedElements ?? 0) - (a?.barelyMatchedElements ?? 0))[0];
166
152
  return cleanObject({
167
153
  ...a,
168
154
  ...b,
169
155
  missing: missing && cleanObject(missing),
170
156
  });
171
157
  }
172
- exports.mergeHints = mergeHints;
173
- function cleanObject(object) {
158
+ export function cleanObject(object) {
174
159
  const newObject = {};
175
160
  Object.entries(object).forEach(([key, value]) => {
176
161
  if (value !== undefined) {
@@ -179,8 +164,7 @@ function cleanObject(object) {
179
164
  });
180
165
  return newObject;
181
166
  }
182
- exports.cleanObject = cleanObject;
183
- class Collection {
167
+ export class Collection {
184
168
  constructor(
185
169
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
186
170
  origin) {
@@ -188,76 +172,76 @@ class Collection {
188
172
  _Collection_matched.set(this, new Set());
189
173
  _Collection_nodes.set(this, void 0);
190
174
  _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");
175
+ __classPrivateFieldSet(this, _Collection_origin, origin.slice(), "f");
176
+ __classPrivateFieldSet(this, _Collection_nodes, new Set(__classPrivateFieldGet(this, _Collection_origin, "f")), "f");
193
177
  }
194
178
  get matched() {
195
- return Array.from(tslib_1.__classPrivateFieldGet(this, _Collection_matched, "f"));
179
+ return Array.from(__classPrivateFieldGet(this, _Collection_matched, "f"));
196
180
  }
197
181
  get matchedCount() {
198
- return tslib_1.__classPrivateFieldGet(this, _Collection_matched, "f").size;
182
+ return __classPrivateFieldGet(this, _Collection_matched, "f").size;
199
183
  }
200
184
  get nodes() {
201
- return tslib_1.__classPrivateFieldGet(this, _Collection_origin, "f").slice();
185
+ return __classPrivateFieldGet(this, _Collection_origin, "f").slice();
202
186
  }
203
187
  get unmatched() {
204
- return Array.from(tslib_1.__classPrivateFieldGet(this, _Collection_nodes, "f")).filter(n => !tslib_1.__classPrivateFieldGet(this, _Collection_matched, "f").has(n));
188
+ return Array.from(__classPrivateFieldGet(this, _Collection_nodes, "f")).filter(n => !__classPrivateFieldGet(this, _Collection_matched, "f").has(n));
205
189
  }
206
190
  addMatched(
207
191
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
208
192
  nodes) {
209
- const i = tslib_1.__classPrivateFieldGet(this, _Collection_matched, "f").size;
193
+ const i = __classPrivateFieldGet(this, _Collection_matched, "f").size;
210
194
  for (const node of nodes) {
211
- if (!tslib_1.__classPrivateFieldGet(this, _Collection_nodes, "f").has(node)) {
195
+ if (!__classPrivateFieldGet(this, _Collection_nodes, "f").has(node)) {
212
196
  throw new ReferenceError(`External Node: ${node.nodeName}`);
213
197
  }
214
- tslib_1.__classPrivateFieldGet(this, _Collection_matched, "f").add(node);
198
+ __classPrivateFieldGet(this, _Collection_matched, "f").add(node);
215
199
  }
216
- return i < tslib_1.__classPrivateFieldGet(this, _Collection_matched, "f").size;
200
+ return i < __classPrivateFieldGet(this, _Collection_matched, "f").size;
217
201
  }
218
202
  back() {
219
- tslib_1.__classPrivateFieldSet(this, _Collection_matched, new Set(tslib_1.__classPrivateFieldGet(this, _Collection_locked, "f")), "f");
203
+ __classPrivateFieldSet(this, _Collection_matched, new Set(__classPrivateFieldGet(this, _Collection_locked, "f")), "f");
220
204
  }
221
205
  lock() {
222
- tslib_1.__classPrivateFieldSet(this, _Collection_locked, new Set(tslib_1.__classPrivateFieldGet(this, _Collection_matched, "f")), "f");
206
+ __classPrivateFieldSet(this, _Collection_locked, new Set(__classPrivateFieldGet(this, _Collection_matched, "f")), "f");
223
207
  }
224
208
  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));
209
+ const sliced = Array.from(__classPrivateFieldGet(this, _Collection_matched, "f")).slice(max);
210
+ sliced.forEach(n => __classPrivateFieldGet(this, _Collection_matched, "f").delete(n));
227
211
  }
228
212
  toString(highlightExtraNodes = false) {
229
213
  const out = [];
230
- for (const n of tslib_1.__classPrivateFieldGet(this, _Collection_origin, "f")) {
214
+ for (const n of __classPrivateFieldGet(this, _Collection_origin, "f")) {
231
215
  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));
216
+ if (__classPrivateFieldGet(this, _Collection_locked, "f").has(n)) {
217
+ if (transparentMode.has(n)) {
218
+ out.push(bgBlue.bold(raw));
235
219
  }
236
220
  else {
237
- out.push(debug_1.bgGreen.bold(raw));
221
+ out.push(bgGreen.bold(raw));
238
222
  }
239
223
  continue;
240
224
  }
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));
225
+ if (__classPrivateFieldGet(this, _Collection_matched, "f").has(n)) {
226
+ if (transparentMode.has(n)) {
227
+ out.push(blue.bold(raw));
244
228
  }
245
229
  else {
246
- out.push(debug_1.green.bold(raw));
230
+ out.push(green.bold(raw));
247
231
  }
248
232
  continue;
249
233
  }
250
234
  if (highlightExtraNodes) {
251
- if (represent_transparent_nodes_1.transparentMode.has(n)) {
252
- out.push(debug_1.bgMagenta.bold(raw));
235
+ if (transparentMode.has(n)) {
236
+ out.push(bgMagenta.bold(raw));
253
237
  }
254
238
  else {
255
- out.push(debug_1.bgRed.bold(raw));
239
+ out.push(bgRed.bold(raw));
256
240
  }
257
241
  continue;
258
242
  }
259
- if (represent_transparent_nodes_1.transparentMode.has(n)) {
260
- out.push((0, debug_1.cyan)(raw));
243
+ if (transparentMode.has(n)) {
244
+ out.push(cyan(raw));
261
245
  }
262
246
  else {
263
247
  out.push(raw);
@@ -266,12 +250,10 @@ class Collection {
266
250
  return `[ ${out.join(', ')} ]`;
267
251
  }
268
252
  }
269
- exports.Collection = Collection;
270
253
  _Collection_locked = new WeakMap(), _Collection_matched = new WeakMap(), _Collection_nodes = new WeakMap(), _Collection_origin = new WeakMap();
271
- class UnsupportedError extends Error {
254
+ export class UnsupportedError extends Error {
272
255
  }
273
- exports.UnsupportedError = UnsupportedError;
274
- function modelLog(model, repeat) {
256
+ export function modelLog(model, repeat) {
275
257
  if (!isModel(model)) {
276
258
  return orderLog(model, repeat);
277
259
  }
@@ -280,7 +262,6 @@ function modelLog(model, repeat) {
280
262
  }
281
263
  return `(<${model.join('>|<')}>)${repeat}`;
282
264
  }
283
- exports.modelLog = modelLog;
284
265
  function orderLog(order, repeat) {
285
266
  return order.length === 1 && order[0]
286
267
  ? markRepeat(patternLog(order[0]), repeat)
@@ -1,7 +1,5 @@
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({
5
3
  verify({ document, report, t }) {
6
4
  document.querySelectorAll('select').forEach(select => {
7
5
  if (hasPlaceholderLabelOption(select)) {
@@ -29,7 +27,6 @@ exports.default = (0, ml_core_1.createRule)({
29
27
  function needPlaceholderLabelOption(
30
28
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
31
29
  select) {
32
- var _a;
33
30
  const hasRequired = select.hasAttribute('required');
34
31
  if (!hasRequired) {
35
32
  return false;
@@ -38,7 +35,7 @@ select) {
38
35
  if (hasMultiple) {
39
36
  return false;
40
37
  }
41
- const size = (_a = select.getAttribute('size')) !== null && _a !== void 0 ? _a : '1';
38
+ const size = select.getAttribute('size') ?? '1';
42
39
  if (size !== '1') {
43
40
  return false;
44
41
  }
@@ -59,7 +56,6 @@ select) {
59
56
  function hasPlaceholderLabelOption(
60
57
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
61
58
  select) {
62
- var _a, _b;
63
59
  // > has a required attribute specified
64
60
  if (!select.hasAttribute('required')) {
65
61
  return false;
@@ -69,7 +65,7 @@ select) {
69
65
  return false;
70
66
  }
71
67
  // > has a display size of 1
72
- const size = (_a = select.getAttribute('size')) !== null && _a !== void 0 ? _a : '1';
68
+ const size = select.getAttribute('size') ?? '1';
73
69
  if (size !== '1') {
74
70
  return false;
75
71
  }
@@ -80,7 +76,7 @@ select) {
80
76
  return true;
81
77
  }
82
78
  // > 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') {
79
+ if (firstOption.parentElement?.localName === 'optgroup') {
84
80
  return false;
85
81
  }
86
82
  const value = firstOption.getAttribute('value');
@@ -1,29 +1,26 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ml_core_1 = require("@markuplint/ml-core");
4
- const ml_spec_1 = require("@markuplint/ml-spec");
5
- const helpers_1 = require("../helpers");
6
- exports.default = (0, ml_core_1.createRule)({
1
+ import { createRule, getRoleSpec, getComputedRole } from '@markuplint/ml-core';
2
+ import { ARIA_RECOMMENDED_VERSION, isExposed } from '@markuplint/ml-spec';
3
+ import { accnameMayBeMutable } from '../helpers.js';
4
+ export default createRule({
7
5
  defaultOptions: {
8
- ariaVersion: ml_spec_1.ARIA_RECOMMENDED_VERSION,
6
+ ariaVersion: ARIA_RECOMMENDED_VERSION,
9
7
  },
10
8
  async verify({ document, report, t }) {
11
9
  await document.walkOn('Element', el => {
12
- var _a;
13
- if (((_a = el.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender') {
10
+ if (el.pretenderContext?.type === 'pretender') {
14
11
  return;
15
12
  }
16
- if ((0, helpers_1.accnameMayBeMutable)(el, document)) {
13
+ if (accnameMayBeMutable(el, document)) {
17
14
  return;
18
15
  }
19
- if (!(0, ml_spec_1.isExposed)(el, document.specs, el.rule.options.ariaVersion)) {
16
+ if (!isExposed(el, document.specs, el.rule.options.ariaVersion)) {
20
17
  return;
21
18
  }
22
- const computed = (0, ml_core_1.getComputedRole)(document.specs, el, el.rule.options.ariaVersion);
19
+ const computed = getComputedRole(document.specs, el, el.rule.options.ariaVersion);
23
20
  if (!computed.role) {
24
21
  return;
25
22
  }
26
- const roleSpec = (0, ml_core_1.getRoleSpec)(document.specs, computed.role.name, el.namespaceURI, el.rule.options.ariaVersion);
23
+ const roleSpec = getRoleSpec(document.specs, computed.role.name, el.namespaceURI, el.rule.options.ariaVersion);
27
24
  if (!roleSpec || !roleSpec.accessibleNameRequired) {
28
25
  return;
29
26
  }
@@ -1,4 +1,4 @@
1
- import type { Lang } from './types';
1
+ import type { Lang } from './types.js';
2
2
  type Options = {
3
3
  langs?: Lang[];
4
4
  };
@@ -1,9 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ml_core_1 = require("@markuplint/ml-core");
4
- const types_1 = require("@markuplint/types");
5
- const utils_1 = require("./utils");
6
- exports.default = (0, ml_core_1.createRule)({
1
+ import { createRule } from '@markuplint/ml-core';
2
+ import { check } from '@markuplint/types';
3
+ import { getCandidateDatetimeString } from './utils.js';
4
+ export default createRule({
7
5
  defaultOptions: {
8
6
  langs: undefined,
9
7
  },
@@ -13,11 +11,11 @@ exports.default = (0, ml_core_1.createRule)({
13
11
  return;
14
12
  }
15
13
  const content = time.textContent.trim();
16
- const result = (0, types_1.check)(content, 'DateTime');
14
+ const result = check(content, 'DateTime');
17
15
  if (result.matched) {
18
16
  return;
19
17
  }
20
- const candidate = (0, utils_1.getCandidateDatetimeString)(content, time.rule.options.langs);
18
+ const candidate = getCandidateDatetimeString(content, time.rule.options.langs);
21
19
  if (candidate) {
22
20
  report({
23
21
  scope: time,
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,4 +1,4 @@
1
- import type { DateTime, Lang } from './types';
1
+ import type { DateTime, Lang } from './types.js';
2
2
  /**
3
3
  * Datetime-ish text to a datetime data
4
4
  *
@@ -1,8 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCandidateDatetimeString = exports.parseADatetime = void 0;
4
- const tslib_1 = require("tslib");
5
- const chrono = tslib_1.__importStar(require("chrono-node"));
1
+ import * as chrono from 'chrono-node';
6
2
  const defaultLangs = ['en', 'ja', 'fr', 'nl', 'ru', 'de', 'pt', 'zh'];
7
3
  /**
8
4
  * Datetime-ish text to a datetime data
@@ -12,8 +8,7 @@ const defaultLangs = ['en', 'ja', 'fr', 'nl', 'ru', 'de', 'pt', 'zh'];
12
8
  * @param base Reference date for a test
13
9
  * @returns
14
10
  */
15
- function parseADatetime(content, langs, base) {
16
- var _a;
11
+ export function parseADatetime(content, langs, base) {
17
12
  const date = parseTryMultipleLangs(content, langs, base);
18
13
  if (!date) {
19
14
  return null;
@@ -32,7 +27,7 @@ function parseADatetime(content, langs, base) {
32
27
  data.hour = date.get('hour');
33
28
  }
34
29
  if (date.isCertain('hour')) {
35
- data.minute = (_a = date.get('minute')) !== null && _a !== void 0 ? _a : 0;
30
+ data.minute = date.get('minute') ?? 0;
36
31
  }
37
32
  if (date.isCertain('second')) {
38
33
  data.second = date.get('second');
@@ -48,8 +43,7 @@ function parseADatetime(content, langs, base) {
48
43
  }
49
44
  return datetime;
50
45
  }
51
- exports.parseADatetime = parseADatetime;
52
- function getCandidateDatetimeString(content, langs = defaultLangs) {
46
+ export function getCandidateDatetimeString(content, langs = defaultLangs) {
53
47
  const date = parseADatetime(content, langs);
54
48
  if (!date) {
55
49
  return null;
@@ -66,7 +60,6 @@ function getCandidateDatetimeString(content, langs = defaultLangs) {
66
60
  }
67
61
  return datetimeStr;
68
62
  }
69
- exports.getCandidateDatetimeString = getCandidateDatetimeString;
70
63
  function toDatetimeString(date) {
71
64
  if (only(date, ['year', 'month'])) {
72
65
  return `${f(date.year, 4)}-${f(date.month, 2)}`;
@@ -1,17 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ml_core_1 = require("@markuplint/ml-core");
4
- const helpers_1 = require("../helpers");
5
- exports.default = (0, ml_core_1.createRule)({
1
+ import { createRule, getAttrSpecs } from '@markuplint/ml-core';
2
+ import { attrMatches, match } from '../helpers.js';
3
+ export default createRule({
6
4
  defaultValue: [],
7
5
  async verify({ document, report, t }) {
8
6
  await document.walkOn('Element', el => {
9
- var _a;
10
7
  if (el.hasSpreadAttr) {
11
8
  return;
12
9
  }
13
10
  const customRequiredAttrs = typeof el.rule.value === 'string' ? [el.rule.value] : el.rule.value;
14
- const attrSpec = (0, ml_core_1.getAttrSpecs)(el, document.specs);
11
+ const attrSpec = getAttrSpecs(el, document.specs);
15
12
  const attributeSpecs = {};
16
13
  if (attrSpec && el.elementType === 'html') {
17
14
  for (const spec of attrSpec) {
@@ -52,7 +49,7 @@ exports.default = (0, ml_core_1.createRule)({
52
49
  invalid = !candidate.some(attrName => el.hasAttribute(attrName));
53
50
  }
54
51
  else if (spec.required === true) {
55
- invalid = (0, helpers_1.attrMatches)(el, spec.condition) && didntHave;
52
+ invalid = attrMatches(el, spec.condition) && didntHave;
56
53
  }
57
54
  else if (spec.required != null && spec.required !== false) {
58
55
  const selector = typeof spec.required === 'string' ? spec.required : spec.required.join(',');
@@ -67,13 +64,13 @@ exports.default = (0, ml_core_1.createRule)({
67
64
  }
68
65
  const value = el.getAttribute(spec.name);
69
66
  if (spec.values.length > 0 && value) {
70
- const matched = spec.values.some(pattern => (0, helpers_1.match)(value, pattern));
67
+ const matched = spec.values.some(pattern => match(value, pattern));
71
68
  if (!matched) {
72
69
  const expects = spec.values.length === 1 ? t(spec.values) : t('either {0}', t(spec.values));
73
70
  const message = t('{0} expects {1}', t('the "{0*}" {1}', spec.name, 'attribute'), expects);
74
71
  const attrToken = el.getAttributeToken(spec.name);
75
- const valueToken = (_a = attrToken[0]) === null || _a === void 0 ? void 0 : _a.valueNode;
76
- const token = valueToken !== null && valueToken !== void 0 ? valueToken : attrToken[0];
72
+ const valueToken = attrToken[0]?.valueNode;
73
+ const token = valueToken ?? attrToken[0];
77
74
  if (token) {
78
75
  report({
79
76
  scope: {
@@ -1,13 +1,10 @@
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({
5
3
  defaultValue: [],
6
4
  defaultOptions: {
7
5
  ignoreHasMutableContents: true,
8
6
  },
9
7
  async verify({ document, report, t }) {
10
- var _a, _b;
11
8
  const hasMutableContent = document.nodeList.some(n => n.is(n.ELEMENT_NODE) && n.hasMutableChildren());
12
9
  if (!hasMutableContent) {
13
10
  for (const query of document.rule.value) {
@@ -18,7 +15,7 @@ exports.default = (0, ml_core_1.createRule)({
18
15
  message,
19
16
  line: 1,
20
17
  col: 1,
21
- raw: (_b = (_a = document.nodeList[0]) === null || _a === void 0 ? void 0 : _a.raw.slice(0, 1)) !== null && _b !== void 0 ? _b : '',
18
+ raw: document.nodeList[0]?.raw.slice(0, 1) ?? '',
22
19
  });
23
20
  }
24
21
  }
@@ -1,13 +1,10 @@
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({
5
3
  defaultOptions: {
6
4
  'expected-once': true,
7
5
  'in-document-fragment': false,
8
6
  },
9
7
  async verify({ document, report, t }) {
10
- var _a, _b;
11
8
  const h1Stack = [];
12
9
  if (document.nodeList.length === 0) {
13
10
  return;
@@ -26,7 +23,7 @@ exports.default = (0, ml_core_1.createRule)({
26
23
  message,
27
24
  line: 1,
28
25
  col: 1,
29
- raw: (_b = (_a = document.nodeList[0]) === null || _a === void 0 ? void 0 : _a.raw.slice(0, 1)) !== null && _b !== void 0 ? _b : '',
26
+ raw: document.nodeList[0]?.raw.slice(0, 1) ?? '',
30
27
  });
31
28
  }
32
29
  else if (document.rule.options['expected-once'] && h1Stack.length > 1 && h1Stack[1]) {
@@ -1,8 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ml_core_1 = require("@markuplint/ml-core");
4
- const shared_1 = require("@markuplint/shared");
5
- exports.default = (0, ml_core_1.createRule)({
1
+ import { createRule } from '@markuplint/ml-core';
2
+ import { decodeEntities } from '@markuplint/shared';
3
+ export default createRule({
6
4
  defaultValue: [
7
5
  /**
8
6
  * @see https://en.wikipedia.org/wiki/Bullet_(typography)#In_Unicode
@@ -57,8 +55,7 @@ exports.default = (0, ml_core_1.createRule)({
57
55
  defaultSeverity: 'warning',
58
56
  async verify({ document, report, t }) {
59
57
  await document.walkOn('Text', textNode => {
60
- var _a;
61
- const text = (0, shared_1.decodeEntities)(textNode.raw.trim());
58
+ const text = decodeEntities(textNode.raw.trim());
62
59
  if (!text) {
63
60
  // empty
64
61
  return;
@@ -68,7 +65,7 @@ exports.default = (0, ml_core_1.createRule)({
68
65
  return;
69
66
  }
70
67
  const bullets = textNode.rule.value;
71
- const spaceNeededBullets = (_a = textNode.rule.options.spaceNeededBullets) !== null && _a !== void 0 ? _a : [];
68
+ const spaceNeededBullets = textNode.rule.options.spaceNeededBullets ?? [];
72
69
  if (isMayListItem(text, bullets, spaceNeededBullets)) {
73
70
  report({
74
71
  scope: textNode,
@@ -79,9 +76,8 @@ exports.default = (0, ml_core_1.createRule)({
79
76
  },
80
77
  });
81
78
  function isMayListItem(text, bullets, spaceNeededBullets) {
82
- var _a;
83
79
  const textArray = Array.from(text);
84
- const firstLetter = (_a = textArray[0]) !== null && _a !== void 0 ? _a : '';
80
+ const firstLetter = textArray[0] ?? '';
85
81
  const isBullet = bullets.includes(firstLetter);
86
82
  const needSpace = spaceNeededBullets.includes(firstLetter);
87
83
  const continuous = firstLetter === textArray[1];
@@ -1,3 +1,3 @@
1
- import type { Options } from '../types';
1
+ import type { Options } from '../types.js';
2
2
  import type { AttrChecker } from '@markuplint/ml-core';
3
3
  export declare const checkingAbstractRole: AttrChecker<boolean, Options>;