html-validate 7.14.0 → 7.15.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 (59) 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 +5 -5
  7. package/dist/cjs/cli.js.map +1 -1
  8. package/dist/cjs/core.js +193 -122
  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 +4 -4
  30. package/dist/es/cli.js.map +1 -1
  31. package/dist/es/core.js +172 -105
  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/tsdoc-metadata.json +11 -0
  49. package/dist/{es/core.d.ts → types/browser.d.ts} +2435 -2615
  50. package/dist/{cjs/core.d.ts → types/index.d.ts} +2628 -2615
  51. package/dist/types/jest.d.ts +44 -0
  52. package/dist/types/test-utils.d.ts +40 -0
  53. package/jest.d.ts +1 -2
  54. package/package.json +33 -27
  55. package/test-utils.d.ts +1 -2
  56. package/dist/cjs/meta-helper.d.ts +0 -28
  57. package/dist/cjs/rules-helper.d.ts +0 -54
  58. package/dist/es/meta-helper.d.ts +0 -28
  59. package/dist/es/rules-helper.d.ts +0 -54
package/dist/es/core.js CHANGED
@@ -261,6 +261,8 @@ class DynamicValue {
261
261
  *
262
262
  * Represents a HTML attribute. Can contain either a fixed static value or a
263
263
  * placeholder for dynamic values (e.g. interpolated).
264
+ *
265
+ * @public
264
266
  */
265
267
  class Attribute {
266
268
  /**
@@ -374,7 +376,7 @@ function sliceLocation(location, begin, end, wrap) {
374
376
  else {
375
377
  break;
376
378
  }
377
- } while (true); // eslint-disable-line no-constant-condition
379
+ } while (true); // eslint-disable-line no-constant-condition -- it will break out
378
380
  }
379
381
  return sliced;
380
382
  }
@@ -443,6 +445,9 @@ class Context {
443
445
  }
444
446
  }
445
447
 
448
+ /**
449
+ * @public
450
+ */
446
451
  var TextContent$1;
447
452
  (function (TextContent) {
448
453
  /* forbid node to have text content, inter-element whitespace is ignored */
@@ -487,6 +492,9 @@ function setMetaProperty(dst, key, value) {
487
492
  dst[key] = value;
488
493
  }
489
494
 
495
+ /**
496
+ * @public
497
+ */
490
498
  var NodeType;
491
499
  (function (NodeType) {
492
500
  NodeType[NodeType["ELEMENT_NODE"] = 1] = "ELEMENT_NODE";
@@ -497,6 +505,9 @@ var NodeType;
497
505
  const DOCUMENT_NODE_NAME = "#document";
498
506
  const TEXT_CONTENT = Symbol("textContent");
499
507
  let counter = 0;
508
+ /**
509
+ * @public
510
+ */
500
511
  class DOMNode {
501
512
  /**
502
513
  * Create a new DOMNode.
@@ -520,6 +531,8 @@ class DOMNode {
520
531
  * Enable cache for this node.
521
532
  *
522
533
  * Should not be called before the node and all children are fully constructed.
534
+ *
535
+ * @internal
523
536
  */
524
537
  cacheEnable() {
525
538
  this.cache = new Map();
@@ -569,6 +582,8 @@ class DOMNode {
569
582
  }
570
583
  /**
571
584
  * Tests if two nodes are the same (references the same object).
585
+ *
586
+ * @since v4.11.0
572
587
  */
573
588
  isSameNode(otherNode) {
574
589
  return this.unique === otherNode.unique;
@@ -694,6 +709,9 @@ function parse(text, baseLocation) {
694
709
  }
695
710
  return { tokens, locations };
696
711
  }
712
+ /**
713
+ * @public
714
+ */
697
715
  class DOMTokenList extends Array {
698
716
  constructor(value, location) {
699
717
  if (value && typeof value === "string") {
@@ -730,7 +748,7 @@ class DOMTokenList extends Array {
730
748
  }
731
749
  *iterator() {
732
750
  for (let index = 0; index < this.length; index++) {
733
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
751
+ /* eslint-disable @typescript-eslint/no-non-null-assertion -- as we loop over length this should always be set */
734
752
  const item = this.item(index);
735
753
  const location = this.location(index);
736
754
  /* eslint-enable @typescript-eslint/no-non-null-assertion */
@@ -1249,7 +1267,7 @@ class HtmlElement extends DOMNode {
1249
1267
  * Implementation of DOM specification of Element.closest(selectors).
1250
1268
  */
1251
1269
  closest(selectors) {
1252
- /* eslint-disable-next-line @typescript-eslint/no-this-alias */
1270
+ /* eslint-disable-next-line @typescript-eslint/no-this-alias -- false positive*/
1253
1271
  let node = this;
1254
1272
  while (node) {
1255
1273
  if (node.matches(selectors)) {
@@ -1270,11 +1288,11 @@ class HtmlElement extends DOMNode {
1270
1288
  }
1271
1289
  const parts = [];
1272
1290
  let root;
1273
- /* eslint-disable-next-line @typescript-eslint/no-this-alias */
1291
+ /* eslint-disable-next-line @typescript-eslint/no-this-alias -- false positive */
1274
1292
  for (root = this; root.parent; root = root.parent) {
1275
1293
  /* .. */
1276
1294
  }
1277
- // eslint-disable-next-line @typescript-eslint/no-this-alias
1295
+ // eslint-disable-next-line @typescript-eslint/no-this-alias -- false positive
1278
1296
  for (let cur = this; cur.parent; cur = cur.parent) {
1279
1297
  /* if a unique id is present, use it and short-circuit */
1280
1298
  if (cur.id) {
@@ -1358,7 +1376,7 @@ class HtmlElement extends DOMNode {
1358
1376
  */
1359
1377
  matches(selector) {
1360
1378
  /* find root element */
1361
- /* eslint-disable-next-line @typescript-eslint/no-this-alias */
1379
+ /* eslint-disable-next-line @typescript-eslint/no-this-alias -- false positive */
1362
1380
  let root = this;
1363
1381
  while (root.parent) {
1364
1382
  root = root.parent;
@@ -1507,9 +1525,14 @@ class HtmlElement extends DOMNode {
1507
1525
  }, []);
1508
1526
  }
1509
1527
  querySelector(selector) {
1510
- var _a;
1511
1528
  const it = this.querySelectorImpl(selector);
1512
- return (_a = it.next().value) !== null && _a !== void 0 ? _a : null; // eslint-disable-line @typescript-eslint/no-unsafe-return
1529
+ const next = it.next();
1530
+ if (next.done) {
1531
+ return null;
1532
+ }
1533
+ else {
1534
+ return next.value;
1535
+ }
1513
1536
  }
1514
1537
  querySelectorAll(selector) {
1515
1538
  const it = this.querySelectorImpl(selector);
@@ -1603,6 +1626,9 @@ function isClosed(endToken, meta) {
1603
1626
  return closed;
1604
1627
  }
1605
1628
 
1629
+ /**
1630
+ * @public
1631
+ */
1606
1632
  class DOMTree {
1607
1633
  constructor(location) {
1608
1634
  this.root = HtmlElement.rootNode(location);
@@ -1681,6 +1707,9 @@ function ensureError(value) {
1681
1707
  }
1682
1708
  }
1683
1709
 
1710
+ /**
1711
+ * @public
1712
+ */
1684
1713
  class NestedError extends Error {
1685
1714
  constructor(message, nested) {
1686
1715
  super(message);
@@ -2447,7 +2476,7 @@ class MetaTable {
2447
2476
  /**
2448
2477
  * Extend validation schema.
2449
2478
  *
2450
- * @internal
2479
+ * @public
2451
2480
  */
2452
2481
  extendValidationSchema(patch) {
2453
2482
  if (patch.properties) {
@@ -2468,7 +2497,7 @@ class MetaTable {
2468
2497
  /**
2469
2498
  * Load metadata table from object.
2470
2499
  *
2471
- * @internal
2500
+ * @public
2472
2501
  * @param obj - Object with metadata to load
2473
2502
  * @param filename - Optional filename used when presenting validation error
2474
2503
  */
@@ -2489,7 +2518,7 @@ class MetaTable {
2489
2518
  /**
2490
2519
  * Load metadata table from filename
2491
2520
  *
2492
- * @internal
2521
+ * @public
2493
2522
  * @param filename - Filename to load
2494
2523
  */
2495
2524
  loadFromFile(filename) {
@@ -2652,7 +2681,7 @@ function expandRegexValue(value) {
2652
2681
  const match = value.match(/^\/\^?([^/$]*)\$?\/([i]*)$/);
2653
2682
  if (match) {
2654
2683
  const [, expr, flags] = match;
2655
- // eslint-disable-next-line security/detect-non-literal-regexp
2684
+ // eslint-disable-next-line security/detect-non-literal-regexp -- expected to be regexp
2656
2685
  return new RegExp(`^${expr}$`, flags);
2657
2686
  }
2658
2687
  else {
@@ -2853,7 +2882,6 @@ class Validator {
2853
2882
  * @param rules - Element attribute metadta.
2854
2883
  * @returns `true` if attribute passes all tests.
2855
2884
  */
2856
- /* eslint-disable-next-line complexity */
2857
2885
  static validateAttribute(attr, rules) {
2858
2886
  const rule = rules[attr.key];
2859
2887
  if (!rule) {
@@ -2944,7 +2972,7 @@ class Validator {
2944
2972
  * @param category - Name of category with `@` prefix or tag name.
2945
2973
  * @param defaultMatch - The default return value when node categories is not known.
2946
2974
  */
2947
- // eslint-disable-next-line complexity
2975
+ /* eslint-disable-next-line complexity -- rule does not like switch */
2948
2976
  static validatePermittedCategory(node, category, defaultMatch) {
2949
2977
  const [, rawCategory] = category.match(/^(@?.*?)([?*]?)$/);
2950
2978
  /* match tagName when an explicit name is given */
@@ -3151,7 +3179,8 @@ var configurationSchema = {
3151
3179
  properties: properties
3152
3180
  };
3153
3181
 
3154
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
3182
+ /* eslint-disable @typescript-eslint/no-non-null-assertion -- declarations say
3183
+ * location fields are optional but they are always present when `{loc: true}` */
3155
3184
  function joinTemplateLiteral(nodes) {
3156
3185
  let offset = nodes[0].start + 1;
3157
3186
  let output = "";
@@ -3372,7 +3401,7 @@ function parseSeverity(value) {
3372
3401
  return Severity.DISABLED;
3373
3402
  /* istanbul ignore next: deprecated code which will be removed later */
3374
3403
  case "disable":
3375
- // eslint-disable-next-line no-console
3404
+ // eslint-disable-next-line no-console -- expected to log
3376
3405
  console.warn(`Deprecated alias "disabled" will be removed, replace with severity "off"`);
3377
3406
  return Severity.DISABLED;
3378
3407
  case 1:
@@ -3483,8 +3512,8 @@ class Rule {
3483
3512
  this.severity = severity;
3484
3513
  }
3485
3514
  /**
3486
- * Block this rule from generating errors. Pass in an id generated by {@link
3487
- * createBlocker}. Can be unblocked by {@link unblock}.
3515
+ * Block this rule from generating errors. Pass in an id generated by
3516
+ * `createBlocker`. Can be unblocked by {@link Rule.unblock}.
3488
3517
  *
3489
3518
  * A blocked rule is similar to disabling it but it will still receive parser
3490
3519
  * events. A list of all blockers is passed to the `rule:error` event.
@@ -3495,7 +3524,7 @@ class Rule {
3495
3524
  this.blockers.push(id);
3496
3525
  }
3497
3526
  /**
3498
- * Unblock a rule previously blocked by {@link block}.
3527
+ * Unblock a rule previously blocked by {@link Rule.block}.
3499
3528
  *
3500
3529
  * @internal
3501
3530
  */
@@ -3713,12 +3742,20 @@ class Rule {
3713
3742
  * @returns Rule documentation and url with additional details or `null` if no
3714
3743
  * additional documentation is available.
3715
3744
  */
3716
- /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
3745
+ /* eslint-disable-next-line @typescript-eslint/no-unused-vars -- technical debt, prototype should be moved to interface */
3717
3746
  documentation(context) {
3718
3747
  return null;
3719
3748
  }
3720
3749
  }
3721
3750
 
3751
+ var Style$2;
3752
+ (function (Style) {
3753
+ Style["EXTERNAL"] = "external";
3754
+ Style["RELATIVE_BASE"] = "relative-base";
3755
+ Style["RELATIVE_PATH"] = "relative-path";
3756
+ Style["ABSOLUTE"] = "absolute";
3757
+ Style["ANCHOR"] = "anchor";
3758
+ })(Style$2 || (Style$2 = {}));
3722
3759
  const defaults$w = {
3723
3760
  allowExternal: true,
3724
3761
  allowRelative: true,
@@ -3732,18 +3769,18 @@ const mapping$1 = {
3732
3769
  script: "src",
3733
3770
  };
3734
3771
  const description = {
3735
- ["external" /* Style.EXTERNAL */]: "External links are not allowed by current configuration.",
3736
- ["relative-base" /* Style.RELATIVE_BASE */]: "Links relative to <base> are not allowed by current configuration.",
3737
- ["relative-path" /* Style.RELATIVE_PATH */]: "Relative links are not allowed by current configuration.",
3738
- ["absolute" /* Style.ABSOLUTE */]: "Absolute links are not allowed by current configuration.",
3739
- ["anchor" /* Style.ANCHOR */]: null,
3772
+ [Style$2.EXTERNAL]: "External links are not allowed by current configuration.",
3773
+ [Style$2.RELATIVE_BASE]: "Links relative to <base> are not allowed by current configuration.",
3774
+ [Style$2.RELATIVE_PATH]: "Relative links are not allowed by current configuration.",
3775
+ [Style$2.ABSOLUTE]: "Absolute links are not allowed by current configuration.",
3776
+ [Style$2.ANCHOR]: null,
3740
3777
  };
3741
3778
  function parseAllow(value) {
3742
3779
  if (typeof value === "boolean") {
3743
3780
  return value;
3744
3781
  }
3745
3782
  return {
3746
- /* eslint-disable security/detect-non-literal-regexp */
3783
+ /* eslint-disable security/detect-non-literal-regexp -- expected to be regexp */
3747
3784
  include: value.include ? value.include.map((it) => new RegExp(it)) : null,
3748
3785
  exclude: value.exclude ? value.exclude.map((it) => new RegExp(it)) : null,
3749
3786
  /* eslint-enable security/detect-non-literal-regexp */
@@ -3809,19 +3846,19 @@ class AllowedLinks extends Rule {
3809
3846
  const link = event.value.toString();
3810
3847
  const style = this.getStyle(link);
3811
3848
  switch (style) {
3812
- case "anchor" /* Style.ANCHOR */:
3849
+ case Style$2.ANCHOR:
3813
3850
  /* anchor links are always allowed by this rule */
3814
3851
  break;
3815
- case "absolute" /* Style.ABSOLUTE */:
3852
+ case Style$2.ABSOLUTE:
3816
3853
  this.handleAbsolute(link, event, style);
3817
3854
  break;
3818
- case "external" /* Style.EXTERNAL */:
3855
+ case Style$2.EXTERNAL:
3819
3856
  this.handleExternal(link, event, style);
3820
3857
  break;
3821
- case "relative-base" /* Style.RELATIVE_BASE */:
3858
+ case Style$2.RELATIVE_BASE:
3822
3859
  this.handleRelativeBase(link, event, style);
3823
3860
  break;
3824
- case "relative-path" /* Style.RELATIVE_PATH */:
3861
+ case Style$2.RELATIVE_PATH:
3825
3862
  this.handleRelativePath(link, event, style);
3826
3863
  break;
3827
3864
  }
@@ -3839,21 +3876,21 @@ class AllowedLinks extends Rule {
3839
3876
  getStyle(value) {
3840
3877
  /* http://example.net or //example.net */
3841
3878
  if (value.match(/^([a-z]+:)?\/\//g)) {
3842
- return "external" /* Style.EXTERNAL */;
3879
+ return Style$2.EXTERNAL;
3843
3880
  }
3844
3881
  switch (value[0]) {
3845
3882
  /* /foo/bar */
3846
3883
  case "/":
3847
- return "absolute" /* Style.ABSOLUTE */;
3884
+ return Style$2.ABSOLUTE;
3848
3885
  /* ../foo/bar */
3849
3886
  case ".":
3850
- return "relative-path" /* Style.RELATIVE_PATH */;
3887
+ return Style$2.RELATIVE_PATH;
3851
3888
  /* #foo */
3852
3889
  case "#":
3853
- return "anchor" /* Style.ANCHOR */;
3890
+ return Style$2.ANCHOR;
3854
3891
  /* foo/bar */
3855
3892
  default:
3856
- return "relative-base" /* Style.RELATIVE_BASE */;
3893
+ return Style$2.RELATIVE_BASE;
3857
3894
  }
3858
3895
  }
3859
3896
  handleAbsolute(target, event, style) {
@@ -4191,6 +4228,9 @@ class AttrCase extends Rule {
4191
4228
  }
4192
4229
  }
4193
4230
 
4231
+ /**
4232
+ * @internal
4233
+ */
4194
4234
  var TokenType;
4195
4235
  (function (TokenType) {
4196
4236
  TokenType[TokenType["UNICODE_BOM"] = 1] = "UNICODE_BOM";
@@ -4212,7 +4252,7 @@ var TokenType;
4212
4252
  TokenType[TokenType["EOF"] = 17] = "EOF";
4213
4253
  })(TokenType || (TokenType = {}));
4214
4254
 
4215
- /* eslint-disable no-useless-escape */
4255
+ /* eslint-disable no-useless-escape -- false positives */
4216
4256
  const MATCH_UNICODE_BOM = /^\uFEFF/;
4217
4257
  const MATCH_WHITESPACE = /^(?:\r\n|\r|\n|[ \t]+(?:\r\n|\r|\n)?)/;
4218
4258
  const MATCH_DOCTYPE_OPEN = /^<!(DOCTYPE)\s/i;
@@ -4237,6 +4277,7 @@ const MATCH_STYLE_END = /^<(\/)(style)/;
4237
4277
  const MATCH_DIRECTIVE = /^(<!--\s*\[html-validate-)([a-z0-9-]+)(\s*)(.*?)(]?\s*-->)/;
4238
4278
  const MATCH_COMMENT = /^<!--([^]*?)-->/;
4239
4279
  const MATCH_CONDITIONAL = /^<!\[([^\]]*?)\]>/;
4280
+ /* eslint-enable no-useless-escape */
4240
4281
  class InvalidTokenError extends Error {
4241
4282
  constructor(location, message) {
4242
4283
  super(message);
@@ -4244,7 +4285,7 @@ class InvalidTokenError extends Error {
4244
4285
  }
4245
4286
  }
4246
4287
  class Lexer {
4247
- // eslint-disable-next-line complexity
4288
+ /* eslint-disable-next-line complexity -- there isn't really a good way to refactor this while keeping readability */
4248
4289
  *tokenize(source) {
4249
4290
  const context = new Context(source);
4250
4291
  /* for sanity check */
@@ -4378,7 +4419,6 @@ class Lexer {
4378
4419
  ], "expected doctype name");
4379
4420
  }
4380
4421
  *tokenizeTag(context) {
4381
- /* eslint-disable-next-line consistent-return -- exhaustive switch handled by typescript */
4382
4422
  function nextState(token) {
4383
4423
  const tagCloseToken = token;
4384
4424
  switch (context.contentModel) {
@@ -4475,11 +4515,11 @@ const defaults$t = {
4475
4515
  };
4476
4516
  function generateRegexp(pattern) {
4477
4517
  if (Array.isArray(pattern)) {
4478
- /* eslint-disable-next-line security/detect-non-literal-regexp */
4518
+ /* eslint-disable-next-line security/detect-non-literal-regexp -- expected to be regexp */
4479
4519
  return new RegExp(`^(${pattern.join("|")})$`, "i");
4480
4520
  }
4481
4521
  else {
4482
- /* eslint-disable-next-line security/detect-non-literal-regexp */
4522
+ /* eslint-disable-next-line security/detect-non-literal-regexp -- expected to be regexp */
4483
4523
  return new RegExp(`^${pattern}$`, "i");
4484
4524
  }
4485
4525
  }
@@ -5029,7 +5069,7 @@ function parsePattern(pattern) {
5029
5069
  case "underscore":
5030
5070
  return /^[a-z0-9_]+$/;
5031
5071
  default:
5032
- // eslint-disable-next-line security/detect-non-literal-regexp
5072
+ /* eslint-disable-next-line security/detect-non-literal-regexp -- expected to be regexp */
5033
5073
  return new RegExp(pattern);
5034
5074
  }
5035
5075
  }
@@ -5445,7 +5485,7 @@ const defaults$l = {
5445
5485
  class ElementName extends Rule {
5446
5486
  constructor(options) {
5447
5487
  super({ ...defaults$l, ...options });
5448
- // eslint-disable-next-line security/detect-non-literal-regexp
5488
+ /* eslint-disable-next-line security/detect-non-literal-regexp -- expected to be a regexp */
5449
5489
  this.pattern = new RegExp(this.options.pattern);
5450
5490
  }
5451
5491
  static schema() {
@@ -6453,7 +6493,7 @@ class IdPattern extends Rule {
6453
6493
  }
6454
6494
  }
6455
6495
 
6456
- /* eslint-disable sonarjs/no-duplicate-string */
6496
+ /* eslint-disable sonarjs/no-duplicate-string -- wont be easier to read or manage with constants */
6457
6497
  const restricted = new Map([
6458
6498
  ["accept", ["file"]],
6459
6499
  ["alt", ["image"]],
@@ -8269,11 +8309,11 @@ function constructRegex(characters) {
8269
8309
  })
8270
8310
  .join("|");
8271
8311
  const pattern = `(${disallowed})`;
8272
- /* eslint-disable-next-line security/detect-non-literal-regexp */
8312
+ /* eslint-disable-next-line security/detect-non-literal-regexp -- technical debt, should do more input sanitation */
8273
8313
  return new RegExp(pattern, "g");
8274
8314
  }
8275
8315
  function getText(node) {
8276
- /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
8316
+ /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- this will always match something, it cannot be null */
8277
8317
  const match = node.textContent.match(/^(\s*)(.*)$/);
8278
8318
  const [, leading, text] = match;
8279
8319
  return [leading.length, text.trimEnd()];
@@ -8282,15 +8322,11 @@ function getText(node) {
8282
8322
  * Node 12 does not support String.matchAll, this simulates it's behavior.
8283
8323
  */
8284
8324
  function matchAll(text, regexp) {
8285
- /* eslint-disable-next-line security/detect-non-literal-regexp */
8325
+ /* eslint-disable-next-line security/detect-non-literal-regexp -- makes copy of existing one only */
8286
8326
  const copy = new RegExp(regexp);
8287
8327
  const matches = [];
8288
- /* eslint-disable-next-line no-constant-condition */
8289
- while (true) {
8290
- const match = copy.exec(text);
8291
- if (match === null) {
8292
- break;
8293
- }
8328
+ let match;
8329
+ while ((match = copy.exec(text))) {
8294
8330
  matches.push(match);
8295
8331
  }
8296
8332
  return matches;
@@ -8676,43 +8712,46 @@ class UnknownCharReference extends Rule {
8676
8712
  return entities$1;
8677
8713
  }
8678
8714
  }
8679
- /* eslint-disable-next-line complexity */
8680
8715
  findCharacterReferences(node, text, location, { isAttribute }) {
8681
- const { requireSemicolon } = this.options;
8682
8716
  const isQuerystring = isAttribute && text.includes("?");
8683
- for (const { match, entity, raw, terminated } of this.getMatches(text)) {
8684
- /* assume numeric entities are valid for now */
8685
- if (isNumerical(entity)) {
8686
- continue;
8687
- }
8688
- /* special case: when attributes use query parameters we skip checking
8689
- * unterminated attributes */
8690
- if (isQuerystring && !terminated) {
8691
- continue;
8692
- }
8693
- const found = this.entities.includes(entity);
8694
- /* ignore if this is a known character reference name */
8695
- if (found && (terminated || !requireSemicolon)) {
8696
- continue;
8697
- }
8698
- if (found && !terminated) {
8699
- const entityLocation = getLocation(location, entity, match);
8700
- const message = `Character reference "{{ entity }}" must be terminated by a semicolon`;
8701
- const context = {
8702
- entity: raw,
8703
- terminated: false,
8704
- };
8705
- this.report(node, message, entityLocation, context);
8706
- continue;
8707
- }
8717
+ for (const match of this.getMatches(text)) {
8718
+ this.validateCharacterReference(node, location, match, { isQuerystring });
8719
+ }
8720
+ }
8721
+ validateCharacterReference(node, location, foobar, { isQuerystring }) {
8722
+ const { requireSemicolon } = this.options;
8723
+ const { match, entity, raw, terminated } = foobar;
8724
+ /* assume numeric entities are valid for now */
8725
+ if (isNumerical(entity)) {
8726
+ return;
8727
+ }
8728
+ /* special case: when attributes use query parameters we skip checking
8729
+ * unterminated attributes */
8730
+ if (isQuerystring && !terminated) {
8731
+ return;
8732
+ }
8733
+ const found = this.entities.includes(entity);
8734
+ /* ignore if this is a known character reference name */
8735
+ if (found && (terminated || !requireSemicolon)) {
8736
+ return;
8737
+ }
8738
+ if (found && !terminated) {
8708
8739
  const entityLocation = getLocation(location, entity, match);
8709
- const message = `Unrecognized character reference "{{ entity }}"`;
8740
+ const message = `Character reference "{{ entity }}" must be terminated by a semicolon`;
8710
8741
  const context = {
8711
8742
  entity: raw,
8712
- terminated: true,
8743
+ terminated: false,
8713
8744
  };
8714
8745
  this.report(node, message, entityLocation, context);
8746
+ return;
8715
8747
  }
8748
+ const entityLocation = getLocation(location, entity, match);
8749
+ const message = `Unrecognized character reference "{{ entity }}"`;
8750
+ const context = {
8751
+ entity: raw,
8752
+ terminated: true,
8753
+ };
8754
+ this.report(node, message, entityLocation, context);
8716
8755
  }
8717
8756
  *getMatches(text) {
8718
8757
  let match;
@@ -9576,6 +9615,8 @@ const presets = {
9576
9615
  /**
9577
9616
  * A resolved configuration is a normalized configuration with all extends,
9578
9617
  * plugins etc resolved.
9618
+ *
9619
+ * @public
9579
9620
  */
9580
9621
  class ResolvedConfig {
9581
9622
  constructor({ metaTable, plugins, rules, transformers }) {
@@ -9821,7 +9862,7 @@ class Config {
9821
9862
  * Must be called before trying to use config. Can safely be called multiple
9822
9863
  * times.
9823
9864
  *
9824
- * @internal
9865
+ * @public
9825
9866
  */
9826
9867
  init() {
9827
9868
  if (this.initialized) {
@@ -9841,7 +9882,7 @@ class Config {
9841
9882
  * Returns a new configuration as a merge of the two. Entries from the passed
9842
9883
  * object takes priority over this object.
9843
9884
  *
9844
- * @internal
9885
+ * @public
9845
9886
  * @param rhs - Configuration to merge with this one.
9846
9887
  */
9847
9888
  merge(rhs) {
@@ -9868,7 +9909,7 @@ class Config {
9868
9909
  /**
9869
9910
  * Get element metadata.
9870
9911
  */
9871
- /* eslint-disable-next-line complexity, sonarjs/cognitive-complexity */
9912
+ /* eslint-disable-next-line complexity, sonarjs/cognitive-complexity -- technical debt, should be refactored */
9872
9913
  getMetaTable() {
9873
9914
  /* use cached table if it exists */
9874
9915
  if (this.metaTable) {
@@ -10041,7 +10082,7 @@ class Config {
10041
10082
  * A resolved configuration will merge all extended configs and load all
10042
10083
  * plugins and transformers, and normalize the rest of the configuration.
10043
10084
  *
10044
- * @internal
10085
+ * @public
10045
10086
  */
10046
10087
  resolve() {
10047
10088
  return new ResolvedConfig(this.resolveData());
@@ -10070,7 +10111,7 @@ class Config {
10070
10111
  throw new ConfigError(`Transformer uses API version ${version} but only version ${TRANSFORMER_API.VERSION} is supported`);
10071
10112
  }
10072
10113
  return {
10073
- // eslint-disable-next-line security/detect-non-literal-regexp
10114
+ // eslint-disable-next-line security/detect-non-literal-regexp -- expected to be a regexp
10074
10115
  pattern: new RegExp(pattern),
10075
10116
  name,
10076
10117
  fn,
@@ -10175,6 +10216,9 @@ class Config {
10175
10216
  /* set global instance */
10176
10217
  rootDirCache = value;
10177
10218
  }
10219
+ /**
10220
+ * @internal
10221
+ */
10178
10222
  findRootDir() {
10179
10223
  const cache = this.rootDirCache;
10180
10224
  if (cache !== null) {
@@ -10182,7 +10226,7 @@ class Config {
10182
10226
  }
10183
10227
  /* try to locate package.json */
10184
10228
  let current = process.cwd();
10185
- // eslint-disable-next-line no-constant-condition
10229
+ // eslint-disable-next-line no-constant-condition -- break outs when filesystem is traversed
10186
10230
  while (true) {
10187
10231
  const search = path.join(current, "package.json");
10188
10232
  if (fs.existsSync(search)) {
@@ -10227,7 +10271,7 @@ class ConfigLoader {
10227
10271
  }
10228
10272
 
10229
10273
  /**
10230
- * @internal
10274
+ * @public
10231
10275
  */
10232
10276
  class EventHandler {
10233
10277
  constructor() {
@@ -10275,7 +10319,6 @@ class EventHandler {
10275
10319
  * @param event - Event name.
10276
10320
  * @param data - Event data.
10277
10321
  */
10278
- /* eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types */
10279
10322
  trigger(event, data) {
10280
10323
  var _a, _b;
10281
10324
  const callbacks = [...((_a = this.listeners[event]) !== null && _a !== void 0 ? _a : []), ...((_b = this.listeners["*"]) !== null && _b !== void 0 ? _b : [])];
@@ -10320,12 +10363,13 @@ function isValidDirective(action) {
10320
10363
  /**
10321
10364
  * Parse HTML document into a DOM tree.
10322
10365
  *
10323
- * @internal
10366
+ * @public
10324
10367
  */
10325
10368
  class Parser {
10326
10369
  /**
10327
10370
  * Create a new parser instance.
10328
10371
  *
10372
+ * @public
10329
10373
  * @param config - Configuration
10330
10374
  */
10331
10375
  constructor(config) {
@@ -10337,6 +10381,7 @@ class Parser {
10337
10381
  /**
10338
10382
  * Parse HTML markup.
10339
10383
  *
10384
+ * @public
10340
10385
  * @param source - HTML markup.
10341
10386
  * @returns DOM tree representing the HTML markup.
10342
10387
  */
@@ -10427,7 +10472,10 @@ class Parser {
10427
10472
  return Boolean(active.parent && active.parent.is(tagName) && meta.includes(active.tagName));
10428
10473
  }
10429
10474
  }
10430
- /* eslint-disable-next-line complexity */
10475
+ /**
10476
+ * @internal
10477
+ */
10478
+ /* eslint-disable-next-line complexity -- there isn't really a good other way to structure this method (that is still readable) */
10431
10479
  consume(source, token, tokenStream) {
10432
10480
  switch (token.type) {
10433
10481
  case TokenType.UNICODE_BOM:
@@ -10464,7 +10512,10 @@ class Parser {
10464
10512
  break;
10465
10513
  }
10466
10514
  }
10467
- /* eslint-disable-next-line complexity, sonarjs/cognitive-complexity */
10515
+ /**
10516
+ * @internal
10517
+ */
10518
+ /* eslint-disable-next-line complexity, sonarjs/cognitive-complexity -- technical debt, chould be refactored a bit */
10468
10519
  consumeTag(source, startToken, tokenStream) {
10469
10520
  const tokens = Array.from(this.consumeUntil(tokenStream, TokenType.TAG_CLOSE, startToken.location));
10470
10521
  const endToken = tokens.slice(-1)[0];
@@ -10529,6 +10580,9 @@ class Parser {
10529
10580
  this.discardForeignBody(source, node.tagName, tokenStream, startToken.location);
10530
10581
  }
10531
10582
  }
10583
+ /**
10584
+ * @internal
10585
+ */
10532
10586
  closeElement(source, node, active, location) {
10533
10587
  /* call processElement hook */
10534
10588
  this.processElement(active, source);
@@ -10564,6 +10618,8 @@ class Parser {
10564
10618
  }
10565
10619
  /**
10566
10620
  * Discard tokens until the end tag for the foreign element is found.
10621
+ *
10622
+ * @internal
10567
10623
  */
10568
10624
  discardForeignBody(source, foreignTagName, tokenStream, errorLocation) {
10569
10625
  /* consume elements until the end tag for this foreign element is found */
@@ -10612,6 +10668,9 @@ class Parser {
10612
10668
  this.closeElement(source, node, active, endToken.location);
10613
10669
  this.dom.popActive();
10614
10670
  }
10671
+ /**
10672
+ * @internal
10673
+ */
10615
10674
  consumeAttribute(source, node, token, next) {
10616
10675
  const keyLocation = this.getAttributeKeyLocation(token);
10617
10676
  const valueLocation = this.getAttributeValueLocation(next);
@@ -10702,6 +10761,9 @@ class Parser {
10702
10761
  offset: begin.offset,
10703
10762
  };
10704
10763
  }
10764
+ /**
10765
+ * @internal
10766
+ */
10705
10767
  consumeDirective(token) {
10706
10768
  const [text, preamble, action, separator1, directive, postamble] = token.data;
10707
10769
  if (!postamble.startsWith("]")) {
@@ -10747,6 +10809,8 @@ class Parser {
10747
10809
  * Consumes conditional comment in tag form.
10748
10810
  *
10749
10811
  * See also the related [[consumeCommend]] method.
10812
+ *
10813
+ * @internal
10750
10814
  */
10751
10815
  consumeConditional(token) {
10752
10816
  const element = this.dom.getActive();
@@ -10761,6 +10825,8 @@ class Parser {
10761
10825
  *
10762
10826
  * Tries to find IE conditional comments and emits conditional token if
10763
10827
  * found. See also the related [[consumeConditional]] method.
10828
+ *
10829
+ * @internal
10764
10830
  */
10765
10831
  consumeComment(token) {
10766
10832
  const comment = token.data[0];
@@ -10775,6 +10841,8 @@ class Parser {
10775
10841
  }
10776
10842
  /**
10777
10843
  * Consumes doctype tokens. Emits doctype event.
10844
+ *
10845
+ * @internal
10778
10846
  */
10779
10847
  consumeDoctype(startToken, tokenStream) {
10780
10848
  const tokens = Array.from(this.consumeUntil(tokenStream, TokenType.DOCTYPE_CLOSE, startToken.location));
@@ -10792,6 +10860,7 @@ class Parser {
10792
10860
  /**
10793
10861
  * Return a list of tokens found until the expected token was found.
10794
10862
  *
10863
+ * @internal
10795
10864
  * @param errorLocation - What location to use if an error occurs
10796
10865
  */
10797
10866
  *consumeUntil(tokenStream, search, errorLocation) {
@@ -10856,6 +10925,7 @@ class Parser {
10856
10925
  /**
10857
10926
  * Defer execution. Will call function sometime later.
10858
10927
  *
10928
+ * @internal
10859
10929
  * @param cb - Callback to execute later.
10860
10930
  */
10861
10931
  defer(cb) {
@@ -10898,7 +10968,7 @@ function freeze(src) {
10898
10968
  };
10899
10969
  }
10900
10970
  /**
10901
- * @internal
10971
+ * @public
10902
10972
  */
10903
10973
  class Reporter {
10904
10974
  constructor() {
@@ -11090,7 +11160,6 @@ class Engine {
11090
11160
  };
11091
11161
  parser.trigger("config:ready", configEvent);
11092
11162
  /* trigger source ready event */
11093
- /* eslint-disable-next-line @typescript-eslint/no-unused-vars -- object destructured on purpose to remove property */
11094
11163
  const { hooks: _, ...sourceData } = source;
11095
11164
  const sourceEvent = {
11096
11165
  location,
@@ -11185,8 +11254,7 @@ class Engine {
11185
11254
  /**
11186
11255
  * Get rule documentation.
11187
11256
  */
11188
- getRuleDocumentation(ruleId, context // eslint-disable-line @typescript-eslint/explicit-module-boundary-types
11189
- ) {
11257
+ getRuleDocumentation(ruleId, context) {
11190
11258
  const rules = this.config.getRules();
11191
11259
  const ruleData = rules.get(ruleId);
11192
11260
  if (ruleData) {
@@ -11712,7 +11780,7 @@ class HtmlValidate {
11712
11780
  /** @public */
11713
11781
  const name = "html-validate";
11714
11782
  /** @public */
11715
- const version = "7.14.0";
11783
+ const version = "7.15.1";
11716
11784
  /** @public */
11717
11785
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
11718
11786
 
@@ -11729,7 +11797,7 @@ const defaults$1 = {
11729
11797
  silent: false,
11730
11798
  version,
11731
11799
  logger(text) {
11732
- /* eslint-disable-next-line no-console */
11800
+ /* eslint-disable-next-line no-console -- expected to log */
11733
11801
  console.error(kleur.red(text));
11734
11802
  },
11735
11803
  };
@@ -11874,7 +11942,7 @@ class FileSystemConfigLoader extends ConfigLoader {
11874
11942
  let found = false;
11875
11943
  let current = path.resolve(path.dirname(filename));
11876
11944
  let config = this.empty();
11877
- // eslint-disable-next-line no-constant-condition
11945
+ // eslint-disable-next-line no-constant-condition -- it will break out when filesystem is traversed
11878
11946
  while (true) {
11879
11947
  /* search configuration files in current directory */
11880
11948
  for (const configFile of findConfigurationFiles(current)) {
@@ -11953,7 +12021,7 @@ function checkstyleFormatter(results) {
11953
12021
  output += "</checkstyle>\n";
11954
12022
  return output;
11955
12023
  }
11956
- const formatter$4 = checkstyleFormatter;
12024
+ const formatter$3 = checkstyleFormatter;
11957
12025
 
11958
12026
  const defaults = {
11959
12027
  showLink: true,
@@ -12084,7 +12152,6 @@ function codeframe(results, options) {
12084
12152
  }
12085
12153
  return errors + warnings > 0 ? output : "";
12086
12154
  }
12087
- const formatter$3 = codeframe;
12088
12155
 
12089
12156
  function jsonFormatter(results) {
12090
12157
  return JSON.stringify(results);
@@ -12144,8 +12211,8 @@ function textFormatter(results) {
12144
12211
  const formatter = textFormatter;
12145
12212
 
12146
12213
  const availableFormatters = {
12147
- checkstyle: formatter$4,
12148
- codeframe: formatter$3,
12214
+ checkstyle: formatter$3,
12215
+ codeframe,
12149
12216
  json: formatter$2,
12150
12217
  stylish: formatter$1,
12151
12218
  text: formatter,
@@ -12155,5 +12222,5 @@ function getFormatter(name) {
12155
12222
  return (_a = availableFormatters[name]) !== null && _a !== void 0 ? _a : null;
12156
12223
  }
12157
12224
 
12158
- export { Attribute as A, Config as C, DynamicValue as D, EventHandler as E, FileSystemConfigLoader as F, HtmlValidate as H, MetaTable as M, NodeClosed as N, Parser as P, Rule as R, Severity as S, TextNode as T, UserError as U, Validator as V, WrappedError as W, ConfigError as a, ConfigLoader as b, StaticConfigLoader as c, HtmlElement as d, SchemaValidationError as e, NestedError as f, MetaCopyableProperty as g, Reporter as h, TemplateExtractor as i, definePlugin as j, getFormatter as k, legacyRequire as l, ensureError as m, configDataFromFile as n, compatibilityCheck as o, presets as p, codeframe as q, ruleExists as r, sliceLocation as s, isTextNode as t, isElementNode as u, version as v, generateIdSelector as w, name as x, bugs as y };
12225
+ export { Attribute as A, isTextNode as B, Config as C, DynamicValue as D, EventHandler as E, FileSystemConfigLoader as F, isElementNode as G, HtmlValidate as H, generateIdSelector as I, name as J, bugs as K, MetaTable as M, NodeClosed as N, Parser as P, ResolvedConfig as R, Severity as S, TextNode as T, UserError as U, Validator as V, WrappedError as W, ConfigError as a, ConfigLoader as b, StaticConfigLoader as c, DOMTokenList as d, HtmlElement as e, DOMNode as f, DOMTree as g, NodeType as h, SchemaValidationError as i, NestedError as j, TextContent$1 as k, MetaCopyableProperty as l, Rule as m, Reporter as n, TemplateExtractor as o, presets as p, definePlugin as q, ruleExists as r, sliceLocation as s, getFormatter as t, legacyRequire as u, version as v, ensureError as w, configDataFromFile as x, compatibilityCheck as y, codeframe as z };
12159
12226
  //# sourceMappingURL=core.js.map