html-validate 7.13.3 → 7.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/browser.d.ts +1 -0
  2. package/browser.js +1 -0
  3. package/dist/cjs/browser.d.ts +1 -4
  4. package/dist/cjs/browser.js +13 -1
  5. package/dist/cjs/browser.js.map +1 -1
  6. package/dist/cjs/cli.js +17 -9
  7. package/dist/cjs/cli.js.map +1 -1
  8. package/dist/cjs/core.js +160 -118
  9. package/dist/cjs/core.js.map +1 -1
  10. package/dist/cjs/elements.js +1 -1
  11. package/dist/cjs/html-validate.js +1 -1
  12. package/dist/cjs/index.d.ts +1 -89
  13. package/dist/cjs/index.js +13 -1
  14. package/dist/cjs/index.js.map +1 -1
  15. package/dist/cjs/jest-lib.js +17 -12
  16. package/dist/cjs/jest-lib.js.map +1 -1
  17. package/dist/cjs/jest.d.ts +1 -42
  18. package/dist/cjs/jest.js.map +1 -1
  19. package/dist/cjs/meta-helper.js +3 -0
  20. package/dist/cjs/meta-helper.js.map +1 -1
  21. package/dist/cjs/rules-helper.js +3 -3
  22. package/dist/cjs/rules-helper.js.map +1 -1
  23. package/dist/cjs/test-utils.d.ts +1 -30
  24. package/dist/cjs/test-utils.js +3 -0
  25. package/dist/cjs/test-utils.js.map +1 -1
  26. package/dist/cjs/tsdoc-metadata.json +11 -0
  27. package/dist/es/browser.d.ts +1 -4
  28. package/dist/es/browser.js +2 -2
  29. package/dist/es/cli.js +17 -8
  30. package/dist/es/cli.js.map +1 -1
  31. package/dist/es/core.js +139 -101
  32. package/dist/es/core.js.map +1 -1
  33. package/dist/es/elements.js +1 -1
  34. package/dist/es/html-validate.js +2 -2
  35. package/dist/es/index.d.ts +1 -89
  36. package/dist/es/index.js +2 -2
  37. package/dist/es/jest-lib.js +18 -13
  38. package/dist/es/jest-lib.js.map +1 -1
  39. package/dist/es/jest.d.ts +1 -42
  40. package/dist/es/jest.js.map +1 -1
  41. package/dist/es/meta-helper.js +3 -0
  42. package/dist/es/meta-helper.js.map +1 -1
  43. package/dist/es/rules-helper.js +4 -4
  44. package/dist/es/rules-helper.js.map +1 -1
  45. package/dist/es/test-utils.d.ts +1 -30
  46. package/dist/es/test-utils.js +3 -0
  47. package/dist/es/test-utils.js.map +1 -1
  48. package/dist/{es/core.d.ts → types/browser.d.ts} +2312 -2615
  49. package/dist/{cjs/core.d.ts → types/index.d.ts} +2505 -2615
  50. package/dist/types/jest.d.ts +44 -0
  51. package/dist/types/test-utils.d.ts +817 -0
  52. package/jest.d.ts +1 -2
  53. package/package.json +38 -32
  54. package/test-utils.d.ts +1 -2
  55. package/dist/cjs/meta-helper.d.ts +0 -28
  56. package/dist/cjs/rules-helper.d.ts +0 -54
  57. package/dist/es/meta-helper.d.ts +0 -28
  58. package/dist/es/rules-helper.d.ts +0 -54
package/dist/cjs/core.js CHANGED
@@ -293,6 +293,8 @@ class DynamicValue {
293
293
  *
294
294
  * Represents a HTML attribute. Can contain either a fixed static value or a
295
295
  * placeholder for dynamic values (e.g. interpolated).
296
+ *
297
+ * @public
296
298
  */
297
299
  class Attribute {
298
300
  /**
@@ -406,7 +408,7 @@ function sliceLocation(location, begin, end, wrap) {
406
408
  else {
407
409
  break;
408
410
  }
409
- } while (true); // eslint-disable-line no-constant-condition
411
+ } while (true); // eslint-disable-line no-constant-condition -- it will break out
410
412
  }
411
413
  return sliced;
412
414
  }
@@ -475,7 +477,10 @@ class Context {
475
477
  }
476
478
  }
477
479
 
478
- var TextContent$1;
480
+ /**
481
+ * @public
482
+ */
483
+ exports.TextContent = void 0;
479
484
  (function (TextContent) {
480
485
  /* forbid node to have text content, inter-element whitespace is ignored */
481
486
  TextContent["NONE"] = "none";
@@ -485,7 +490,7 @@ var TextContent$1;
485
490
  TextContent["REQUIRED"] = "required";
486
491
  /* node requires accessible text (hidden text is ignored, tries to get text from accessibility tree) */
487
492
  TextContent["ACCESSIBLE"] = "accessible";
488
- })(TextContent$1 || (TextContent$1 = {}));
493
+ })(exports.TextContent || (exports.TextContent = {}));
489
494
  /**
490
495
  * Properties listed here can be copied (loaded) onto another element using
491
496
  * [[HtmlElement.loadMeta]].
@@ -519,16 +524,22 @@ function setMetaProperty(dst, key, value) {
519
524
  dst[key] = value;
520
525
  }
521
526
 
522
- var NodeType;
527
+ /**
528
+ * @public
529
+ */
530
+ exports.NodeType = void 0;
523
531
  (function (NodeType) {
524
532
  NodeType[NodeType["ELEMENT_NODE"] = 1] = "ELEMENT_NODE";
525
533
  NodeType[NodeType["TEXT_NODE"] = 3] = "TEXT_NODE";
526
534
  NodeType[NodeType["DOCUMENT_NODE"] = 9] = "DOCUMENT_NODE";
527
- })(NodeType || (NodeType = {}));
535
+ })(exports.NodeType || (exports.NodeType = {}));
528
536
 
