html-validate 7.11.0 → 7.11.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.
@@ -2041,6 +2041,8 @@ declare class NestedError extends Error {
2041
2041
  * @public
2042
2042
  */
2043
2043
  declare class UserError extends NestedError {
2044
+ constructor(message: string, nested?: Error);
2045
+ prettyFormat(): string | undefined;
2044
2046
  }
2045
2047
 
2046
2048
  /**
@@ -2069,6 +2071,7 @@ declare class WrappedError<T> extends Error {
2069
2071
  * @public
2070
2072
  */
2071
2073
  declare class ConfigError extends UserError {
2074
+ constructor(message: string, nested?: Error);
2072
2075
  }
2073
2076
 
2074
2077
  /**
package/dist/cjs/core.js CHANGED
@@ -1672,6 +1672,7 @@ class NestedError extends Error {
1672
1672
  constructor(message, nested) {
1673
1673
  super(message);
1674
1674
  Error.captureStackTrace(this, NestedError);
1675
+ this.name = NestedError.name;
1675
1676
  if (nested && nested.stack) {
1676
1677
  this.stack += `\nCaused by: ${nested.stack}`;
1677
1678
  }
@@ -1682,6 +1683,44 @@ class NestedError extends Error {
1682
1683
  * @public
1683
1684
  */
1684
1685
  class UserError extends NestedError {
1686
+ constructor(message, nested) {
1687
+ super(message, nested);
1688
+ Error.captureStackTrace(this, UserError);
1689
+ this.name = UserError.name;
1690
+ }
1691
+ prettyFormat() {
1692
+ return undefined;
1693
+ }
1694
+ }
1695
+
1696
+ /**
1697
+ * @internal
1698
+ */
1699
+ class InheritError extends UserError {
1700
+ constructor({ tagName, inherit }) {
1701
+ const message = `Element <${tagName}> cannot inherit from <${inherit}>: no such element`;
1702
+ super(message);
1703
+ Error.captureStackTrace(this, InheritError);
1704
+ this.name = InheritError.name;
1705
+ this.tagName = tagName;
1706
+ this.inherit = inherit;
1707
+ this.filename = null;
1708
+ }
1709
+ prettyFormat() {
1710
+ const { message, tagName, inherit } = this;
1711
+ const source = this.filename
1712
+ ? ["", "This error occurred when loading element metadata from:", `"${this.filename}"`, ""]
1713
+ : [""];
1714
+ return [
1715
+ message,
1716
+ ...source,
1717
+ "This usually occurs when the elements are defined in the wrong order, try one of the following:",
1718
+ "",
1719
+ ` - Ensure the spelling of "${inherit}" is correct.`,
1720
+ ` - Ensure the file containing "${inherit}" is loaded before the file containing "${tagName}".`,
1721
+ ` - Move the definition of "${inherit}" above the definition for "${tagName}".`,
1722
+ ].join("\n");
1723
+ }
1685
1724
  }
1686
1725
 
1687
1726
  function getSummary(schema, obj, errors) {
@@ -2105,6 +2144,9 @@ const definitions = {
2105
2144
  items: {
2106
2145
  type: "string"
2107
2146
  }
2147
+ },
2148
+ {
2149
+ type: "null"
2108
2150
  }
2109
2151
  ]
2110
2152
  }
@@ -2415,6 +2457,10 @@ class MetaTable {
2415
2457
  this.loadFromObject(data, filename);
2416
2458
  }
2417
2459
  catch (err) {
2460
+ if (err instanceof InheritError) {
2461
+ err.filename = filename;
2462
+ throw err;
2463
+ }
2418
2464
  if (err instanceof SchemaValidationError) {
2419
2465
  throw err;
2420
2466
  }
@@ -2467,7 +2513,10 @@ class MetaTable {
2467
2513
  const name = entry.inherit;
2468
2514
  parent = this.elements[name];
2469
2515
  if (!parent) {
2470
- throw new UserError(`Element <${tagName}> cannot inherit from <${name}>: no such element`);
2516
+ throw new InheritError({
2517
+ tagName,
2518
+ inherit: name,
2519
+ });
2471
2520
  }
2472
2521
  }
2473
2522
  /* merge all sources together */
@@ -3952,6 +4001,11 @@ class AriaLabelMisuse extends Rule {
3952
4001
  * @public
3953
4002
  */
3954
4003
  class ConfigError extends UserError {
4004
+ constructor(message, nested) {
4005
+ super(message, nested);
4006
+ Error.captureStackTrace(this, ConfigError);
4007
+ this.name = ConfigError.name;
4008
+ }
3955
4009
  }
3956
4010
 
3957
4011
  const defaults$t = {
@@ -11201,7 +11255,7 @@ class HtmlValidate {
11201
11255
  /** @public */
11202
11256
  const name = "html-validate";
11203
11257
  /** @public */
11204
- const version = "7.11.0";
11258
+ const version = "7.11.1";
11205
11259
  /** @public */
11206
11260
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
11207
11261