html-validate 6.0.2 → 6.1.3
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 +29 -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 +220 -7
- package/dist/cjs/core.js +241 -45
- 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/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 +220 -7
- package/dist/es/core.js +241 -45
- 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/elements/html5.json +0 -1
- package/package.json +39 -37
package/dist/cjs/core.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ import { SchemaObject as SchemaObject$1 } from 'ajv/dist/types';
|
|
|
3
3
|
|
|
4
4
|
/** @internal */
|
|
5
5
|
declare type EventCallback = (event: string, data: any) => void;
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
6
9
|
declare class EventHandler {
|
|
7
10
|
listeners: {
|
|
8
11
|
[event: string]: EventCallback[];
|
|
@@ -48,10 +51,11 @@ declare enum TokenType {
|
|
|
48
51
|
TEXT = 11,
|
|
49
52
|
TEMPLATING = 12,
|
|
50
53
|
SCRIPT = 13,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
STYLE = 14,
|
|
55
|
+
COMMENT = 15,
|
|
56
|
+
CONDITIONAL = 16,
|
|
57
|
+
DIRECTIVE = 17,
|
|
58
|
+
EOF = 18
|
|
55
59
|
}
|
|
56
60
|
interface Token {
|
|
57
61
|
type: TokenType;
|
|
@@ -67,6 +71,9 @@ declare type RuleConfig = Record<string, RuleSeverity | [RuleSeverity] | [RuleSe
|
|
|
67
71
|
interface TransformMap {
|
|
68
72
|
[key: string]: string;
|
|
69
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
70
77
|
interface ConfigData {
|
|
71
78
|
/**
|
|
72
79
|
* If set to true no new configurations will be searched.
|
|
@@ -112,6 +119,8 @@ interface ConfigData {
|
|
|
112
119
|
|
|
113
120
|
/**
|
|
114
121
|
* Reported error message.
|
|
122
|
+
*
|
|
123
|
+
* @public
|
|
115
124
|
*/
|
|
116
125
|
interface Message {
|
|
117
126
|
/** Rule that triggered this message */
|
|
@@ -139,6 +148,9 @@ interface Message {
|
|
|
139
148
|
*/
|
|
140
149
|
context?: any;
|
|
141
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* @public
|
|
153
|
+
*/
|
|
142
154
|
interface Result {
|
|
143
155
|
messages: Message[];
|
|
144
156
|
filePath: string;
|
|
@@ -148,6 +160,8 @@ interface Result {
|
|
|
148
160
|
}
|
|
149
161
|
/**
|
|
150
162
|
* Report object returned by [[HtmlValidate]].
|
|
163
|
+
*
|
|
164
|
+
* @public
|
|
151
165
|
*/
|
|
152
166
|
interface Report {
|
|
153
167
|
/** `true` if validation was successful */
|
|
@@ -159,6 +173,9 @@ interface Report {
|
|
|
159
173
|
/** Total warnings of errors across all sources */
|
|
160
174
|
warningCount: number;
|
|
161
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* @internal
|
|
178
|
+
*/
|
|
162
179
|
declare class Reporter {
|
|
163
180
|
protected result: {
|
|
164
181
|
[filename: string]: Message[];
|
|
@@ -174,6 +191,9 @@ declare class Reporter {
|
|
|
174
191
|
protected isValid(): boolean;
|
|
175
192
|
}
|
|
176
193
|
|
|
194
|
+
/**
|
|
195
|
+
* @public
|
|
196
|
+
*/
|
|
177
197
|
interface RuleDocumentation {
|
|
178
198
|
description: string;
|
|
179
199
|
url?: string;
|
|
@@ -186,6 +206,9 @@ interface IncludeExcludeOptions {
|
|
|
186
206
|
include: string[] | null;
|
|
187
207
|
exclude: string[] | null;
|
|
188
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* @public
|
|
211
|
+
*/
|
|
189
212
|
declare abstract class Rule<ContextType = void, OptionsType = void> {
|
|
190
213
|
private reporter;
|
|
191
214
|
private parser;
|
|
@@ -341,6 +364,8 @@ interface Event {
|
|
|
341
364
|
}
|
|
342
365
|
/**
|
|
343
366
|
* Configuration ready event.
|
|
367
|
+
*
|
|
368
|
+
* @public
|
|
344
369
|
*/
|
|
345
370
|
interface ConfigReadyEvent extends Event {
|
|
346
371
|
config: ResolvedConfig;
|
|
@@ -354,12 +379,16 @@ interface ConfigReadyEvent extends Event {
|
|
|
354
379
|
*
|
|
355
380
|
* The source object must not be modified (use a transformer if modifications
|
|
356
381
|
* are required)
|
|
382
|
+
*
|
|
383
|
+
* @public
|
|
357
384
|
*/
|
|
358
385
|
interface SourceReadyEvent extends Event {
|
|
359
386
|
source: Source;
|
|
360
387
|
}
|
|
361
388
|
/**
|
|
362
389
|
* Token event.
|
|
390
|
+
*
|
|
391
|
+
* @public
|
|
363
392
|
*/
|
|
364
393
|
interface TokenEvent extends Event {
|
|
365
394
|
type: TokenType;
|
|
@@ -367,6 +396,8 @@ interface TokenEvent extends Event {
|
|
|
367
396
|
}
|
|
368
397
|
/**
|
|
369
398
|
* Event emitted when starting tags are encountered.
|
|
399
|
+
*
|
|
400
|
+
* @public
|
|
370
401
|
*/
|
|
371
402
|
interface TagStartEvent extends Event {
|
|
372
403
|
/** Event location. */
|
|
@@ -374,10 +405,17 @@ interface TagStartEvent extends Event {
|
|
|
374
405
|
/** The node being started. */
|
|
375
406
|
target: HtmlElement;
|
|
376
407
|
}
|
|
377
|
-
/**
|
|
408
|
+
/**
|
|
409
|
+
* Deprecated alias for TagStartEvent
|
|
410
|
+
*
|
|
411
|
+
* @public
|
|
412
|
+
* @deprecated Use TagStartEvent instead
|
|
413
|
+
*/
|
|
378
414
|
declare type TagOpenEvent = TagStartEvent;
|
|
379
415
|
/**
|
|
380
416
|
* Event emitted when end tags `</..>` are encountered.
|
|
417
|
+
*
|
|
418
|
+
* @public
|
|
381
419
|
*/
|
|
382
420
|
interface TagEndEvent extends Event {
|
|
383
421
|
/** Event location. */
|
|
@@ -388,11 +426,18 @@ interface TagEndEvent extends Event {
|
|
|
388
426
|
/** The node being closed. */
|
|
389
427
|
previous: HtmlElement;
|
|
390
428
|
}
|
|
391
|
-
/**
|
|
429
|
+
/**
|
|
430
|
+
* Deprecated alias for TagEndEvent
|
|
431
|
+
*
|
|
432
|
+
* @public
|
|
433
|
+
* @deprecated Use TagEndEvent instead
|
|
434
|
+
*/
|
|
392
435
|
declare type TagCloseEvent = TagEndEvent;
|
|
393
436
|
/**
|
|
394
437
|
* Event emitted when a tag is ready (i.e. all the attributes has been
|
|
395
438
|
* parsed). The children of the element will not yet be finished.
|
|
439
|
+
*
|
|
440
|
+
* @public
|
|
396
441
|
*/
|
|
397
442
|
interface TagReadyEvent extends Event {
|
|
398
443
|
/** Event location. */
|
|
@@ -402,6 +447,8 @@ interface TagReadyEvent extends Event {
|
|
|
402
447
|
}
|
|
403
448
|
/**
|
|
404
449
|
* Event emitted when an element is fully constructed (including its children).
|
|
450
|
+
*
|
|
451
|
+
* @public
|
|
405
452
|
*/
|
|
406
453
|
interface ElementReadyEvent extends Event {
|
|
407
454
|
/** Event location. */
|
|
@@ -411,6 +458,8 @@ interface ElementReadyEvent extends Event {
|
|
|
411
458
|
}
|
|
412
459
|
/**
|
|
413
460
|
* Event emitted when attributes are encountered.
|
|
461
|
+
*
|
|
462
|
+
* @public
|
|
414
463
|
*/
|
|
415
464
|
interface AttributeEvent extends Event {
|
|
416
465
|
/** Location of the full attribute (key, quotes and value) */
|
|
@@ -433,6 +482,8 @@ interface AttributeEvent extends Event {
|
|
|
433
482
|
}
|
|
434
483
|
/**
|
|
435
484
|
* Event emitted when whitespace content is parsed.
|
|
485
|
+
*
|
|
486
|
+
* @public
|
|
436
487
|
*/
|
|
437
488
|
interface WhitespaceEvent extends Event {
|
|
438
489
|
/** Event location. */
|
|
@@ -443,6 +494,8 @@ interface WhitespaceEvent extends Event {
|
|
|
443
494
|
/**
|
|
444
495
|
* Event emitted when Internet Explorer conditionals `<![if ...]>` are
|
|
445
496
|
* encountered.
|
|
497
|
+
*
|
|
498
|
+
* @public
|
|
446
499
|
*/
|
|
447
500
|
interface ConditionalEvent extends Event {
|
|
448
501
|
/** Event location. */
|
|
@@ -453,6 +506,8 @@ interface ConditionalEvent extends Event {
|
|
|
453
506
|
/**
|
|
454
507
|
* Event emitted when html-validate directives `<!-- [html-validate-...] -->`
|
|
455
508
|
* are encountered.
|
|
509
|
+
*
|
|
510
|
+
* @public
|
|
456
511
|
*/
|
|
457
512
|
interface DirectiveEvent extends Event {
|
|
458
513
|
/** Event location. */
|
|
@@ -466,6 +521,8 @@ interface DirectiveEvent extends Event {
|
|
|
466
521
|
}
|
|
467
522
|
/**
|
|
468
523
|
* Event emitted when doctypes `<!DOCTYPE ..>` are encountered.
|
|
524
|
+
*
|
|
525
|
+
* @public
|
|
469
526
|
*/
|
|
470
527
|
interface DoctypeEvent extends Event {
|
|
471
528
|
/** Event location. */
|
|
@@ -480,18 +537,25 @@ interface DoctypeEvent extends Event {
|
|
|
480
537
|
/**
|
|
481
538
|
* Event emitted after initialization but before tokenization and parsing occurs.
|
|
482
539
|
* Can be used to initialize state in rules.
|
|
540
|
+
*
|
|
541
|
+
* @public
|
|
483
542
|
*/
|
|
484
543
|
interface DOMLoadEvent extends Event {
|
|
485
544
|
source: Source;
|
|
486
545
|
}
|
|
487
546
|
/**
|
|
488
547
|
* Event emitted when DOM tree is fully constructed.
|
|
548
|
+
*
|
|
549
|
+
* @public
|
|
489
550
|
*/
|
|
490
551
|
interface DOMReadyEvent extends Event {
|
|
491
552
|
/** DOM Tree */
|
|
492
553
|
document: DOMTree;
|
|
493
554
|
source: Source;
|
|
494
555
|
}
|
|
556
|
+
/**
|
|
557
|
+
* @public
|
|
558
|
+
*/
|
|
495
559
|
interface TriggerEventMap {
|
|
496
560
|
"config:ready": ConfigReadyEvent;
|
|
497
561
|
"source:ready": SourceReadyEvent;
|
|
@@ -508,6 +572,9 @@ interface TriggerEventMap {
|
|
|
508
572
|
conditional: ConditionalEvent;
|
|
509
573
|
directive: DirectiveEvent;
|
|
510
574
|
}
|
|
575
|
+
/**
|
|
576
|
+
* @public
|
|
577
|
+
*/
|
|
511
578
|
interface ListenEventMap {
|
|
512
579
|
"config:ready": ConfigReadyEvent;
|
|
513
580
|
"source:ready": SourceReadyEvent;
|
|
@@ -530,6 +597,8 @@ interface ListenEventMap {
|
|
|
530
597
|
|
|
531
598
|
/**
|
|
532
599
|
* Parse HTML document into a DOM tree.
|
|
600
|
+
*
|
|
601
|
+
* @internal
|
|
533
602
|
*/
|
|
534
603
|
declare class Parser {
|
|
535
604
|
private readonly event;
|
|
@@ -647,6 +716,8 @@ declare class Parser {
|
|
|
647
716
|
|
|
648
717
|
/**
|
|
649
718
|
* Raw attribute data.
|
|
719
|
+
*
|
|
720
|
+
* @public
|
|
650
721
|
*/
|
|
651
722
|
interface AttributeData {
|
|
652
723
|
/** Attribute name */
|
|
@@ -660,11 +731,23 @@ interface AttributeData {
|
|
|
660
731
|
originalAttribute?: string;
|
|
661
732
|
}
|
|
662
733
|
|
|
734
|
+
/**
|
|
735
|
+
* @public
|
|
736
|
+
*/
|
|
663
737
|
declare type ProcessAttributeCallback = (this: unknown, attr: AttributeData) => Iterable<AttributeData>;
|
|
738
|
+
/**
|
|
739
|
+
* @public
|
|
740
|
+
*/
|
|
664
741
|
interface ProcessElementContext {
|
|
665
742
|
getMetaFor(tagName: string): MetaElement | null;
|
|
666
743
|
}
|
|
744
|
+
/**
|
|
745
|
+
* @public
|
|
746
|
+
*/
|
|
667
747
|
declare type ProcessElementCallback = (this: ProcessElementContext, node: HtmlElement) => void;
|
|
748
|
+
/**
|
|
749
|
+
* @public
|
|
750
|
+
*/
|
|
668
751
|
interface SourceHooks {
|
|
669
752
|
/**
|
|
670
753
|
* Called for every attribute.
|
|
@@ -689,6 +772,8 @@ interface SourceHooks {
|
|
|
689
772
|
*
|
|
690
773
|
* Optional hooks can be attached. This is usually added by transformers to
|
|
691
774
|
* postprocess.
|
|
775
|
+
*
|
|
776
|
+
* @public
|
|
692
777
|
*/
|
|
693
778
|
interface Source {
|
|
694
779
|
data: string;
|
|
@@ -733,6 +818,9 @@ interface Source {
|
|
|
733
818
|
transformedBy?: string[];
|
|
734
819
|
}
|
|
735
820
|
|
|
821
|
+
/**
|
|
822
|
+
* @public
|
|
823
|
+
*/
|
|
736
824
|
interface Location {
|
|
737
825
|
/**
|
|
738
826
|
* The filemane this location refers to.
|
|
@@ -758,6 +846,9 @@ interface Location {
|
|
|
758
846
|
readonly size: number;
|
|
759
847
|
}
|
|
760
848
|
|
|
849
|
+
/**
|
|
850
|
+
* @public
|
|
851
|
+
*/
|
|
761
852
|
declare class DynamicValue {
|
|
762
853
|
readonly expr: string;
|
|
763
854
|
constructor(expr: string);
|
|
@@ -839,6 +930,9 @@ interface DeprecatedElement {
|
|
|
839
930
|
documentation?: string;
|
|
840
931
|
source?: string;
|
|
841
932
|
}
|
|
933
|
+
/**
|
|
934
|
+
* @public
|
|
935
|
+
*/
|
|
842
936
|
interface MetaData {
|
|
843
937
|
inherit?: string;
|
|
844
938
|
metadata?: boolean | PropertyExpression;
|
|
@@ -874,8 +968,13 @@ declare type MetaLookupableProperty = "metadata" | "flow" | "sectioning" | "head
|
|
|
874
968
|
/**
|
|
875
969
|
* Properties listed here can be copied (loaded) onto another element using
|
|
876
970
|
* [[HtmlElement.loadMeta]].
|
|
971
|
+
*
|
|
972
|
+
* @public
|
|
877
973
|
*/
|
|
878
974
|
declare const MetaCopyableProperty: Array<keyof MetaElement>;
|
|
975
|
+
/**
|
|
976
|
+
* @public
|
|
977
|
+
*/
|
|
879
978
|
interface MetaElement extends Omit<MetaData, "deprecatedAttributes" | "requiredAttributes"> {
|
|
880
979
|
tagName: string;
|
|
881
980
|
attributes: Record<string, MetaAttribute>;
|
|
@@ -1014,6 +1113,9 @@ declare class DOMTokenList extends Array<string> {
|
|
|
1014
1113
|
}>;
|
|
1015
1114
|
}
|
|
1016
1115
|
|
|
1116
|
+
/**
|
|
1117
|
+
* @public
|
|
1118
|
+
*/
|
|
1017
1119
|
declare enum NodeClosed {
|
|
1018
1120
|
Open = 0,
|
|
1019
1121
|
EndTag = 1,
|
|
@@ -1021,6 +1123,9 @@ declare enum NodeClosed {
|
|
|
1021
1123
|
VoidSelfClosed = 3,
|
|
1022
1124
|
ImplicitClosed = 4
|
|
1023
1125
|
}
|
|
1126
|
+
/**
|
|
1127
|
+
* @public
|
|
1128
|
+
*/
|
|
1024
1129
|
declare class HtmlElement extends DOMNode {
|
|
1025
1130
|
readonly tagName: string;
|
|
1026
1131
|
readonly parent: HtmlElement | null;
|
|
@@ -1033,7 +1138,13 @@ declare class HtmlElement extends DOMNode {
|
|
|
1033
1138
|
private metaElement;
|
|
1034
1139
|
private annotation;
|
|
1035
1140
|
constructor(tagName: string | undefined, parent: HtmlElement | null, closed: NodeClosed, meta: MetaElement | null, location: Location);
|
|
1141
|
+
/**
|
|
1142
|
+
* @internal
|
|
1143
|
+
*/
|
|
1036
1144
|
static rootNode(location: Location): HtmlElement;
|
|
1145
|
+
/**
|
|
1146
|
+
* @internal
|
|
1147
|
+
*/
|
|
1037
1148
|
static fromTokens(startToken: Token, endToken: Token, parent: HtmlElement | null, metaTable: MetaTable | null): HtmlElement;
|
|
1038
1149
|
/**
|
|
1039
1150
|
* Returns annotated name if set or defaults to `<tagName>`.
|
|
@@ -1183,20 +1294,28 @@ declare class HtmlElement extends DOMNode {
|
|
|
1183
1294
|
private querySelectorImpl;
|
|
1184
1295
|
/**
|
|
1185
1296
|
* Visit all nodes from this node and down. Depth first.
|
|
1297
|
+
*
|
|
1298
|
+
* @internal
|
|
1186
1299
|
*/
|
|
1187
1300
|
visitDepthFirst(callback: (node: HtmlElement) => void): void;
|
|
1188
1301
|
/**
|
|
1189
1302
|
* Evaluates callbackk on all descendants, returning true if any are true.
|
|
1303
|
+
*
|
|
1304
|
+
* @internal
|
|
1190
1305
|
*/
|
|
1191
1306
|
someChildren(callback: (node: HtmlElement) => boolean): boolean;
|
|
1192
1307
|
/**
|
|
1193
1308
|
* Evaluates callbackk on all descendants, returning true if all are true.
|
|
1309
|
+
*
|
|
1310
|
+
* @internal
|
|
1194
1311
|
*/
|
|
1195
1312
|
everyChildren(callback: (node: HtmlElement) => boolean): boolean;
|
|
1196
1313
|
/**
|
|
1197
1314
|
* Visit all nodes from this node and down. Breadth first.
|
|
1198
1315
|
*
|
|
1199
1316
|
* The first node for which the callback evaluates to true is returned.
|
|
1317
|
+
*
|
|
1318
|
+
* @internal
|
|
1200
1319
|
*/
|
|
1201
1320
|
find(callback: (node: HtmlElement) => boolean): HtmlElement | null;
|
|
1202
1321
|
}
|
|
@@ -1225,6 +1344,8 @@ declare class DOMTree {
|
|
|
1225
1344
|
*
|
|
1226
1345
|
* Text nodes are appended as children of `HtmlElement` and cannot have childen
|
|
1227
1346
|
* of its own.
|
|
1347
|
+
*
|
|
1348
|
+
* @public
|
|
1228
1349
|
*/
|
|
1229
1350
|
declare class TextNode extends DOMNode {
|
|
1230
1351
|
private readonly text;
|
|
@@ -1248,6 +1369,9 @@ declare class TextNode extends DOMNode {
|
|
|
1248
1369
|
get isDynamic(): boolean;
|
|
1249
1370
|
}
|
|
1250
1371
|
|
|
1372
|
+
/**
|
|
1373
|
+
* @public
|
|
1374
|
+
*/
|
|
1251
1375
|
interface TransformContext {
|
|
1252
1376
|
/**
|
|
1253
1377
|
* Test if an additional chainable transformer is present.
|
|
@@ -1277,6 +1401,9 @@ declare module "estree" {
|
|
|
1277
1401
|
end: number;
|
|
1278
1402
|
}
|
|
1279
1403
|
}
|
|
1404
|
+
/**
|
|
1405
|
+
* @public
|
|
1406
|
+
*/
|
|
1280
1407
|
declare class TemplateExtractor {
|
|
1281
1408
|
private ast;
|
|
1282
1409
|
private filename;
|
|
@@ -1323,12 +1450,18 @@ declare class TemplateExtractor {
|
|
|
1323
1450
|
extractObjectProperty(key: string): Source[];
|
|
1324
1451
|
}
|
|
1325
1452
|
|
|
1453
|
+
/**
|
|
1454
|
+
* @public
|
|
1455
|
+
*/
|
|
1326
1456
|
declare type Transformer = (this: TransformContext, source: Source) => Iterable<Source>;
|
|
1327
1457
|
|
|
1328
1458
|
interface SchemaValidationPatch {
|
|
1329
1459
|
properties?: Record<string, unknown>;
|
|
1330
1460
|
definitions?: Record<string, unknown>;
|
|
1331
1461
|
}
|
|
1462
|
+
/**
|
|
1463
|
+
* @public
|
|
1464
|
+
*/
|
|
1332
1465
|
interface Plugin {
|
|
1333
1466
|
/**
|
|
1334
1467
|
* Name of the plugin.
|
|
@@ -1406,18 +1539,30 @@ interface Plugin {
|
|
|
1406
1539
|
elementSchema?: SchemaValidationPatch | null;
|
|
1407
1540
|
}
|
|
1408
1541
|
|
|
1542
|
+
/**
|
|
1543
|
+
* @public
|
|
1544
|
+
*/
|
|
1409
1545
|
declare class MetaTable {
|
|
1410
1546
|
readonly elements: ElementTable;
|
|
1411
1547
|
private schema;
|
|
1548
|
+
/**
|
|
1549
|
+
* @internal
|
|
1550
|
+
*/
|
|
1412
1551
|
constructor();
|
|
1552
|
+
/**
|
|
1553
|
+
* @internal
|
|
1554
|
+
*/
|
|
1413
1555
|
init(): void;
|
|
1414
1556
|
/**
|
|
1415
1557
|
* Extend validation schema.
|
|
1558
|
+
*
|
|
1559
|
+
* @internal
|
|
1416
1560
|
*/
|
|
1417
1561
|
extendValidationSchema(patch: SchemaValidationPatch): void;
|
|
1418
1562
|
/**
|
|
1419
1563
|
* Load metadata table from object.
|
|
1420
1564
|
*
|
|
1565
|
+
* @internal
|
|
1421
1566
|
* @param obj - Object with metadata to load
|
|
1422
1567
|
* @param filename - Optional filename used when presenting validation error
|
|
1423
1568
|
*/
|
|
@@ -1425,21 +1570,27 @@ declare class MetaTable {
|
|
|
1425
1570
|
/**
|
|
1426
1571
|
* Load metadata table from filename
|
|
1427
1572
|
*
|
|
1573
|
+
* @internal
|
|
1428
1574
|
* @param filename - Filename to load
|
|
1429
1575
|
*/
|
|
1430
1576
|
loadFromFile(filename: string): void;
|
|
1431
1577
|
/**
|
|
1432
1578
|
* Get [[MetaElement]] for the given tag or null if the element doesn't exist.
|
|
1433
1579
|
*
|
|
1580
|
+
* @public
|
|
1434
1581
|
* @returns A shallow copy of metadata.
|
|
1435
1582
|
*/
|
|
1436
1583
|
getMetaFor(tagName: string): MetaElement | null;
|
|
1437
1584
|
/**
|
|
1438
1585
|
* Find all tags which has enabled given property.
|
|
1586
|
+
*
|
|
1587
|
+
* @public
|
|
1439
1588
|
*/
|
|
1440
1589
|
getTagsWithProperty(propName: MetaLookupableProperty): string[];
|
|
1441
1590
|
/**
|
|
1442
1591
|
* Find tag matching tagName or inheriting from it.
|
|
1592
|
+
*
|
|
1593
|
+
* @public
|
|
1443
1594
|
*/
|
|
1444
1595
|
getTagsDerivedFrom(tagName: string): string[];
|
|
1445
1596
|
private addEntry;
|
|
@@ -1447,6 +1598,9 @@ declare class MetaTable {
|
|
|
1447
1598
|
* Construct a new AJV schema validator.
|
|
1448
1599
|
*/
|
|
1449
1600
|
private getSchemaValidator;
|
|
1601
|
+
/**
|
|
1602
|
+
* @public
|
|
1603
|
+
*/
|
|
1450
1604
|
getJSONSchema(): SchemaObject$1;
|
|
1451
1605
|
/**
|
|
1452
1606
|
* Finds the global element definition and merges each known element with the
|
|
@@ -1454,9 +1608,15 @@ declare class MetaTable {
|
|
|
1454
1608
|
*/
|
|
1455
1609
|
private resolveGlobal;
|
|
1456
1610
|
private mergeElement;
|
|
1611
|
+
/**
|
|
1612
|
+
* @internal
|
|
1613
|
+
*/
|
|
1457
1614
|
resolve(node: HtmlElement): void;
|
|
1458
1615
|
}
|
|
1459
1616
|
|
|
1617
|
+
/**
|
|
1618
|
+
* @public
|
|
1619
|
+
*/
|
|
1460
1620
|
declare enum Severity {
|
|
1461
1621
|
DISABLED = 0,
|
|
1462
1622
|
WARN = 1,
|
|
@@ -1525,6 +1685,8 @@ interface LoadedPlugin extends Plugin {
|
|
|
1525
1685
|
* Configuration holder.
|
|
1526
1686
|
*
|
|
1527
1687
|
* Each file being validated will have a unique instance of this class.
|
|
1688
|
+
*
|
|
1689
|
+
* @public
|
|
1528
1690
|
*/
|
|
1529
1691
|
declare class Config {
|
|
1530
1692
|
private config;
|
|
@@ -1556,18 +1718,25 @@ declare class Config {
|
|
|
1556
1718
|
* Validate configuration data.
|
|
1557
1719
|
*
|
|
1558
1720
|
* Throws SchemaValidationError if invalid.
|
|
1721
|
+
*
|
|
1722
|
+
* @internal
|
|
1559
1723
|
*/
|
|
1560
1724
|
static validate(configData: ConfigData, filename?: string | null): void;
|
|
1561
1725
|
/**
|
|
1562
1726
|
* Load a default configuration object.
|
|
1563
1727
|
*/
|
|
1564
1728
|
static defaultConfig(): Config;
|
|
1729
|
+
/**
|
|
1730
|
+
* @internal
|
|
1731
|
+
*/
|
|
1565
1732
|
constructor(options?: ConfigData);
|
|
1566
1733
|
/**
|
|
1567
1734
|
* Initialize plugins, transforms etc.
|
|
1568
1735
|
*
|
|
1569
1736
|
* Must be called before trying to use config. Can safely be called multiple
|
|
1570
1737
|
* times.
|
|
1738
|
+
*
|
|
1739
|
+
* @internal
|
|
1571
1740
|
*/
|
|
1572
1741
|
init(): void;
|
|
1573
1742
|
/**
|
|
@@ -1578,6 +1747,7 @@ declare class Config {
|
|
|
1578
1747
|
* Returns a new configuration as a merge of the two. Entries from the passed
|
|
1579
1748
|
* object takes priority over this object.
|
|
1580
1749
|
*
|
|
1750
|
+
* @internal
|
|
1581
1751
|
* @param rhs - Configuration to merge with this one.
|
|
1582
1752
|
*/
|
|
1583
1753
|
merge(rhs: Config): Config;
|
|
@@ -1598,11 +1768,15 @@ declare class Config {
|
|
|
1598
1768
|
get(): ConfigData;
|
|
1599
1769
|
/**
|
|
1600
1770
|
* Get all configured rules, their severity and options.
|
|
1771
|
+
*
|
|
1772
|
+
* @internal
|
|
1601
1773
|
*/
|
|
1602
1774
|
getRules(): Map<string, [Severity, RuleOptions]>;
|
|
1603
1775
|
private static getRulesObject;
|
|
1604
1776
|
/**
|
|
1605
1777
|
* Get all configured plugins.
|
|
1778
|
+
*
|
|
1779
|
+
* @internal
|
|
1606
1780
|
*/
|
|
1607
1781
|
getPlugins(): Plugin[];
|
|
1608
1782
|
private loadPlugins;
|
|
@@ -1613,6 +1787,8 @@ declare class Config {
|
|
|
1613
1787
|
*
|
|
1614
1788
|
* A resolved configuration will merge all extended configs and load all
|
|
1615
1789
|
* plugins and transformers, and normalize the rest of the configuration.
|
|
1790
|
+
*
|
|
1791
|
+
* @internal
|
|
1616
1792
|
*/
|
|
1617
1793
|
resolve(): ResolvedConfig;
|
|
1618
1794
|
/**
|
|
@@ -1709,9 +1885,15 @@ declare class NestedError extends Error {
|
|
|
1709
1885
|
constructor(message: string, nested?: Error);
|
|
1710
1886
|
}
|
|
1711
1887
|
|
|
1888
|
+
/**
|
|
1889
|
+
* @public
|
|
1890
|
+
*/
|
|
1712
1891
|
declare class UserError extends NestedError {
|
|
1713
1892
|
}
|
|
1714
1893
|
|
|
1894
|
+
/**
|
|
1895
|
+
* @public
|
|
1896
|
+
*/
|
|
1715
1897
|
declare class SchemaValidationError extends UserError {
|
|
1716
1898
|
filename: string | null;
|
|
1717
1899
|
private obj;
|
|
@@ -1722,15 +1904,27 @@ declare class SchemaValidationError extends UserError {
|
|
|
1722
1904
|
private getRawJSON;
|
|
1723
1905
|
}
|
|
1724
1906
|
|
|
1907
|
+
/**
|
|
1908
|
+
* @public
|
|
1909
|
+
*/
|
|
1725
1910
|
declare class ConfigError extends UserError {
|
|
1726
1911
|
}
|
|
1727
1912
|
|
|
1913
|
+
/**
|
|
1914
|
+
* @internal
|
|
1915
|
+
*/
|
|
1728
1916
|
declare const presets: Record<string, ConfigData>;
|
|
1729
1917
|
|
|
1918
|
+
/**
|
|
1919
|
+
* @internal
|
|
1920
|
+
*/
|
|
1730
1921
|
interface EventDump {
|
|
1731
1922
|
event: string;
|
|
1732
1923
|
data: any;
|
|
1733
1924
|
}
|
|
1925
|
+
/**
|
|
1926
|
+
* @internal
|
|
1927
|
+
*/
|
|
1734
1928
|
interface TokenDump {
|
|
1735
1929
|
token: string;
|
|
1736
1930
|
data: string;
|
|
@@ -1741,6 +1935,8 @@ interface TokenDump {
|
|
|
1741
1935
|
* Primary API for using HTML-validate.
|
|
1742
1936
|
*
|
|
1743
1937
|
* Provides high-level abstractions for common operations.
|
|
1938
|
+
*
|
|
1939
|
+
* @public
|
|
1744
1940
|
*/
|
|
1745
1941
|
declare class HtmlValidate {
|
|
1746
1942
|
protected configLoader: ConfigLoader;
|
|
@@ -1879,6 +2075,7 @@ declare class HtmlValidate {
|
|
|
1879
2075
|
/**
|
|
1880
2076
|
* Create a parser configured for given filename.
|
|
1881
2077
|
*
|
|
2078
|
+
* @internal
|
|
1882
2079
|
* @param source - Source to use.
|
|
1883
2080
|
*/
|
|
1884
2081
|
getParserFor(source: Source): Parser;
|
|
@@ -1909,6 +2106,8 @@ declare class HtmlValidate {
|
|
|
1909
2106
|
*
|
|
1910
2107
|
* In practice this means no configuration is fetch by traversing the
|
|
1911
2108
|
* filesystem.
|
|
2109
|
+
*
|
|
2110
|
+
* @public
|
|
1912
2111
|
*/
|
|
1913
2112
|
declare class StaticConfigLoader extends ConfigLoader {
|
|
1914
2113
|
getConfigFor(handle: string, configOverride?: ConfigData): Config;
|
|
@@ -1916,6 +2115,12 @@ declare class StaticConfigLoader extends ConfigLoader {
|
|
|
1916
2115
|
protected defaultConfig(): Config;
|
|
1917
2116
|
}
|
|
1918
2117
|
|
|
2118
|
+
/** @public */
|
|
2119
|
+
declare const version: string;
|
|
2120
|
+
|
|
2121
|
+
/**
|
|
2122
|
+
* @public
|
|
2123
|
+
*/
|
|
1919
2124
|
interface CompatibilityOptions {
|
|
1920
2125
|
/** If `true` nothing no output will be generated on console. Default: `false` */
|
|
1921
2126
|
silent: boolean;
|
|
@@ -1928,6 +2133,7 @@ interface CompatibilityOptions {
|
|
|
1928
2133
|
* Tests if plugin is compatible with html-validate library. Unless the `silent`
|
|
1929
2134
|
* option is used a warning is displayed on the console.
|
|
1930
2135
|
*
|
|
2136
|
+
* @public
|
|
1931
2137
|
* @param name - Name of plugin
|
|
1932
2138
|
* @param declared - What library versions the plugin support (e.g. declared peerDependencies)
|
|
1933
2139
|
* @returns - `true` if version is compatible
|
|
@@ -1941,6 +2147,7 @@ declare function compatibilityCheck(name: string, declared: string, options?: Pa
|
|
|
1941
2147
|
* Can be used to create forward/backward compatibility by checking if a rule
|
|
1942
2148
|
* exists to enable/disable it.
|
|
1943
2149
|
*
|
|
2150
|
+
* @public
|
|
1944
2151
|
* @param ruleId - Rule id to check
|
|
1945
2152
|
* @returns `true` if rule exists
|
|
1946
2153
|
*/
|
|
@@ -1970,6 +2177,8 @@ declare function ruleExists(ruleId: string): boolean;
|
|
|
1970
2177
|
* 2. If set in the global config the override is merged into global and
|
|
1971
2178
|
* returned. No configuration files are searched.
|
|
1972
2179
|
* 3. Setting `root` in configuration file only stops directory traversal.
|
|
2180
|
+
*
|
|
2181
|
+
* @public
|
|
1973
2182
|
*/
|
|
1974
2183
|
declare class FileSystemConfigLoader extends ConfigLoader {
|
|
1975
2184
|
protected cache: Map<string, Config | null>;
|
|
@@ -2001,14 +2210,18 @@ declare class FileSystemConfigLoader extends ConfigLoader {
|
|
|
2001
2210
|
protected defaultConfig(): Config;
|
|
2002
2211
|
}
|
|
2003
2212
|
|
|
2213
|
+
/**
|
|
2214
|
+
* @public
|
|
2215
|
+
*/
|
|
2004
2216
|
declare type Formatter = (results: Result[]) => string;
|
|
2005
2217
|
|
|
2006
2218
|
/**
|
|
2007
2219
|
* Get formatter function by name.
|
|
2008
2220
|
*
|
|
2221
|
+
* @internal
|
|
2009
2222
|
* @param name - Name of formatter.
|
|
2010
2223
|
* @returns Formatter function or null if it doesn't exist.
|
|
2011
2224
|
*/
|
|
2012
2225
|
declare function getFormatter(name: string): Formatter | null;
|
|
2013
2226
|
|
|
2014
|
-
export {
|
|
2227
|
+
export { DoctypeEvent as $, AttributeData as A, Event as B, Config as C, DynamicValue as D, EventDump as E, ConfigReadyEvent as F, SourceReadyEvent as G, HtmlValidate as H, TokenEvent as I, TagStartEvent as J, TagOpenEvent as K, Location as L, MetaData as M, NodeClosed as N, TagEndEvent as O, ProcessElementContext as P, TagCloseEvent as Q, Rule as R, Severity as S, TextNode as T, UserError as U, TagReadyEvent as V, ElementReadyEvent as W, AttributeEvent as X, WhitespaceEvent as Y, ConditionalEvent as Z, DirectiveEvent as _, ConfigData as a, DOMLoadEvent as a0, DOMReadyEvent as a1, TriggerEventMap as a2, ListenEventMap as a3, FileSystemConfigLoader as a4, Formatter as a5, getFormatter as a6, compatibilityCheck as a7, CompatibilityOptions as a8, TokenType as a9, ConfigError as b, ConfigLoader as c, StaticConfigLoader as d, HtmlElement as e, TokenDump as f, SchemaValidationError as g, MetaElement as h, MetaTable as i, MetaCopyableProperty as j, RuleDocumentation as k, Source as l, Report as m, Reporter as n, Message as o, presets as p, Result as q, TransformContext as r, Transformer as s, TemplateExtractor as t, Plugin as u, version as v, Parser as w, ruleExists as x, EventHandler as y, EventCallback as z };
|