html-validate 6.0.1 → 6.1.2
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/CHANGELOG.md +28 -0
- package/README.md +10 -2
- package/dist/cjs/browser.d.ts +1 -2
- package/dist/cjs/cli.js +3 -0
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/core.d.ts +215 -3
- package/dist/cjs/core.js +210 -35
- package/dist/cjs/core.js.map +1 -1
- package/dist/cjs/html-validate.js +1 -1
- package/dist/cjs/html-validate.js.map +1 -1
- package/dist/cjs/index.d.ts +5 -4
- package/dist/cjs/jest-lib.d.ts +1 -1
- package/dist/cjs/jest-lib.js +2 -1
- package/dist/cjs/jest-lib.js.map +1 -1
- package/dist/es/browser.d.ts +1 -2
- package/dist/es/cli.js +3 -0
- package/dist/es/cli.js.map +1 -1
- package/dist/es/core.d.ts +215 -3
- package/dist/es/core.js +210 -35
- package/dist/es/core.js.map +1 -1
- package/dist/es/html-validate.js +1 -1
- package/dist/es/html-validate.js.map +1 -1
- package/dist/es/index.d.ts +5 -4
- package/dist/es/jest-lib.d.ts +1 -1
- package/dist/es/jest-lib.js +3 -2
- package/dist/es/jest-lib.js.map +1 -1
- package/package.json +39 -36
package/dist/es/core.js
CHANGED
|
@@ -252,6 +252,9 @@ class NestedError extends Error {
|
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
+
/**
|
|
256
|
+
* @public
|
|
257
|
+
*/
|
|
255
258
|
class UserError extends NestedError {
|
|
256
259
|
}
|
|
257
260
|
|
|
@@ -262,6 +265,9 @@ function getSummary(schema, obj, errors) {
|
|
|
262
265
|
// istanbul ignore next: for safety only
|
|
263
266
|
return output.length > 0 ? output[0].error : "unknown validation error";
|
|
264
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* @public
|
|
270
|
+
*/
|
|
265
271
|
class SchemaValidationError extends UserError {
|
|
266
272
|
constructor(filename, message, obj, schema, errors) {
|
|
267
273
|
const summary = getSummary(schema, obj, errors);
|
|
@@ -695,6 +701,8 @@ var TextContent$1;
|
|
|
695
701
|
/**
|
|
696
702
|
* Properties listed here can be copied (loaded) onto another element using
|
|
697
703
|
* [[HtmlElement.loadMeta]].
|
|
704
|
+
*
|
|
705
|
+
* @public
|
|
698
706
|
*/
|
|
699
707
|
const MetaCopyableProperty = [
|
|
700
708
|
"metadata",
|
|
@@ -835,16 +843,27 @@ const ajvRegexpKeyword = {
|
|
|
835
843
|
errors: true,
|
|
836
844
|
validate: ajvRegexpValidate,
|
|
837
845
|
};
|
|
846
|
+
/**
|
|
847
|
+
* @public
|
|
848
|
+
*/
|
|
838
849
|
class MetaTable {
|
|
850
|
+
/**
|
|
851
|
+
* @internal
|
|
852
|
+
*/
|
|
839
853
|
constructor() {
|
|
840
854
|
this.elements = {};
|
|
841
855
|
this.schema = clone(schema);
|
|
842
856
|
}
|
|
857
|
+
/**
|
|
858
|
+
* @internal
|
|
859
|
+
*/
|
|
843
860
|
init() {
|
|
844
861
|
this.resolveGlobal();
|
|
845
862
|
}
|
|
846
863
|
/**
|
|
847
864
|
* Extend validation schema.
|
|
865
|
+
*
|
|
866
|
+
* @internal
|
|
848
867
|
*/
|
|
849
868
|
extendValidationSchema(patch) {
|
|
850
869
|
if (patch.properties) {
|
|
@@ -865,6 +884,7 @@ class MetaTable {
|
|
|
865
884
|
/**
|
|
866
885
|
* Load metadata table from object.
|
|
867
886
|
*
|
|
887
|
+
* @internal
|
|
868
888
|
* @param obj - Object with metadata to load
|
|
869
889
|
* @param filename - Optional filename used when presenting validation error
|
|
870
890
|
*/
|
|
@@ -885,6 +905,7 @@ class MetaTable {
|
|
|
885
905
|
/**
|
|
886
906
|
* Load metadata table from filename
|
|
887
907
|
*
|
|
908
|
+
* @internal
|
|
888
909
|
* @param filename - Filename to load
|
|
889
910
|
*/
|
|
890
911
|
loadFromFile(filename) {
|
|
@@ -903,6 +924,7 @@ class MetaTable {
|
|
|
903
924
|
/**
|
|
904
925
|
* Get [[MetaElement]] for the given tag or null if the element doesn't exist.
|
|
905
926
|
*
|
|
927
|
+
* @public
|
|
906
928
|
* @returns A shallow copy of metadata.
|
|
907
929
|
*/
|
|
908
930
|
getMetaFor(tagName) {
|
|
@@ -911,6 +933,8 @@ class MetaTable {
|
|
|
911
933
|
}
|
|
912
934
|
/**
|
|
913
935
|
* Find all tags which has enabled given property.
|
|
936
|
+
*
|
|
937
|
+
* @public
|
|
914
938
|
*/
|
|
915
939
|
getTagsWithProperty(propName) {
|
|
916
940
|
return Object.entries(this.elements)
|
|
@@ -919,6 +943,8 @@ class MetaTable {
|
|
|
919
943
|
}
|
|
920
944
|
/**
|
|
921
945
|
* Find tag matching tagName or inheriting from it.
|
|
946
|
+
*
|
|
947
|
+
* @public
|
|
922
948
|
*/
|
|
923
949
|
getTagsDerivedFrom(tagName) {
|
|
924
950
|
return Object.entries(this.elements)
|
|
@@ -950,6 +976,9 @@ class MetaTable {
|
|
|
950
976
|
ajv.addKeyword({ keyword: "copyable" });
|
|
951
977
|
return ajv.compile(this.schema);
|
|
952
978
|
}
|
|
979
|
+
/**
|
|
980
|
+
* @public
|
|
981
|
+
*/
|
|
953
982
|
getJSONSchema() {
|
|
954
983
|
return this.schema;
|
|
955
984
|
}
|
|
@@ -985,6 +1014,9 @@ class MetaTable {
|
|
|
985
1014
|
merged.attributes = Object.fromEntries(filteredAttrs);
|
|
986
1015
|
return merged;
|
|
987
1016
|
}
|
|
1017
|
+
/**
|
|
1018
|
+
* @internal
|
|
1019
|
+
*/
|
|
988
1020
|
resolve(node) {
|
|
989
1021
|
if (node.meta) {
|
|
990
1022
|
expandProperties(node, node.meta);
|
|
@@ -1079,6 +1111,9 @@ function matchAttribute(node, match) {
|
|
|
1079
1111
|
}
|
|
1080
1112
|
}
|
|
1081
1113
|
|
|
1114
|
+
/**
|
|
1115
|
+
* @public
|
|
1116
|
+
*/
|
|
1082
1117
|
class DynamicValue {
|
|
1083
1118
|
constructor(expr) {
|
|
1084
1119
|
this.expr = expr;
|
|
@@ -1729,6 +1764,8 @@ const TEXT_NODE_NAME = "#text";
|
|
|
1729
1764
|
*
|
|
1730
1765
|
* Text nodes are appended as children of `HtmlElement` and cannot have childen
|
|
1731
1766
|
* of its own.
|
|
1767
|
+
*
|
|
1768
|
+
* @public
|
|
1732
1769
|
*/
|
|
1733
1770
|
class TextNode extends DOMNode {
|
|
1734
1771
|
/**
|
|
@@ -1760,6 +1797,9 @@ class TextNode extends DOMNode {
|
|
|
1760
1797
|
}
|
|
1761
1798
|
}
|
|
1762
1799
|
|
|
1800
|
+
/**
|
|
1801
|
+
* @public
|
|
1802
|
+
*/
|
|
1763
1803
|
var NodeClosed;
|
|
1764
1804
|
(function (NodeClosed) {
|
|
1765
1805
|
NodeClosed[NodeClosed["Open"] = 0] = "Open";
|
|
@@ -1774,6 +1814,9 @@ function isElement(node) {
|
|
|
1774
1814
|
function isValidTagName(tagName) {
|
|
1775
1815
|
return Boolean(tagName !== "" && tagName !== "*");
|
|
1776
1816
|
}
|
|
1817
|
+
/**
|
|
1818
|
+
* @public
|
|
1819
|
+
*/
|
|
1777
1820
|
class HtmlElement extends DOMNode {
|
|
1778
1821
|
constructor(tagName, parent, closed, meta, location) {
|
|
1779
1822
|
const nodeType = tagName ? NodeType.ELEMENT_NODE : NodeType.DOCUMENT_NODE;
|
|
@@ -1799,9 +1842,15 @@ class HtmlElement extends DOMNode {
|
|
|
1799
1842
|
}
|
|
1800
1843
|
}
|
|
1801
1844
|
}
|
|
1845
|
+
/**
|
|
1846
|
+
* @internal
|
|
1847
|
+
*/
|
|
1802
1848
|
static rootNode(location) {
|
|
1803
1849
|
return new HtmlElement(undefined, null, NodeClosed.EndTag, null, location);
|
|
1804
1850
|
}
|
|
1851
|
+
/**
|
|
1852
|
+
* @internal
|
|
1853
|
+
*/
|
|
1805
1854
|
static fromTokens(startToken, endToken, parent, metaTable) {
|
|
1806
1855
|
const tagName = startToken.data[2];
|
|
1807
1856
|
if (!tagName) {
|
|
@@ -2111,6 +2160,8 @@ class HtmlElement extends DOMNode {
|
|
|
2111
2160
|
}
|
|
2112
2161
|
/**
|
|
2113
2162
|
* Visit all nodes from this node and down. Depth first.
|
|
2163
|
+
*
|
|
2164
|
+
* @internal
|
|
2114
2165
|
*/
|
|
2115
2166
|
visitDepthFirst(callback) {
|
|
2116
2167
|
function visit(node) {
|
|
@@ -2123,6 +2174,8 @@ class HtmlElement extends DOMNode {
|
|
|
2123
2174
|
}
|
|
2124
2175
|
/**
|
|
2125
2176
|
* Evaluates callbackk on all descendants, returning true if any are true.
|
|
2177
|
+
*
|
|
2178
|
+
* @internal
|
|
2126
2179
|
*/
|
|
2127
2180
|
someChildren(callback) {
|
|
2128
2181
|
return this.childElements.some(visit);
|
|
@@ -2137,6 +2190,8 @@ class HtmlElement extends DOMNode {
|
|
|
2137
2190
|
}
|
|
2138
2191
|
/**
|
|
2139
2192
|
* Evaluates callbackk on all descendants, returning true if all are true.
|
|
2193
|
+
*
|
|
2194
|
+
* @internal
|
|
2140
2195
|
*/
|
|
2141
2196
|
everyChildren(callback) {
|
|
2142
2197
|
return this.childElements.every(visit);
|
|
@@ -2151,6 +2206,8 @@ class HtmlElement extends DOMNode {
|
|
|
2151
2206
|
* Visit all nodes from this node and down. Breadth first.
|
|
2152
2207
|
*
|
|
2153
2208
|
* The first node for which the callback evaluates to true is returned.
|
|
2209
|
+
*
|
|
2210
|
+
* @internal
|
|
2154
2211
|
*/
|
|
2155
2212
|
find(callback) {
|
|
2156
2213
|
function visit(node) {
|
|
@@ -2758,6 +2815,9 @@ function compareKey(node, key, filename) {
|
|
|
2758
2815
|
}
|
|
2759
2816
|
}
|
|
2760
2817
|
}
|
|
2818
|
+
/**
|
|
2819
|
+
* @public
|
|
2820
|
+
*/
|
|
2761
2821
|
class TemplateExtractor {
|
|
2762
2822
|
constructor(ast, filename, data) {
|
|
2763
2823
|
this.ast = ast;
|
|
@@ -2851,19 +2911,28 @@ var TRANSFORMER_API;
|
|
|
2851
2911
|
TRANSFORMER_API[TRANSFORMER_API["VERSION"] = 1] = "VERSION";
|
|
2852
2912
|
})(TRANSFORMER_API || (TRANSFORMER_API = {}));
|
|
2853
2913
|
|
|
2914
|
+
/* generated file, changes will be overwritten */
|
|
2915
|
+
/** @public */
|
|
2854
2916
|
const name = "html-validate";
|
|
2855
|
-
|
|
2917
|
+
/** @public */
|
|
2918
|
+
const version = "6.1.2";
|
|
2919
|
+
/** @public */
|
|
2856
2920
|
const homepage = "https://html-validate.org";
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
};
|
|
2921
|
+
/** @public */
|
|
2922
|
+
const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
|
|
2860
2923
|
|
|
2924
|
+
/**
|
|
2925
|
+
* @public
|
|
2926
|
+
*/
|
|
2861
2927
|
var Severity;
|
|
2862
2928
|
(function (Severity) {
|
|
2863
2929
|
Severity[Severity["DISABLED"] = 0] = "DISABLED";
|
|
2864
2930
|
Severity[Severity["WARN"] = 1] = "WARN";
|
|
2865
2931
|
Severity[Severity["ERROR"] = 2] = "ERROR";
|
|
2866
2932
|
})(Severity || (Severity = {}));
|
|
2933
|
+
/**
|
|
2934
|
+
* @internal
|
|
2935
|
+
*/
|
|
2867
2936
|
function parseSeverity(value) {
|
|
2868
2937
|
switch (value) {
|
|
2869
2938
|
case 0:
|
|
@@ -2911,6 +2980,9 @@ function getSchemaValidator(ruleId, properties) {
|
|
|
2911
2980
|
};
|
|
2912
2981
|
return ajv$1.compile(schema);
|
|
2913
2982
|
}
|
|
2983
|
+
/**
|
|
2984
|
+
* @public
|
|
2985
|
+
*/
|
|
2914
2986
|
class Rule {
|
|
2915
2987
|
constructor(options) {
|
|
2916
2988
|
/* faux initialization, properly initialized by init(). This is to keep TS happy without adding null-checks everywhere */
|
|
@@ -3112,6 +3184,9 @@ class Rule {
|
|
|
3112
3184
|
return null;
|
|
3113
3185
|
}
|
|
3114
3186
|
}
|
|
3187
|
+
/**
|
|
3188
|
+
* @internal
|
|
3189
|
+
*/
|
|
3115
3190
|
function ruleDocumentationUrl(filename) {
|
|
3116
3191
|
/* during bundling all "@/rule.ts"'s are converted to paths relative to the src
|
|
3117
3192
|
* folder and with the @/ prefix, by replacing the @ with the dist folder we
|
|
@@ -3142,24 +3217,60 @@ const description = {
|
|
|
3142
3217
|
["absolute" /* ABSOLUTE */]: "Absolute links are not allowed by current configuration.",
|
|
3143
3218
|
["anchor" /* ANCHOR */]: null,
|
|
3144
3219
|
};
|
|
3220
|
+
function parseAllow(value) {
|
|
3221
|
+
if (typeof value === "boolean") {
|
|
3222
|
+
return value;
|
|
3223
|
+
}
|
|
3224
|
+
return {
|
|
3225
|
+
/* eslint-disable security/detect-non-literal-regexp */
|
|
3226
|
+
include: value.include ? value.include.map((it) => new RegExp(it)) : null,
|
|
3227
|
+
exclude: value.exclude ? value.exclude.map((it) => new RegExp(it)) : null,
|
|
3228
|
+
/* eslint-enable security/detect-non-literal-regexp */
|
|
3229
|
+
};
|
|
3230
|
+
}
|
|
3231
|
+
/**
|
|
3232
|
+
* @internal
|
|
3233
|
+
*/
|
|
3234
|
+
function matchList(value, list) {
|
|
3235
|
+
if (list.include && !list.include.some((it) => it.test(value))) {
|
|
3236
|
+
return false;
|
|
3237
|
+
}
|
|
3238
|
+
if (list.exclude && list.exclude.some((it) => it.test(value))) {
|
|
3239
|
+
return false;
|
|
3240
|
+
}
|
|
3241
|
+
return true;
|
|
3242
|
+
}
|
|
3145
3243
|
class AllowedLinks extends Rule {
|
|
3146
3244
|
constructor(options) {
|
|
3147
3245
|
super({ ...defaults$p, ...options });
|
|
3246
|
+
this.allowExternal = parseAllow(this.options.allowExternal);
|
|
3247
|
+
this.allowRelative = parseAllow(this.options.allowRelative);
|
|
3248
|
+
this.allowAbsolute = parseAllow(this.options.allowAbsolute);
|
|
3148
3249
|
}
|
|
3149
3250
|
static schema() {
|
|
3251
|
+
const booleanOrObject = {
|
|
3252
|
+
anyOf: [
|
|
3253
|
+
{ type: "boolean" },
|
|
3254
|
+
{
|
|
3255
|
+
type: "object",
|
|
3256
|
+
properties: {
|
|
3257
|
+
include: {
|
|
3258
|
+
type: "array",
|
|
3259
|
+
items: { type: "string" },
|
|
3260
|
+
},
|
|
3261
|
+
exclude: {
|
|
3262
|
+
type: "array",
|
|
3263
|
+
items: { type: "string" },
|
|
3264
|
+
},
|
|
3265
|
+
},
|
|
3266
|
+
},
|
|
3267
|
+
],
|
|
3268
|
+
};
|
|
3150
3269
|
return {
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
},
|
|
3154
|
-
allowBase: {
|
|
3155
|
-
type: "boolean",
|
|
3156
|
-
},
|
|
3157
|
-
allowExternal: {
|
|
3158
|
-
type: "boolean",
|
|
3159
|
-
},
|
|
3160
|
-
allowRelative: {
|
|
3161
|
-
type: "boolean",
|
|
3162
|
-
},
|
|
3270
|
+
allowExternal: { ...booleanOrObject },
|
|
3271
|
+
allowRelative: { ...booleanOrObject },
|
|
3272
|
+
allowAbsolute: { ...booleanOrObject },
|
|
3273
|
+
allowBase: { type: "boolean" },
|
|
3163
3274
|
};
|
|
3164
3275
|
}
|
|
3165
3276
|
documentation(context) {
|
|
@@ -3181,16 +3292,16 @@ class AllowedLinks extends Rule {
|
|
|
3181
3292
|
/* anchor links are always allowed by this rule */
|
|
3182
3293
|
break;
|
|
3183
3294
|
case "absolute" /* ABSOLUTE */:
|
|
3184
|
-
this.handleAbsolute(event, style);
|
|
3295
|
+
this.handleAbsolute(link, event, style);
|
|
3185
3296
|
break;
|
|
3186
3297
|
case "external" /* EXTERNAL */:
|
|
3187
|
-
this.handleExternal(event, style);
|
|
3298
|
+
this.handleExternal(link, event, style);
|
|
3188
3299
|
break;
|
|
3189
3300
|
case "relative-base" /* RELATIVE_BASE */:
|
|
3190
|
-
this.handleRelativeBase(event, style);
|
|
3301
|
+
this.handleRelativeBase(link, event, style);
|
|
3191
3302
|
break;
|
|
3192
3303
|
case "relative-path" /* RELATIVE_PATH */:
|
|
3193
|
-
this.handleRelativePath(event, style);
|
|
3304
|
+
this.handleRelativePath(link, event, style);
|
|
3194
3305
|
break;
|
|
3195
3306
|
}
|
|
3196
3307
|
});
|
|
@@ -3224,28 +3335,49 @@ class AllowedLinks extends Rule {
|
|
|
3224
3335
|
return "relative-base" /* RELATIVE_BASE */;
|
|
3225
3336
|
}
|
|
3226
3337
|
}
|
|
3227
|
-
handleAbsolute(event, style) {
|
|
3228
|
-
const { allowAbsolute } = this
|
|
3229
|
-
if (
|
|
3338
|
+
handleAbsolute(target, event, style) {
|
|
3339
|
+
const { allowAbsolute } = this;
|
|
3340
|
+
if (allowAbsolute === true) {
|
|
3341
|
+
return;
|
|
3342
|
+
}
|
|
3343
|
+
else if (allowAbsolute === false) {
|
|
3230
3344
|
this.report(event.target, "Link destination must not be absolute url", event.valueLocation, style);
|
|
3231
3345
|
}
|
|
3346
|
+
else if (!matchList(target, allowAbsolute)) {
|
|
3347
|
+
this.report(event.target, "Absolute link to this destination is not allowed by current configuration", event.valueLocation, style);
|
|
3348
|
+
}
|
|
3232
3349
|
}
|
|
3233
|
-
handleExternal(event, style) {
|
|
3234
|
-
const { allowExternal } = this
|
|
3235
|
-
if (
|
|
3350
|
+
handleExternal(target, event, style) {
|
|
3351
|
+
const { allowExternal } = this;
|
|
3352
|
+
if (allowExternal === true) {
|
|
3353
|
+
return;
|
|
3354
|
+
}
|
|
3355
|
+
else if (allowExternal === false) {
|
|
3236
3356
|
this.report(event.target, "Link destination must not be external url", event.valueLocation, style);
|
|
3237
3357
|
}
|
|
3358
|
+
else if (!matchList(target, allowExternal)) {
|
|
3359
|
+
this.report(event.target, "External link to this destination is not allowed by current configuration", event.valueLocation, style);
|
|
3360
|
+
}
|
|
3238
3361
|
}
|
|
3239
|
-
handleRelativePath(event, style) {
|
|
3240
|
-
const { allowRelative } = this
|
|
3241
|
-
if (
|
|
3362
|
+
handleRelativePath(target, event, style) {
|
|
3363
|
+
const { allowRelative } = this;
|
|
3364
|
+
if (allowRelative === true) {
|
|
3365
|
+
return false;
|
|
3366
|
+
}
|
|
3367
|
+
else if (allowRelative === false) {
|
|
3242
3368
|
this.report(event.target, "Link destination must not be relative url", event.valueLocation, style);
|
|
3369
|
+
return true;
|
|
3243
3370
|
}
|
|
3371
|
+
else if (!matchList(target, allowRelative)) {
|
|
3372
|
+
this.report(event.target, "Relative link to this destination is not allowed by current configuration", event.valueLocation, style);
|
|
3373
|
+
return true;
|
|
3374
|
+
}
|
|
3375
|
+
return false;
|
|
3244
3376
|
}
|
|
3245
|
-
handleRelativeBase(event, style) {
|
|
3246
|
-
const {
|
|
3247
|
-
if (
|
|
3248
|
-
|
|
3377
|
+
handleRelativeBase(target, event, style) {
|
|
3378
|
+
const { allowBase } = this.options;
|
|
3379
|
+
if (this.handleRelativePath(target, event, style)) {
|
|
3380
|
+
return;
|
|
3249
3381
|
}
|
|
3250
3382
|
else if (!allowBase) {
|
|
3251
3383
|
this.report(event.target, "Relative links must be relative to current folder", event.valueLocation, style);
|
|
@@ -3329,6 +3461,9 @@ class AriaLabelMisuse extends Rule {
|
|
|
3329
3461
|
}
|
|
3330
3462
|
}
|
|
3331
3463
|
|
|
3464
|
+
/**
|
|
3465
|
+
* @public
|
|
3466
|
+
*/
|
|
3332
3467
|
class ConfigError extends UserError {
|
|
3333
3468
|
}
|
|
3334
3469
|
|
|
@@ -3482,7 +3617,7 @@ const MATCH_XML_TAG = /^<\?xml.*?\?>\s+/;
|
|
|
3482
3617
|
const MATCH_TAG_OPEN = /^<(\/?)([a-zA-Z0-9\-:]+)/; // https://www.w3.org/TR/html/syntax.html#start-tags
|
|
3483
3618
|
const MATCH_TAG_CLOSE = /^\/?>/;
|
|
3484
3619
|
const MATCH_TEXT = /^[^]*?(?=(?:[ \t]*(?:\r\n|\r|\n)|<[^ ]|$))/;
|
|
3485
|
-
const MATCH_TEMPLATING = /^(?:<%.*?%>|<\?.*?\?>|<\$.*?\$>)
|
|
3620
|
+
const MATCH_TEMPLATING = /^(?:<%.*?%>|<\?.*?\?>|<\$.*?\$>)/s;
|
|
3486
3621
|
const MATCH_TAG_LOOKAHEAD = /^[^]*?(?=<|$)/;
|
|
3487
3622
|
const MATCH_ATTR_START = /^([^\t\r\n\f \/><"'=]+)/; // https://www.w3.org/TR/html/syntax.html#elements-attributes
|
|
3488
3623
|
const MATCH_ATTR_SINGLE = /^(\s*=\s*)'([^']*?)(')/;
|
|
@@ -6147,7 +6282,7 @@ const defaults$9 = {
|
|
|
6147
6282
|
};
|
|
6148
6283
|
const textRegexp = /([<>]|&(?![a-zA-Z0-9#]+;))/g;
|
|
6149
6284
|
const unquotedAttrRegexp = /([<>"'=`]|&(?![a-zA-Z0-9#]+;))/g;
|
|
6150
|
-
const matchTemplate = /^(<%.*?%>|<\?.*?\?>|<\$.*?\$>)
|
|
6285
|
+
const matchTemplate = /^(<%.*?%>|<\?.*?\?>|<\$.*?\$>)$/s;
|
|
6151
6286
|
const replacementTable = new Map([
|
|
6152
6287
|
['"', """],
|
|
6153
6288
|
["&", "&"],
|
|
@@ -9447,6 +9582,9 @@ const config = {
|
|
|
9447
9582
|
},
|
|
9448
9583
|
};
|
|
9449
9584
|
|
|
9585
|
+
/**
|
|
9586
|
+
* @internal
|
|
9587
|
+
*/
|
|
9450
9588
|
const presets = {
|
|
9451
9589
|
"html-validate:a17y": config$3,
|
|
9452
9590
|
"html-validate:document": config$2,
|
|
@@ -9594,8 +9732,13 @@ function loadFromFile(filename) {
|
|
|
9594
9732
|
* Configuration holder.
|
|
9595
9733
|
*
|
|
9596
9734
|
* Each file being validated will have a unique instance of this class.
|
|
9735
|
+
*
|
|
9736
|
+
* @public
|
|
9597
9737
|
*/
|
|
9598
9738
|
class Config {
|
|
9739
|
+
/**
|
|
9740
|
+
* @internal
|
|
9741
|
+
*/
|
|
9599
9742
|
constructor(options) {
|
|
9600
9743
|
var _a;
|
|
9601
9744
|
this.transformers = [];
|
|
@@ -9658,6 +9801,8 @@ class Config {
|
|
|
9658
9801
|
* Validate configuration data.
|
|
9659
9802
|
*
|
|
9660
9803
|
* Throws SchemaValidationError if invalid.
|
|
9804
|
+
*
|
|
9805
|
+
* @internal
|
|
9661
9806
|
*/
|
|
9662
9807
|
static validate(configData, filename = null) {
|
|
9663
9808
|
var _a;
|
|
@@ -9685,6 +9830,8 @@ class Config {
|
|
|
9685
9830
|
*
|
|
9686
9831
|
* Must be called before trying to use config. Can safely be called multiple
|
|
9687
9832
|
* times.
|
|
9833
|
+
*
|
|
9834
|
+
* @internal
|
|
9688
9835
|
*/
|
|
9689
9836
|
init() {
|
|
9690
9837
|
if (this.initialized) {
|
|
@@ -9704,6 +9851,7 @@ class Config {
|
|
|
9704
9851
|
* Returns a new configuration as a merge of the two. Entries from the passed
|
|
9705
9852
|
* object takes priority over this object.
|
|
9706
9853
|
*
|
|
9854
|
+
* @internal
|
|
9707
9855
|
* @param rhs - Configuration to merge with this one.
|
|
9708
9856
|
*/
|
|
9709
9857
|
merge(rhs) {
|
|
@@ -9796,6 +9944,8 @@ class Config {
|
|
|
9796
9944
|
}
|
|
9797
9945
|
/**
|
|
9798
9946
|
* Get all configured rules, their severity and options.
|
|
9947
|
+
*
|
|
9948
|
+
* @internal
|
|
9799
9949
|
*/
|
|
9800
9950
|
getRules() {
|
|
9801
9951
|
var _a;
|
|
@@ -9818,6 +9968,8 @@ class Config {
|
|
|
9818
9968
|
}
|
|
9819
9969
|
/**
|
|
9820
9970
|
* Get all configured plugins.
|
|
9971
|
+
*
|
|
9972
|
+
* @internal
|
|
9821
9973
|
*/
|
|
9822
9974
|
getPlugins() {
|
|
9823
9975
|
return this.plugins;
|
|
@@ -9883,6 +10035,8 @@ class Config {
|
|
|
9883
10035
|
*
|
|
9884
10036
|
* A resolved configuration will merge all extended configs and load all
|
|
9885
10037
|
* plugins and transformers, and normalize the rest of the configuration.
|
|
10038
|
+
*
|
|
10039
|
+
* @internal
|
|
9886
10040
|
*/
|
|
9887
10041
|
resolve() {
|
|
9888
10042
|
return new ResolvedConfig(this.resolveData());
|
|
@@ -10067,6 +10221,9 @@ class ConfigLoader {
|
|
|
10067
10221
|
}
|
|
10068
10222
|
}
|
|
10069
10223
|
|
|
10224
|
+
/**
|
|
10225
|
+
* @internal
|
|
10226
|
+
*/
|
|
10070
10227
|
class EventHandler {
|
|
10071
10228
|
constructor() {
|
|
10072
10229
|
this.listeners = {};
|
|
@@ -10147,6 +10304,8 @@ class ParserError extends Error {
|
|
|
10147
10304
|
|
|
10148
10305
|
/**
|
|
10149
10306
|
* Parse HTML document into a DOM tree.
|
|
10307
|
+
*
|
|
10308
|
+
* @internal
|
|
10150
10309
|
*/
|
|
10151
10310
|
class Parser {
|
|
10152
10311
|
/**
|
|
@@ -10623,6 +10782,9 @@ class Parser {
|
|
|
10623
10782
|
}
|
|
10624
10783
|
}
|
|
10625
10784
|
|
|
10785
|
+
/**
|
|
10786
|
+
* @internal
|
|
10787
|
+
*/
|
|
10626
10788
|
class Reporter {
|
|
10627
10789
|
constructor() {
|
|
10628
10790
|
this.result = {};
|
|
@@ -10741,6 +10903,9 @@ function messageSort(a, b) {
|
|
|
10741
10903
|
return 0;
|
|
10742
10904
|
}
|
|
10743
10905
|
|
|
10906
|
+
/**
|
|
10907
|
+
* @internal
|
|
10908
|
+
*/
|
|
10744
10909
|
class Engine {
|
|
10745
10910
|
constructor(config, ParserClass) {
|
|
10746
10911
|
this.report = new Reporter();
|
|
@@ -11094,6 +11259,8 @@ class Engine {
|
|
|
11094
11259
|
*
|
|
11095
11260
|
* In practice this means no configuration is fetch by traversing the
|
|
11096
11261
|
* filesystem.
|
|
11262
|
+
*
|
|
11263
|
+
* @public
|
|
11097
11264
|
*/
|
|
11098
11265
|
class StaticConfigLoader extends ConfigLoader {
|
|
11099
11266
|
getConfigFor(handle, configOverride) {
|
|
@@ -11133,6 +11300,8 @@ function isConfigData(value) {
|
|
|
11133
11300
|
* Primary API for using HTML-validate.
|
|
11134
11301
|
*
|
|
11135
11302
|
* Provides high-level abstractions for common operations.
|
|
11303
|
+
*
|
|
11304
|
+
* @public
|
|
11136
11305
|
*/
|
|
11137
11306
|
class HtmlValidate {
|
|
11138
11307
|
constructor(arg) {
|
|
@@ -11337,6 +11506,7 @@ class HtmlValidate {
|
|
|
11337
11506
|
/**
|
|
11338
11507
|
* Create a parser configured for given filename.
|
|
11339
11508
|
*
|
|
11509
|
+
* @internal
|
|
11340
11510
|
* @param source - Source to use.
|
|
11341
11511
|
*/
|
|
11342
11512
|
getParserFor(source) {
|
|
@@ -11380,6 +11550,7 @@ const defaults$1 = {
|
|
|
11380
11550
|
* Tests if plugin is compatible with html-validate library. Unless the `silent`
|
|
11381
11551
|
* option is used a warning is displayed on the console.
|
|
11382
11552
|
*
|
|
11553
|
+
* @public
|
|
11383
11554
|
* @param name - Name of plugin
|
|
11384
11555
|
* @param declared - What library versions the plugin support (e.g. declared peerDependencies)
|
|
11385
11556
|
* @returns - `true` if version is compatible
|
|
@@ -11408,6 +11579,7 @@ const ruleIds = new Set(Object.keys(bundledRules));
|
|
|
11408
11579
|
* Can be used to create forward/backward compatibility by checking if a rule
|
|
11409
11580
|
* exists to enable/disable it.
|
|
11410
11581
|
*
|
|
11582
|
+
* @public
|
|
11411
11583
|
* @param ruleId - Rule id to check
|
|
11412
11584
|
* @returns `true` if rule exists
|
|
11413
11585
|
*/
|
|
@@ -11447,6 +11619,8 @@ function findConfigurationFiles(directory) {
|
|
|
11447
11619
|
* 2. If set in the global config the override is merged into global and
|
|
11448
11620
|
* returned. No configuration files are searched.
|
|
11449
11621
|
* 3. Setting `root` in configuration file only stops directory traversal.
|
|
11622
|
+
*
|
|
11623
|
+
* @public
|
|
11450
11624
|
*/
|
|
11451
11625
|
class FileSystemConfigLoader extends ConfigLoader {
|
|
11452
11626
|
/**
|
|
@@ -11784,6 +11958,7 @@ const availableFormatters = {
|
|
|
11784
11958
|
/**
|
|
11785
11959
|
* Get formatter function by name.
|
|
11786
11960
|
*
|
|
11961
|
+
* @internal
|
|
11787
11962
|
* @param name - Name of formatter.
|
|
11788
11963
|
* @returns Formatter function or null if it doesn't exist.
|
|
11789
11964
|
*/
|