html-validate 7.14.0 → 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 +5 -5
  7. package/dist/cjs/cli.js.map +1 -1
  8. package/dist/cjs/core.js +159 -117
  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 +138 -100
  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 +33 -27
  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/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();
@@ -694,6 +707,9 @@ function parse(text, baseLocation) {
694
707
  }
695
708
  return { tokens, locations };
696
709
  }
710
+ /**
711
+ * @public
712
+ */
697
713
  class DOMTokenList extends Array {
698
714
  constructor(value, location) {
699
715
  if (value && typeof value === "string") {
@@ -730,7 +746,7 @@ class DOMTokenList extends Array {
730
746
  }
731
747
  *iterator() {
732
748
  for (let index = 0; index < this.length; index++) {
733
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
749
+ /* eslint-disable @typescript-eslint/no-non-null-assertion -- as we loop over length this should always be set */
734
750
  const item = this.item(index);
735
751
  const location = this.location(index);
736
752
  /* eslint-enable @typescript-eslint/no-non-null-assertion */
@@ -1249,7 +1265,7 @@ class HtmlElement extends DOMNode {
1249
1265
  * Implementation of DOM specification of Element.closest(selectors).
1250
1266
  */
1251
1267
  closest(selectors) {
1252
- /* eslint-disable-next-line @typescript-eslint/no-this-alias */
1268
+ /* eslint-disable-next-line @typescript-eslint/no-this-alias -- false positive*/
1253
1269
  let node = this;
1254
1270
  while (node) {
1255
1271
  if (node.matches(selectors)) {
@@ -1270,11 +1286,11 @@ class HtmlElement extends DOMNode {
1270
1286
  }
1271
1287
  const parts = [];
1272
1288
  let root;
1273
- /* eslint-disable-next-line @typescript-eslint/no-this-alias */
1289
+ /* eslint-disable-next-line @typescript-eslint/no-this-alias -- false positive */
1274
1290
  for (root = this; root.parent; root = root.parent) {
1275
1291
  /* .. */
1276
1292
  }
1277
- // eslint-disable-next-line @typescript-eslint/no-this-alias
1293
+ // eslint-disable-next-line @typescript-eslint/no-this-alias -- false positive
1278
1294
  for (let cur = this; cur.parent; cur = cur.parent) {
1279
1295
  /* if a unique id is present, use it and short-circuit */
1280
1296
  if (cur.id) {
@@ -1358,7 +1374,7 @@ class HtmlElement extends DOMNode {
1358
1374
  */
1359
1375
  matches(selector) {
1360
1376
  /* find root element */
1361
- /* eslint-disable-next-line @typescript-eslint/no-this-alias */
1377
+ /* eslint-disable-next-line @typescript-eslint/no-this-alias -- false positive */
1362
1378
  let root = this;
1363
1379
  while (root.parent) {
1364
1380
  root = root.parent;
@@ -1507,9 +1523,14 @@ class HtmlElement extends DOMNode {
1507
1523
  }, []);
1508
1524
  }
1509
1525
  querySelector(selector) {
1510
- var _a;
1511
1526
  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
1527
+ const next = it.next();
1528
+ if (next.done) {
1529
+ return null;
1530
+ }
1531
+ else {
1532
+ return next.value;
1533
+ }
1513
1534
  }
1514
1535
  querySelectorAll(selector) {
1515
1536
  const it = this.querySelectorImpl(selector);
@@ -1603,6 +1624,9 @@ function isClosed(endToken, meta) {
1603
1624
  return closed;
1604
1625
  }
1605
1626
 
1627
+ /**
1628
+ * @public
1629
+ */
1606
1630
  class DOMTree {
1607
1631
  constructor(location) {
1608
1632
  this.root = HtmlElement.rootNode(location);
@@ -1681,6 +1705,9 @@ function ensureError(value) {
1681
1705
  }
1682
1706
  }
1683
1707
 
1708
+ /**
1709
+ * @public
1710
+ */
1684
1711
  class NestedError extends Error {
1685
1712
  constructor(message, nested) {
1686
1713
  super(message);
@@ -2652,7 +2679,7 @@ function expandRegexValue(value) {
2652
2679
  const match = value.match(/^\/\^?([^/$]*)\$?\/([i]*)$/);
2653
2680
  if (match) {
2654
2681
  const [, expr, flags] = match;
2655
- // eslint-disable-next-line security/detect-non-literal-regexp
2682
+ // eslint-disable-next-line security/detect-non-literal-regexp -- expected to be regexp
2656
2683
  return new RegExp(`^${expr}$`, flags);
2657
2684
  }
2658
2685
  else {
@@ -2853,7 +2880,6 @@ class Validator {
2853
2880
  * @param rules - Element attribute metadta.
2854
2881
  * @returns `true` if attribute passes all tests.
2855
2882
  */
2856
- /* eslint-disable-next-line complexity */
2857
2883
  static validateAttribute(attr, rules) {
2858
2884
  const rule = rules[attr.key];
2859
2885
  if (!rule) {
@@ -2944,7 +2970,7 @@ class Validator {
2944
2970
  * @param category - Name of category with `@` prefix or tag name.
2945
2971
  * @param defaultMatch - The default return value when node categories is not known.
2946
2972
  */
2947
- // eslint-disable-next-line complexity
2973
+ /* eslint-disable-next-line complexity -- rule does not like switch */
2948
2974
  static validatePermittedCategory(node, category, defaultMatch) {
2949
2975
  const [, rawCategory] = category.match(/^(@?.*?)([?*]?)$/);
2950
2976
  /* match tagName when an explicit name is given */
@@ -3151,7 +3177,8 @@ var configurationSchema = {
3151
3177
  properties: properties
3152
3178
  };
3153
3179
 
3154
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
3180
+ /* eslint-disable @typescript-eslint/no-non-null-assertion -- declarations say
3181
+ * location fields are optional but they are always present when `{loc: true}` */
3155
3182
  function joinTemplateLiteral(nodes) {
3156
3183
  let offset = nodes[0].start + 1;
3157
3184
  let output = "";
@@ -3372,7 +3399,7 @@ function parseSeverity(value) {
3372
3399
  return Severity.DISABLED;
3373
3400
  /* istanbul ignore next: deprecated code which will be removed later */
3374
3401
  case "disable":
3375
- // eslint-disable-next-line no-console
3402
+ // eslint-disable-next-line no-console -- expected to log
3376
3403
  console.warn(`Deprecated alias "disabled" will be removed, replace with severity "off"`);
3377
3404
  return Severity.DISABLED;
3378
3405
  case 1:
@@ -3483,8 +3510,8 @@ class Rule {
3483
3510
  this.severity = severity;
3484
3511
  }
3485
3512
  /**
3486
- * Block this rule from generating errors. Pass in an id generated by {@link
3487
- * createBlocker}. Can be unblocked by {@link unblock}.
3513
+ * Block this rule from generating errors. Pass in an id generated by
3514
+ * `createBlocker`. Can be unblocked by {@link Rule.unblock}.
3488
3515
  *
3489
3516
  * A blocked rule is similar to disabling it but it will still receive parser
3490
3517
  * events. A list of all blockers is passed to the `rule:error` event.
@@ -3495,7 +3522,7 @@ class Rule {
3495
3522
  this.blockers.push(id);
3496
3523
  }
3497
3524
  /**
3498
- * Unblock a rule previously blocked by {@link block}.
3525
+ * Unblock a rule previously blocked by {@link Rule.block}.
3499
3526
  *
3500
3527
  * @internal
3501
3528
  */
@@ -3713,12 +3740,20 @@ class Rule {
3713
3740
  * @returns Rule documentation and url with additional details or `null` if no
3714
3741
  * additional documentation is available.
3715
3742
  */
3716
- /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
3743
+ /* eslint-disable-next-line @typescript-eslint/no-unused-vars -- technical debt, prototype should be moved to interface */
3717
3744
  documentation(context) {
3718
3745
  return null;
3719
3746
  }
3720
3747
  }
3721
3748
 
3749
+ var Style$2;
3750
+ (function (Style) {
3751
+ Style["EXTERNAL"] = "external";
3752
+ Style["RELATIVE_BASE"] = "relative-base";
3753
+ Style["RELATIVE_PATH"] = "relative-path";
3754
+ Style["ABSOLUTE"] = "absolute";
3755
+ Style["ANCHOR"] = "anchor";
3756
+ })(Style$2 || (Style$2 = {}));
3722
3757
  const defaults$w = {
3723
3758
  allowExternal: true,
3724
3759
  allowRelative: true,
@@ -3732,18 +3767,18 @@ const mapping$1 = {
3732
3767
  script: "src",
3733
3768
  };
3734
3769
  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,
3770
+ [Style$2.EXTERNAL]: "External links are not allowed by current configuration.",
3771
+ [Style$2.RELATIVE_BASE]: "Links relative to <base> are not allowed by current configuration.",
3772
+ [Style$2.RELATIVE_PATH]: "Relative links are not allowed by current configuration.",
3773
+ [Style$2.ABSOLUTE]: "Absolute links are not allowed by current configuration.",
3774
+ [Style$2.ANCHOR]: null,
3740
3775
  };
3741
3776
  function parseAllow(value) {
3742
3777
  if (typeof value === "boolean") {
3743
3778
  return value;
3744
3779
  }
3745
3780
  return {
3746
- /* eslint-disable security/detect-non-literal-regexp */
3781
+ /* eslint-disable security/detect-non-literal-regexp -- expected to be regexp */
3747
3782
  include: value.include ? value.include.map((it) => new RegExp(it)) : null,
3748
3783
  exclude: value.exclude ? value.exclude.map((it) => new RegExp(it)) : null,
3749
3784
  /* eslint-enable security/detect-non-literal-regexp */
@@ -3809,19 +3844,19 @@ class AllowedLinks extends Rule {
3809
3844
  const link = event.value.toString();
3810
3845
  const style = this.getStyle(link);
3811
3846
  switch (style) {
3812
- case "anchor" /* Style.ANCHOR */:
3847
+ case Style$2.ANCHOR:
3813
3848
  /* anchor links are always allowed by this rule */
3814
3849
  break;
3815
- case "absolute" /* Style.ABSOLUTE */:
3850
+ case Style$2.ABSOLUTE:
3816
3851
  this.handleAbsolute(link, event, style);
3817
3852
  break;
3818
- case "external" /* Style.EXTERNAL */:
3853
+ case Style$2.EXTERNAL:
3819
3854
  this.handleExternal(link, event, style);
3820
3855
  break;
3821
- case "relative-base" /* Style.RELATIVE_BASE */:
3856
+ case Style$2.RELATIVE_BASE:
3822
3857
  this.handleRelativeBase(link, event, style);
3823
3858
  break;
3824
- case "relative-path" /* Style.RELATIVE_PATH */:
3859
+ case Style$2.RELATIVE_PATH:
3825
3860
  this.handleRelativePath(link, event, style);
3826
3861
  break;
3827
3862
  }
@@ -3839,21 +3874,21 @@ class AllowedLinks extends Rule {
3839
3874
  getStyle(value) {
3840
3875
  /* http://example.net or //example.net */
3841
3876
  if (value.match(/^([a-z]+:)?\/\//g)) {
3842
- return "external" /* Style.EXTERNAL */;
3877
+ return Style$2.EXTERNAL;
3843
3878
  }
3844
3879
  switch (value[0]) {
3845
3880
  /* /foo/bar */
3846
3881
  case "/":
3847
- return "absolute" /* Style.ABSOLUTE */;
3882
+ return Style$2.ABSOLUTE;
3848
3883
  /* ../foo/bar */
3849
3884
  case ".":
3850
- return "relative-path" /* Style.RELATIVE_PATH */;
3885
+ return Style$2.RELATIVE_PATH;
3851
3886
  /* #foo */
3852
3887
  case "#":
3853
- return "anchor" /* Style.ANCHOR */;
3888
+ return Style$2.ANCHOR;
3854
3889
  /* foo/bar */
3855
3890
  default:
3856
- return "relative-base" /* Style.RELATIVE_BASE */;
3891
+ return Style$2.RELATIVE_BASE;
3857
3892
  }
3858
3893
  }
3859
3894
  handleAbsolute(target, event, style) {
@@ -4191,6 +4226,9 @@ class AttrCase extends Rule {
4191
4226
  }
4192
4227
  }
4193
4228
 
4229
+ /**
4230
+ * @internal
4231
+ */
4194
4232
  var TokenType;
4195
4233
  (function (TokenType) {
4196
4234
  TokenType[TokenType["UNICODE_BOM"] = 1] = "UNICODE_BOM";
@@ -4212,7 +4250,7 @@ var TokenType;
4212
4250
  TokenType[TokenType["EOF"] = 17] = "EOF";
4213
4251
  })(TokenType || (TokenType = {}));
4214
4252
 
4215
- /* eslint-disable no-useless-escape */
4253
+ /* eslint-disable no-useless-escape -- false positives */
4216
4254
  const MATCH_UNICODE_BOM = /^\uFEFF/;
4217
4255
  const MATCH_WHITESPACE = /^(?:\r\n|\r|\n|[ \t]+(?:\r\n|\r|\n)?)/;
4218
4256
  const MATCH_DOCTYPE_OPEN = /^<!(DOCTYPE)\s/i;
@@ -4237,6 +4275,7 @@ const MATCH_STYLE_END = /^<(\/)(style)/;
4237
4275
  const MATCH_DIRECTIVE = /^(<!--\s*\[html-validate-)([a-z0-9-]+)(\s*)(.*?)(]?\s*-->)/;
4238
4276
  const MATCH_COMMENT = /^<!--([^]*?)-->/;
4239
4277
  const MATCH_CONDITIONAL = /^<!\[([^\]]*?)\]>/;
4278
+ /* eslint-enable no-useless-escape */
4240
4279
  class InvalidTokenError extends Error {
4241
4280
  constructor(location, message) {
4242
4281
  super(message);
@@ -4244,7 +4283,7 @@ class InvalidTokenError extends Error {
4244
4283
  }
4245
4284
  }
4246
4285
  class Lexer {
4247
- // eslint-disable-next-line complexity
4286
+ /* eslint-disable-next-line complexity -- there isn't really a good way to refactor this while keeping readability */
4248
4287
  *tokenize(source) {
4249
4288
  const context = new Context(source);
4250
4289
  /* for sanity check */
@@ -4378,7 +4417,6 @@ class Lexer {
4378
4417
  ], "expected doctype name");
4379
4418
  }
4380
4419
  *tokenizeTag(context) {
4381
- /* eslint-disable-next-line consistent-return -- exhaustive switch handled by typescript */
4382
4420
  function nextState(token) {
4383
4421
  const tagCloseToken = token;
4384
4422
  switch (context.contentModel) {
@@ -4475,11 +4513,11 @@ const defaults$t = {
4475
4513
  };
4476
4514
  function generateRegexp(pattern) {
4477
4515
  if (Array.isArray(pattern)) {
4478
- /* eslint-disable-next-line security/detect-non-literal-regexp */
4516
+ /* eslint-disable-next-line security/detect-non-literal-regexp -- expected to be regexp */
4479
4517
  return new RegExp(`^(${pattern.join("|")})$`, "i");
4480
4518
  }
4481
4519
  else {
4482
- /* eslint-disable-next-line security/detect-non-literal-regexp */
4520
+ /* eslint-disable-next-line security/detect-non-literal-regexp -- expected to be regexp */
4483
4521
  return new RegExp(`^${pattern}$`, "i");
4484
4522
  }
4485
4523
  }
@@ -5029,7 +5067,7 @@ function parsePattern(pattern) {
5029
5067
  case "underscore":
5030
5068
  return /^[a-z0-9_]+$/;
5031
5069
  default:
5032
- // eslint-disable-next-line security/detect-non-literal-regexp
5070
+ /* eslint-disable-next-line security/detect-non-literal-regexp -- expected to be regexp */
5033
5071
  return new RegExp(pattern);
5034
5072
  }
5035
5073
  }
@@ -5445,7 +5483,7 @@ const defaults$l = {
5445
5483
  class ElementName extends Rule {
5446
5484
  constructor(options) {
5447
5485
  super({ ...defaults$l, ...options });
5448
- // eslint-disable-next-line security/detect-non-literal-regexp
5486
+ /* eslint-disable-next-line security/detect-non-literal-regexp -- expected to be a regexp */
5449
5487
  this.pattern = new RegExp(this.options.pattern);
5450
5488
  }
5451
5489
  static schema() {
@@ -6453,7 +6491,7 @@ class IdPattern extends Rule {
6453
6491
  }
6454
6492
  }
6455
6493
 
6456
- /* eslint-disable sonarjs/no-duplicate-string */
6494
+ /* eslint-disable sonarjs/no-duplicate-string -- wont be easier to read or manage with constants */
6457
6495
  const restricted = new Map([
6458
6496
  ["accept", ["file"]],
6459
6497
  ["alt", ["image"]],
@@ -8269,11 +8307,11 @@ function constructRegex(characters) {
8269
8307
  })
8270
8308
  .join("|");
8271
8309
  const pattern = `(${disallowed})`;
8272
- /* eslint-disable-next-line security/detect-non-literal-regexp */
8310
+ /* eslint-disable-next-line security/detect-non-literal-regexp -- technical debt, should do more input sanitation */
8273
8311
  return new RegExp(pattern, "g");
8274
8312
  }
8275
8313
  function getText(node) {
8276
- /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
8314
+ /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- this will always match something, it cannot be null */
8277
8315
  const match = node.textContent.match(/^(\s*)(.*)$/);
8278
8316
  const [, leading, text] = match;
8279
8317
  return [leading.length, text.trimEnd()];
@@ -8282,15 +8320,11 @@ function getText(node) {
8282
8320
  * Node 12 does not support String.matchAll, this simulates it's behavior.
8283
8321
  */
8284
8322
  function matchAll(text, regexp) {
8285
- /* eslint-disable-next-line security/detect-non-literal-regexp */
8323
+ /* eslint-disable-next-line security/detect-non-literal-regexp -- makes copy of existing one only */
8286
8324
  const copy = new RegExp(regexp);
8287
8325
  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
- }
8326
+ let match;
8327
+ while ((match = copy.exec(text))) {
8294
8328
  matches.push(match);
8295
8329
  }
8296
8330
  return matches;
@@ -8676,43 +8710,46 @@ class UnknownCharReference extends Rule {
8676
8710
  return entities$1;
8677
8711
  }
8678
8712
  }
8679
- /* eslint-disable-next-line complexity */
8680
8713
  findCharacterReferences(node, text, location, { isAttribute }) {
8681
- const { requireSemicolon } = this.options;
8682
8714
  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
- }
8715
+ for (const match of this.getMatches(text)) {
8716
+ this.validateCharacterReference(node, location, match, { isQuerystring });
8717
+ }
8718
+ }
8719
+ validateCharacterReference(node, location, foobar, { isQuerystring }) {
8720
+ const { requireSemicolon } = this.options;
8721
+ const { match, entity, raw, terminated } = foobar;
8722
+ /* assume numeric entities are valid for now */
8723
+ if (isNumerical(entity)) {
8724
+ return;
8725
+ }
8726
+ /* special case: when attributes use query parameters we skip checking
8727
+ * unterminated attributes */
8728
+ if (isQuerystring && !terminated) {
8729
+ return;
8730
+ }
8731
+ const found = this.entities.includes(entity);
8732
+ /* ignore if this is a known character reference name */
8733
+ if (found && (terminated || !requireSemicolon)) {
8734
+ return;
8735
+ }
8736
+ if (found && !terminated) {
8708
8737
  const entityLocation = getLocation(location, entity, match);
8709
- const message = `Unrecognized character reference "{{ entity }}"`;
8738
+ const message = `Character reference "{{ entity }}" must be terminated by a semicolon`;
8710
8739
  const context = {
8711
8740
  entity: raw,
8712
- terminated: true,
8741
+ terminated: false,
8713
8742
  };
8714
8743
  this.report(node, message, entityLocation, context);
8744
+ return;
8715
8745
  }
8746
+ const entityLocation = getLocation(location, entity, match);
8747
+ const message = `Unrecognized character reference "{{ entity }}"`;
8748
+ const context = {
8749
+ entity: raw,
8750
+ terminated: true,
8751
+ };
8752
+ this.report(node, message, entityLocation, context);
8716
8753
  }
8717
8754
  *getMatches(text) {
8718
8755
  let match;
@@ -9576,6 +9613,8 @@ const presets = {
9576
9613
  /**
9577
9614
  * A resolved configuration is a normalized configuration with all extends,
9578
9615
  * plugins etc resolved.
9616
+ *
9617
+ * @public
9579
9618
  */
9580
9619
  class ResolvedConfig {
9581
9620
  constructor({ metaTable, plugins, rules, transformers }) {
@@ -9821,7 +9860,7 @@ class Config {
9821
9860
  * Must be called before trying to use config. Can safely be called multiple
9822
9861
  * times.
9823
9862
  *
9824
- * @internal
9863
+ * @public
9825
9864
  */
9826
9865
  init() {
9827
9866
  if (this.initialized) {
@@ -9841,7 +9880,7 @@ class Config {
9841
9880
  * Returns a new configuration as a merge of the two. Entries from the passed
9842
9881
  * object takes priority over this object.
9843
9882
  *
9844
- * @internal
9883
+ * @public
9845
9884
  * @param rhs - Configuration to merge with this one.
9846
9885
  */
9847
9886
  merge(rhs) {
@@ -9868,7 +9907,7 @@ class Config {
9868
9907
  /**
9869
9908
  * Get element metadata.
9870
9909
  */
9871
- /* eslint-disable-next-line complexity, sonarjs/cognitive-complexity */
9910
+ /* eslint-disable-next-line complexity, sonarjs/cognitive-complexity -- technical debt, should be refactored */
9872
9911
  getMetaTable() {
9873
9912
  /* use cached table if it exists */
9874
9913
  if (this.metaTable) {
@@ -10070,7 +10109,7 @@ class Config {
10070
10109
  throw new ConfigError(`Transformer uses API version ${version} but only version ${TRANSFORMER_API.VERSION} is supported`);
10071
10110
  }
10072
10111
  return {
10073
- // eslint-disable-next-line security/detect-non-literal-regexp
10112
+ // eslint-disable-next-line security/detect-non-literal-regexp -- expected to be a regexp
10074
10113
  pattern: new RegExp(pattern),
10075
10114
  name,
10076
10115
  fn,
@@ -10175,6 +10214,9 @@ class Config {
10175
10214
  /* set global instance */
10176
10215
  rootDirCache = value;
10177
10216
  }
10217
+ /**
10218
+ * @internal
10219
+ */
10178
10220
  findRootDir() {
10179
10221
  const cache = this.rootDirCache;
10180
10222
  if (cache !== null) {
@@ -10182,7 +10224,7 @@ class Config {
10182
10224
  }
10183
10225
  /* try to locate package.json */
10184
10226
  let current = process.cwd();
10185
- // eslint-disable-next-line no-constant-condition
10227
+ // eslint-disable-next-line no-constant-condition -- break outs when filesystem is traversed
10186
10228
  while (true) {
10187
10229
  const search = path.join(current, "package.json");
10188
10230
  if (fs.existsSync(search)) {
@@ -10227,7 +10269,7 @@ class ConfigLoader {
10227
10269
  }
10228
10270
 
10229
10271
  /**
10230
- * @internal
10272
+ * @public
10231
10273
  */
10232
10274
  class EventHandler {
10233
10275
  constructor() {
@@ -10275,7 +10317,6 @@ class EventHandler {
10275
10317
  * @param event - Event name.
10276
10318
  * @param data - Event data.
10277
10319
  */
10278
- /* eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types */
10279
10320
  trigger(event, data) {
10280
10321
  var _a, _b;
10281
10322
  const callbacks = [...((_a = this.listeners[event]) !== null && _a !== void 0 ? _a : []), ...((_b = this.listeners["*"]) !== null && _b !== void 0 ? _b : [])];
@@ -10427,7 +10468,7 @@ class Parser {
10427
10468
  return Boolean(active.parent && active.parent.is(tagName) && meta.includes(active.tagName));
10428
10469
  }
10429
10470
  }
10430
- /* eslint-disable-next-line complexity */
10471
+ /* eslint-disable-next-line complexity -- there isn't really a good other way to structure this method (that is still readable) */
10431
10472
  consume(source, token, tokenStream) {
10432
10473
  switch (token.type) {
10433
10474
  case TokenType.UNICODE_BOM:
@@ -10464,7 +10505,7 @@ class Parser {
10464
10505
  break;
10465
10506
  }
10466
10507
  }
10467
- /* eslint-disable-next-line complexity, sonarjs/cognitive-complexity */
10508
+ /* eslint-disable-next-line complexity, sonarjs/cognitive-complexity -- technical debt, chould be refactored a bit */
10468
10509
  consumeTag(source, startToken, tokenStream) {
10469
10510
  const tokens = Array.from(this.consumeUntil(tokenStream, TokenType.TAG_CLOSE, startToken.location));
10470
10511
  const endToken = tokens.slice(-1)[0];
@@ -10898,7 +10939,7 @@ function freeze(src) {
10898
10939
  };
10899
10940
  }
10900
10941
  /**
10901
- * @internal
10942
+ * @public
10902
10943
  */
10903
10944
  class Reporter {
10904
10945
  constructor() {
@@ -11090,7 +11131,6 @@ class Engine {
11090
11131
  };
11091
11132
  parser.trigger("config:ready", configEvent);
11092
11133
  /* trigger source ready event */
11093
- /* eslint-disable-next-line @typescript-eslint/no-unused-vars -- object destructured on purpose to remove property */
11094
11134
  const { hooks: _, ...sourceData } = source;
11095
11135
  const sourceEvent = {
11096
11136
  location,
@@ -11185,8 +11225,7 @@ class Engine {
11185
11225
  /**
11186
11226
  * Get rule documentation.
11187
11227
  */
11188
- getRuleDocumentation(ruleId, context // eslint-disable-line @typescript-eslint/explicit-module-boundary-types
11189
- ) {
11228
+ getRuleDocumentation(ruleId, context) {
11190
11229
  const rules = this.config.getRules();
11191
11230
  const ruleData = rules.get(ruleId);
11192
11231
  if (ruleData) {
@@ -11712,7 +11751,7 @@ class HtmlValidate {
11712
11751
  /** @public */
11713
11752
  const name = "html-validate";
11714
11753
  /** @public */
11715
- const version = "7.14.0";
11754
+ const version = "7.15.0";
11716
11755
  /** @public */
11717
11756
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
11718
11757
 
@@ -11729,7 +11768,7 @@ const defaults$1 = {
11729
11768
  silent: false,
11730
11769
  version,
11731
11770
  logger(text) {
11732
- /* eslint-disable-next-line no-console */
11771
+ /* eslint-disable-next-line no-console -- expected to log */
11733
11772
  console.error(kleur.red(text));
11734
11773
  },
11735
11774
  };
@@ -11874,7 +11913,7 @@ class FileSystemConfigLoader extends ConfigLoader {
11874
11913
  let found = false;
11875
11914
  let current = path.resolve(path.dirname(filename));
11876
11915
  let config = this.empty();
11877
- // eslint-disable-next-line no-constant-condition
11916
+ // eslint-disable-next-line no-constant-condition -- it will break out when filesystem is traversed
11878
11917
  while (true) {
11879
11918
  /* search configuration files in current directory */
11880
11919
  for (const configFile of findConfigurationFiles(current)) {
@@ -11953,7 +11992,7 @@ function checkstyleFormatter(results) {
11953
11992
  output += "</checkstyle>\n";
11954
11993
  return output;
11955
11994
  }
11956
- const formatter$4 = checkstyleFormatter;
11995
+ const formatter$3 = checkstyleFormatter;
11957
11996
 
11958
11997
  const defaults = {
11959
11998
  showLink: true,
@@ -12084,7 +12123,6 @@ function codeframe(results, options) {
12084
12123
  }
12085
12124
  return errors + warnings > 0 ? output : "";
12086
12125
  }
12087
- const formatter$3 = codeframe;
12088
12126
 
12089
12127
  function jsonFormatter(results) {
12090
12128
  return JSON.stringify(results);
@@ -12144,8 +12182,8 @@ function textFormatter(results) {
12144
12182
  const formatter = textFormatter;
12145
12183
 
12146
12184
  const availableFormatters = {
12147
- checkstyle: formatter$4,
12148
- codeframe: formatter$3,
12185
+ checkstyle: formatter$3,
12186
+ codeframe,
12149
12187
  json: formatter$2,
12150
12188
  stylish: formatter$1,
12151
12189
  text: formatter,
@@ -12155,5 +12193,5 @@ function getFormatter(name) {
12155
12193
  return (_a = availableFormatters[name]) !== null && _a !== void 0 ? _a : null;
12156
12194
  }
12157
12195
 
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 };
12196
+ 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
12197
  //# sourceMappingURL=core.js.map