529
537
  const DOCUMENT_NODE_NAME = "#document";
530
538
  const TEXT_CONTENT = Symbol("textContent");
531
539
  let counter = 0;
540
+ /**
541
+ * @public
542
+ */
532
543
  class DOMNode {
533
544
  /**
534
545
  * Create a new DOMNode.
@@ -552,6 +563,8 @@ class DOMNode {
552
563
  * Enable cache for this node.
553
564
  *
554
565
  * Should not be called before the node and all children are fully constructed.
566
+ *
567
+ * @internal
555
568
  */
556
569
  cacheEnable() {
557
570
  this.cache = new Map();
@@ -597,7 +610,7 @@ class DOMNode {
597
610
  this.childNodes.push(node);
598
611
  }
599
612
  isRootElement() {
600
- return this.nodeType === NodeType.DOCUMENT_NODE;
613
+ return this.nodeType === exports.NodeType.DOCUMENT_NODE;
601
614
  }
602
615
  /**
603
616
  * Tests if two nodes are the same (references the same object).
@@ -726,6 +739,9 @@ function parse(text, baseLocation) {
726
739
  }
727
740
  return { tokens, locations };
728
741
  }
742
+ /**
743
+ * @public
744
+ */
729
745
  class DOMTokenList extends Array {
730
746
  constructor(value, location) {
731
747
  if (value && typeof value === "string") {
@@ -762,7 +778,7 @@ class DOMTokenList extends Array {
762
778
  }
763
779
  *iterator() {
764
780
  for (let index = 0; index < this.length; index++) {
765
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
781
+ /* eslint-disable @typescript-eslint/no-non-null-assertion -- as we loop over length this should always be set */
766
782
  const item = this.item(index);
767
783
  const location = this.location(index);
768
784
  /* eslint-enable @typescript-eslint/no-non-null-assertion */
@@ -1121,7 +1137,7 @@ const TEXT_NODE_NAME = "#text";
1121
1137
  * @public
1122
1138
  */
1123
1139
  function isTextNode(node) {
1124
- return Boolean(node && node.nodeType === NodeType.TEXT_NODE);
1140
+ return Boolean(node && node.nodeType === exports.NodeType.TEXT_NODE);
1125
1141
  }
1126
1142
  /**
1127
1143
  * Represents a text in the HTML document.
@@ -1138,7 +1154,7 @@ class TextNode extends DOMNode {
1138
1154
  * @param location - Source code location of this node.
1139
1155
  */
1140
1156
  constructor(text, location) {
1141
- super(NodeType.TEXT_NODE, TEXT_NODE_NAME, location);
1157
+ super(exports.NodeType.TEXT_NODE, TEXT_NODE_NAME, location);
1142
1158
  this.text = text;
1143
1159
  }
1144
1160
  /**
@@ -1178,7 +1194,7 @@ exports.NodeClosed = void 0;
1178
1194
  * @public
1179
1195
  */
1180
1196
  function isElementNode(node) {
1181
- return Boolean(node && node.nodeType === NodeType.ELEMENT_NODE);
1197
+ return Boolean(node && node.nodeType === exports.NodeType.ELEMENT_NODE);
1182
1198
  }
1183
1199
  function isValidTagName(tagName) {
1184
1200
  return Boolean(tagName !== "" && tagName !== "*");
@@ -1188,7 +1204,7 @@ function isValidTagName(tagName) {
1188
1204
  */
1189
1205
  class HtmlElement extends DOMNode {
1190
1206
  constructor(tagName, parent, closed, meta, location) {
1191
- const nodeType = tagName ? NodeType.ELEMENT_NODE : NodeType.DOCUMENT_NODE;
1207
+ const nodeType = tagName ? exports.NodeType.ELEMENT_NODE : exports.NodeType.DOCUMENT_NODE;
1192
1208
  super(nodeType, tagName, location);
1193
1209
  if (!isValidTagName(tagName)) {
1194
1210
  throw new Error(`The tag name provided ('${tagName || ""}') is not a valid name`);
@@ -1281,7 +1297,7 @@ class HtmlElement extends DOMNode {
1281
1297
  * Implementation of DOM specification of Element.closest(selectors).
1282
1298
  */
1283
1299
  closest(selectors) {
1284
- /* eslint-disable-next-line @typescript-eslint/no-this-alias */
1300
+ /* eslint-disable-next-line @typescript-eslint/no-this-alias -- false positive*/
1285
1301
  let node = this;
1286
1302
  while (node) {
1287
1303
  if (node.matches(selectors)) {
@@ -1302,11 +1318,11 @@ class HtmlElement extends DOMNode {
1302
1318
  }
1303
1319
  const parts = [];
1304
1320
  let root;
1305
- /* eslint-disable-next-line @typescript-eslint/no-this-alias */
1321
+ /* eslint-disable-next-line @typescript-eslint/no-this-alias -- false positive */
1306
1322
  for (root = this; root.parent; root = root.parent) {
1307
1323
  /* .. */
1308
1324
  }
1309
- // eslint-disable-next-line @typescript-eslint/no-this-alias
1325
+ // eslint-disable-next-line @typescript-eslint/no-this-alias -- false positive
1310
1326
  for (let cur = this; cur.parent; cur = cur.parent) {
1311
1327
  /* if a unique id is present, use it and short-circuit */
1312
1328
  if (cur.id) {
@@ -1390,7 +1406,7 @@ class HtmlElement extends DOMNode {
1390
1406
  */
1391
1407
  matches(selector) {
1392
1408
  /* find root element */
1393
- /* eslint-disable-next-line @typescript-eslint/no-this-alias */
1409
+ /* eslint-disable-next-line @typescript-eslint/no-this-alias -- false positive */
1394
1410
  let root = this;
1395
1411
  while (root.parent) {
1396
1412
  root = root.parent;
@@ -1539,9 +1555,14 @@ class HtmlElement extends DOMNode {
1539
1555
  }, []);
1540
1556
  }
1541
1557
  querySelector(selector) {
1542
- var _a;
1543
1558
  const it = this.querySelectorImpl(selector);
1544
- return (_a = it.next().value) !== null && _a !== void 0 ? _a : null; // eslint-disable-line @typescript-eslint/no-unsafe-return
1559
+ const next = it.next();
1560
+ if (next.done) {
1561
+ return null;
1562
+ }
1563
+ else {
1564
+ return next.value;
1565
+ }
1545
1566
  }
1546
1567
  querySelectorAll(selector) {
1547
1568
  const it = this.querySelectorImpl(selector);
@@ -1635,6 +1656,9 @@ function isClosed(endToken, meta) {
1635
1656
  return closed;
1636
1657
  }
1637
1658
 
1659
+ /**
1660
+ * @public
1661
+ */
1638
1662
  class DOMTree {
1639
1663
  constructor(location) {
1640
1664
  this.root = HtmlElement.rootNode(location);
@@ -1713,6 +1737,9 @@ function ensureError(value) {
1713
1737
  }
1714
1738
  }
1715
1739
 
1740
+ /**
1741
+ * @public
1742
+ */
1716
1743
  class NestedError extends Error {
1717
1744
  constructor(message, nested) {
1718
1745
  super(message);
@@ -2684,7 +2711,7 @@ function expandRegexValue(value) {
2684
2711
  const match = value.match(/^\/\^?([^/$]*)\$?\/([i]*)$/);
2685
2712
  if (match) {
2686
2713
  const [, expr, flags] = match;
2687
- // eslint-disable-next-line security/detect-non-literal-regexp
2714
+ // eslint-disable-next-line security/detect-non-literal-regexp -- expected to be regexp
2688
2715
  return new RegExp(`^${expr}$`, flags);
2689
2716
  }
2690
2717
  else {
@@ -2885,7 +2912,6 @@ class Validator {
2885
2912
  * @param rules - Element attribute metadta.
2886
2913
  * @returns `true` if attribute passes all tests.
2887
2914
  */
2888
- /* eslint-disable-next-line complexity */
2889
2915
  static validateAttribute(attr, rules) {
2890
2916
  const rule = rules[attr.key];
2891
2917
  if (!rule) {
@@ -2976,7 +3002,7 @@ class Validator {
2976
3002
  * @param category - Name of category with `@` prefix or tag name.
2977
3003
  * @param defaultMatch - The default return value when node categories is not known.
2978
3004
  */
2979
- // eslint-disable-next-line complexity
3005
+ /* eslint-disable-next-line complexity -- rule does not like switch */
2980
3006
  static validatePermittedCategory(node, category, defaultMatch) {
2981
3007
  const [, rawCategory] = category.match(/^(@?.*?)([?*]?)$/);
2982
3008
  /* match tagName when an explicit name is given */
@@ -3183,7 +3209,8 @@ var configurationSchema = {
3183
3209
  properties: properties
3184
3210
  };
3185
3211
 
3186
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
3212
+ /* eslint-disable @typescript-eslint/no-non-null-assertion -- declarations say
3213
+ * location fields are optional but they are always present when `{loc: true}` */
3187
3214
  function joinTemplateLiteral(nodes) {
3188
3215
  let offset = nodes[0].start + 1;
3189
3216
  let output = "";
@@ -3404,7 +3431,7 @@ function parseSeverity(value) {
3404
3431
  return exports.Severity.DISABLED;
3405
3432
  /* istanbul ignore next: deprecated code which will be removed later */
3406
3433
  case "disable":
3407
- // eslint-disable-next-line no-console
3434
+ // eslint-disable-next-line no-console -- expected to log
3408
3435
  console.warn(`Deprecated alias "disabled" will be removed, replace with severity "off"`);
3409
3436
  return exports.Severity.DISABLED;
3410
3437
  case 1:
@@ -3515,8 +3542,8 @@ class Rule {
3515
3542
  this.severity = severity;
3516
3543
  }
3517
3544
  /**
3518
- * Block this rule from generating errors. Pass in an id generated by {@link
3519
- * createBlocker}. Can be unblocked by {@link unblock}.
3545
+ * Block this rule from generating errors. Pass in an id generated by
3546
+ * `createBlocker`. Can be unblocked by {@link Rule.unblock}.
3520
3547
  *
3521
3548
  * A blocked rule is similar to disabling it but it will still receive parser
3522
3549
  * events. A list of all blockers is passed to the `rule:error` event.
@@ -3527,7 +3554,7 @@ class Rule {
3527
3554
  this.blockers.push(id);
3528
3555
  }
3529
3556
  /**
3530
- * Unblock a rule previously blocked by {@link block}.
3557
+ * Unblock a rule previously blocked by {@link Rule.block}.
3531
3558
  *
3532
3559
  * @internal
3533
3560
  */
@@ -3745,12 +3772,20 @@ class Rule {
3745
3772
  * @returns Rule documentation and url with additional details or `null` if no
3746
3773
  * additional documentation is available.
3747
3774
  */
3748
- /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
3775
+ /* eslint-disable-next-line @typescript-eslint/no-unused-vars -- technical debt, prototype should be moved to interface */
3749
3776
  documentation(context) {
3750
3777
  return null;
3751
3778
  }
3752
3779
  }
3753
3780
 
3781
+ var Style$2;
3782
+ (function (Style) {
3783
+ Style["EXTERNAL"] = "external";
3784
+ Style["RELATIVE_BASE"] = "relative-base";
3785
+ Style["RELATIVE_PATH"] = "relative-path";
3786
+ Style["ABSOLUTE"] = "absolute";
3787
+ Style["ANCHOR"] = "anchor";
3788
+ })(Style$2 || (Style$2 = {}));
3754
3789
  const defaults$w = {
3755
3790
  allowExternal: true,
3756
3791
  allowRelative: true,
@@ -3764,18 +3799,18 @@ const mapping$1 = {
3764
3799
  script: "src",
3765
3800
  };
3766
3801
  const description = {
3767
- ["external" /* Style.EXTERNAL */]: "External links are not allowed by current configuration.",
3768
- ["relative-base" /* Style.RELATIVE_BASE */]: "Links relative to <base> are not allowed by current configuration.",
3769
- ["relative-path" /* Style.RELATIVE_PATH */]: "Relative links are not allowed by current configuration.",
3770
- ["absolute" /* Style.ABSOLUTE */]: "Absolute links are not allowed by current configuration.",
3771
- ["anchor" /* Style.ANCHOR */]: null,
3802
+ [Style$2.EXTERNAL]: "External links are not allowed by current configuration.",
3803
+ [Style$2.RELATIVE_BASE]: "Links relative to <base> are not allowed by current configuration.",
3804
+ [Style$2.RELATIVE_PATH]: "Relative links are not allowed by current configuration.",
3805
+ [Style$2.ABSOLUTE]: "Absolute links are not allowed by current configuration.",
3806
+ [Style$2.ANCHOR]: null,
3772
3807
  };
3773
3808
  function parseAllow(value) {
3774
3809
  if (typeof value === "boolean") {
3775
3810
  return value;
3776
3811
  }
3777
3812
  return {
3778
- /* eslint-disable security/detect-non-literal-regexp */
3813
+ /* eslint-disable security/detect-non-literal-regexp -- expected to be regexp */
3779
3814
  include: value.include ? value.include.map((it) => new RegExp(it)) : null,
3780
3815
  exclude: value.exclude ? value.exclude.map((it) => new RegExp(it)) : null,
3781
3816
  /* eslint-enable security/detect-non-literal-regexp */
@@ -3841,19 +3876,19 @@ class AllowedLinks extends Rule {
3841
3876
  const link = event.value.toString();
3842
3877
  const style = this.getStyle(link);
3843
3878
  switch (style) {
3844
- case "anchor" /* Style.ANCHOR */:
3879
+ case Style$2.ANCHOR:
3845
3880
  /* anchor links are always allowed by this rule */
3846
3881
  break;
3847
- case "absolute" /* Style.ABSOLUTE */:
3882
+ case Style$2.ABSOLUTE:
3848
3883
  this.handleAbsolute(link, event, style);
3849
3884
  break;
3850
- case "external" /* Style.EXTERNAL */:
3885
+ case Style$2.EXTERNAL:
3851
3886
  this.handleExternal(link, event, style);
3852
3887
  break;
3853
- case "relative-base" /* Style.RELATIVE_BASE */:
3888
+ case Style$2.RELATIVE_BASE:
3854
3889
  this.handleRelativeBase(link, event, style);
3855
3890
  break;
3856
- case "relative-path" /* Style.RELATIVE_PATH */:
3891
+ case Style$2.RELATIVE_PATH:
3857
3892
  this.handleRelativePath(link, event, style);
3858
3893
  break;
3859
3894
  }
@@ -3871,21 +3906,21 @@ class AllowedLinks extends Rule {
3871
3906
  getStyle(value) {
3872
3907
  /* http://example.net or //example.net */
3873
3908
  if (value.match(/^([a-z]+:)?\/\//g)) {
3874
- return "external" /* Style.EXTERNAL */;
3909
+ return Style$2.EXTERNAL;
3875
3910
  }
3876
3911
  switch (value[0]) {
3877
3912
  /* /foo/bar */
3878
3913
  case "/":
3879
- return "absolute" /* Style.ABSOLUTE */;
3914
+ return Style$2.ABSOLUTE;
3880
3915
  /* ../foo/bar */
3881
3916
  case ".":
3882
- return "relative-path" /* Style.RELATIVE_PATH */;
3917
+ return Style$2.RELATIVE_PATH;
3883
3918
  /* #foo */
3884
3919
  case "#":
3885
- return "anchor" /* Style.ANCHOR */;
3920
+ return Style$2.ANCHOR;
3886
3921
  /* foo/bar */
3887
3922
  default:
3888
- return "relative-base" /* Style.RELATIVE_BASE */;
3923
+ return Style$2.RELATIVE_BASE;
3889
3924
  }
3890
3925
  }
3891
3926
  handleAbsolute(target, event, style) {
@@ -4223,6 +4258,9 @@ class AttrCase extends Rule {
4223
4258
  }
4224
4259
  }
4225
4260
 
4261
+ /**
4262
+ * @internal
4263
+ */
4226
4264
  var TokenType;
4227
4265
  (function (TokenType) {
4228
4266
  TokenType[TokenType["UNICODE_BOM"] = 1] = "UNICODE_BOM";
@@ -4244,7 +4282,7 @@ var TokenType;
4244
4282
  TokenType[TokenType["EOF"] = 17] = "EOF";
4245
4283
  })(TokenType || (TokenType = {}));
4246
4284
 
4247
- /* eslint-disable no-useless-escape */
4285
+ /* eslint-disable no-useless-escape -- false positives */
4248
4286
  const MATCH_UNICODE_BOM = /^\uFEFF/;
4249
4287
  const MATCH_WHITESPACE = /^(?:\r\n|\r|\n|[ \t]+(?:\r\n|\r|\n)?)/;
4250
4288
  const MATCH_DOCTYPE_OPEN = /^<!(DOCTYPE)\s/i;
@@ -4269,6 +4307,7 @@ const MATCH_STYLE_END = /^<(\/)(style)/;
4269
4307
  const MATCH_DIRECTIVE = /^(<!--\s*\[html-validate-)([a-z0-9-]+)(\s*)(.*?)(]?\s*-->)/;
4270
4308
  const MATCH_COMMENT = /^<!--([^]*?)-->/;
4271
4309
  const MATCH_CONDITIONAL = /^<!\[([^\]]*?)\]>/;
4310
+ /* eslint-enable no-useless-escape */
4272
4311
  class InvalidTokenError extends Error {
4273
4312
  constructor(location, message) {
4274
4313
  super(message);
@@ -4276,7 +4315,7 @@ class InvalidTokenError extends Error {
4276
4315
  }
4277
4316
  }
4278
4317
  class Lexer {
4279
- // eslint-disable-next-line complexity
4318
+ /* eslint-disable-next-line complexity -- there isn't really a good way to refactor this while keeping readability */
4280
4319
  *tokenize(source) {
4281
4320
  const context = new Context(source);
4282
4321
  /* for sanity check */
@@ -4410,7 +4449,6 @@ class Lexer {
4410
4449
  ], "expected doctype name");
4411
4450
  }
4412
4451
  *tokenizeTag(context) {
4413
- /* eslint-disable-next-line consistent-return -- exhaustive switch handled by typescript */
4414
4452
  function nextState(token) {
4415
4453
  const tagCloseToken = token;
4416
4454
  switch (context.contentModel) {
@@ -4507,11 +4545,11 @@ const defaults$t = {
4507
4545
  };
4508
4546
  function generateRegexp(pattern) {
4509
4547
  if (Array.isArray(pattern)) {
4510
- /* eslint-disable-next-line security/detect-non-literal-regexp */
4548
+ /* eslint-disable-next-line security/detect-non-literal-regexp -- expected to be regexp */
4511
4549
  return new RegExp(`^(${pattern.join("|")})$`, "i");
4512
4550
  }
4513
4551
  else {
4514
- /* eslint-disable-next-line security/detect-non-literal-regexp */
4552
+ /* eslint-disable-next-line security/detect-non-literal-regexp -- expected to be regexp */
4515
4553
  return new RegExp(`^${pattern}$`, "i");
4516
4554
  }
4517
4555
  }
@@ -5061,7 +5099,7 @@ function parsePattern(pattern) {
5061
5099
  case "underscore":
5062
5100
  return /^[a-z0-9_]+$/;
5063
5101
  default:
5064
- // eslint-disable-next-line security/detect-non-literal-regexp
5102
+ /* eslint-disable-next-line security/detect-non-literal-regexp -- expected to be regexp */
5065
5103
  return new RegExp(pattern);
5066
5104
  }
5067
5105
  }
@@ -5477,7 +5515,7 @@ const defaults$l = {
5477
5515
  class ElementName extends Rule {
5478
5516
  constructor(options) {
5479
5517
  super({ ...defaults$l, ...options });
5480
- // eslint-disable-next-line security/detect-non-literal-regexp
5518
+ /* eslint-disable-next-line security/detect-non-literal-regexp -- expected to be a regexp */
5481
5519
  this.pattern = new RegExp(this.options.pattern);
5482
5520
  }
5483
5521
  static schema() {
@@ -6257,7 +6295,7 @@ class FormDupName extends Rule {
6257
6295
  const defaults$j = {
6258
6296
  allowMultipleH1: false,
6259
6297
  minInitialRank: "h1",
6260
- sectioningRoots: ["dialog", '[role="dialog"]'],
6298
+ sectioningRoots: ["dialog", '[role="dialog"]', '[role="alertdialog"]'],
6261
6299
  };
6262
6300
  function isRelevant$3(event) {
6263
6301
  const node = event.target;
@@ -6485,7 +6523,7 @@ class IdPattern extends Rule {
6485
6523
  }
6486
6524
  }
6487
6525
 
6488
- /* eslint-disable sonarjs/no-duplicate-string */
6526
+ /* eslint-disable sonarjs/no-duplicate-string -- wont be easier to read or manage with constants */
6489
6527
  const restricted = new Map([
6490
6528
  ["accept", ["file"]],
6491
6529
  ["alt", ["image"]],
@@ -7455,7 +7493,7 @@ class NoRawCharacters extends Rule {
7455
7493
  const node = event.target;
7456
7494
  /* only iterate over direct descendants */
7457
7495
  for (const child of node.childNodes) {
7458
- if (child.nodeType !== NodeType.TEXT_NODE) {
7496
+ if (child.nodeType !== exports.NodeType.TEXT_NODE) {
7459
7497
  continue;
7460
7498
  }
7461
7499
  /* workaround for templating <% ... %> etc */
@@ -8301,11 +8339,11 @@ function constructRegex(characters) {
8301
8339
  })
8302
8340
  .join("|");
8303
8341
  const pattern = `(${disallowed})`;
8304
- /* eslint-disable-next-line security/detect-non-literal-regexp */
8342
+ /* eslint-disable-next-line security/detect-non-literal-regexp -- technical debt, should do more input sanitation */
8305
8343
  return new RegExp(pattern, "g");
8306
8344
  }
8307
8345
  function getText(node) {
8308
- /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
8346
+ /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- this will always match something, it cannot be null */
8309
8347
  const match = node.textContent.match(/^(\s*)(.*)$/);
8310
8348
  const [, leading, text] = match;
8311
8349
  return [leading.length, text.trimEnd()];
@@ -8314,15 +8352,11 @@ function getText(node) {
8314
8352
  * Node 12 does not support String.matchAll, this simulates it's behavior.
8315
8353
  */
8316
8354
  function matchAll(text, regexp) {
8317
- /* eslint-disable-next-line security/detect-non-literal-regexp */
8355
+ /* eslint-disable-next-line security/detect-non-literal-regexp -- makes copy of existing one only */
8318
8356
  const copy = new RegExp(regexp);
8319
8357
  const matches = [];
8320
- /* eslint-disable-next-line no-constant-condition */
8321
- while (true) {
8322
- const match = copy.exec(text);
8323
- if (match === null) {
8324
- break;
8325
- }
8358
+ let match;
8359
+ while ((match = copy.exec(text))) {
8326
8360
  matches.push(match);
8327
8361
  }
8328
8362
  return matches;
@@ -8532,13 +8566,13 @@ class TextContent extends Rule {
8532
8566
  };
8533
8567
  if (context === null || context === void 0 ? void 0 : context.textContent) {
8534
8568
  switch (context.textContent) {
8535
- case TextContent$1.NONE:
8569
+ case exports.TextContent.NONE:
8536
8570
  doc.description = `The \`<${context.tagName}>\` element must not have textual content.`;
8537
8571
  break;
8538
- case TextContent$1.REQUIRED:
8572
+ case exports.TextContent.REQUIRED:
8539
8573
  doc.description = `The \`<${context.tagName}>\` element must have textual content.`;
8540
8574
  break;
8541
- case TextContent$1.ACCESSIBLE:
8575
+ case exports.TextContent.ACCESSIBLE:
8542
8576
  doc.description = `The \`<${context.tagName}>\` element must have accessible text.`;
8543
8577
  break;
8544
8578
  }
@@ -8553,7 +8587,7 @@ class TextContent extends Rule {
8553
8587
  }
8554
8588
  /* skip elements without explicit and default textContent */
8555
8589
  const { textContent } = target.meta;
8556
- if (!textContent || textContent === TextContent$1.DEFAULT) {
8590
+ if (!textContent || textContent === exports.TextContent.DEFAULT) {
8557
8591
  return false;
8558
8592
  }
8559
8593
  return true;
@@ -8563,13 +8597,13 @@ class TextContent extends Rule {
8563
8597
  const target = event.target;
8564
8598
  const { textContent } = target.meta;
8565
8599
  switch (textContent) {
8566
- case TextContent$1.NONE:
8600
+ case exports.TextContent.NONE:
8567
8601
  this.validateNone(target);
8568
8602
  break;
8569
- case TextContent$1.REQUIRED:
8603
+ case exports.TextContent.REQUIRED:
8570
8604
  this.validateRequired(target);
8571
8605
  break;
8572
- case TextContent$1.ACCESSIBLE:
8606
+ case exports.TextContent.ACCESSIBLE:
8573
8607
  this.validateAccessible(target);
8574
8608
  break;
8575
8609
  }
@@ -8682,7 +8716,7 @@ class UnknownCharReference extends Rule {
8682
8716
  const node = event.target;
8683
8717
  /* only iterate over direct descendants */
8684
8718
  for (const child of node.childNodes) {
8685
- if (child.nodeType !== NodeType.TEXT_NODE) {
8719
+ if (child.nodeType !== exports.NodeType.TEXT_NODE) {
8686
8720
  continue;
8687
8721
  }
8688
8722
  this.findCharacterReferences(node, child.textContent, child.location, {
@@ -8708,43 +8742,46 @@ class UnknownCharReference extends Rule {
8708
8742
  return elements.entities;
8709
8743
  }
8710
8744
  }
8711
- /* eslint-disable-next-line complexity */
8712
8745
  findCharacterReferences(node, text, location, { isAttribute }) {
8713
- const { requireSemicolon } = this.options;
8714
8746
  const isQuerystring = isAttribute && text.includes("?");
8715
- for (const { match, entity, raw, terminated } of this.getMatches(text)) {
8716
- /* assume numeric entities are valid for now */
8717
- if (isNumerical(entity)) {
8718
- continue;
8719
- }
8720
- /* special case: when attributes use query parameters we skip checking
8721
- * unterminated attributes */
8722
- if (isQuerystring && !terminated) {
8723
- continue;
8724
- }
8725
- const found = this.entities.includes(entity);
8726
- /* ignore if this is a known character reference name */
8727
- if (found && (terminated || !requireSemicolon)) {
8728
- continue;
8729
- }
8730
- if (found && !terminated) {
8731
- const entityLocation = getLocation(location, entity, match);
8732
- const message = `Character reference "{{ entity }}" must be terminated by a semicolon`;
8733
- const context = {
8734
- entity: raw,
8735
- terminated: false,
8736
- };
8737
- this.report(node, message, entityLocation, context);
8738
- continue;
8739
- }
8747
+ for (const match of this.getMatches(text)) {
8748
+ this.validateCharacterReference(node, location, match, { isQuerystring });
8749
+ }
8750
+ }
8751
+ validateCharacterReference(node, location, foobar, { isQuerystring }) {
8752
+ const { requireSemicolon } = this.options;
8753
+ const { match, entity, raw, terminated } = foobar;
8754
+ /* assume numeric entities are valid for now */
8755
+ if (isNumerical(entity)) {
8756
+ return;
8757
+ }
8758
+ /* special case: when attributes use query parameters we skip checking
8759
+ * unterminated attributes */
8760
+ if (isQuerystring && !terminated) {
8761
+ return;
8762
+ }
8763
+ const found = this.entities.includes(entity);
8764
+ /* ignore if this is a known character reference name */
8765
+ if (found && (terminated || !requireSemicolon)) {
8766
+ return;
8767
+ }
8768
+ if (found && !terminated) {
8740
8769
  const entityLocation = getLocation(location, entity, match);
8741
- const message = `Unrecognized character reference "{{ entity }}"`;
8770
+ const message = `Character reference "{{ entity }}" must be terminated by a semicolon`;
8742
8771
  const context = {
8743
8772
  entity: raw,
8744
- terminated: true,
8773
+ terminated: false,
8745
8774
  };
8746
8775
  this.report(node, message, entityLocation, context);
8776
+ return;
8747
8777
  }
8778
+ const entityLocation = getLocation(location, entity, match);
8779
+ const message = `Unrecognized character reference "{{ entity }}"`;
8780
+ const context = {
8781
+ entity: raw,
8782
+ terminated: true,
8783
+ };
8784
+ this.report(node, message, entityLocation, context);
8748
8785
  }
8749
8786
  *getMatches(text) {
8750
8787
  let match;
@@ -9608,6 +9645,8 @@ const presets = {
9608
9645
  /**
9609
9646
  * A resolved configuration is a normalized configuration with all extends,
9610
9647
  * plugins etc resolved.
9648
+ *
9649
+ * @public
9611
9650
  */
9612
9651
  class ResolvedConfig {
9613
9652
  constructor({ metaTable, plugins, rules, transformers }) {
@@ -9853,7 +9892,7 @@ class Config {
9853
9892
  * Must be called before trying to use config. Can safely be called multiple
9854
9893
  * times.
9855
9894
  *
9856
- * @internal
9895
+ * @public
9857
9896
  */
9858
9897
  init() {
9859
9898
  if (this.initialized) {
@@ -9873,7 +9912,7 @@ class Config {
9873
9912
  * Returns a new configuration as a merge of the two. Entries from the passed
9874
9913
  * object takes priority over this object.
9875
9914
  *
9876
- * @internal
9915
+ * @public
9877
9916
  * @param rhs - Configuration to merge with this one.
9878
9917
  */
9879
9918
  merge(rhs) {
@@ -9900,7 +9939,7 @@ class Config {
9900
9939
  /**
9901
9940
  * Get element metadata.
9902
9941
  */
9903
- /* eslint-disable-next-line complexity, sonarjs/cognitive-complexity */
9942
+ /* eslint-disable-next-line complexity, sonarjs/cognitive-complexity -- technical debt, should be refactored */
9904
9943
  getMetaTable() {
9905
9944
  /* use cached table if it exists */
9906
9945
  if (this.metaTable) {
@@ -10102,7 +10141,7 @@ class Config {
10102
10141
  throw new ConfigError(`Transformer uses API version ${version} but only version ${TRANSFORMER_API.VERSION} is supported`);
10103
10142
  }
10104
10143
  return {
10105
- // eslint-disable-next-line security/detect-non-literal-regexp
10144
+ // eslint-disable-next-line security/detect-non-literal-regexp -- expected to be a regexp
10106
10145
  pattern: new RegExp(pattern),
10107
10146
  name,
10108
10147
  fn,
@@ -10207,6 +10246,9 @@ class Config {
10207
10246
  /* set global instance */
10208
10247
  rootDirCache = value;
10209
10248
  }
10249
+ /**
10250
+ * @internal
10251
+ */
10210
10252
  findRootDir() {
10211
10253
  const cache = this.rootDirCache;
10212
10254
  if (cache !== null) {
@@ -10214,7 +10256,7 @@ class Config {
10214
10256
  }
10215
10257
  /* try to locate package.json */
10216
10258
  let current = process.cwd();
10217
- // eslint-disable-next-line no-constant-condition
10259
+ // eslint-disable-next-line no-constant-condition -- break outs when filesystem is traversed
10218
10260
  while (true) {
10219
10261
  const search = path__default.default.join(current, "package.json");
10220
10262
  if (fs__default.default.existsSync(search)) {
@@ -10259,7 +10301,7 @@ class ConfigLoader {
10259
10301
  }
10260
10302
 
10261
10303
  /**
10262
- * @internal
10304
+ * @public
10263
10305
  */
10264
10306
  class EventHandler {
10265
10307
  constructor() {
@@ -10307,7 +10349,6 @@ class EventHandler {
10307
10349
  * @param event - Event name.
10308
10350
  * @param data - Event data.
10309
10351
  */
10310
- /* eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types */
10311
10352
  trigger(event, data) {
10312
10353
  var _a, _b;
10313
10354
  const callbacks = [...((_a = this.listeners[event]) !== null && _a !== void 0 ? _a : []), ...((_b = this.listeners["*"]) !== null && _b !== void 0 ? _b : [])];
@@ -10459,7 +10500,7 @@ class Parser {
10459
10500
  return Boolean(active.parent && active.parent.is(tagName) && meta.includes(active.tagName));
10460
10501
  }
10461
10502
  }
10462
- /* eslint-disable-next-line complexity */
10503
+ /* eslint-disable-next-line complexity -- there isn't really a good other way to structure this method (that is still readable) */
10463
10504
  consume(source, token, tokenStream) {
10464
10505
  switch (token.type) {
10465
10506
  case TokenType.UNICODE_BOM:
@@ -10496,7 +10537,7 @@ class Parser {
10496
10537
  break;
10497
10538
  }
10498
10539
  }
10499
- /* eslint-disable-next-line complexity, sonarjs/cognitive-complexity */
10540
+ /* eslint-disable-next-line complexity, sonarjs/cognitive-complexity -- technical debt, chould be refactored a bit */
10500
10541
  consumeTag(source, startToken, tokenStream) {
10501
10542
  const tokens = Array.from(this.consumeUntil(tokenStream, TokenType.TAG_CLOSE, startToken.location));
10502
10543
  const endToken = tokens.slice(-1)[0];
@@ -10930,7 +10971,7 @@ function freeze(src) {
10930
10971
  };
10931
10972
  }
10932
10973
  /**
10933
- * @internal
10974
+ * @public
10934
10975
  */
10935
10976
  class Reporter {
10936
10977
  constructor() {
@@ -11122,7 +11163,6 @@ class Engine {
11122
11163
  };
11123
11164
  parser.trigger("config:ready", configEvent);
11124
11165
  /* trigger source ready event */
11125
- /* eslint-disable-next-line @typescript-eslint/no-unused-vars -- object destructured on purpose to remove property */
11126
11166
  const { hooks: _, ...sourceData } = source;
11127
11167
  const sourceEvent = {
11128
11168
  location,
@@ -11217,8 +11257,7 @@ class Engine {
11217
11257
  /**
11218
11258
  * Get rule documentation.
11219
11259
  */
11220
- getRuleDocumentation(ruleId, context // eslint-disable-line @typescript-eslint/explicit-module-boundary-types
11221
- ) {
11260
+ getRuleDocumentation(ruleId, context) {
11222
11261
  const rules = this.config.getRules();
11223
11262
  const ruleData = rules.get(ruleId);
11224
11263
  if (ruleData) {
@@ -11744,7 +11783,7 @@ class HtmlValidate {
11744
11783
  /** @public */
11745
11784
  const name = "html-validate";
11746
11785
  /** @public */
11747
- const version = "7.13.3";
11786
+ const version = "7.15.0";
11748
11787
  /** @public */
11749
11788
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
11750
11789
 
@@ -11761,7 +11800,7 @@ const defaults$1 = {
11761
11800
  silent: false,
11762
11801
  version,
11763
11802
  logger(text) {
11764
- /* eslint-disable-next-line no-console */
11803
+ /* eslint-disable-next-line no-console -- expected to log */
11765
11804
  console.error(kleur__default.default.red(text));
11766
11805
  },
11767
11806
  };
@@ -11906,7 +11945,7 @@ class FileSystemConfigLoader extends ConfigLoader {
11906
11945
  let found = false;
11907
11946
  let current = path__default.default.resolve(path__default.default.dirname(filename));
11908
11947
  let config = this.empty();
11909
- // eslint-disable-next-line no-constant-condition
11948
+ // eslint-disable-next-line no-constant-condition -- it will break out when filesystem is traversed
11910
11949
  while (true) {
11911
11950
  /* search configuration files in current directory */
11912
11951
  for (const configFile of findConfigurationFiles(current)) {
@@ -11985,7 +12024,7 @@ function checkstyleFormatter(results) {
11985
12024
  output += "</checkstyle>\n";
11986
12025
  return output;
11987
12026
  }
11988
- const formatter$4 = checkstyleFormatter;
12027
+ const formatter$3 = checkstyleFormatter;
11989
12028
 
11990
12029
  const defaults = {
11991
12030
  showLink: true,
@@ -12116,7 +12155,6 @@ function codeframe(results, options) {
12116
12155
  }
12117
12156
  return errors + warnings > 0 ? output : "";
12118
12157
  }
12119
- const formatter$3 = codeframe;
12120
12158
 
12121
12159
  function jsonFormatter(results) {
12122
12160
  return JSON.stringify(results);
@@ -12176,8 +12214,8 @@ function textFormatter(results) {
12176
12214
  const formatter = textFormatter;
12177
12215
 
12178
12216
  const availableFormatters = {
12179
- checkstyle: formatter$4,
12180
- codeframe: formatter$3,
12217
+ checkstyle: formatter$3,
12218
+ codeframe,
12181
12219
  json: formatter$2,
12182
12220
  stylish: formatter$1,
12183
12221
  text: formatter,
@@ -12191,6 +12229,9 @@ exports.Attribute = Attribute;
12191
12229
  exports.Config = Config;
12192
12230
  exports.ConfigError = ConfigError;
12193
12231
  exports.ConfigLoader = ConfigLoader;
12232
+ exports.DOMNode = DOMNode;
12233
+ exports.DOMTokenList = DOMTokenList;
12234
+ exports.DOMTree = DOMTree;
12194
12235
  exports.DynamicValue = DynamicValue;
12195
12236
  exports.EventHandler = EventHandler;
12196
12237
  exports.FileSystemConfigLoader = FileSystemConfigLoader;
@@ -12201,6 +12242,7 @@ exports.MetaTable = MetaTable;
12201
12242
  exports.NestedError = NestedError;
12202
12243
  exports.Parser = Parser;
12203
12244
  exports.Reporter = Reporter;
12245
+ exports.ResolvedConfig = ResolvedConfig;
12204
12246
  exports.Rule = Rule;
12205
12247
  exports.SchemaValidationError = SchemaValidationError;
12206
12248
  exports.StaticConfigLoader = StaticConfigLoader;