html-validate 7.9.0 → 7.10.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.
package/dist/es/core.js CHANGED
@@ -5,10 +5,10 @@ import Ajv from 'ajv';
5
5
  import deepmerge from 'deepmerge';
6
6
  import * as espree from 'espree';
7
7
  import * as walk from 'acorn-walk';
8
+ import { e as entities$1, h as html5, b as bundledElements } from './elements.js';
8
9
  import path from 'path';
9
10
  import semver from 'semver';
10
11
  import kleur from 'kleur';
11
- import { e as entities$1, b as bundledElements } from './elements.js';
12
12
  import { createRequire } from 'module';
13
13
  import { codeFrameColumns } from '@babel/code-frame';
14
14
  import stylishImpl from '@html-validate/stylish';
@@ -4416,10 +4416,6 @@ function describeStyle(style, unquoted) {
4416
4416
  return `${description.join(" or\n")}\n`;
4417
4417
  }
4418
4418
  class AttrQuotes extends Rule {
4419
- constructor(options) {
4420
- super({ ...defaults$q, ...options });
4421
- this.style = parseStyle$4(this.options.style);
4422
- }
4423
4419
  static schema() {
4424
4420
  return {
4425
4421
  style: {
@@ -4446,6 +4442,10 @@ class AttrQuotes extends Rule {
4446
4442
  url: "https://html-validate.org/rules/attr-quotes.html",
4447
4443
  };
4448
4444
  }
4445
+ constructor(options) {
4446
+ super({ ...defaults$q, ...options });
4447
+ this.style = parseStyle$4(this.options.style);
4448
+ }
4449
4449
  setup() {
4450
4450
  this.on("attr", (event) => {
4451
4451
  /* ignore attributes with no value */
@@ -5767,9 +5767,9 @@ function hasImgAltText(node) {
5767
5767
  else if (node.is("svg")) {
5768
5768
  return node.textContent.trim() !== "";
5769
5769
  }
5770
- else {
5771
- return false;
5772
- }
5770
+ /* istanbul ignore next -- querySelector(..) is only going to return the two
5771
+ * above tags but this serves as a sane default if above assumption changes */
5772
+ return false;
5773
5773
  }
5774
5774
  class EmptyHeading extends Rule {
5775
5775
  documentation() {
@@ -5793,7 +5793,7 @@ class EmptyHeading extends Rule {
5793
5793
  return;
5794
5794
  }
5795
5795
  }
5796
- switch (classifyNodeText(heading)) {
5796
+ switch (classifyNodeText(heading, { ignoreHiddenRoot: true })) {
5797
5797
  case TextClassification.DYNAMIC_TEXT:
5798
5798
  case TextClassification.STATIC_TEXT:
5799
5799
  /* have some text content, consider ok */
@@ -8343,10 +8343,6 @@ const defaults$4 = {
8343
8343
  style: "omit",
8344
8344
  };
8345
8345
  class Void extends Rule {
8346
- constructor(options) {
8347
- super({ ...defaults$4, ...options });
8348
- this.style = parseStyle$1(this.options.style);
8349
- }
8350
8346
  get deprecated() {
8351
8347
  return true;
8352
8348
  }
@@ -8364,6 +8360,10 @@ class Void extends Rule {
8364
8360
  url: "https://html-validate.org/rules/void.html",
8365
8361
  };
8366
8362
  }
8363
+ constructor(options) {
8364
+ super({ ...defaults$4, ...options });
8365
+ this.style = parseStyle$1(this.options.style);
8366
+ }
8367
8367
  setup() {
8368
8368
  this.on("tag:end", (event) => {
8369
8369
  const current = event.target; // The current element being closed
@@ -8546,7 +8546,7 @@ class H30 extends Rule {
8546
8546
  continue;
8547
8547
  }
8548
8548
  /* check if text content is present (or dynamic) */
8549
- const textClassification = classifyNodeText(link);
8549
+ const textClassification = classifyNodeText(link, { ignoreHiddenRoot: true });
8550
8550
  if (textClassification !== TextClassification.EMPTY_TEXT) {
8551
8551
  continue;
8552
8552
  }
@@ -8734,6 +8734,32 @@ class H37 extends Rule {
8734
8734
  }
8735
8735
  }
8736
8736
 
8737
+ class H63 extends Rule {
8738
+ documentation() {
8739
+ return {
8740
+ description: "H63: Using the scope attribute to associate header cells and data cells in data tables",
8741
+ url: "https://html-validate.org/rules/wcag/h63.html",
8742
+ };
8743
+ }
8744
+ setup() {
8745
+ this.on("tag:ready", (event) => {
8746
+ var _a, _b, _c, _d;
8747
+ const node = event.target;
8748
+ /* only validate th */
8749
+ if (!node || node.tagName !== "th") {
8750
+ return;
8751
+ }
8752
+ /* ignore elements with valid scope values */
8753
+ const scope = node.getAttributeValue("scope");
8754
+ const scopeMeta = (_b = (_a = html5 === null || html5 === void 0 ? void 0 : html5.th) === null || _a === void 0 ? void 0 : _a.attributes) === null || _b === void 0 ? void 0 : _b.scope;
8755
+ if (scope && ((_c = scopeMeta.enum) === null || _c === void 0 ? void 0 : _c.includes(scope))) {
8756
+ return;
8757
+ }
8758
+ this.report(node, `<th> element must have a valid scope attribute: ${((_d = scopeMeta.enum) !== null && _d !== void 0 ? _d : []).join(", ")}`, node.location);
8759
+ });
8760
+ }
8761
+ }
8762
+
8737
8763
  class H67 extends Rule {
8738
8764
  documentation() {
8739
8765
  return {
@@ -8798,6 +8824,7 @@ const bundledRules$1 = {
8798
8824
  "wcag/h32": H32,
8799
8825
  "wcag/h36": H36,
8800
8826
  "wcag/h37": H37,
8827
+ "wcag/h63": H63,
8801
8828
  "wcag/h67": H67,
8802
8829
  "wcag/h71": H71,
8803
8830
  };
@@ -8902,6 +8929,7 @@ const config$3 = {
8902
8929
  "wcag/h32": "error",
8903
8930
  "wcag/h36": "error",
8904
8931
  "wcag/h37": "error",
8932
+ "wcag/h63": "error",
8905
8933
  "wcag/h67": "error",
8906
8934
  "wcag/h71": "error",
8907
8935
  },
@@ -8984,6 +9012,7 @@ const config$1 = {
8984
9012
  "wcag/h32": "error",
8985
9013
  "wcag/h36": "error",
8986
9014
  "wcag/h37": "error",
9015
+ "wcag/h63": "error",
8987
9016
  "wcag/h67": "error",
8988
9017
  "wcag/h71": "error",
8989
9018
  },
@@ -9185,38 +9214,6 @@ function configDataFromFile(filename) {
9185
9214
  * @public
9186
9215
  */
9187
9216
  class Config {
9188
- /**
9189
- * @internal
9190
- */
9191
- constructor(options) {
9192
- var _a;
9193
- this.transformers = [];
9194
- const initial = {
9195
- extends: [],
9196
- plugins: [],
9197
- rules: {},
9198
- transform: {},
9199
- };
9200
- this.config = mergeInternal(initial, options || {});
9201
- this.metaTable = null;
9202
- this.rootDir = this.findRootDir();
9203
- this.initialized = false;
9204
- /* load plugins */
9205
- this.plugins = this.loadPlugins(this.config.plugins || []);
9206
- this.configurations = this.loadConfigurations(this.plugins);
9207
- this.extendMeta(this.plugins);
9208
- /* process extended configs */
9209
- this.config = this.extendConfig((_a = this.config.extends) !== null && _a !== void 0 ? _a : []);
9210
- /* reset extends as we already processed them, this prevents the next config
9211
- * from reapplying config from extended config as well as duplicate entries
9212
- * when merging arrays */
9213
- this.config.extends = [];
9214
- /* rules explicitly set by passed options should have precedence over any
9215
- * extended rules, not the other way around. */
9216
- if (options && options.rules) {
9217
- this.config = mergeInternal(this.config, { rules: options.rules });
9218
- }
9219
- }
9220
9217
  /**
9221
9218
  * Create a new blank configuration. See also `Config.defaultConfig()`.
9222
9219
  */
@@ -9278,6 +9275,38 @@ class Config {
9278
9275
  static defaultConfig() {
9279
9276
  return new Config(defaultConfig);
9280
9277
  }
9278
+ /**
9279
+ * @internal
9280
+ */
9281
+ constructor(options) {
9282
+ var _a;
9283
+ this.transformers = [];
9284
+ const initial = {
9285
+ extends: [],
9286
+ plugins: [],
9287
+ rules: {},
9288
+ transform: {},
9289
+ };
9290
+ this.config = mergeInternal(initial, options || {});
9291
+ this.metaTable = null;
9292
+ this.rootDir = this.findRootDir();
9293
+ this.initialized = false;
9294
+ /* load plugins */
9295
+ this.plugins = this.loadPlugins(this.config.plugins || []);
9296
+ this.configurations = this.loadConfigurations(this.plugins);
9297
+ this.extendMeta(this.plugins);
9298
+ /* process extended configs */
9299
+ this.config = this.extendConfig((_a = this.config.extends) !== null && _a !== void 0 ? _a : []);
9300
+ /* reset extends as we already processed them, this prevents the next config
9301
+ * from reapplying config from extended config as well as duplicate entries
9302
+ * when merging arrays */
9303
+ this.config.extends = [];
9304
+ /* rules explicitly set by passed options should have precedence over any
9305
+ * extended rules, not the other way around. */
9306
+ if (options && options.rules) {
9307
+ this.config = mergeInternal(this.config, { rules: options.rules });
9308
+ }
9309
+ }
9281
9310
  /**
9282
9311
  * Initialize plugins, transforms etc.
9283
9312
  *
@@ -11097,7 +11126,7 @@ class HtmlValidate {
11097
11126
  /** @public */
11098
11127
  const name = "html-validate";
11099
11128
  /** @public */
11100
- const version = "7.9.0";
11129
+ const version = "7.10.0";
11101
11130
  /** @public */
11102
11131
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
11103
11132