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/cjs/core.js
CHANGED
|
@@ -264,6 +264,9 @@ class NestedError extends Error {
|
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
+
/**
|
|
268
|
+
* @public
|
|
269
|
+
*/
|
|
267
270
|
class UserError extends NestedError {
|
|
268
271
|
}
|
|
269
272
|
|
|
@@ -274,6 +277,9 @@ function getSummary(schema, obj, errors) {
|
|
|
274
277
|
// istanbul ignore next: for safety only
|
|
275
278
|
return output.length > 0 ? output[0].error : "unknown validation error";
|
|
276
279
|
}
|
|
280
|
+
/**
|
|
281
|
+
* @public
|
|
282
|
+
*/
|
|
277
283
|
class SchemaValidationError extends UserError {
|
|
278
284
|
constructor(filename, message, obj, schema, errors) {
|
|
279
285
|
const summary = getSummary(schema, obj, errors);
|
|
@@ -707,6 +713,8 @@ var TextContent$1;
|
|
|
707
713
|
/**
|
|
708
714
|
* Properties listed here can be copied (loaded) onto another element using
|
|
709
715
|
* [[HtmlElement.loadMeta]].
|
|
716
|
+
*
|
|
717
|
+
* @public
|
|
710
718
|
*/
|
|
711
719
|
const MetaCopyableProperty = [
|
|
712
720
|
"metadata",
|
|
@@ -847,16 +855,27 @@ const ajvRegexpKeyword = {
|
|
|
847
855
|
errors: true,
|
|
848
856
|
validate: ajvRegexpValidate,
|
|
849
857
|
};
|
|
858
|
+
/**
|
|
859
|
+
* @public
|
|
860
|
+
*/
|
|
850
861
|
class MetaTable {
|
|
862
|
+
/**
|
|
863
|
+
* @internal
|
|
864
|
+
*/
|
|
851
865
|
constructor() {
|
|
852
866
|
this.elements = {};
|
|
853
867
|
this.schema = clone(schema);
|
|
854
868
|
}
|
|
869
|
+
/**
|
|
870
|
+
* @internal
|
|
871
|
+
*/
|
|
855
872
|
init() {
|
|
856
873
|
this.resolveGlobal();
|
|
857
874
|
}
|
|
858
875
|
/**
|
|
859
876
|
* Extend validation schema.
|
|
877
|
+
*
|
|
878
|
+
* @internal
|
|
860
879
|
*/
|
|
861
880
|
extendValidationSchema(patch) {
|
|
862
881
|
if (patch.properties) {
|
|
@@ -877,6 +896,7 @@ class MetaTable {
|
|
|
877
896
|
/**
|
|
878
897
|
* Load metadata table from object.
|
|
879
898
|
*
|
|
899
|
+
* @internal
|
|
880
900
|
* @param obj - Object with metadata to load
|
|
881
901
|
* @param filename - Optional filename used when presenting validation error
|
|
882
902
|
*/
|
|
@@ -897,6 +917,7 @@ class MetaTable {
|
|
|
897
917
|
/**
|
|
898
918
|
* Load metadata table from filename
|
|
899
919
|
*
|
|
920
|
+
* @internal
|
|
900
921
|
* @param filename - Filename to load
|
|
901
922
|
*/
|
|
902
923
|
loadFromFile(filename) {
|
|
@@ -915,6 +936,7 @@ class MetaTable {
|
|
|
915
936
|
/**
|
|
916
937
|
* Get [[MetaElement]] for the given tag or null if the element doesn't exist.
|
|
917
938
|
*
|
|
939
|
+
* @public
|
|
918
940
|
* @returns A shallow copy of metadata.
|
|
919
941
|
*/
|
|
920
942
|
getMetaFor(tagName) {
|
|
@@ -923,6 +945,8 @@ class MetaTable {
|
|
|
923
945
|
}
|
|
924
946
|
/**
|
|
925
947
|
* Find all tags which has enabled given property.
|
|
948
|
+
*
|
|
949
|
+
* @public
|
|
926
950
|
*/
|
|
927
951
|
getTagsWithProperty(propName) {
|
|
928
952
|
return Object.entries(this.elements)
|
|
@@ -931,6 +955,8 @@ class MetaTable {
|
|
|
931
955
|
}
|
|
932
956
|
/**
|
|
933
957
|
* Find tag matching tagName or inheriting from it.
|
|
958
|
+
*
|
|
959
|
+
* @public
|
|
934
960
|
*/
|
|
935
961
|
getTagsDerivedFrom(tagName) {
|
|
936
962
|
return Object.entries(this.elements)
|
|
@@ -962,6 +988,9 @@ class MetaTable {
|
|
|
962
988
|
ajv.addKeyword({ keyword: "copyable" });
|
|
963
989
|
return ajv.compile(this.schema);
|
|
964
990
|
}
|
|
991
|
+
/**
|
|
992
|
+
* @public
|
|
993
|
+
*/
|
|
965
994
|
getJSONSchema() {
|
|
966
995
|
return this.schema;
|
|
967
996
|
}
|
|
@@ -997,6 +1026,9 @@ class MetaTable {
|
|
|
997
1026
|
merged.attributes = Object.fromEntries(filteredAttrs);
|
|
998
1027
|
return merged;
|
|
999
1028
|
}
|
|
1029
|
+
/**
|
|
1030
|
+
* @internal
|
|
1031
|
+
*/
|
|
1000
1032
|
resolve(node) {
|
|
1001
1033
|
if (node.meta) {
|
|
1002
1034
|
expandProperties(node, node.meta);
|
|
@@ -1091,6 +1123,9 @@ function matchAttribute(node, match) {
|
|
|
1091
1123
|
}
|
|
1092
1124
|
}
|
|
1093
1125
|
|
|
1126
|
+
/**
|
|
1127
|
+
* @public
|
|
1128
|
+
*/
|
|
1094
1129
|
class DynamicValue {
|
|
1095
1130
|
constructor(expr) {
|
|
1096
1131
|
this.expr = expr;
|
|
@@ -1741,6 +1776,8 @@ const TEXT_NODE_NAME = "#text";
|
|
|
1741
1776
|
*
|
|
1742
1777
|
* Text nodes are appended as children of `HtmlElement` and cannot have childen
|
|
1743
1778
|
* of its own.
|
|
1779
|
+
*
|
|
1780
|
+
* @public
|
|
1744
1781
|
*/
|
|
1745
1782
|
class TextNode extends DOMNode {
|
|
1746
1783
|
/**
|
|
@@ -1772,6 +1809,9 @@ class TextNode extends DOMNode {
|
|
|
1772
1809
|
}
|
|
1773
1810
|
}
|
|
1774
1811
|
|
|
1812
|
+
/**
|
|
1813
|
+
* @public
|
|
1814
|
+
*/
|
|
1775
1815
|
exports.NodeClosed = void 0;
|
|
1776
1816
|
(function (NodeClosed) {
|
|
1777
1817
|
NodeClosed[NodeClosed["Open"] = 0] = "Open";
|
|
@@ -1786,6 +1826,9 @@ function isElement(node) {
|
|
|
1786
1826
|
function isValidTagName(tagName) {
|
|
1787
1827
|
return Boolean(tagName !== "" && tagName !== "*");
|
|
1788
1828
|
}
|
|
1829
|
+
/**
|
|
1830
|
+
* @public
|
|
1831
|
+
*/
|
|
1789
1832
|
class HtmlElement extends DOMNode {
|
|
1790
1833
|
constructor(tagName, parent, closed, meta, location) {
|
|
1791
1834
|
const nodeType = tagName ? NodeType.ELEMENT_NODE : NodeType.DOCUMENT_NODE;
|
|
@@ -1811,9 +1854,15 @@ class HtmlElement extends DOMNode {
|
|
|
1811
1854
|
}
|
|
1812
1855
|
}
|
|
1813
1856
|
}
|
|
1857
|
+
/**
|
|
1858
|
+
* @internal
|
|
1859
|
+
*/
|
|
1814
1860
|
static rootNode(location) {
|
|
1815
1861
|
return new HtmlElement(undefined, null, exports.NodeClosed.EndTag, null, location);
|
|
1816
1862
|
}
|
|
1863
|
+
/**
|
|
1864
|
+
* @internal
|
|
1865
|
+
*/
|
|
1817
1866
|
static fromTokens(startToken, endToken, parent, metaTable) {
|
|
1818
1867
|
const tagName = startToken.data[2];
|
|
1819
1868
|
if (!tagName) {
|
|
@@ -2123,6 +2172,8 @@ class HtmlElement extends DOMNode {
|
|
|
2123
2172
|
}
|
|
2124
2173
|
/**
|
|
2125
2174
|
* Visit all nodes from this node and down. Depth first.
|
|
2175
|
+
*
|
|
2176
|
+
* @internal
|
|
2126
2177
|
*/
|
|
2127
2178
|
visitDepthFirst(callback) {
|
|
2128
2179
|
function visit(node) {
|
|
@@ -2135,6 +2186,8 @@ class HtmlElement extends DOMNode {
|
|
|
2135
2186
|
}
|
|
2136
2187
|
/**
|
|
2137
2188
|
* Evaluates callbackk on all descendants, returning true if any are true.
|
|
2189
|
+
*
|
|
2190
|
+
* @internal
|
|
2138
2191
|
*/
|
|
2139
2192
|
someChildren(callback) {
|
|
2140
2193
|
return this.childElements.some(visit);
|
|
@@ -2149,6 +2202,8 @@ class HtmlElement extends DOMNode {
|
|
|
2149
2202
|
}
|
|
2150
2203
|
/**
|
|
2151
2204
|
* Evaluates callbackk on all descendants, returning true if all are true.
|
|
2205
|
+
*
|
|
2206
|
+
* @internal
|
|
2152
2207
|
*/
|
|
2153
2208
|
everyChildren(callback) {
|
|
2154
2209
|
return this.childElements.every(visit);
|
|
@@ -2163,6 +2218,8 @@ class HtmlElement extends DOMNode {
|
|
|
2163
2218
|
* Visit all nodes from this node and down. Breadth first.
|
|
2164
2219
|
*
|
|
2165
2220
|
* The first node for which the callback evaluates to true is returned.
|
|
2221
|
+
*
|
|
2222
|
+
* @internal
|
|
2166
2223
|
*/
|
|
2167
2224
|
find(callback) {
|
|
2168
2225
|
function visit(node) {
|
|
@@ -2770,6 +2827,9 @@ function compareKey(node, key, filename) {
|
|
|
2770
2827
|
}
|
|
2771
2828
|
}
|
|
2772
2829
|
}
|
|
2830
|
+
/**
|
|
2831
|
+
* @public
|
|
2832
|
+
*/
|
|
2773
2833
|
class TemplateExtractor {
|
|
2774
2834
|
constructor(ast, filename, data) {
|
|
2775
2835
|
this.ast = ast;
|
|
@@ -2863,19 +2923,28 @@ var TRANSFORMER_API;
|
|
|
2863
2923
|
TRANSFORMER_API[TRANSFORMER_API["VERSION"] = 1] = "VERSION";
|
|
2864
2924
|
})(TRANSFORMER_API || (TRANSFORMER_API = {}));
|
|
2865
2925
|
|
|
2926
|
+
/* generated file, changes will be overwritten */
|
|
2927
|
+
/** @public */
|
|
2866
2928
|
const name = "html-validate";
|
|
2867
|
-
|
|
2929
|
+
/** @public */
|
|
2930
|
+
const version = "6.1.2";
|
|
2931
|
+
/** @public */
|
|
2868
2932
|
const homepage = "https://html-validate.org";
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
};
|
|
2933
|
+
/** @public */
|
|
2934
|
+
const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
|
|
2872
2935
|
|
|
2936
|
+
/**
|
|
2937
|
+
* @public
|
|
2938
|
+
*/
|
|
2873
2939
|
exports.Severity = void 0;
|
|
2874
2940
|
(function (Severity) {
|
|
2875
2941
|
Severity[Severity["DISABLED"] = 0] = "DISABLED";
|
|
2876
2942
|
Severity[Severity["WARN"] = 1] = "WARN";
|
|
2877
2943
|
Severity[Severity["ERROR"] = 2] = "ERROR";
|
|
2878
2944
|
})(exports.Severity || (exports.Severity = {}));
|
|
2945
|
+
/**
|
|
2946
|
+
* @internal
|
|
2947
|
+
*/
|
|
2879
2948
|
function parseSeverity(value) {
|
|
2880
2949
|
switch (value) {
|
|
2881
2950
|
case 0:
|
|
@@ -2923,6 +2992,9 @@ function getSchemaValidator(ruleId, properties) {
|
|
|
2923
2992
|
};
|
|
2924
2993
|
return ajv$1.compile(schema);
|
|
2925
2994
|
}
|
|
2995
|
+
/**
|
|
2996
|
+
* @public
|
|
2997
|
+
*/
|
|
2926
2998
|
class Rule {
|
|
2927
2999
|
constructor(options) {
|
|
2928
3000
|
/* faux initialization, properly initialized by init(). This is to keep TS happy without adding null-checks everywhere */
|
|
@@ -3124,6 +3196,9 @@ class Rule {
|
|
|
3124
3196
|
return null;
|
|
3125
3197
|
}
|
|
3126
3198
|
}
|
|
3199
|
+
/**
|
|
3200
|
+
* @internal
|
|
3201
|
+
*/
|
|
3127
3202
|
function ruleDocumentationUrl(filename) {
|
|
3128
3203
|
/* during bundling all "@/rule.ts"'s are converted to paths relative to the src
|
|
3129
3204
|
* folder and with the @/ prefix, by replacing the @ with the dist folder we
|
|
@@ -3154,24 +3229,60 @@ const description = {
|
|
|
3154
3229
|
["absolute" /* ABSOLUTE */]: "Absolute links are not allowed by current configuration.",
|
|
3155
3230
|
["anchor" /* ANCHOR */]: null,
|
|
3156
3231
|
};
|
|
3232
|
+
function parseAllow(value) {
|
|
3233
|
+
if (typeof value === "boolean") {
|
|
3234
|
+
return value;
|
|
3235
|
+
}
|
|
3236
|
+
return {
|
|
3237
|
+
/* eslint-disable security/detect-non-literal-regexp */
|
|
3238
|
+
include: value.include ? value.include.map((it) => new RegExp(it)) : null,
|
|
3239
|
+
exclude: value.exclude ? value.exclude.map((it) => new RegExp(it)) : null,
|
|
3240
|
+
/* eslint-enable security/detect-non-literal-regexp */
|
|
3241
|
+
};
|
|
3242
|
+
}
|
|
3243
|
+
/**
|
|
3244
|
+
* @internal
|
|
3245
|
+
*/
|
|
3246
|
+
function matchList(value, list) {
|
|
3247
|
+
if (list.include && !list.include.some((it) => it.test(value))) {
|
|
3248
|
+
return false;
|
|
3249
|
+
}
|
|
3250
|
+
if (list.exclude && list.exclude.some((it) => it.test(value))) {
|
|
3251
|
+
return false;
|
|
3252
|
+
}
|
|
3253
|
+
return true;
|
|
3254
|
+
}
|
|
3157
3255
|
class AllowedLinks extends Rule {
|
|
3158
3256
|
constructor(options) {
|
|
3159
3257
|
super({ ...defaults$p, ...options });
|
|
3258
|
+
this.allowExternal = parseAllow(this.options.allowExternal);
|
|
3259
|
+
this.allowRelative = parseAllow(this.options.allowRelative);
|
|
3260
|
+
this.allowAbsolute = parseAllow(this.options.allowAbsolute);
|
|
3160
3261
|
}
|
|
3161
3262
|
static schema() {
|
|
3263
|
+
const booleanOrObject = {
|
|
3264
|
+
anyOf: [
|
|
3265
|
+
{ type: "boolean" },
|
|
3266
|
+
{
|
|
3267
|
+
type: "object",
|
|
3268
|
+
properties: {
|
|
3269
|
+
include: {
|
|
3270
|
+
type: "array",
|
|
3271
|
+
items: { type: "string" },
|
|
3272
|
+
},
|
|
3273
|
+
exclude: {
|
|
3274
|
+
type: "array",
|
|
3275
|
+
items: { type: "string" },
|
|
3276
|
+
},
|
|
3277
|
+
},
|
|
3278
|
+
},
|
|
3279
|
+
],
|
|
3280
|
+
};
|
|
3162
3281
|
return {
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
},
|
|
3166
|
-
allowBase: {
|
|
3167
|
-
type: "boolean",
|
|
3168
|
-
},
|
|
3169
|
-
allowExternal: {
|
|
3170
|
-
type: "boolean",
|
|
3171
|
-
},
|
|
3172
|
-
allowRelative: {
|
|
3173
|
-
type: "boolean",
|
|
3174
|
-
},
|
|
3282
|
+
allowExternal: { ...booleanOrObject },
|
|
3283
|
+
allowRelative: { ...booleanOrObject },
|
|
3284
|
+
allowAbsolute: { ...booleanOrObject },
|
|
3285
|
+
allowBase: { type: "boolean" },
|
|
3175
3286
|
};
|
|
3176
3287
|
}
|
|
3177
3288
|
documentation(context) {
|
|
@@ -3193,16 +3304,16 @@ class AllowedLinks extends Rule {
|
|
|
3193
3304
|
/* anchor links are always allowed by this rule */
|
|
3194
3305
|
break;
|
|
3195
3306
|
case "absolute" /* ABSOLUTE */:
|
|
3196
|
-
this.handleAbsolute(event, style);
|
|
3307
|
+
this.handleAbsolute(link, event, style);
|
|
3197
3308
|
break;
|
|
3198
3309
|
case "external" /* EXTERNAL */:
|
|
3199
|
-
this.handleExternal(event, style);
|
|
3310
|
+
this.handleExternal(link, event, style);
|
|
3200
3311
|
break;
|
|
3201
3312
|
case "relative-base" /* RELATIVE_BASE */:
|
|
3202
|
-
this.handleRelativeBase(event, style);
|
|
3313
|
+
this.handleRelativeBase(link, event, style);
|
|
3203
3314
|
break;
|
|
3204
3315
|
case "relative-path" /* RELATIVE_PATH */:
|
|
3205
|
-
this.handleRelativePath(event, style);
|
|
3316
|
+
this.handleRelativePath(link, event, style);
|
|
3206
3317
|
break;
|
|
3207
3318
|
}
|
|
3208
3319
|
});
|
|
@@ -3236,28 +3347,49 @@ class AllowedLinks extends Rule {
|
|
|
3236
3347
|
return "relative-base" /* RELATIVE_BASE */;
|
|
3237
3348
|
}
|
|
3238
3349
|
}
|
|
3239
|
-
handleAbsolute(event, style) {
|
|
3240
|
-
const { allowAbsolute } = this
|
|
3241
|
-
if (
|
|
3350
|
+
handleAbsolute(target, event, style) {
|
|
3351
|
+
const { allowAbsolute } = this;
|
|
3352
|
+
if (allowAbsolute === true) {
|
|
3353
|
+
return;
|
|
3354
|
+
}
|
|
3355
|
+
else if (allowAbsolute === false) {
|
|
3242
3356
|
this.report(event.target, "Link destination must not be absolute url", event.valueLocation, style);
|
|
3243
3357
|
}
|
|
3358
|
+
else if (!matchList(target, allowAbsolute)) {
|
|
3359
|
+
this.report(event.target, "Absolute link to this destination is not allowed by current configuration", event.valueLocation, style);
|
|
3360
|
+
}
|
|
3244
3361
|
}
|
|
3245
|
-
handleExternal(event, style) {
|
|
3246
|
-
const { allowExternal } = this
|
|
3247
|
-
if (
|
|
3362
|
+
handleExternal(target, event, style) {
|
|
3363
|
+
const { allowExternal } = this;
|
|
3364
|
+
if (allowExternal === true) {
|
|
3365
|
+
return;
|
|
3366
|
+
}
|
|
3367
|
+
else if (allowExternal === false) {
|
|
3248
3368
|
this.report(event.target, "Link destination must not be external url", event.valueLocation, style);
|
|
3249
3369
|
}
|
|
3370
|
+
else if (!matchList(target, allowExternal)) {
|
|
3371
|
+
this.report(event.target, "External link to this destination is not allowed by current configuration", event.valueLocation, style);
|
|
3372
|
+
}
|
|
3250
3373
|
}
|
|
3251
|
-
handleRelativePath(event, style) {
|
|
3252
|
-
const { allowRelative } = this
|
|
3253
|
-
if (
|
|
3374
|
+
handleRelativePath(target, event, style) {
|
|
3375
|
+
const { allowRelative } = this;
|
|
3376
|
+
if (allowRelative === true) {
|
|
3377
|
+
return false;
|
|
3378
|
+
}
|
|
3379
|
+
else if (allowRelative === false) {
|
|
3254
3380
|
this.report(event.target, "Link destination must not be relative url", event.valueLocation, style);
|
|
3381
|
+
return true;
|
|
3255
3382
|
}
|
|
3383
|
+
else if (!matchList(target, allowRelative)) {
|
|
3384
|
+
this.report(event.target, "Relative link to this destination is not allowed by current configuration", event.valueLocation, style);
|
|
3385
|
+
return true;
|
|
3386
|
+
}
|
|
3387
|
+
return false;
|
|
3256
3388
|
}
|
|
3257
|
-
handleRelativeBase(event, style) {
|
|
3258
|
-
const {
|
|
3259
|
-
if (
|
|
3260
|
-
|
|
3389
|
+
handleRelativeBase(target, event, style) {
|
|
3390
|
+
const { allowBase } = this.options;
|
|
3391
|
+
if (this.handleRelativePath(target, event, style)) {
|
|
3392
|
+
return;
|
|
3261
3393
|
}
|
|
3262
3394
|
else if (!allowBase) {
|
|
3263
3395
|
this.report(event.target, "Relative links must be relative to current folder", event.valueLocation, style);
|
|
@@ -3341,6 +3473,9 @@ class AriaLabelMisuse extends Rule {
|
|
|
3341
3473
|
}
|
|
3342
3474
|
}
|
|
3343
3475
|
|
|
3476
|
+
/**
|
|
3477
|
+
* @public
|
|
3478
|
+
*/
|
|
3344
3479
|
class ConfigError extends UserError {
|
|
3345
3480
|
}
|
|
3346
3481
|
|
|
@@ -3494,7 +3629,7 @@ const MATCH_XML_TAG = /^<\?xml.*?\?>\s+/;
|
|
|
3494
3629
|
const MATCH_TAG_OPEN = /^<(\/?)([a-zA-Z0-9\-:]+)/; // https://www.w3.org/TR/html/syntax.html#start-tags
|
|
3495
3630
|
const MATCH_TAG_CLOSE = /^\/?>/;
|
|
3496
3631
|
const MATCH_TEXT = /^[^]*?(?=(?:[ \t]*(?:\r\n|\r|\n)|<[^ ]|$))/;
|
|
3497
|
-
const MATCH_TEMPLATING = /^(?:<%.*?%>|<\?.*?\?>|<\$.*?\$>)
|
|
3632
|
+
const MATCH_TEMPLATING = /^(?:<%.*?%>|<\?.*?\?>|<\$.*?\$>)/s;
|
|
3498
3633
|
const MATCH_TAG_LOOKAHEAD = /^[^]*?(?=<|$)/;
|
|
3499
3634
|
const MATCH_ATTR_START = /^([^\t\r\n\f \/><"'=]+)/; // https://www.w3.org/TR/html/syntax.html#elements-attributes
|
|
3500
3635
|
const MATCH_ATTR_SINGLE = /^(\s*=\s*)'([^']*?)(')/;
|
|
@@ -6159,7 +6294,7 @@ const defaults$9 = {
|
|
|
6159
6294
|
};
|
|
6160
6295
|
const textRegexp = /([<>]|&(?![a-zA-Z0-9#]+;))/g;
|
|
6161
6296
|
const unquotedAttrRegexp = /([<>"'=`]|&(?![a-zA-Z0-9#]+;))/g;
|
|
6162
|
-
const matchTemplate = /^(<%.*?%>|<\?.*?\?>|<\$.*?\$>)
|
|
6297
|
+
const matchTemplate = /^(<%.*?%>|<\?.*?\?>|<\$.*?\$>)$/s;
|
|
6163
6298
|
const replacementTable = new Map([
|
|
6164
6299
|
['"', """],
|
|
6165
6300
|
["&", "&"],
|
|
@@ -9459,6 +9594,9 @@ const config = {
|
|
|
9459
9594
|
},
|
|
9460
9595
|
};
|
|
9461
9596
|
|
|
9597
|
+
/**
|
|
9598
|
+
* @internal
|
|
9599
|
+
*/
|
|
9462
9600
|
const presets = {
|
|
9463
9601
|
"html-validate:a17y": config$3,
|
|
9464
9602
|
"html-validate:document": config$2,
|
|
@@ -9606,8 +9744,13 @@ function loadFromFile(filename) {
|
|
|
9606
9744
|
* Configuration holder.
|
|
9607
9745
|
*
|
|
9608
9746
|
* Each file being validated will have a unique instance of this class.
|
|
9747
|
+
*
|
|
9748
|
+
* @public
|
|
9609
9749
|
*/
|
|
9610
9750
|
class Config {
|
|
9751
|
+
/**
|
|
9752
|
+
* @internal
|
|
9753
|
+
*/
|
|
9611
9754
|
constructor(options) {
|
|
9612
9755
|
var _a;
|
|
9613
9756
|
this.transformers = [];
|
|
@@ -9670,6 +9813,8 @@ class Config {
|
|
|
9670
9813
|
* Validate configuration data.
|
|
9671
9814
|
*
|
|
9672
9815
|
* Throws SchemaValidationError if invalid.
|
|
9816
|
+
*
|
|
9817
|
+
* @internal
|
|
9673
9818
|
*/
|
|
9674
9819
|
static validate(configData, filename = null) {
|
|
9675
9820
|
var _a;
|
|
@@ -9697,6 +9842,8 @@ class Config {
|
|
|
9697
9842
|
*
|
|
9698
9843
|
* Must be called before trying to use config. Can safely be called multiple
|
|
9699
9844
|
* times.
|
|
9845
|
+
*
|
|
9846
|
+
* @internal
|
|
9700
9847
|
*/
|
|
9701
9848
|
init() {
|
|
9702
9849
|
if (this.initialized) {
|
|
@@ -9716,6 +9863,7 @@ class Config {
|
|
|
9716
9863
|
* Returns a new configuration as a merge of the two. Entries from the passed
|
|
9717
9864
|
* object takes priority over this object.
|
|
9718
9865
|
*
|
|
9866
|
+
* @internal
|
|
9719
9867
|
* @param rhs - Configuration to merge with this one.
|
|
9720
9868
|
*/
|
|
9721
9869
|
merge(rhs) {
|
|
@@ -9808,6 +9956,8 @@ class Config {
|
|
|
9808
9956
|
}
|
|
9809
9957
|
/**
|
|
9810
9958
|
* Get all configured rules, their severity and options.
|
|
9959
|
+
*
|
|
9960
|
+
* @internal
|
|
9811
9961
|
*/
|
|
9812
9962
|
getRules() {
|
|
9813
9963
|
var _a;
|
|
@@ -9830,6 +9980,8 @@ class Config {
|
|
|
9830
9980
|
}
|
|
9831
9981
|
/**
|
|
9832
9982
|
* Get all configured plugins.
|
|
9983
|
+
*
|
|
9984
|
+
* @internal
|
|
9833
9985
|
*/
|
|
9834
9986
|
getPlugins() {
|
|
9835
9987
|
return this.plugins;
|
|
@@ -9895,6 +10047,8 @@ class Config {
|
|
|
9895
10047
|
*
|
|
9896
10048
|
* A resolved configuration will merge all extended configs and load all
|
|
9897
10049
|
* plugins and transformers, and normalize the rest of the configuration.
|
|
10050
|
+
*
|
|
10051
|
+
* @internal
|
|
9898
10052
|
*/
|
|
9899
10053
|
resolve() {
|
|
9900
10054
|
return new ResolvedConfig(this.resolveData());
|
|
@@ -10079,6 +10233,9 @@ class ConfigLoader {
|
|
|
10079
10233
|
}
|
|
10080
10234
|
}
|
|
10081
10235
|
|
|
10236
|
+
/**
|
|
10237
|
+
* @internal
|
|
10238
|
+
*/
|
|
10082
10239
|
class EventHandler {
|
|
10083
10240
|
constructor() {
|
|
10084
10241
|
this.listeners = {};
|
|
@@ -10159,6 +10316,8 @@ class ParserError extends Error {
|
|
|
10159
10316
|
|
|
10160
10317
|
/**
|
|
10161
10318
|
* Parse HTML document into a DOM tree.
|
|
10319
|
+
*
|
|
10320
|
+
* @internal
|
|
10162
10321
|
*/
|
|
10163
10322
|
class Parser {
|
|
10164
10323
|
/**
|
|
@@ -10635,6 +10794,9 @@ class Parser {
|
|
|
10635
10794
|
}
|
|
10636
10795
|
}
|
|
10637
10796
|
|
|
10797
|
+
/**
|
|
10798
|
+
* @internal
|
|
10799
|
+
*/
|
|
10638
10800
|
class Reporter {
|
|
10639
10801
|
constructor() {
|
|
10640
10802
|
this.result = {};
|
|
@@ -10753,6 +10915,9 @@ function messageSort(a, b) {
|
|
|
10753
10915
|
return 0;
|
|
10754
10916
|
}
|
|
10755
10917
|
|
|
10918
|
+
/**
|
|
10919
|
+
* @internal
|
|
10920
|
+
*/
|
|
10756
10921
|
class Engine {
|
|
10757
10922
|
constructor(config, ParserClass) {
|
|
10758
10923
|
this.report = new Reporter();
|
|
@@ -11106,6 +11271,8 @@ class Engine {
|
|
|
11106
11271
|
*
|
|
11107
11272
|
* In practice this means no configuration is fetch by traversing the
|
|
11108
11273
|
* filesystem.
|
|
11274
|
+
*
|
|
11275
|
+
* @public
|
|
11109
11276
|
*/
|
|
11110
11277
|
class StaticConfigLoader extends ConfigLoader {
|
|
11111
11278
|
getConfigFor(handle, configOverride) {
|
|
@@ -11145,6 +11312,8 @@ function isConfigData(value) {
|
|
|
11145
11312
|
* Primary API for using HTML-validate.
|
|
11146
11313
|
*
|
|
11147
11314
|
* Provides high-level abstractions for common operations.
|
|
11315
|
+
*
|
|
11316
|
+
* @public
|
|
11148
11317
|
*/
|
|
11149
11318
|
class HtmlValidate {
|
|
11150
11319
|
constructor(arg) {
|
|
@@ -11349,6 +11518,7 @@ class HtmlValidate {
|
|
|
11349
11518
|
/**
|
|
11350
11519
|
* Create a parser configured for given filename.
|
|
11351
11520
|
*
|
|
11521
|
+
* @internal
|
|
11352
11522
|
* @param source - Source to use.
|
|
11353
11523
|
*/
|
|
11354
11524
|
getParserFor(source) {
|
|
@@ -11392,6 +11562,7 @@ const defaults$1 = {
|
|
|
11392
11562
|
* Tests if plugin is compatible with html-validate library. Unless the `silent`
|
|
11393
11563
|
* option is used a warning is displayed on the console.
|
|
11394
11564
|
*
|
|
11565
|
+
* @public
|
|
11395
11566
|
* @param name - Name of plugin
|
|
11396
11567
|
* @param declared - What library versions the plugin support (e.g. declared peerDependencies)
|
|
11397
11568
|
* @returns - `true` if version is compatible
|
|
@@ -11420,6 +11591,7 @@ const ruleIds = new Set(Object.keys(bundledRules));
|
|
|
11420
11591
|
* Can be used to create forward/backward compatibility by checking if a rule
|
|
11421
11592
|
* exists to enable/disable it.
|
|
11422
11593
|
*
|
|
11594
|
+
* @public
|
|
11423
11595
|
* @param ruleId - Rule id to check
|
|
11424
11596
|
* @returns `true` if rule exists
|
|
11425
11597
|
*/
|
|
@@ -11459,6 +11631,8 @@ function findConfigurationFiles(directory) {
|
|
|
11459
11631
|
* 2. If set in the global config the override is merged into global and
|
|
11460
11632
|
* returned. No configuration files are searched.
|
|
11461
11633
|
* 3. Setting `root` in configuration file only stops directory traversal.
|
|
11634
|
+
*
|
|
11635
|
+
* @public
|
|
11462
11636
|
*/
|
|
11463
11637
|
class FileSystemConfigLoader extends ConfigLoader {
|
|
11464
11638
|
/**
|
|
@@ -11796,6 +11970,7 @@ const availableFormatters = {
|
|
|
11796
11970
|
/**
|
|
11797
11971
|
* Get formatter function by name.
|
|
11798
11972
|
*
|
|
11973
|
+
* @internal
|
|
11799
11974
|
* @param name - Name of formatter.
|
|
11800
11975
|
* @returns Formatter function or null if it doesn't exist.
|
|
11801
11976
|
*/
|