html-validate 6.1.0 → 6.1.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/CHANGELOG.md +6 -0
- package/README.md +10 -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 +122 -4
- package/dist/cjs/core.js.map +1 -1
- package/dist/cjs/dist/types/browser.d.ts +3 -0
- package/dist/{es → cjs/dist/types}/index.d.ts +6 -5
- package/dist/cjs/dist/types/jest/jest.d.ts +4 -0
- package/dist/{es → cjs/dist/types/transform}/test-utils.d.ts +1 -1
- package/dist/cjs/html-validate.js +1 -1
- package/dist/cjs/html-validate.js.map +1 -1
- package/dist/cjs/jest-lib.d.ts +1 -1
- 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 +122 -4
- package/dist/es/core.js.map +1 -1
- package/dist/es/dist/types/browser.d.ts +3 -0
- package/dist/{cjs → es/dist/types}/index.d.ts +6 -5
- package/dist/es/dist/types/jest/jest.d.ts +4 -0
- package/dist/{cjs → es/dist/types/transform}/test-utils.d.ts +1 -1
- package/dist/es/html-validate.js +1 -1
- package/dist/es/html-validate.js.map +1 -1
- package/dist/es/jest-lib.d.ts +1 -1
- package/package.json +39 -36
- package/dist/cjs/browser.d.ts +0 -4
- package/dist/cjs/jest.d.ts +0 -4
- package/dist/es/browser.d.ts +0 -4
- package/dist/es/jest.d.ts +0 -4
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.1";
|
|
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
|
|
@@ -3386,6 +3461,9 @@ class AriaLabelMisuse extends Rule {
|
|
|
3386
3461
|
}
|
|
3387
3462
|
}
|
|
3388
3463
|
|
|
3464
|
+
/**
|
|
3465
|
+
* @public
|
|
3466
|
+
*/
|
|
3389
3467
|
class ConfigError extends UserError {
|
|
3390
3468
|
}
|
|
3391
3469
|
|
|
@@ -9504,6 +9582,9 @@ const config = {
|
|
|
9504
9582
|
},
|
|
9505
9583
|
};
|
|
9506
9584
|
|
|
9585
|
+
/**
|
|
9586
|
+
* @internal
|
|
9587
|
+
*/
|
|
9507
9588
|
const presets = {
|
|
9508
9589
|
"html-validate:a17y": config$3,
|
|
9509
9590
|
"html-validate:document": config$2,
|
|
@@ -9651,8 +9732,13 @@ function loadFromFile(filename) {
|
|
|
9651
9732
|
* Configuration holder.
|
|
9652
9733
|
*
|
|
9653
9734
|
* Each file being validated will have a unique instance of this class.
|
|
9735
|
+
*
|
|
9736
|
+
* @public
|
|
9654
9737
|
*/
|
|
9655
9738
|
class Config {
|
|
9739
|
+
/**
|
|
9740
|
+
* @internal
|
|
9741
|
+
*/
|
|
9656
9742
|
constructor(options) {
|
|
9657
9743
|
var _a;
|
|
9658
9744
|
this.transformers = [];
|
|
@@ -9715,6 +9801,8 @@ class Config {
|
|
|
9715
9801
|
* Validate configuration data.
|
|
9716
9802
|
*
|
|
9717
9803
|
* Throws SchemaValidationError if invalid.
|
|
9804
|
+
*
|
|
9805
|
+
* @internal
|
|
9718
9806
|
*/
|
|
9719
9807
|
static validate(configData, filename = null) {
|
|
9720
9808
|
var _a;
|
|
@@ -9742,6 +9830,8 @@ class Config {
|
|
|
9742
9830
|
*
|
|
9743
9831
|
* Must be called before trying to use config. Can safely be called multiple
|
|
9744
9832
|
* times.
|
|
9833
|
+
*
|
|
9834
|
+
* @internal
|
|
9745
9835
|
*/
|
|
9746
9836
|
init() {
|
|
9747
9837
|
if (this.initialized) {
|
|
@@ -9761,6 +9851,7 @@ class Config {
|
|
|
9761
9851
|
* Returns a new configuration as a merge of the two. Entries from the passed
|
|
9762
9852
|
* object takes priority over this object.
|
|
9763
9853
|
*
|
|
9854
|
+
* @internal
|
|
9764
9855
|
* @param rhs - Configuration to merge with this one.
|
|
9765
9856
|
*/
|
|
9766
9857
|
merge(rhs) {
|
|
@@ -9853,6 +9944,8 @@ class Config {
|
|
|
9853
9944
|
}
|
|
9854
9945
|
/**
|
|
9855
9946
|
* Get all configured rules, their severity and options.
|
|
9947
|
+
*
|
|
9948
|
+
* @internal
|
|
9856
9949
|
*/
|
|
9857
9950
|
getRules() {
|
|
9858
9951
|
var _a;
|
|
@@ -9875,6 +9968,8 @@ class Config {
|
|
|
9875
9968
|
}
|
|
9876
9969
|
/**
|
|
9877
9970
|
* Get all configured plugins.
|
|
9971
|
+
*
|
|
9972
|
+
* @internal
|
|
9878
9973
|
*/
|
|
9879
9974
|
getPlugins() {
|
|
9880
9975
|
return this.plugins;
|
|
@@ -9940,6 +10035,8 @@ class Config {
|
|
|
9940
10035
|
*
|
|
9941
10036
|
* A resolved configuration will merge all extended configs and load all
|
|
9942
10037
|
* plugins and transformers, and normalize the rest of the configuration.
|
|
10038
|
+
*
|
|
10039
|
+
* @internal
|
|
9943
10040
|
*/
|
|
9944
10041
|
resolve() {
|
|
9945
10042
|
return new ResolvedConfig(this.resolveData());
|
|
@@ -10124,6 +10221,9 @@ class ConfigLoader {
|
|
|
10124
10221
|
}
|
|
10125
10222
|
}
|
|
10126
10223
|
|
|
10224
|
+
/**
|
|
10225
|
+
* @internal
|
|
10226
|
+
*/
|
|
10127
10227
|
class EventHandler {
|
|
10128
10228
|
constructor() {
|
|
10129
10229
|
this.listeners = {};
|
|
@@ -10204,6 +10304,8 @@ class ParserError extends Error {
|
|
|
10204
10304
|
|
|
10205
10305
|
/**
|
|
10206
10306
|
* Parse HTML document into a DOM tree.
|
|
10307
|
+
*
|
|
10308
|
+
* @internal
|
|
10207
10309
|
*/
|
|
10208
10310
|
class Parser {
|
|
10209
10311
|
/**
|
|
@@ -10680,6 +10782,9 @@ class Parser {
|
|
|
10680
10782
|
}
|
|
10681
10783
|
}
|
|
10682
10784
|
|
|
10785
|
+
/**
|
|
10786
|
+
* @internal
|
|
10787
|
+
*/
|
|
10683
10788
|
class Reporter {
|
|
10684
10789
|
constructor() {
|
|
10685
10790
|
this.result = {};
|
|
@@ -10798,6 +10903,9 @@ function messageSort(a, b) {
|
|
|
10798
10903
|
return 0;
|
|
10799
10904
|
}
|
|
10800
10905
|
|
|
10906
|
+
/**
|
|
10907
|
+
* @internal
|
|
10908
|
+
*/
|
|
10801
10909
|
class Engine {
|
|
10802
10910
|
constructor(config, ParserClass) {
|
|
10803
10911
|
this.report = new Reporter();
|
|
@@ -11151,6 +11259,8 @@ class Engine {
|
|
|
11151
11259
|
*
|
|
11152
11260
|
* In practice this means no configuration is fetch by traversing the
|
|
11153
11261
|
* filesystem.
|
|
11262
|
+
*
|
|
11263
|
+
* @public
|
|
11154
11264
|
*/
|
|
11155
11265
|
class StaticConfigLoader extends ConfigLoader {
|
|
11156
11266
|
getConfigFor(handle, configOverride) {
|
|
@@ -11190,6 +11300,8 @@ function isConfigData(value) {
|
|
|
11190
11300
|
* Primary API for using HTML-validate.
|
|
11191
11301
|
*
|
|
11192
11302
|
* Provides high-level abstractions for common operations.
|
|
11303
|
+
*
|
|
11304
|
+
* @public
|
|
11193
11305
|
*/
|
|
11194
11306
|
class HtmlValidate {
|
|
11195
11307
|
constructor(arg) {
|
|
@@ -11394,6 +11506,7 @@ class HtmlValidate {
|
|
|
11394
11506
|
/**
|
|
11395
11507
|
* Create a parser configured for given filename.
|
|
11396
11508
|
*
|
|
11509
|
+
* @internal
|
|
11397
11510
|
* @param source - Source to use.
|
|
11398
11511
|
*/
|
|
11399
11512
|
getParserFor(source) {
|
|
@@ -11437,6 +11550,7 @@ const defaults$1 = {
|
|
|
11437
11550
|
* Tests if plugin is compatible with html-validate library. Unless the `silent`
|
|
11438
11551
|
* option is used a warning is displayed on the console.
|
|
11439
11552
|
*
|
|
11553
|
+
* @public
|
|
11440
11554
|
* @param name - Name of plugin
|
|
11441
11555
|
* @param declared - What library versions the plugin support (e.g. declared peerDependencies)
|
|
11442
11556
|
* @returns - `true` if version is compatible
|
|
@@ -11465,6 +11579,7 @@ const ruleIds = new Set(Object.keys(bundledRules));
|
|
|
11465
11579
|
* Can be used to create forward/backward compatibility by checking if a rule
|
|
11466
11580
|
* exists to enable/disable it.
|
|
11467
11581
|
*
|
|
11582
|
+
* @public
|
|
11468
11583
|
* @param ruleId - Rule id to check
|
|
11469
11584
|
* @returns `true` if rule exists
|
|
11470
11585
|
*/
|
|
@@ -11504,6 +11619,8 @@ function findConfigurationFiles(directory) {
|
|
|
11504
11619
|
* 2. If set in the global config the override is merged into global and
|
|
11505
11620
|
* returned. No configuration files are searched.
|
|
11506
11621
|
* 3. Setting `root` in configuration file only stops directory traversal.
|
|
11622
|
+
*
|
|
11623
|
+
* @public
|
|
11507
11624
|
*/
|
|
11508
11625
|
class FileSystemConfigLoader extends ConfigLoader {
|
|
11509
11626
|
/**
|
|
@@ -11841,6 +11958,7 @@ const availableFormatters = {
|
|
|
11841
11958
|
/**
|
|
11842
11959
|
* Get formatter function by name.
|
|
11843
11960
|
*
|
|
11961
|
+
* @internal
|
|
11844
11962
|
* @param name - Name of formatter.
|
|
11845
11963
|
* @returns Formatter function or null if it doesn't exist.
|
|
11846
11964
|
*/
|