html-validate 10.16.0 → 11.0.0
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/README.md +1 -1
- package/dist/cjs/browser.js +1 -3
- package/dist/cjs/browser.js.map +1 -1
- package/dist/cjs/core-browser.js +2 -2
- package/dist/cjs/core-browser.js.map +1 -1
- package/dist/cjs/core-nodejs.js +2 -6
- package/dist/cjs/core-nodejs.js.map +1 -1
- package/dist/cjs/core.js +100 -65
- package/dist/cjs/core.js.map +1 -1
- package/dist/cjs/index.js +1 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/browser.js +1 -1
- package/dist/esm/cli.js +1 -1
- package/dist/esm/core-browser.js +2 -2
- package/dist/esm/core-browser.js.map +1 -1
- package/dist/esm/core-nodejs.js +3 -6
- package/dist/esm/core-nodejs.js.map +1 -1
- package/dist/esm/core.js +100 -63
- package/dist/esm/core.js.map +1 -1
- package/dist/esm/html-validate.js +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/matcher-utils.js +1 -1
- package/dist/esm/matchers.js +1 -1
- package/dist/types/browser.d.ts +40 -156
- package/dist/types/index.d.ts +36 -177
- package/package.json +7 -7
|
@@ -2,7 +2,7 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import kleur from 'kleur';
|
|
4
4
|
import minimist from 'minimist';
|
|
5
|
-
import {
|
|
5
|
+
import { a3 as name, v as version, y as SchemaValidationError, O as isUserError, a4 as bugs } from './core.js';
|
|
6
6
|
import { M as Mode, m as modeToFlag, C as CLI, h as haveImportMetaResolve, I as ImportResolveMissingError, d as dump, p as printConfig, i as init, l as lint, a as handleSchemaValidationError } from './cli.js';
|
|
7
7
|
import 'ajv';
|
|
8
8
|
import './elements.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { F as FileSystemConfigLoader, H as HtmlValidate, c as cjsResolver, a as compatibilityCheck, e as esmResolver
|
|
2
|
-
export { A as Attribute, g as Config, f as ConfigError, C as ConfigLoader, D as DOMNode, o as DOMTokenList, p as DOMTree, q as DynamicValue, r as EventHandler, H as HtmlElement, M as MetaCopyableProperty, s as MetaTable, N as NestedError, u as
|
|
1
|
+
export { F as FileSystemConfigLoader, H as HtmlValidate, c as cjsResolver, a as compatibilityCheck, e as esmResolver } from './core-nodejs.js';
|
|
2
|
+
export { A as Attribute, g as Config, f as ConfigError, C as ConfigLoader, D as DOMNode, o as DOMTokenList, p as DOMTree, q as DynamicValue, r as EventHandler, H as HtmlElement, M as MetaCopyableProperty, s as MetaTable, N as NestedError, u as Node, a as Parser, P as PerformanceTracker, R as Reporter, w as ResolvedConfig, x as Rule, y as SchemaValidationError, z as Severity, S as StaticConfigLoader, T as TextClassification, B as TextContent, F as TextNode, U as UserError, W as WrappedError, G as ariaNaming, I as classifyNodeText, J as configPresets, K as defineConfig, L as definePlugin, k as formatterFactory, O as isUserError, Q as keywordPatternMatcher, V as ruleExists, X as sliceLocation, Y as staticResolver, v as version, Z as walk } from './core.js';
|
|
3
3
|
export { C as CLI } from './cli.js';
|
|
4
4
|
export { d as defineMetadata, m as metadataHelper } from './meta-helper.js';
|
|
5
5
|
import 'node:fs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $ as codeFrameColumns, a0 as getEndLocation, a1 as getStartLocation } from './core.js';
|
|
2
2
|
import { MessageChannel, Worker, receiveMessageOnPort } from 'node:worker_threads';
|
|
3
3
|
import { l as legacyRequire } from './core-nodejs.js';
|
|
4
4
|
|
package/dist/esm/matchers.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { d as diverge, c as createSyncFn, f as flattenMessages } from './matcher-utils.js';
|
|
2
|
-
import { l as deepmerge,
|
|
2
|
+
import { l as deepmerge, a2 as workerPath } from './core.js';
|
|
3
3
|
|
|
4
4
|
function createMatcher$4() {
|
|
5
5
|
function toBeValid(report) {
|
package/dist/types/browser.d.ts
CHANGED
|
@@ -638,14 +638,6 @@ export declare class DOMTree {
|
|
|
638
638
|
get readyState(): "loading" | "complete";
|
|
639
639
|
/* Excluded from this release type: resolveMeta */
|
|
640
640
|
getElementsByTagName(tagName: string): HtmlElement[];
|
|
641
|
-
/**
|
|
642
|
-
* @deprecated use utility function `walk.depthFirst(..)` instead (since 8.21.0).
|
|
643
|
-
*/
|
|
644
|
-
visitDepthFirst(callback: (node: HtmlElement) => void): void;
|
|
645
|
-
/**
|
|
646
|
-
* @deprecated use `querySelector(..)` instead (since 8.21.0)
|
|
647
|
-
*/
|
|
648
|
-
find(callback: (node: HtmlElement) => boolean): HtmlElement | null;
|
|
649
641
|
querySelector(selector: string): HtmlElement | null;
|
|
650
642
|
querySelectorAll(selector: string): HtmlElement[];
|
|
651
643
|
}
|
|
@@ -1246,56 +1238,8 @@ export declare class HtmlValidate {
|
|
|
1246
1238
|
* @returns Contextual documentation or `null` if the rule does not exist.
|
|
1247
1239
|
*/
|
|
1248
1240
|
getContextualDocumentationSync(message: Pick<Message, "ruleId" | "context">, config: ResolvedConfig): RuleDocumentation | null;
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
*
|
|
1252
|
-
* Typical usage:
|
|
1253
|
-
*
|
|
1254
|
-
* ```js
|
|
1255
|
-
* const report = await htmlvalidate.validateFile("my-file.html");
|
|
1256
|
-
* for (const result of report.results){
|
|
1257
|
-
* const config = await htmlvalidate.getConfigFor(result.filePath);
|
|
1258
|
-
* for (const message of result.messages){
|
|
1259
|
-
* const documentation = await htmlvalidate.getRuleDocumentation(message.ruleId, config, message.context);
|
|
1260
|
-
* // do something with documentation
|
|
1261
|
-
* }
|
|
1262
|
-
* }
|
|
1263
|
-
* ```
|
|
1264
|
-
*
|
|
1265
|
-
* @public
|
|
1266
|
-
* @deprecated Deprecated since 8.0.0, use [[getContextualDocumentation]] instead.
|
|
1267
|
-
* @param ruleId - Rule to get documentation for.
|
|
1268
|
-
* @param config - If set it provides more accurate description by using the
|
|
1269
|
-
* correct configuration for the file.
|
|
1270
|
-
* @param context - If set to `Message.context` some rules can provide
|
|
1271
|
-
* contextual details and suggestions.
|
|
1272
|
-
*/
|
|
1273
|
-
getRuleDocumentation(ruleId: string, config?: ResolvedConfig | Promise<ResolvedConfig> | null, context?: unknown | null): Promise<RuleDocumentation | null>;
|
|
1274
|
-
/**
|
|
1275
|
-
* Get contextual documentation for the given rule.
|
|
1276
|
-
*
|
|
1277
|
-
* Typical usage:
|
|
1278
|
-
*
|
|
1279
|
-
* ```js
|
|
1280
|
-
* const report = htmlvalidate.validateFileSync("my-file.html");
|
|
1281
|
-
* for (const result of report.results){
|
|
1282
|
-
* const config = htmlvalidate.getConfigForSync(result.filePath);
|
|
1283
|
-
* for (const message of result.messages){
|
|
1284
|
-
* const documentation = htmlvalidate.getRuleDocumentationSync(message.ruleId, config, message.context);
|
|
1285
|
-
* // do something with documentation
|
|
1286
|
-
* }
|
|
1287
|
-
* }
|
|
1288
|
-
* ```
|
|
1289
|
-
*
|
|
1290
|
-
* @public
|
|
1291
|
-
* @deprecated Deprecated since 8.0.0, use [[getContextualDocumentationSync]] instead.
|
|
1292
|
-
* @param ruleId - Rule to get documentation for.
|
|
1293
|
-
* @param config - If set it provides more accurate description by using the
|
|
1294
|
-
* correct configuration for the file.
|
|
1295
|
-
* @param context - If set to `Message.context` some rules can provide
|
|
1296
|
-
* contextual details and suggestions.
|
|
1297
|
-
*/
|
|
1298
|
-
getRuleDocumentationSync(ruleId: string, config?: ResolvedConfig | null, context?: unknown | null): RuleDocumentation | null;
|
|
1241
|
+
/* Excluded from this release type: getRuleDocumentation */
|
|
1242
|
+
/* Excluded from this release type: getRuleDocumentationSync */
|
|
1299
1243
|
/* Excluded from this release type: getParserFor */
|
|
1300
1244
|
/**
|
|
1301
1245
|
* Get configuration for given filename.
|
|
@@ -1633,8 +1577,6 @@ export declare interface MetaData {
|
|
|
1633
1577
|
* does not directly affect the DOM tree.
|
|
1634
1578
|
*/
|
|
1635
1579
|
templateRoot?: boolean;
|
|
1636
|
-
/** @deprecated use {@link MetaAria.implicitRole} instead */
|
|
1637
|
-
implicitRole?: MetaImplicitRoleCallback;
|
|
1638
1580
|
/** WAI-ARIA attributes */
|
|
1639
1581
|
aria?: MetaAria;
|
|
1640
1582
|
deprecatedAttributes?: string[];
|
|
@@ -1705,8 +1647,6 @@ export declare interface MetaElement extends Omit<MetaData, "deprecatedAttribute
|
|
|
1705
1647
|
* does not directly affect the DOM tree.
|
|
1706
1648
|
*/
|
|
1707
1649
|
templateRoot: boolean;
|
|
1708
|
-
/** @deprecated Use {@link MetaAria.implicitRole} instead */
|
|
1709
|
-
implicitRole: MetaImplicitRoleCallback;
|
|
1710
1650
|
/** WAI-ARIA attributes */
|
|
1711
1651
|
aria: NormalizedMetaAria;
|
|
1712
1652
|
attributes: Record<string, MetaAttribute>;
|
|
@@ -1836,22 +1776,48 @@ export declare class NestedError extends Error {
|
|
|
1836
1776
|
/**
|
|
1837
1777
|
* @public
|
|
1838
1778
|
*/
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
}
|
|
1779
|
+
declare const Node_2: {
|
|
1780
|
+
readonly ELEMENT_NODE: 1 & {
|
|
1781
|
+
NODE_TYPE: 1;
|
|
1782
|
+
};
|
|
1783
|
+
readonly TEXT_NODE: 3 & {
|
|
1784
|
+
NODE_TYPE: 3;
|
|
1785
|
+
};
|
|
1786
|
+
readonly DOCUMENT_NODE: 9 & {
|
|
1787
|
+
NODE_TYPE: 9;
|
|
1788
|
+
};
|
|
1789
|
+
/** element wasn't closed */
|
|
1790
|
+
readonly CLOSED_OPEN: 0 & {
|
|
1791
|
+
CLOSED: 0;
|
|
1792
|
+
};
|
|
1793
|
+
/** element closed with end tag <p>...</p> */
|
|
1794
|
+
readonly CLOSED_END_TAG: 1 & {
|
|
1795
|
+
CLOSED: 1;
|
|
1796
|
+
};
|
|
1797
|
+
/** void element with omitted end tag <input> */
|
|
1798
|
+
readonly CLOSED_VOID_OMITTED: 2 & {
|
|
1799
|
+
CLOSED: 2;
|
|
1800
|
+
};
|
|
1801
|
+
/** self-closed void element <input/> */
|
|
1802
|
+
readonly CLOSED_VOID_SELF_CLOSED: 3 & {
|
|
1803
|
+
CLOSED: 3;
|
|
1804
|
+
};
|
|
1805
|
+
/** element with optional end tag <li>foo<li>bar */
|
|
1806
|
+
readonly CLOSED_IMPLICIT_CLOSED: 4 & {
|
|
1807
|
+
CLOSED: 4;
|
|
1808
|
+
};
|
|
1809
|
+
};
|
|
1810
|
+
export { Node_2 as Node }
|
|
1846
1811
|
|
|
1847
1812
|
/**
|
|
1848
1813
|
* @public
|
|
1849
1814
|
*/
|
|
1850
|
-
export declare
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1815
|
+
export declare type NodeClosed = typeof Node_2.CLOSED_OPEN | typeof Node_2.CLOSED_END_TAG | typeof Node_2.CLOSED_VOID_OMITTED | typeof Node_2.CLOSED_VOID_SELF_CLOSED | typeof Node_2.CLOSED_IMPLICIT_CLOSED;
|
|
1816
|
+
|
|
1817
|
+
/**
|
|
1818
|
+
* @public
|
|
1819
|
+
*/
|
|
1820
|
+
export declare type NodeType = typeof Node_2.ELEMENT_NODE | typeof Node_2.TEXT_NODE | typeof Node_2.DOCUMENT_NODE;
|
|
1855
1821
|
|
|
1856
1822
|
/**
|
|
1857
1823
|
* Element ARIA metadata.
|
|
@@ -2967,88 +2933,6 @@ export declare interface UserErrorData extends Error {
|
|
|
2967
2933
|
prettyFormat(): string | undefined;
|
|
2968
2934
|
}
|
|
2969
2935
|
|
|
2970
|
-
/**
|
|
2971
|
-
* Helper class to validate elements against metadata rules.
|
|
2972
|
-
*
|
|
2973
|
-
* @public
|
|
2974
|
-
*/
|
|
2975
|
-
export declare class Validator {
|
|
2976
|
-
/**
|
|
2977
|
-
* Test if element is used in a proper context.
|
|
2978
|
-
*
|
|
2979
|
-
* @param node - Element to test.
|
|
2980
|
-
* @param rules - List of rules.
|
|
2981
|
-
* @returns `true` if element passes all tests.
|
|
2982
|
-
*/
|
|
2983
|
-
static validatePermitted(node: HtmlElement, rules: Permitted | null): boolean;
|
|
2984
|
-
/**
|
|
2985
|
-
* Test if an element is used the correct amount of times.
|
|
2986
|
-
*
|
|
2987
|
-
* For instance, a `<table>` element can only contain a single `<tbody>`
|
|
2988
|
-
* child. If multiple `<tbody>` exists this test will fail both nodes.
|
|
2989
|
-
* Note that this is called on the parent but will fail the children violating
|
|
2990
|
-
* the rule.
|
|
2991
|
-
*
|
|
2992
|
-
* @param children - Array of children to validate.
|
|
2993
|
-
* @param rules - List of rules of the parent element.
|
|
2994
|
-
* @returns `true` if the parent element of the children passes the test.
|
|
2995
|
-
*/
|
|
2996
|
-
static validateOccurrences(children: HtmlElement[], rules: Permitted | null, cb: (node: HtmlElement, category: string) => void): boolean;
|
|
2997
|
-
/**
|
|
2998
|
-
* Validate elements order.
|
|
2999
|
-
*
|
|
3000
|
-
* Given a parent element with children and metadata containing permitted
|
|
3001
|
-
* order it will validate each children and ensure each one exists in the
|
|
3002
|
-
* specified order.
|
|
3003
|
-
*
|
|
3004
|
-
* For instance, for a `<table>` element the `<caption>` element must come
|
|
3005
|
-
* before a `<thead>` which must come before `<tbody>`.
|
|
3006
|
-
*
|
|
3007
|
-
* @param children - Array of children to validate.
|
|
3008
|
-
*/
|
|
3009
|
-
static validateOrder(children: HtmlElement[], rules: PermittedOrder | null, cb: (node: HtmlElement, prev: HtmlElement) => void): boolean;
|
|
3010
|
-
/**
|
|
3011
|
-
* Validate element ancestors.
|
|
3012
|
-
*
|
|
3013
|
-
* Check if an element has the required set of elements. At least one of the
|
|
3014
|
-
* selectors must match.
|
|
3015
|
-
*/
|
|
3016
|
-
static validateAncestors(node: HtmlElement, rules: RequiredAncestors | null): boolean;
|
|
3017
|
-
/**
|
|
3018
|
-
* Validate element required content.
|
|
3019
|
-
*
|
|
3020
|
-
* Check if an element has the required set of elements. At least one of the
|
|
3021
|
-
* selectors must match.
|
|
3022
|
-
*
|
|
3023
|
-
* Returns `[]` when valid or a list of required but missing tagnames or
|
|
3024
|
-
* categories.
|
|
3025
|
-
*/
|
|
3026
|
-
static validateRequiredContent(node: HtmlElement, rules: RequiredContent | null): CategoryOrTag[];
|
|
3027
|
-
/**
|
|
3028
|
-
* Test if an attribute has an allowed value and/or format.
|
|
3029
|
-
*
|
|
3030
|
-
* @param attr - Attribute to test.
|
|
3031
|
-
* @param rules - Element attribute metadta.
|
|
3032
|
-
* @returns `true` if attribute passes all tests.
|
|
3033
|
-
*/
|
|
3034
|
-
static validateAttribute(attr: Attribute, rules: Record<string, MetaAttribute | undefined>): boolean;
|
|
3035
|
-
private static validateAttributeValue;
|
|
3036
|
-
private static validatePermittedRule;
|
|
3037
|
-
/**
|
|
3038
|
-
* Validate node against a content category.
|
|
3039
|
-
*
|
|
3040
|
-
* When matching parent nodes against permitted parents use the superset
|
|
3041
|
-
* parameter to also match for `@flow`. E.g. if a node expects a `@phrasing`
|
|
3042
|
-
* parent it should also allow `@flow` parent since `@phrasing` is a subset of
|
|
3043
|
-
* `@flow`.
|
|
3044
|
-
*
|
|
3045
|
-
* @param node - The node to test against
|
|
3046
|
-
* @param category - Name of category with `@` prefix or tag name.
|
|
3047
|
-
* @param defaultMatch - The default return value when node categories is not known.
|
|
3048
|
-
*/
|
|
3049
|
-
static validatePermittedCategory(node: HtmlElement, category: string, defaultMatch: boolean): boolean;
|
|
3050
|
-
}
|
|
3051
|
-
|
|
3052
2936
|
/** @public */
|
|
3053
2937
|
export declare const version: string;
|
|
3054
2938
|
|
package/dist/types/index.d.ts
CHANGED
|
@@ -736,14 +736,6 @@ export declare class DOMTree {
|
|
|
736
736
|
get readyState(): "loading" | "complete";
|
|
737
737
|
/* Excluded from this release type: resolveMeta */
|
|
738
738
|
getElementsByTagName(tagName: string): HtmlElement[];
|
|
739
|
-
/**
|
|
740
|
-
* @deprecated use utility function `walk.depthFirst(..)` instead (since 8.21.0).
|
|
741
|
-
*/
|
|
742
|
-
visitDepthFirst(callback: (node: HtmlElement) => void): void;
|
|
743
|
-
/**
|
|
744
|
-
* @deprecated use `querySelector(..)` instead (since 8.21.0)
|
|
745
|
-
*/
|
|
746
|
-
find(callback: (node: HtmlElement) => boolean): HtmlElement | null;
|
|
747
739
|
querySelector(selector: string): HtmlElement | null;
|
|
748
740
|
querySelectorAll(selector: string): HtmlElement[];
|
|
749
741
|
}
|
|
@@ -1482,56 +1474,8 @@ export declare class HtmlValidate {
|
|
|
1482
1474
|
* @returns Contextual documentation or `null` if the rule does not exist.
|
|
1483
1475
|
*/
|
|
1484
1476
|
getContextualDocumentationSync(message: Pick<Message, "ruleId" | "context">, config: ResolvedConfig): RuleDocumentation | null;
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
*
|
|
1488
|
-
* Typical usage:
|
|
1489
|
-
*
|
|
1490
|
-
* ```js
|
|
1491
|
-
* const report = await htmlvalidate.validateFile("my-file.html");
|
|
1492
|
-
* for (const result of report.results){
|
|
1493
|
-
* const config = await htmlvalidate.getConfigFor(result.filePath);
|
|
1494
|
-
* for (const message of result.messages){
|
|
1495
|
-
* const documentation = await htmlvalidate.getRuleDocumentation(message.ruleId, config, message.context);
|
|
1496
|
-
* // do something with documentation
|
|
1497
|
-
* }
|
|
1498
|
-
* }
|
|
1499
|
-
* ```
|
|
1500
|
-
*
|
|
1501
|
-
* @public
|
|
1502
|
-
* @deprecated Deprecated since 8.0.0, use [[getContextualDocumentation]] instead.
|
|
1503
|
-
* @param ruleId - Rule to get documentation for.
|
|
1504
|
-
* @param config - If set it provides more accurate description by using the
|
|
1505
|
-
* correct configuration for the file.
|
|
1506
|
-
* @param context - If set to `Message.context` some rules can provide
|
|
1507
|
-
* contextual details and suggestions.
|
|
1508
|
-
*/
|
|
1509
|
-
getRuleDocumentation(ruleId: string, config?: ResolvedConfig | Promise<ResolvedConfig> | null, context?: unknown | null): Promise<RuleDocumentation | null>;
|
|
1510
|
-
/**
|
|
1511
|
-
* Get contextual documentation for the given rule.
|
|
1512
|
-
*
|
|
1513
|
-
* Typical usage:
|
|
1514
|
-
*
|
|
1515
|
-
* ```js
|
|
1516
|
-
* const report = htmlvalidate.validateFileSync("my-file.html");
|
|
1517
|
-
* for (const result of report.results){
|
|
1518
|
-
* const config = htmlvalidate.getConfigForSync(result.filePath);
|
|
1519
|
-
* for (const message of result.messages){
|
|
1520
|
-
* const documentation = htmlvalidate.getRuleDocumentationSync(message.ruleId, config, message.context);
|
|
1521
|
-
* // do something with documentation
|
|
1522
|
-
* }
|
|
1523
|
-
* }
|
|
1524
|
-
* ```
|
|
1525
|
-
*
|
|
1526
|
-
* @public
|
|
1527
|
-
* @deprecated Deprecated since 8.0.0, use [[getContextualDocumentationSync]] instead.
|
|
1528
|
-
* @param ruleId - Rule to get documentation for.
|
|
1529
|
-
* @param config - If set it provides more accurate description by using the
|
|
1530
|
-
* correct configuration for the file.
|
|
1531
|
-
* @param context - If set to `Message.context` some rules can provide
|
|
1532
|
-
* contextual details and suggestions.
|
|
1533
|
-
*/
|
|
1534
|
-
getRuleDocumentationSync(ruleId: string, config?: ResolvedConfig | null, context?: unknown | null): RuleDocumentation | null;
|
|
1477
|
+
/* Excluded from this release type: getRuleDocumentation */
|
|
1478
|
+
/* Excluded from this release type: getRuleDocumentationSync */
|
|
1535
1479
|
/* Excluded from this release type: getParserFor */
|
|
1536
1480
|
/**
|
|
1537
1481
|
* Get configuration for given filename.
|
|
@@ -1876,8 +1820,6 @@ export declare interface MetaData {
|
|
|
1876
1820
|
* does not directly affect the DOM tree.
|
|
1877
1821
|
*/
|
|
1878
1822
|
templateRoot?: boolean;
|
|
1879
|
-
/** @deprecated use {@link MetaAria.implicitRole} instead */
|
|
1880
|
-
implicitRole?: MetaImplicitRoleCallback;
|
|
1881
1823
|
/** WAI-ARIA attributes */
|
|
1882
1824
|
aria?: MetaAria;
|
|
1883
1825
|
deprecatedAttributes?: string[];
|
|
@@ -1948,8 +1890,6 @@ export declare interface MetaElement extends Omit<MetaData, "deprecatedAttribute
|
|
|
1948
1890
|
* does not directly affect the DOM tree.
|
|
1949
1891
|
*/
|
|
1950
1892
|
templateRoot: boolean;
|
|
1951
|
-
/** @deprecated Use {@link MetaAria.implicitRole} instead */
|
|
1952
|
-
implicitRole: MetaImplicitRoleCallback;
|
|
1953
1893
|
/** WAI-ARIA attributes */
|
|
1954
1894
|
aria: NormalizedMetaAria;
|
|
1955
1895
|
attributes: Record<string, MetaAttribute>;
|
|
@@ -2079,47 +2019,48 @@ export declare class NestedError extends Error {
|
|
|
2079
2019
|
/**
|
|
2080
2020
|
* @public
|
|
2081
2021
|
*/
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
}
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
*/
|
|
2097
|
-
|
|
2022
|
+
declare const Node_2: {
|
|
2023
|
+
readonly ELEMENT_NODE: 1 & {
|
|
2024
|
+
NODE_TYPE: 1;
|
|
2025
|
+
};
|
|
2026
|
+
readonly TEXT_NODE: 3 & {
|
|
2027
|
+
NODE_TYPE: 3;
|
|
2028
|
+
};
|
|
2029
|
+
readonly DOCUMENT_NODE: 9 & {
|
|
2030
|
+
NODE_TYPE: 9;
|
|
2031
|
+
};
|
|
2032
|
+
/** element wasn't closed */
|
|
2033
|
+
readonly CLOSED_OPEN: 0 & {
|
|
2034
|
+
CLOSED: 0;
|
|
2035
|
+
};
|
|
2036
|
+
/** element closed with end tag <p>...</p> */
|
|
2037
|
+
readonly CLOSED_END_TAG: 1 & {
|
|
2038
|
+
CLOSED: 1;
|
|
2039
|
+
};
|
|
2040
|
+
/** void element with omitted end tag <input> */
|
|
2041
|
+
readonly CLOSED_VOID_OMITTED: 2 & {
|
|
2042
|
+
CLOSED: 2;
|
|
2043
|
+
};
|
|
2044
|
+
/** self-closed void element <input/> */
|
|
2045
|
+
readonly CLOSED_VOID_SELF_CLOSED: 3 & {
|
|
2046
|
+
CLOSED: 3;
|
|
2047
|
+
};
|
|
2048
|
+
/** element with optional end tag <li>foo<li>bar */
|
|
2049
|
+
readonly CLOSED_IMPLICIT_CLOSED: 4 & {
|
|
2050
|
+
CLOSED: 4;
|
|
2051
|
+
};
|
|
2052
|
+
};
|
|
2053
|
+
export { Node_2 as Node }
|
|
2098
2054
|
|
|
2099
2055
|
/**
|
|
2100
|
-
* Create a new resolver for NodeJS packages using `require(..)`.
|
|
2101
|
-
*
|
|
2102
|
-
* If the module name contains `<rootDir>` (e.g. `<rootDir/foo`) it will be
|
|
2103
|
-
* expanded relative to the root directory either explicitly set by the
|
|
2104
|
-
* `rootDir` parameter or determined automatically by the closest `package.json`
|
|
2105
|
-
* file (starting at the current working directory).
|
|
2106
|
-
*
|
|
2107
2056
|
* @public
|
|
2108
|
-
* @deprecated Deprecated alias for [[commonjsResolver]].
|
|
2109
|
-
* @since 8.0.0
|
|
2110
2057
|
*/
|
|
2111
|
-
export declare
|
|
2112
|
-
rootDir?: string;
|
|
2113
|
-
}): NodeJSResolver;
|
|
2058
|
+
export declare type NodeClosed = typeof Node_2.CLOSED_OPEN | typeof Node_2.CLOSED_END_TAG | typeof Node_2.CLOSED_VOID_OMITTED | typeof Node_2.CLOSED_VOID_SELF_CLOSED | typeof Node_2.CLOSED_IMPLICIT_CLOSED;
|
|
2114
2059
|
|
|
2115
2060
|
/**
|
|
2116
2061
|
* @public
|
|
2117
2062
|
*/
|
|
2118
|
-
export declare
|
|
2119
|
-
ELEMENT_NODE = 1,
|
|
2120
|
-
TEXT_NODE = 3,
|
|
2121
|
-
DOCUMENT_NODE = 9
|
|
2122
|
-
}
|
|
2063
|
+
export declare type NodeType = typeof Node_2.ELEMENT_NODE | typeof Node_2.TEXT_NODE | typeof Node_2.DOCUMENT_NODE;
|
|
2123
2064
|
|
|
2124
2065
|
/**
|
|
2125
2066
|
* Element ARIA metadata.
|
|
@@ -3235,88 +3176,6 @@ export declare interface UserErrorData extends Error {
|
|
|
3235
3176
|
prettyFormat(): string | undefined;
|
|
3236
3177
|
}
|
|
3237
3178
|
|
|
3238
|
-
/**
|
|
3239
|
-
* Helper class to validate elements against metadata rules.
|
|
3240
|
-
*
|
|
3241
|
-
* @public
|
|
3242
|
-
*/
|
|
3243
|
-
export declare class Validator {
|
|
3244
|
-
/**
|
|
3245
|
-
* Test if element is used in a proper context.
|
|
3246
|
-
*
|
|
3247
|
-
* @param node - Element to test.
|
|
3248
|
-
* @param rules - List of rules.
|
|
3249
|
-
* @returns `true` if element passes all tests.
|
|
3250
|
-
*/
|
|
3251
|
-
static validatePermitted(node: HtmlElement, rules: Permitted | null): boolean;
|
|
3252
|
-
/**
|
|
3253
|
-
* Test if an element is used the correct amount of times.
|
|
3254
|
-
*
|
|
3255
|
-
* For instance, a `<table>` element can only contain a single `<tbody>`
|
|
3256
|
-
* child. If multiple `<tbody>` exists this test will fail both nodes.
|
|
3257
|
-
* Note that this is called on the parent but will fail the children violating
|
|
3258
|
-
* the rule.
|
|
3259
|
-
*
|
|
3260
|
-
* @param children - Array of children to validate.
|
|
3261
|
-
* @param rules - List of rules of the parent element.
|
|
3262
|
-
* @returns `true` if the parent element of the children passes the test.
|
|
3263
|
-
*/
|
|
3264
|
-
static validateOccurrences(children: HtmlElement[], rules: Permitted | null, cb: (node: HtmlElement, category: string) => void): boolean;
|
|
3265
|
-
/**
|
|
3266
|
-
* Validate elements order.
|
|
3267
|
-
*
|
|
3268
|
-
* Given a parent element with children and metadata containing permitted
|
|
3269
|
-
* order it will validate each children and ensure each one exists in the
|
|
3270
|
-
* specified order.
|
|
3271
|
-
*
|
|
3272
|
-
* For instance, for a `<table>` element the `<caption>` element must come
|
|
3273
|
-
* before a `<thead>` which must come before `<tbody>`.
|
|
3274
|
-
*
|
|
3275
|
-
* @param children - Array of children to validate.
|
|
3276
|
-
*/
|
|
3277
|
-
static validateOrder(children: HtmlElement[], rules: PermittedOrder | null, cb: (node: HtmlElement, prev: HtmlElement) => void): boolean;
|
|
3278
|
-
/**
|
|
3279
|
-
* Validate element ancestors.
|
|
3280
|
-
*
|
|
3281
|
-
* Check if an element has the required set of elements. At least one of the
|
|
3282
|
-
* selectors must match.
|
|
3283
|
-
*/
|
|
3284
|
-
static validateAncestors(node: HtmlElement, rules: RequiredAncestors | null): boolean;
|
|
3285
|
-
/**
|
|
3286
|
-
* Validate element required content.
|
|
3287
|
-
*
|
|
3288
|
-
* Check if an element has the required set of elements. At least one of the
|
|
3289
|
-
* selectors must match.
|
|
3290
|
-
*
|
|
3291
|
-
* Returns `[]` when valid or a list of required but missing tagnames or
|
|
3292
|
-
* categories.
|
|
3293
|
-
*/
|
|
3294
|
-
static validateRequiredContent(node: HtmlElement, rules: RequiredContent | null): CategoryOrTag[];
|
|
3295
|
-
/**
|
|
3296
|
-
* Test if an attribute has an allowed value and/or format.
|
|
3297
|
-
*
|
|
3298
|
-
* @param attr - Attribute to test.
|
|
3299
|
-
* @param rules - Element attribute metadta.
|
|
3300
|
-
* @returns `true` if attribute passes all tests.
|
|
3301
|
-
*/
|
|
3302
|
-
static validateAttribute(attr: Attribute, rules: Record<string, MetaAttribute | undefined>): boolean;
|
|
3303
|
-
private static validateAttributeValue;
|
|
3304
|
-
private static validatePermittedRule;
|
|
3305
|
-
/**
|
|
3306
|
-
* Validate node against a content category.
|
|
3307
|
-
*
|
|
3308
|
-
* When matching parent nodes against permitted parents use the superset
|
|
3309
|
-
* parameter to also match for `@flow`. E.g. if a node expects a `@phrasing`
|
|
3310
|
-
* parent it should also allow `@flow` parent since `@phrasing` is a subset of
|
|
3311
|
-
* `@flow`.
|
|
3312
|
-
*
|
|
3313
|
-
* @param node - The node to test against
|
|
3314
|
-
* @param category - Name of category with `@` prefix or tag name.
|
|
3315
|
-
* @param defaultMatch - The default return value when node categories is not known.
|
|
3316
|
-
*/
|
|
3317
|
-
static validatePermittedCategory(node: HtmlElement, category: string, defaultMatch: boolean): boolean;
|
|
3318
|
-
}
|
|
3319
|
-
|
|
3320
3179
|
/** @public */
|
|
3321
3180
|
export declare const version: string;
|
|
3322
3181
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-validate",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "Offline HTML5 validator and linter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"html",
|
|
@@ -99,11 +99,11 @@
|
|
|
99
99
|
"semver": "^7.0.0"
|
|
100
100
|
},
|
|
101
101
|
"peerDependencies": {
|
|
102
|
-
"@jest/globals": "^
|
|
103
|
-
"jest": "^
|
|
104
|
-
"jest-diff": "^
|
|
105
|
-
"jest-snapshot": "^
|
|
106
|
-
"vitest": "^
|
|
102
|
+
"@jest/globals": "^29.0.3 || ^30.0.0",
|
|
103
|
+
"jest": "^29.0.3 || ^30.0.0",
|
|
104
|
+
"jest-diff": "^29.0.3 || ^30.0.0",
|
|
105
|
+
"jest-snapshot": "^29.0.3 || ^30.0.0",
|
|
106
|
+
"vitest": "^3.0.0 || ^4.0.1"
|
|
107
107
|
},
|
|
108
108
|
"peerDependenciesMeta": {
|
|
109
109
|
"@jest/globals": {
|
|
@@ -123,6 +123,6 @@
|
|
|
123
123
|
}
|
|
124
124
|
},
|
|
125
125
|
"engines": {
|
|
126
|
-
"node": "^
|
|
126
|
+
"node": "^22.16.0 || >= 24.0.0"
|
|
127
127
|
}
|
|
128
128
|
}
|