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.
- package/browser.d.ts +1 -0
- package/browser.js +1 -0
- package/dist/cjs/browser.d.ts +1 -4
- package/dist/cjs/browser.js +13 -1
- package/dist/cjs/browser.js.map +1 -1
- package/dist/cjs/cli.js +5 -5
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/core.js +193 -122
- package/dist/cjs/core.js.map +1 -1
- package/dist/cjs/elements.js +1 -1
- package/dist/cjs/html-validate.js +1 -1
- package/dist/cjs/index.d.ts +1 -89
- package/dist/cjs/index.js +13 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/jest-lib.js +17 -12
- package/dist/cjs/jest-lib.js.map +1 -1
- package/dist/cjs/jest.d.ts +1 -42
- package/dist/cjs/jest.js.map +1 -1
- package/dist/cjs/meta-helper.js +3 -0
- package/dist/cjs/meta-helper.js.map +1 -1
- package/dist/cjs/rules-helper.js +3 -3
- package/dist/cjs/rules-helper.js.map +1 -1
- package/dist/cjs/test-utils.d.ts +1 -30
- package/dist/cjs/test-utils.js +3 -0
- package/dist/cjs/test-utils.js.map +1 -1
- package/dist/cjs/tsdoc-metadata.json +11 -0
- package/dist/es/browser.d.ts +1 -4
- package/dist/es/browser.js +2 -2
- package/dist/es/cli.js +4 -4
- package/dist/es/cli.js.map +1 -1
- package/dist/es/core.js +172 -105
- package/dist/es/core.js.map +1 -1
- package/dist/es/elements.js +1 -1
- package/dist/es/html-validate.js +2 -2
- package/dist/es/index.d.ts +1 -89
- package/dist/es/index.js +2 -2
- package/dist/es/jest-lib.js +18 -13
- package/dist/es/jest-lib.js.map +1 -1
- package/dist/es/jest.d.ts +1 -42
- package/dist/es/jest.js.map +1 -1
- package/dist/es/meta-helper.js +3 -0
- package/dist/es/meta-helper.js.map +1 -1
- package/dist/es/rules-helper.js +4 -4
- package/dist/es/rules-helper.js.map +1 -1
- package/dist/es/test-utils.d.ts +1 -30
- package/dist/es/test-utils.js +3 -0
- package/dist/es/test-utils.js.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/{es/core.d.ts → types/browser.d.ts} +2435 -2615
- package/dist/{cjs/core.d.ts → types/index.d.ts} +2628 -2615
- package/dist/types/jest.d.ts +44 -0
- package/dist/types/test-utils.d.ts +40 -0
- package/jest.d.ts +1 -2
- package/package.json +33 -27
- package/test-utils.d.ts +1 -2
- package/dist/cjs/meta-helper.d.ts +0 -28
- package/dist/cjs/rules-helper.d.ts +0 -54
- package/dist/es/meta-helper.d.ts +0 -28
- 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
|
-
|
|
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
|
|
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
|
-
|
|
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,10 +610,12 @@ 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).
|
|
617
|
+
*
|
|
618
|
+
* @since v4.11.0
|
|
604
619
|
*/
|
|
605
620
|
isSameNode(otherNode) {
|
|
606
621
|
return this.unique === otherNode.unique;
|
|
@@ -726,6 +741,9 @@ function parse(text, baseLocation) {
|
|
|
726
741
|
}
|
|
727
742
|
return { tokens, locations };
|
|
728
743
|
}
|
|
744
|
+
/**
|
|
745
|
+
* @public
|
|
746
|
+
*/
|
|
729
747
|
class DOMTokenList extends Array {
|
|
730
748
|
constructor(value, location) {
|
|
731
749
|
if (value && typeof value === "string") {
|
|
@@ -762,7 +780,7 @@ class DOMTokenList extends Array {
|
|
|
762
780
|
}
|
|
763
781
|
*iterator() {
|
|
764
782
|
for (let index = 0; index < this.length; index++) {
|
|
765
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
783
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion -- as we loop over length this should always be set */
|
|
766
784
|
const item = this.item(index);
|
|
767
785
|
const location = this.location(index);
|
|
768
786
|
/* eslint-enable @typescript-eslint/no-non-null-assertion */
|
|
@@ -1121,7 +1139,7 @@ const TEXT_NODE_NAME = "#text";
|
|
|
1121
1139
|
* @public
|
|
1122
1140
|
*/
|
|
1123
1141
|
function isTextNode(node) {
|
|
1124
|
-
return Boolean(node && node.nodeType === NodeType.TEXT_NODE);
|
|
1142
|
+
return Boolean(node && node.nodeType === exports.NodeType.TEXT_NODE);
|
|
1125
1143
|
}
|
|
1126
1144
|
/**
|
|
1127
1145
|
* Represents a text in the HTML document.
|
|
@@ -1138,7 +1156,7 @@ class TextNode extends DOMNode {
|
|
|
1138
1156
|
* @param location - Source code location of this node.
|
|
1139
1157
|
*/
|
|
1140
1158
|
constructor(text, location) {
|
|
1141
|
-
super(NodeType.TEXT_NODE, TEXT_NODE_NAME, location);
|
|
1159
|
+
super(exports.NodeType.TEXT_NODE, TEXT_NODE_NAME, location);
|
|
1142
1160
|
this.text = text;
|
|
1143
1161
|
}
|
|
1144
1162
|
/**
|
|
@@ -1178,7 +1196,7 @@ exports.NodeClosed = void 0;
|
|
|
1178
1196
|
* @public
|
|
1179
1197
|
*/
|
|
1180
1198
|
function isElementNode(node) {
|
|
1181
|
-
return Boolean(node && node.nodeType === NodeType.ELEMENT_NODE);
|
|
1199
|
+
return Boolean(node && node.nodeType === exports.NodeType.ELEMENT_NODE);
|
|
1182
1200
|
}
|
|
1183
1201
|
function isValidTagName(tagName) {
|
|
1184
1202
|
return Boolean(tagName !== "" && tagName !== "*");
|
|
@@ -1188,7 +1206,7 @@ function isValidTagName(tagName) {
|
|
|
1188
1206
|
*/
|
|
1189
1207
|
class HtmlElement extends DOMNode {
|
|
1190
1208
|
constructor(tagName, parent, closed, meta, location) {
|
|
1191
|
-
const nodeType = tagName ? NodeType.ELEMENT_NODE : NodeType.DOCUMENT_NODE;
|
|
1209
|
+
const nodeType = tagName ? exports.NodeType.ELEMENT_NODE : exports.NodeType.DOCUMENT_NODE;
|
|
1192
1210
|
super(nodeType, tagName, location);
|
|
1193
1211
|
if (!isValidTagName(tagName)) {
|
|
1194
1212
|
throw new Error(`The tag name provided ('${tagName || ""}') is not a valid name`);
|
|
@@ -1281,7 +1299,7 @@ class HtmlElement extends DOMNode {
|
|
|
1281
1299
|
* Implementation of DOM specification of Element.closest(selectors).
|
|
1282
1300
|
*/
|
|
1283
1301
|
closest(selectors) {
|
|
1284
|
-
/* eslint-disable-next-line @typescript-eslint/no-this-alias */
|
|
1302
|
+
/* eslint-disable-next-line @typescript-eslint/no-this-alias -- false positive*/
|
|
1285
1303
|
let node = this;
|
|
1286
1304
|
while (node) {
|
|
1287
1305
|
if (node.matches(selectors)) {
|
|
@@ -1302,11 +1320,11 @@ class HtmlElement extends DOMNode {
|
|
|
1302
1320
|
}
|
|
1303
1321
|
const parts = [];
|
|
1304
1322
|
let root;
|
|
1305
|
-
/* eslint-disable-next-line @typescript-eslint/no-this-alias */
|
|
1323
|
+
/* eslint-disable-next-line @typescript-eslint/no-this-alias -- false positive */
|
|
1306
1324
|
for (root = this; root.parent; root = root.parent) {
|
|
1307
1325
|
/* .. */
|
|
1308
1326
|
}
|
|
1309
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
1327
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias -- false positive
|
|
1310
1328
|
for (let cur = this; cur.parent; cur = cur.parent) {
|
|
1311
1329
|
/* if a unique id is present, use it and short-circuit */
|
|
1312
1330
|
if (cur.id) {
|
|
@@ -1390,7 +1408,7 @@ class HtmlElement extends DOMNode {
|
|
|
1390
1408
|
*/
|
|
1391
1409
|
matches(selector) {
|
|
1392
1410
|
/* find root element */
|
|
1393
|
-
/* eslint-disable-next-line @typescript-eslint/no-this-alias */
|
|
1411
|
+
/* eslint-disable-next-line @typescript-eslint/no-this-alias -- false positive */
|
|
1394
1412
|
let root = this;
|
|
1395
1413
|
while (root.parent) {
|
|
1396
1414
|
root = root.parent;
|
|
@@ -1539,9 +1557,14 @@ class HtmlElement extends DOMNode {
|
|
|
1539
1557
|
}, []);
|
|
1540
1558
|
}
|
|
1541
1559
|
querySelector(selector) {
|
|
1542
|
-
var _a;
|
|
1543
1560
|
const it = this.querySelectorImpl(selector);
|
|
1544
|
-
|
|
1561
|
+
const next = it.next();
|
|
1562
|
+
if (next.done) {
|
|
1563
|
+
return null;
|
|
1564
|
+
}
|
|
1565
|
+
else {
|
|
1566
|
+
return next.value;
|
|
1567
|
+
}
|
|
1545
1568
|
}
|
|
1546
1569
|
querySelectorAll(selector) {
|
|
1547
1570
|
const it = this.querySelectorImpl(selector);
|
|
@@ -1635,6 +1658,9 @@ function isClosed(endToken, meta) {
|
|
|
1635
1658
|
return closed;
|
|
1636
1659
|
}
|
|
1637
1660
|
|
|
1661
|
+
/**
|
|
1662
|
+
* @public
|
|
1663
|
+
*/
|
|
1638
1664
|
class DOMTree {
|
|
1639
1665
|
constructor(location) {
|
|
1640
1666
|
this.root = HtmlElement.rootNode(location);
|
|
@@ -1713,6 +1739,9 @@ function ensureError(value) {
|
|
|
1713
1739
|
}
|
|
1714
1740
|
}
|
|
1715
1741
|
|
|
1742
|
+
/**
|
|
1743
|
+
* @public
|
|
1744
|
+
*/
|
|
1716
1745
|
class NestedError extends Error {
|
|
1717
1746
|
constructor(message, nested) {
|
|
1718
1747
|
super(message);
|
|
@@ -2479,7 +2508,7 @@ class MetaTable {
|
|
|
2479
2508
|
/**
|
|
2480
2509
|
* Extend validation schema.
|
|
2481
2510
|
*
|
|
2482
|
-
* @
|
|
2511
|
+
* @public
|
|
2483
2512
|
*/
|
|
2484
2513
|
extendValidationSchema(patch) {
|
|
2485
2514
|
if (patch.properties) {
|
|
@@ -2500,7 +2529,7 @@ class MetaTable {
|
|
|
2500
2529
|
/**
|
|
2501
2530
|
* Load metadata table from object.
|
|
2502
2531
|
*
|
|
2503
|
-
* @
|
|
2532
|
+
* @public
|
|
2504
2533
|
* @param obj - Object with metadata to load
|
|
2505
2534
|
* @param filename - Optional filename used when presenting validation error
|
|
2506
2535
|
*/
|
|
@@ -2521,7 +2550,7 @@ class MetaTable {
|
|
|
2521
2550
|
/**
|
|
2522
2551
|
* Load metadata table from filename
|
|
2523
2552
|
*
|
|
2524
|
-
* @
|
|
2553
|
+
* @public
|
|
2525
2554
|
* @param filename - Filename to load
|
|
2526
2555
|
*/
|
|
2527
2556
|
loadFromFile(filename) {
|
|
@@ -2684,7 +2713,7 @@ function expandRegexValue(value) {
|
|
|
2684
2713
|
const match = value.match(/^\/\^?([^/$]*)\$?\/([i]*)$/);
|
|
2685
2714
|
if (match) {
|
|
2686
2715
|
const [, expr, flags] = match;
|
|
2687
|
-
// eslint-disable-next-line security/detect-non-literal-regexp
|
|
2716
|
+
// eslint-disable-next-line security/detect-non-literal-regexp -- expected to be regexp
|
|
2688
2717
|
return new RegExp(`^${expr}$`, flags);
|
|
2689
2718
|
}
|
|
2690
2719
|
else {
|
|
@@ -2885,7 +2914,6 @@ class Validator {
|
|
|
2885
2914
|
* @param rules - Element attribute metadta.
|
|
2886
2915
|
* @returns `true` if attribute passes all tests.
|
|
2887
2916
|
*/
|
|
2888
|
-
/* eslint-disable-next-line complexity */
|
|
2889
2917
|
static validateAttribute(attr, rules) {
|
|
2890
2918
|
const rule = rules[attr.key];
|
|
2891
2919
|
if (!rule) {
|
|
@@ -2976,7 +3004,7 @@ class Validator {
|
|
|
2976
3004
|
* @param category - Name of category with `@` prefix or tag name.
|
|
2977
3005
|
* @param defaultMatch - The default return value when node categories is not known.
|
|
2978
3006
|
*/
|
|
2979
|
-
|
|
3007
|
+
/* eslint-disable-next-line complexity -- rule does not like switch */
|
|
2980
3008
|
static validatePermittedCategory(node, category, defaultMatch) {
|
|
2981
3009
|
const [, rawCategory] = category.match(/^(@?.*?)([?*]?)$/);
|
|
2982
3010
|
/* match tagName when an explicit name is given */
|
|
@@ -3183,7 +3211,8 @@ var configurationSchema = {
|
|
|
3183
3211
|
properties: properties
|
|
3184
3212
|
};
|
|
3185
3213
|
|
|
3186
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion
|
|
3214
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion -- declarations say
|
|
3215
|
+
* location fields are optional but they are always present when `{loc: true}` */
|
|
3187
3216
|
function joinTemplateLiteral(nodes) {
|
|
3188
3217
|
let offset = nodes[0].start + 1;
|
|
3189
3218
|
let output = "";
|
|
@@ -3404,7 +3433,7 @@ function parseSeverity(value) {
|
|
|
3404
3433
|
return exports.Severity.DISABLED;
|
|
3405
3434
|
/* istanbul ignore next: deprecated code which will be removed later */
|
|
3406
3435
|
case "disable":
|
|
3407
|
-
// eslint-disable-next-line no-console
|
|
3436
|
+
// eslint-disable-next-line no-console -- expected to log
|
|
3408
3437
|
console.warn(`Deprecated alias "disabled" will be removed, replace with severity "off"`);
|
|
3409
3438
|
return exports.Severity.DISABLED;
|
|
3410
3439
|
case 1:
|
|
@@ -3515,8 +3544,8 @@ class Rule {
|
|
|
3515
3544
|
this.severity = severity;
|
|
3516
3545
|
}
|
|
3517
3546
|
/**
|
|
3518
|
-
* Block this rule from generating errors. Pass in an id generated by
|
|
3519
|
-
* createBlocker
|
|
3547
|
+
* Block this rule from generating errors. Pass in an id generated by
|
|
3548
|
+
* `createBlocker`. Can be unblocked by {@link Rule.unblock}.
|
|
3520
3549
|
*
|
|
3521
3550
|
* A blocked rule is similar to disabling it but it will still receive parser
|
|
3522
3551
|
* events. A list of all blockers is passed to the `rule:error` event.
|
|
@@ -3527,7 +3556,7 @@ class Rule {
|
|
|
3527
3556
|
this.blockers.push(id);
|
|
3528
3557
|
}
|
|
3529
3558
|
/**
|
|
3530
|
-
* Unblock a rule previously blocked by {@link block}.
|
|
3559
|
+
* Unblock a rule previously blocked by {@link Rule.block}.
|
|
3531
3560
|
*
|
|
3532
3561
|
* @internal
|
|
3533
3562
|
*/
|
|
@@ -3745,12 +3774,20 @@ class Rule {
|
|
|
3745
3774
|
* @returns Rule documentation and url with additional details or `null` if no
|
|
3746
3775
|
* additional documentation is available.
|
|
3747
3776
|
*/
|
|
3748
|
-
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
3777
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars -- technical debt, prototype should be moved to interface */
|
|
3749
3778
|
documentation(context) {
|
|
3750
3779
|
return null;
|
|
3751
3780
|
}
|
|
3752
3781
|
}
|
|
3753
3782
|
|
|
3783
|
+
var Style$2;
|
|
3784
|
+
(function (Style) {
|
|
3785
|
+
Style["EXTERNAL"] = "external";
|
|
3786
|
+
Style["RELATIVE_BASE"] = "relative-base";
|
|
3787
|
+
Style["RELATIVE_PATH"] = "relative-path";
|
|
3788
|
+
Style["ABSOLUTE"] = "absolute";
|
|
3789
|
+
Style["ANCHOR"] = "anchor";
|
|
3790
|
+
})(Style$2 || (Style$2 = {}));
|
|
3754
3791
|
const defaults$w = {
|
|
3755
3792
|
allowExternal: true,
|
|
3756
3793
|
allowRelative: true,
|
|
@@ -3764,18 +3801,18 @@ const mapping$1 = {
|
|
|
3764
3801
|
script: "src",
|
|
3765
3802
|
};
|
|
3766
3803
|
const description = {
|
|
3767
|
-
[
|
|
3768
|
-
[
|
|
3769
|
-
[
|
|
3770
|
-
[
|
|
3771
|
-
[
|
|
3804
|
+
[Style$2.EXTERNAL]: "External links are not allowed by current configuration.",
|
|
3805
|
+
[Style$2.RELATIVE_BASE]: "Links relative to <base> are not allowed by current configuration.",
|
|
3806
|
+
[Style$2.RELATIVE_PATH]: "Relative links are not allowed by current configuration.",
|
|
3807
|
+
[Style$2.ABSOLUTE]: "Absolute links are not allowed by current configuration.",
|
|
3808
|
+
[Style$2.ANCHOR]: null,
|
|
3772
3809
|
};
|
|
3773
3810
|
function parseAllow(value) {
|
|
3774
3811
|
if (typeof value === "boolean") {
|
|
3775
3812
|
return value;
|
|
3776
3813
|
}
|
|
3777
3814
|
return {
|
|
3778
|
-
/* eslint-disable security/detect-non-literal-regexp */
|
|
3815
|
+
/* eslint-disable security/detect-non-literal-regexp -- expected to be regexp */
|
|
3779
3816
|
include: value.include ? value.include.map((it) => new RegExp(it)) : null,
|
|
3780
3817
|
exclude: value.exclude ? value.exclude.map((it) => new RegExp(it)) : null,
|
|
3781
3818
|
/* eslint-enable security/detect-non-literal-regexp */
|
|
@@ -3841,19 +3878,19 @@ class AllowedLinks extends Rule {
|
|
|
3841
3878
|
const link = event.value.toString();
|
|
3842
3879
|
const style = this.getStyle(link);
|
|
3843
3880
|
switch (style) {
|
|
3844
|
-
case
|
|
3881
|
+
case Style$2.ANCHOR:
|
|
3845
3882
|
/* anchor links are always allowed by this rule */
|
|
3846
3883
|
break;
|
|
3847
|
-
case
|
|
3884
|
+
case Style$2.ABSOLUTE:
|
|
3848
3885
|
this.handleAbsolute(link, event, style);
|
|
3849
3886
|
break;
|
|
3850
|
-
case
|
|
3887
|
+
case Style$2.EXTERNAL:
|
|
3851
3888
|
this.handleExternal(link, event, style);
|
|
3852
3889
|
break;
|
|
3853
|
-
case
|
|
3890
|
+
case Style$2.RELATIVE_BASE:
|
|
3854
3891
|
this.handleRelativeBase(link, event, style);
|
|
3855
3892
|
break;
|
|
3856
|
-
case
|
|
3893
|
+
case Style$2.RELATIVE_PATH:
|
|
3857
3894
|
this.handleRelativePath(link, event, style);
|
|
3858
3895
|
break;
|
|
3859
3896
|
}
|
|
@@ -3871,21 +3908,21 @@ class AllowedLinks extends Rule {
|
|
|
3871
3908
|
getStyle(value) {
|
|
3872
3909
|
/* http://example.net or //example.net */
|
|
3873
3910
|
if (value.match(/^([a-z]+:)?\/\//g)) {
|
|
3874
|
-
return
|
|
3911
|
+
return Style$2.EXTERNAL;
|
|
3875
3912
|
}
|
|
3876
3913
|
switch (value[0]) {
|
|
3877
3914
|
/* /foo/bar */
|
|
3878
3915
|
case "/":
|
|
3879
|
-
return
|
|
3916
|
+
return Style$2.ABSOLUTE;
|
|
3880
3917
|
/* ../foo/bar */
|
|
3881
3918
|
case ".":
|
|
3882
|
-
return
|
|
3919
|
+
return Style$2.RELATIVE_PATH;
|
|
3883
3920
|
/* #foo */
|
|
3884
3921
|
case "#":
|
|
3885
|
-
return
|
|
3922
|
+
return Style$2.ANCHOR;
|
|
3886
3923
|
/* foo/bar */
|
|
3887
3924
|
default:
|
|
3888
|
-
return
|
|
3925
|
+
return Style$2.RELATIVE_BASE;
|
|
3889
3926
|
}
|
|
3890
3927
|
}
|
|
3891
3928
|
handleAbsolute(target, event, style) {
|
|
@@ -4223,6 +4260,9 @@ class AttrCase extends Rule {
|
|
|
4223
4260
|
}
|
|
4224
4261
|
}
|
|
4225
4262
|
|
|
4263
|
+
/**
|
|
4264
|
+
* @internal
|
|
4265
|
+
*/
|
|
4226
4266
|
var TokenType;
|
|
4227
4267
|
(function (TokenType) {
|
|
4228
4268
|
TokenType[TokenType["UNICODE_BOM"] = 1] = "UNICODE_BOM";
|
|
@@ -4244,7 +4284,7 @@ var TokenType;
|
|
|
4244
4284
|
TokenType[TokenType["EOF"] = 17] = "EOF";
|
|
4245
4285
|
})(TokenType || (TokenType = {}));
|
|
4246
4286
|
|
|
4247
|
-
/* eslint-disable no-useless-escape */
|
|
4287
|
+
/* eslint-disable no-useless-escape -- false positives */
|
|
4248
4288
|
const MATCH_UNICODE_BOM = /^\uFEFF/;
|
|
4249
4289
|
const MATCH_WHITESPACE = /^(?:\r\n|\r|\n|[ \t]+(?:\r\n|\r|\n)?)/;
|
|
4250
4290
|
const MATCH_DOCTYPE_OPEN = /^<!(DOCTYPE)\s/i;
|
|
@@ -4269,6 +4309,7 @@ const MATCH_STYLE_END = /^<(\/)(style)/;
|
|
|
4269
4309
|
const MATCH_DIRECTIVE = /^(<!--\s*\[html-validate-)([a-z0-9-]+)(\s*)(.*?)(]?\s*-->)/;
|
|
4270
4310
|
const MATCH_COMMENT = /^<!--([^]*?)-->/;
|
|
4271
4311
|
const MATCH_CONDITIONAL = /^<!\[([^\]]*?)\]>/;
|
|
4312
|
+
/* eslint-enable no-useless-escape */
|
|
4272
4313
|
class InvalidTokenError extends Error {
|
|
4273
4314
|
constructor(location, message) {
|
|
4274
4315
|
super(message);
|
|
@@ -4276,7 +4317,7 @@ class InvalidTokenError extends Error {
|
|
|
4276
4317
|
}
|
|
4277
4318
|
}
|
|
4278
4319
|
class Lexer {
|
|
4279
|
-
|
|
4320
|
+
/* eslint-disable-next-line complexity -- there isn't really a good way to refactor this while keeping readability */
|
|
4280
4321
|
*tokenize(source) {
|
|
4281
4322
|
const context = new Context(source);
|
|
4282
4323
|
/* for sanity check */
|
|
@@ -4410,7 +4451,6 @@ class Lexer {
|
|
|
4410
4451
|
], "expected doctype name");
|
|
4411
4452
|
}
|
|
4412
4453
|
*tokenizeTag(context) {
|
|
4413
|
-
/* eslint-disable-next-line consistent-return -- exhaustive switch handled by typescript */
|
|
4414
4454
|
function nextState(token) {
|
|
4415
4455
|
const tagCloseToken = token;
|
|
4416
4456
|
switch (context.contentModel) {
|
|
@@ -4507,11 +4547,11 @@ const defaults$t = {
|
|
|
4507
4547
|
};
|
|
4508
4548
|
function generateRegexp(pattern) {
|
|
4509
4549
|
if (Array.isArray(pattern)) {
|
|
4510
|
-
/* eslint-disable-next-line security/detect-non-literal-regexp */
|
|
4550
|
+
/* eslint-disable-next-line security/detect-non-literal-regexp -- expected to be regexp */
|
|
4511
4551
|
return new RegExp(`^(${pattern.join("|")})$`, "i");
|
|
4512
4552
|
}
|
|
4513
4553
|
else {
|
|
4514
|
-
/* eslint-disable-next-line security/detect-non-literal-regexp */
|
|
4554
|
+
/* eslint-disable-next-line security/detect-non-literal-regexp -- expected to be regexp */
|
|
4515
4555
|
return new RegExp(`^${pattern}$`, "i");
|
|
4516
4556
|
}
|
|
4517
4557
|
}
|
|
@@ -5061,7 +5101,7 @@ function parsePattern(pattern) {
|
|
|
5061
5101
|
case "underscore":
|
|
5062
5102
|
return /^[a-z0-9_]+$/;
|
|
5063
5103
|
default:
|
|
5064
|
-
|
|
5104
|
+
/* eslint-disable-next-line security/detect-non-literal-regexp -- expected to be regexp */
|
|
5065
5105
|
return new RegExp(pattern);
|
|
5066
5106
|
}
|
|
5067
5107
|
}
|
|
@@ -5477,7 +5517,7 @@ const defaults$l = {
|
|
|
5477
5517
|
class ElementName extends Rule {
|
|
5478
5518
|
constructor(options) {
|
|
5479
5519
|
super({ ...defaults$l, ...options });
|
|
5480
|
-
|
|
5520
|
+
/* eslint-disable-next-line security/detect-non-literal-regexp -- expected to be a regexp */
|
|
5481
5521
|
this.pattern = new RegExp(this.options.pattern);
|
|
5482
5522
|
}
|
|
5483
5523
|
static schema() {
|
|
@@ -6485,7 +6525,7 @@ class IdPattern extends Rule {
|
|
|
6485
6525
|
}
|
|
6486
6526
|
}
|
|
6487
6527
|
|
|
6488
|
-
/* eslint-disable sonarjs/no-duplicate-string */
|
|
6528
|
+
/* eslint-disable sonarjs/no-duplicate-string -- wont be easier to read or manage with constants */
|
|
6489
6529
|
const restricted = new Map([
|
|
6490
6530
|
["accept", ["file"]],
|
|
6491
6531
|
["alt", ["image"]],
|
|
@@ -7455,7 +7495,7 @@ class NoRawCharacters extends Rule {
|
|
|
7455
7495
|
const node = event.target;
|
|
7456
7496
|
/* only iterate over direct descendants */
|
|
7457
7497
|
for (const child of node.childNodes) {
|
|
7458
|
-
if (child.nodeType !== NodeType.TEXT_NODE) {
|
|
7498
|
+
if (child.nodeType !== exports.NodeType.TEXT_NODE) {
|
|
7459
7499
|
continue;
|
|
7460
7500
|
}
|
|
7461
7501
|
/* workaround for templating <% ... %> etc */
|
|
@@ -8301,11 +8341,11 @@ function constructRegex(characters) {
|
|
|
8301
8341
|
})
|
|
8302
8342
|
.join("|");
|
|
8303
8343
|
const pattern = `(${disallowed})`;
|
|
8304
|
-
/* eslint-disable-next-line security/detect-non-literal-regexp */
|
|
8344
|
+
/* eslint-disable-next-line security/detect-non-literal-regexp -- technical debt, should do more input sanitation */
|
|
8305
8345
|
return new RegExp(pattern, "g");
|
|
8306
8346
|
}
|
|
8307
8347
|
function getText(node) {
|
|
8308
|
-
/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
|
|
8348
|
+
/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- this will always match something, it cannot be null */
|
|
8309
8349
|
const match = node.textContent.match(/^(\s*)(.*)$/);
|
|
8310
8350
|
const [, leading, text] = match;
|
|
8311
8351
|
return [leading.length, text.trimEnd()];
|
|
@@ -8314,15 +8354,11 @@ function getText(node) {
|
|
|
8314
8354
|
* Node 12 does not support String.matchAll, this simulates it's behavior.
|
|
8315
8355
|
*/
|
|
8316
8356
|
function matchAll(text, regexp) {
|
|
8317
|
-
/* eslint-disable-next-line security/detect-non-literal-regexp */
|
|
8357
|
+
/* eslint-disable-next-line security/detect-non-literal-regexp -- makes copy of existing one only */
|
|
8318
8358
|
const copy = new RegExp(regexp);
|
|
8319
8359
|
const matches = [];
|
|
8320
|
-
|
|
8321
|
-
while (
|
|
8322
|
-
const match = copy.exec(text);
|
|
8323
|
-
if (match === null) {
|
|
8324
|
-
break;
|
|
8325
|
-
}
|
|
8360
|
+
let match;
|
|
8361
|
+
while ((match = copy.exec(text))) {
|
|
8326
8362
|
matches.push(match);
|
|
8327
8363
|
}
|
|
8328
8364
|
return matches;
|
|
@@ -8532,13 +8568,13 @@ class TextContent extends Rule {
|
|
|
8532
8568
|
};
|
|
8533
8569
|
if (context === null || context === void 0 ? void 0 : context.textContent) {
|
|
8534
8570
|
switch (context.textContent) {
|
|
8535
|
-
case TextContent
|
|
8571
|
+
case exports.TextContent.NONE:
|
|
8536
8572
|
doc.description = `The \`<${context.tagName}>\` element must not have textual content.`;
|
|
8537
8573
|
break;
|
|
8538
|
-
case TextContent
|
|
8574
|
+
case exports.TextContent.REQUIRED:
|
|
8539
8575
|
doc.description = `The \`<${context.tagName}>\` element must have textual content.`;
|
|
8540
8576
|
break;
|
|
8541
|
-
case TextContent
|
|
8577
|
+
case exports.TextContent.ACCESSIBLE:
|
|
8542
8578
|
doc.description = `The \`<${context.tagName}>\` element must have accessible text.`;
|
|
8543
8579
|
break;
|
|
8544
8580
|
}
|
|
@@ -8553,7 +8589,7 @@ class TextContent extends Rule {
|
|
|
8553
8589
|
}
|
|
8554
8590
|
/* skip elements without explicit and default textContent */
|
|
8555
8591
|
const { textContent } = target.meta;
|
|
8556
|
-
if (!textContent || textContent === TextContent
|
|
8592
|
+
if (!textContent || textContent === exports.TextContent.DEFAULT) {
|
|
8557
8593
|
return false;
|
|
8558
8594
|
}
|
|
8559
8595
|
return true;
|
|
@@ -8563,13 +8599,13 @@ class TextContent extends Rule {
|
|
|
8563
8599
|
const target = event.target;
|
|
8564
8600
|
const { textContent } = target.meta;
|
|
8565
8601
|
switch (textContent) {
|
|
8566
|
-
case TextContent
|
|
8602
|
+
case exports.TextContent.NONE:
|
|
8567
8603
|
this.validateNone(target);
|
|
8568
8604
|
break;
|
|
8569
|
-
case TextContent
|
|
8605
|
+
case exports.TextContent.REQUIRED:
|
|
8570
8606
|
this.validateRequired(target);
|
|
8571
8607
|
break;
|
|
8572
|
-
case TextContent
|
|
8608
|
+
case exports.TextContent.ACCESSIBLE:
|
|
8573
8609
|
this.validateAccessible(target);
|
|
8574
8610
|
break;
|
|
8575
8611
|
}
|
|
@@ -8682,7 +8718,7 @@ class UnknownCharReference extends Rule {
|
|
|
8682
8718
|
const node = event.target;
|
|
8683
8719
|
/* only iterate over direct descendants */
|
|
8684
8720
|
for (const child of node.childNodes) {
|
|
8685
|
-
if (child.nodeType !== NodeType.TEXT_NODE) {
|
|
8721
|
+
if (child.nodeType !== exports.NodeType.TEXT_NODE) {
|
|
8686
8722
|
continue;
|
|
8687
8723
|
}
|
|
8688
8724
|
this.findCharacterReferences(node, child.textContent, child.location, {
|
|
@@ -8708,43 +8744,46 @@ class UnknownCharReference extends Rule {
|
|
|
8708
8744
|
return elements.entities;
|
|
8709
8745
|
}
|
|
8710
8746
|
}
|
|
8711
|
-
/* eslint-disable-next-line complexity */
|
|
8712
8747
|
findCharacterReferences(node, text, location, { isAttribute }) {
|
|
8713
|
-
const { requireSemicolon } = this.options;
|
|
8714
8748
|
const isQuerystring = isAttribute && text.includes("?");
|
|
8715
|
-
for (const
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
|
|
8728
|
-
|
|
8729
|
-
|
|
8730
|
-
|
|
8731
|
-
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
|
|
8735
|
-
|
|
8736
|
-
|
|
8737
|
-
this.report(node, message, entityLocation, context);
|
|
8738
|
-
continue;
|
|
8739
|
-
}
|
|
8749
|
+
for (const match of this.getMatches(text)) {
|
|
8750
|
+
this.validateCharacterReference(node, location, match, { isQuerystring });
|
|
8751
|
+
}
|
|
8752
|
+
}
|
|
8753
|
+
validateCharacterReference(node, location, foobar, { isQuerystring }) {
|
|
8754
|
+
const { requireSemicolon } = this.options;
|
|
8755
|
+
const { match, entity, raw, terminated } = foobar;
|
|
8756
|
+
/* assume numeric entities are valid for now */
|
|
8757
|
+
if (isNumerical(entity)) {
|
|
8758
|
+
return;
|
|
8759
|
+
}
|
|
8760
|
+
/* special case: when attributes use query parameters we skip checking
|
|
8761
|
+
* unterminated attributes */
|
|
8762
|
+
if (isQuerystring && !terminated) {
|
|
8763
|
+
return;
|
|
8764
|
+
}
|
|
8765
|
+
const found = this.entities.includes(entity);
|
|
8766
|
+
/* ignore if this is a known character reference name */
|
|
8767
|
+
if (found && (terminated || !requireSemicolon)) {
|
|
8768
|
+
return;
|
|
8769
|
+
}
|
|
8770
|
+
if (found && !terminated) {
|
|
8740
8771
|
const entityLocation = getLocation(location, entity, match);
|
|
8741
|
-
const message = `
|
|
8772
|
+
const message = `Character reference "{{ entity }}" must be terminated by a semicolon`;
|
|
8742
8773
|
const context = {
|
|
8743
8774
|
entity: raw,
|
|
8744
|
-
terminated:
|
|
8775
|
+
terminated: false,
|
|
8745
8776
|
};
|
|
8746
8777
|
this.report(node, message, entityLocation, context);
|
|
8778
|
+
return;
|
|
8747
8779
|
}
|
|
8780
|
+
const entityLocation = getLocation(location, entity, match);
|
|
8781
|
+
const message = `Unrecognized character reference "{{ entity }}"`;
|
|
8782
|
+
const context = {
|
|
8783
|
+
entity: raw,
|
|
8784
|
+
terminated: true,
|
|
8785
|
+
};
|
|
8786
|
+
this.report(node, message, entityLocation, context);
|
|
8748
8787
|
}
|
|
8749
8788
|
*getMatches(text) {
|
|
8750
8789
|
let match;
|
|
@@ -9608,6 +9647,8 @@ const presets = {
|
|
|
9608
9647
|
/**
|
|
9609
9648
|
* A resolved configuration is a normalized configuration with all extends,
|
|
9610
9649
|
* plugins etc resolved.
|
|
9650
|
+
*
|
|
9651
|
+
* @public
|
|
9611
9652
|
*/
|
|
9612
9653
|
class ResolvedConfig {
|
|
9613
9654
|
constructor({ metaTable, plugins, rules, transformers }) {
|
|
@@ -9853,7 +9894,7 @@ class Config {
|
|
|
9853
9894
|
* Must be called before trying to use config. Can safely be called multiple
|
|
9854
9895
|
* times.
|
|
9855
9896
|
*
|
|
9856
|
-
* @
|
|
9897
|
+
* @public
|
|
9857
9898
|
*/
|
|
9858
9899
|
init() {
|
|
9859
9900
|
if (this.initialized) {
|
|
@@ -9873,7 +9914,7 @@ class Config {
|
|
|
9873
9914
|
* Returns a new configuration as a merge of the two. Entries from the passed
|
|
9874
9915
|
* object takes priority over this object.
|
|
9875
9916
|
*
|
|
9876
|
-
* @
|
|
9917
|
+
* @public
|
|
9877
9918
|
* @param rhs - Configuration to merge with this one.
|
|
9878
9919
|
*/
|
|
9879
9920
|
merge(rhs) {
|
|
@@ -9900,7 +9941,7 @@ class Config {
|
|
|
9900
9941
|
/**
|
|
9901
9942
|
* Get element metadata.
|
|
9902
9943
|
*/
|
|
9903
|
-
/* eslint-disable-next-line complexity, sonarjs/cognitive-complexity */
|
|
9944
|
+
/* eslint-disable-next-line complexity, sonarjs/cognitive-complexity -- technical debt, should be refactored */
|
|
9904
9945
|
getMetaTable() {
|
|
9905
9946
|
/* use cached table if it exists */
|
|
9906
9947
|
if (this.metaTable) {
|
|
@@ -10073,7 +10114,7 @@ class Config {
|
|
|
10073
10114
|
* A resolved configuration will merge all extended configs and load all
|
|
10074
10115
|
* plugins and transformers, and normalize the rest of the configuration.
|
|
10075
10116
|
*
|
|
10076
|
-
* @
|
|
10117
|
+
* @public
|
|
10077
10118
|
*/
|
|
10078
10119
|
resolve() {
|
|
10079
10120
|
return new ResolvedConfig(this.resolveData());
|
|
@@ -10102,7 +10143,7 @@ class Config {
|
|
|
10102
10143
|
throw new ConfigError(`Transformer uses API version ${version} but only version ${TRANSFORMER_API.VERSION} is supported`);
|
|
10103
10144
|
}
|
|
10104
10145
|
return {
|
|
10105
|
-
// eslint-disable-next-line security/detect-non-literal-regexp
|
|
10146
|
+
// eslint-disable-next-line security/detect-non-literal-regexp -- expected to be a regexp
|
|
10106
10147
|
pattern: new RegExp(pattern),
|
|
10107
10148
|
name,
|
|
10108
10149
|
fn,
|
|
@@ -10207,6 +10248,9 @@ class Config {
|
|
|
10207
10248
|
/* set global instance */
|
|
10208
10249
|
rootDirCache = value;
|
|
10209
10250
|
}
|
|
10251
|
+
/**
|
|
10252
|
+
* @internal
|
|
10253
|
+
*/
|
|
10210
10254
|
findRootDir() {
|
|
10211
10255
|
const cache = this.rootDirCache;
|
|
10212
10256
|
if (cache !== null) {
|
|
@@ -10214,7 +10258,7 @@ class Config {
|
|
|
10214
10258
|
}
|
|
10215
10259
|
/* try to locate package.json */
|
|
10216
10260
|
let current = process.cwd();
|
|
10217
|
-
// eslint-disable-next-line no-constant-condition
|
|
10261
|
+
// eslint-disable-next-line no-constant-condition -- break outs when filesystem is traversed
|
|
10218
10262
|
while (true) {
|
|
10219
10263
|
const search = path__default.default.join(current, "package.json");
|
|
10220
10264
|
if (fs__default.default.existsSync(search)) {
|
|
@@ -10259,7 +10303,7 @@ class ConfigLoader {
|
|
|
10259
10303
|
}
|
|
10260
10304
|
|
|
10261
10305
|
/**
|
|
10262
|
-
* @
|
|
10306
|
+
* @public
|
|
10263
10307
|
*/
|
|
10264
10308
|
class EventHandler {
|
|
10265
10309
|
constructor() {
|
|
@@ -10307,7 +10351,6 @@ class EventHandler {
|
|
|
10307
10351
|
* @param event - Event name.
|
|
10308
10352
|
* @param data - Event data.
|
|
10309
10353
|
*/
|
|
10310
|
-
/* eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types */
|
|
10311
10354
|
trigger(event, data) {
|
|
10312
10355
|
var _a, _b;
|
|
10313
10356
|
const callbacks = [...((_a = this.listeners[event]) !== null && _a !== void 0 ? _a : []), ...((_b = this.listeners["*"]) !== null && _b !== void 0 ? _b : [])];
|
|
@@ -10352,12 +10395,13 @@ function isValidDirective(action) {
|
|
|
10352
10395
|
/**
|
|
10353
10396
|
* Parse HTML document into a DOM tree.
|
|
10354
10397
|
*
|
|
10355
|
-
* @
|
|
10398
|
+
* @public
|
|
10356
10399
|
*/
|
|
10357
10400
|
class Parser {
|
|
10358
10401
|
/**
|
|
10359
10402
|
* Create a new parser instance.
|
|
10360
10403
|
*
|
|
10404
|
+
* @public
|
|
10361
10405
|
* @param config - Configuration
|
|
10362
10406
|
*/
|
|
10363
10407
|
constructor(config) {
|
|
@@ -10369,6 +10413,7 @@ class Parser {
|
|
|
10369
10413
|
/**
|
|
10370
10414
|
* Parse HTML markup.
|
|
10371
10415
|
*
|
|
10416
|
+
* @public
|
|
10372
10417
|
* @param source - HTML markup.
|
|
10373
10418
|
* @returns DOM tree representing the HTML markup.
|
|
10374
10419
|
*/
|
|
@@ -10459,7 +10504,10 @@ class Parser {
|
|
|
10459
10504
|
return Boolean(active.parent && active.parent.is(tagName) && meta.includes(active.tagName));
|
|
10460
10505
|
}
|
|
10461
10506
|
}
|
|
10462
|
-
|
|
10507
|
+
/**
|
|
10508
|
+
* @internal
|
|
10509
|
+
*/
|
|
10510
|
+
/* eslint-disable-next-line complexity -- there isn't really a good other way to structure this method (that is still readable) */
|
|
10463
10511
|
consume(source, token, tokenStream) {
|
|
10464
10512
|
switch (token.type) {
|
|
10465
10513
|
case TokenType.UNICODE_BOM:
|
|
@@ -10496,7 +10544,10 @@ class Parser {
|
|
|
10496
10544
|
break;
|
|
10497
10545
|
}
|
|
10498
10546
|
}
|
|
10499
|
-
|
|
10547
|
+
/**
|
|
10548
|
+
* @internal
|
|
10549
|
+
*/
|
|
10550
|
+
/* eslint-disable-next-line complexity, sonarjs/cognitive-complexity -- technical debt, chould be refactored a bit */
|
|
10500
10551
|
consumeTag(source, startToken, tokenStream) {
|
|
10501
10552
|
const tokens = Array.from(this.consumeUntil(tokenStream, TokenType.TAG_CLOSE, startToken.location));
|
|
10502
10553
|
const endToken = tokens.slice(-1)[0];
|
|
@@ -10561,6 +10612,9 @@ class Parser {
|
|
|
10561
10612
|
this.discardForeignBody(source, node.tagName, tokenStream, startToken.location);
|
|
10562
10613
|
}
|
|
10563
10614
|
}
|
|
10615
|
+
/**
|
|
10616
|
+
* @internal
|
|
10617
|
+
*/
|
|
10564
10618
|
closeElement(source, node, active, location) {
|
|
10565
10619
|
/* call processElement hook */
|
|
10566
10620
|
this.processElement(active, source);
|
|
@@ -10596,6 +10650,8 @@ class Parser {
|
|
|
10596
10650
|
}
|
|
10597
10651
|
/**
|
|
10598
10652
|
* Discard tokens until the end tag for the foreign element is found.
|
|
10653
|
+
*
|
|
10654
|
+
* @internal
|
|
10599
10655
|
*/
|
|
10600
10656
|
discardForeignBody(source, foreignTagName, tokenStream, errorLocation) {
|
|
10601
10657
|
/* consume elements until the end tag for this foreign element is found */
|
|
@@ -10644,6 +10700,9 @@ class Parser {
|
|
|
10644
10700
|
this.closeElement(source, node, active, endToken.location);
|
|
10645
10701
|
this.dom.popActive();
|
|
10646
10702
|
}
|
|
10703
|
+
/**
|
|
10704
|
+
* @internal
|
|
10705
|
+
*/
|
|
10647
10706
|
consumeAttribute(source, node, token, next) {
|
|
10648
10707
|
const keyLocation = this.getAttributeKeyLocation(token);
|
|
10649
10708
|
const valueLocation = this.getAttributeValueLocation(next);
|
|
@@ -10734,6 +10793,9 @@ class Parser {
|
|
|
10734
10793
|
offset: begin.offset,
|
|
10735
10794
|
};
|
|
10736
10795
|
}
|
|
10796
|
+
/**
|
|
10797
|
+
* @internal
|
|
10798
|
+
*/
|
|
10737
10799
|
consumeDirective(token) {
|
|
10738
10800
|
const [text, preamble, action, separator1, directive, postamble] = token.data;
|
|
10739
10801
|
if (!postamble.startsWith("]")) {
|
|
@@ -10779,6 +10841,8 @@ class Parser {
|
|
|
10779
10841
|
* Consumes conditional comment in tag form.
|
|
10780
10842
|
*
|
|
10781
10843
|
* See also the related [[consumeCommend]] method.
|
|
10844
|
+
*
|
|
10845
|
+
* @internal
|
|
10782
10846
|
*/
|
|
10783
10847
|
consumeConditional(token) {
|
|
10784
10848
|
const element = this.dom.getActive();
|
|
@@ -10793,6 +10857,8 @@ class Parser {
|
|
|
10793
10857
|
*
|
|
10794
10858
|
* Tries to find IE conditional comments and emits conditional token if
|
|
10795
10859
|
* found. See also the related [[consumeConditional]] method.
|
|
10860
|
+
*
|
|
10861
|
+
* @internal
|
|
10796
10862
|
*/
|
|
10797
10863
|
consumeComment(token) {
|
|
10798
10864
|
const comment = token.data[0];
|
|
@@ -10807,6 +10873,8 @@ class Parser {
|
|
|
10807
10873
|
}
|
|
10808
10874
|
/**
|
|
10809
10875
|
* Consumes doctype tokens. Emits doctype event.
|
|
10876
|
+
*
|
|
10877
|
+
* @internal
|
|
10810
10878
|
*/
|
|
10811
10879
|
consumeDoctype(startToken, tokenStream) {
|
|
10812
10880
|
const tokens = Array.from(this.consumeUntil(tokenStream, TokenType.DOCTYPE_CLOSE, startToken.location));
|
|
@@ -10824,6 +10892,7 @@ class Parser {
|
|
|
10824
10892
|
/**
|
|
10825
10893
|
* Return a list of tokens found until the expected token was found.
|
|
10826
10894
|
*
|
|
10895
|
+
* @internal
|
|
10827
10896
|
* @param errorLocation - What location to use if an error occurs
|
|
10828
10897
|
*/
|
|
10829
10898
|
*consumeUntil(tokenStream, search, errorLocation) {
|
|
@@ -10888,6 +10957,7 @@ class Parser {
|
|
|
10888
10957
|
/**
|
|
10889
10958
|
* Defer execution. Will call function sometime later.
|
|
10890
10959
|
*
|
|
10960
|
+
* @internal
|
|
10891
10961
|
* @param cb - Callback to execute later.
|
|
10892
10962
|
*/
|
|
10893
10963
|
defer(cb) {
|
|
@@ -10930,7 +11000,7 @@ function freeze(src) {
|
|
|
10930
11000
|
};
|
|
10931
11001
|
}
|
|
10932
11002
|
/**
|
|
10933
|
-
* @
|
|
11003
|
+
* @public
|
|
10934
11004
|
*/
|
|
10935
11005
|
class Reporter {
|
|
10936
11006
|
constructor() {
|
|
@@ -11122,7 +11192,6 @@ class Engine {
|
|
|
11122
11192
|
};
|
|
11123
11193
|
parser.trigger("config:ready", configEvent);
|
|
11124
11194
|
/* trigger source ready event */
|
|
11125
|
-
/* eslint-disable-next-line @typescript-eslint/no-unused-vars -- object destructured on purpose to remove property */
|
|
11126
11195
|
const { hooks: _, ...sourceData } = source;
|
|
11127
11196
|
const sourceEvent = {
|
|
11128
11197
|
location,
|
|
@@ -11217,8 +11286,7 @@ class Engine {
|
|
|
11217
11286
|
/**
|
|
11218
11287
|
* Get rule documentation.
|
|
11219
11288
|
*/
|
|
11220
|
-
getRuleDocumentation(ruleId, context
|
|
11221
|
-
) {
|
|
11289
|
+
getRuleDocumentation(ruleId, context) {
|
|
11222
11290
|
const rules = this.config.getRules();
|
|
11223
11291
|
const ruleData = rules.get(ruleId);
|
|
11224
11292
|
if (ruleData) {
|
|
@@ -11744,7 +11812,7 @@ class HtmlValidate {
|
|
|
11744
11812
|
/** @public */
|
|
11745
11813
|
const name = "html-validate";
|
|
11746
11814
|
/** @public */
|
|
11747
|
-
const version = "7.
|
|
11815
|
+
const version = "7.15.1";
|
|
11748
11816
|
/** @public */
|
|
11749
11817
|
const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
|
|
11750
11818
|
|
|
@@ -11761,7 +11829,7 @@ const defaults$1 = {
|
|
|
11761
11829
|
silent: false,
|
|
11762
11830
|
version,
|
|
11763
11831
|
logger(text) {
|
|
11764
|
-
/* eslint-disable-next-line no-console */
|
|
11832
|
+
/* eslint-disable-next-line no-console -- expected to log */
|
|
11765
11833
|
console.error(kleur__default.default.red(text));
|
|
11766
11834
|
},
|
|
11767
11835
|
};
|
|
@@ -11906,7 +11974,7 @@ class FileSystemConfigLoader extends ConfigLoader {
|
|
|
11906
11974
|
let found = false;
|
|
11907
11975
|
let current = path__default.default.resolve(path__default.default.dirname(filename));
|
|
11908
11976
|
let config = this.empty();
|
|
11909
|
-
// eslint-disable-next-line no-constant-condition
|
|
11977
|
+
// eslint-disable-next-line no-constant-condition -- it will break out when filesystem is traversed
|
|
11910
11978
|
while (true) {
|
|
11911
11979
|
/* search configuration files in current directory */
|
|
11912
11980
|
for (const configFile of findConfigurationFiles(current)) {
|
|
@@ -11985,7 +12053,7 @@ function checkstyleFormatter(results) {
|
|
|
11985
12053
|
output += "</checkstyle>\n";
|
|
11986
12054
|
return output;
|
|
11987
12055
|
}
|
|
11988
|
-
const formatter$
|
|
12056
|
+
const formatter$3 = checkstyleFormatter;
|
|
11989
12057
|
|
|
11990
12058
|
const defaults = {
|
|
11991
12059
|
showLink: true,
|
|
@@ -12116,7 +12184,6 @@ function codeframe(results, options) {
|
|
|
12116
12184
|
}
|
|
12117
12185
|
return errors + warnings > 0 ? output : "";
|
|
12118
12186
|
}
|
|
12119
|
-
const formatter$3 = codeframe;
|
|
12120
12187
|
|
|
12121
12188
|
function jsonFormatter(results) {
|
|
12122
12189
|
return JSON.stringify(results);
|
|
@@ -12176,8 +12243,8 @@ function textFormatter(results) {
|
|
|
12176
12243
|
const formatter = textFormatter;
|
|
12177
12244
|
|
|
12178
12245
|
const availableFormatters = {
|
|
12179
|
-
checkstyle: formatter$
|
|
12180
|
-
codeframe
|
|
12246
|
+
checkstyle: formatter$3,
|
|
12247
|
+
codeframe,
|
|
12181
12248
|
json: formatter$2,
|
|
12182
12249
|
stylish: formatter$1,
|
|
12183
12250
|
text: formatter,
|
|
@@ -12191,6 +12258,9 @@ exports.Attribute = Attribute;
|
|
|
12191
12258
|
exports.Config = Config;
|
|
12192
12259
|
exports.ConfigError = ConfigError;
|
|
12193
12260
|
exports.ConfigLoader = ConfigLoader;
|
|
12261
|
+
exports.DOMNode = DOMNode;
|
|
12262
|
+
exports.DOMTokenList = DOMTokenList;
|
|
12263
|
+
exports.DOMTree = DOMTree;
|
|
12194
12264
|
exports.DynamicValue = DynamicValue;
|
|
12195
12265
|
exports.EventHandler = EventHandler;
|
|
12196
12266
|
exports.FileSystemConfigLoader = FileSystemConfigLoader;
|
|
@@ -12201,6 +12271,7 @@ exports.MetaTable = MetaTable;
|
|
|
12201
12271
|
exports.NestedError = NestedError;
|
|
12202
12272
|
exports.Parser = Parser;
|
|
12203
12273
|
exports.Reporter = Reporter;
|
|
12274
|
+
exports.ResolvedConfig = ResolvedConfig;
|
|
12204
12275
|
exports.Rule = Rule;
|
|
12205
12276
|
exports.SchemaValidationError = SchemaValidationError;
|
|
12206
12277
|
exports.StaticConfigLoader = StaticConfigLoader;
|