html-validate 7.15.2 → 7.16.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/dist/cjs/browser.js +6 -7
- package/dist/cjs/browser.js.map +1 -1
- package/dist/cjs/cli.js +3 -6
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/core.js +76 -58
- package/dist/cjs/core.js.map +1 -1
- package/dist/cjs/html-validate.js +5 -6
- package/dist/cjs/html-validate.js.map +1 -1
- package/dist/cjs/index.js +6 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/jest-lib.js +2 -8
- package/dist/cjs/jest-lib.js.map +1 -1
- package/dist/cjs/jest.js +4 -5
- package/dist/cjs/jest.js.map +1 -1
- package/dist/es/browser.js +6 -7
- package/dist/es/browser.js.map +1 -1
- package/dist/es/cli.js +2 -5
- package/dist/es/cli.js.map +1 -1
- package/dist/es/core.js +73 -54
- package/dist/es/core.js.map +1 -1
- package/dist/es/html-validate.js +6 -7
- package/dist/es/html-validate.js.map +1 -1
- package/dist/es/index.js +5 -6
- package/dist/es/index.js.map +1 -1
- package/dist/es/jest-lib.js +2 -8
- package/dist/es/jest-lib.js.map +1 -1
- package/dist/es/jest.js +4 -5
- package/dist/es/jest.js.map +1 -1
- package/dist/types/browser.d.ts +15 -5
- package/dist/types/index.d.ts +16 -6
- package/package.json +5 -5
package/dist/es/core.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
import betterAjvErrors from '@sidvind/better-ajv-errors';
|
|
3
|
-
import { i as isKeywordIgnored, C as CaseStyle, n as naturalJoin, c as classifyNodeText, T as TextClassification, h as hasAltText, p as partition, a as isHTMLHidden, b as isAriaHidden, d as hasAccessibleName, k as keywordPatternMatcher, e as inAccessibilityTree, f as hasAriaLabel } from './rules-helper.js';
|
|
4
|
-
import Ajv from 'ajv';
|
|
5
|
-
import deepmerge from 'deepmerge';
|
|
6
2
|
import * as espree from 'espree';
|
|
7
3
|
import * as walk from 'acorn-walk';
|
|
8
4
|
import path from 'path';
|
|
9
|
-
import 'url';
|
|
10
5
|
import semver from 'semver';
|
|
11
6
|
import kleur from 'kleur';
|
|
7
|
+
import Ajv from 'ajv';
|
|
8
|
+
import deepmerge from 'deepmerge';
|
|
12
9
|
import { e as entities$1, h as html5, b as bundledElements } from './elements.js';
|
|
13
10
|
import { createRequire } from 'module';
|
|
11
|
+
import { i as isKeywordIgnored, C as CaseStyle, n as naturalJoin, c as classifyNodeText, T as TextClassification, h as hasAltText, p as partition, a as isHTMLHidden, b as isAriaHidden, d as hasAccessibleName, k as keywordPatternMatcher, e as inAccessibilityTree, f as hasAriaLabel } from './rules-helper.js';
|
|
12
|
+
import betterAjvErrors from '@sidvind/better-ajv-errors';
|
|
14
13
|
import { codeFrameColumns } from '@babel/code-frame';
|
|
15
|
-
import
|
|
14
|
+
import { stylish as stylish$2 } from '@html-validate/stylish';
|
|
16
15
|
|
|
17
16
|
const $schema$2 = "http://json-schema.org/draft-06/schema#";
|
|
18
17
|
const $id$2 = "http://json-schema.org/draft-06/schema#";
|
|
@@ -9369,6 +9368,7 @@ const bundledRules$1 = {
|
|
|
9369
9368
|
"wcag/h67": H67,
|
|
9370
9369
|
"wcag/h71": H71,
|
|
9371
9370
|
};
|
|
9371
|
+
var WCAG = bundledRules$1;
|
|
9372
9372
|
|
|
9373
9373
|
const bundledRules = {
|
|
9374
9374
|
"allowed-links": AllowedLinks,
|
|
@@ -9447,8 +9447,9 @@ const bundledRules = {
|
|
|
9447
9447
|
void: Void,
|
|
9448
9448
|
"void-content": VoidContent,
|
|
9449
9449
|
"void-style": VoidStyle,
|
|
9450
|
-
...
|
|
9450
|
+
...WCAG,
|
|
9451
9451
|
};
|
|
9452
|
+
var rules = bundledRules;
|
|
9452
9453
|
|
|
9453
9454
|
var defaultConfig = {};
|
|
9454
9455
|
|
|
@@ -9478,6 +9479,7 @@ const config$3 = {
|
|
|
9478
9479
|
"wcag/h71": "error",
|
|
9479
9480
|
},
|
|
9480
9481
|
};
|
|
9482
|
+
var a11y = config$3;
|
|
9481
9483
|
|
|
9482
9484
|
const config$2 = {
|
|
9483
9485
|
rules: {
|
|
@@ -9488,6 +9490,7 @@ const config$2 = {
|
|
|
9488
9490
|
"require-sri": "error",
|
|
9489
9491
|
},
|
|
9490
9492
|
};
|
|
9493
|
+
var document = config$2;
|
|
9491
9494
|
|
|
9492
9495
|
const config$1 = {
|
|
9493
9496
|
rules: {
|
|
@@ -9564,6 +9567,7 @@ const config$1 = {
|
|
|
9564
9567
|
"wcag/h71": "error",
|
|
9565
9568
|
},
|
|
9566
9569
|
};
|
|
9570
|
+
var recommended = config$1;
|
|
9567
9571
|
|
|
9568
9572
|
const config = {
|
|
9569
9573
|
rules: {
|
|
@@ -9599,20 +9603,22 @@ const config = {
|
|
|
9599
9603
|
"void-content": "error",
|
|
9600
9604
|
},
|
|
9601
9605
|
};
|
|
9606
|
+
var standard = config;
|
|
9602
9607
|
|
|
9603
9608
|
/**
|
|
9604
9609
|
* @internal
|
|
9605
9610
|
*/
|
|
9606
9611
|
const presets = {
|
|
9607
|
-
"html-validate:a11y":
|
|
9608
|
-
"html-validate:document":
|
|
9609
|
-
"html-validate:recommended":
|
|
9610
|
-
"html-validate:standard":
|
|
9612
|
+
"html-validate:a11y": a11y,
|
|
9613
|
+
"html-validate:document": document,
|
|
9614
|
+
"html-validate:recommended": recommended,
|
|
9615
|
+
"html-validate:standard": standard,
|
|
9611
9616
|
/* @deprecated aliases */
|
|
9612
|
-
"htmlvalidate:recommended":
|
|
9613
|
-
"htmlvalidate:document":
|
|
9614
|
-
"html-validate:a17y":
|
|
9617
|
+
"htmlvalidate:recommended": recommended,
|
|
9618
|
+
"htmlvalidate:document": document,
|
|
9619
|
+
"html-validate:a17y": a11y,
|
|
9615
9620
|
};
|
|
9621
|
+
var Presets = presets;
|
|
9616
9622
|
|
|
9617
9623
|
/**
|
|
9618
9624
|
* A resolved configuration is a normalized configuration with all extends,
|
|
@@ -9621,11 +9627,22 @@ const presets = {
|
|
|
9621
9627
|
* @public
|
|
9622
9628
|
*/
|
|
9623
9629
|
class ResolvedConfig {
|
|
9624
|
-
|
|
9630
|
+
/**
|
|
9631
|
+
* @internal
|
|
9632
|
+
*/
|
|
9633
|
+
constructor({ metaTable, plugins, rules, transformers }, original) {
|
|
9625
9634
|
this.metaTable = metaTable;
|
|
9626
9635
|
this.plugins = plugins;
|
|
9627
9636
|
this.rules = rules;
|
|
9628
9637
|
this.transformers = transformers;
|
|
9638
|
+
this.original = original;
|
|
9639
|
+
}
|
|
9640
|
+
/**
|
|
9641
|
+
* Returns the (merged) configuration data used to create this resolved
|
|
9642
|
+
* configuration.
|
|
9643
|
+
*/
|
|
9644
|
+
getConfigData() {
|
|
9645
|
+
return this.original;
|
|
9629
9646
|
}
|
|
9630
9647
|
getMetaTable() {
|
|
9631
9648
|
return this.metaTable;
|
|
@@ -9816,7 +9833,7 @@ class Config {
|
|
|
9816
9833
|
if (configData.rules) {
|
|
9817
9834
|
const normalizedRules = Config.getRulesObject(configData.rules);
|
|
9818
9835
|
for (const [ruleId, [, ruleOptions]] of normalizedRules.entries()) {
|
|
9819
|
-
const cls =
|
|
9836
|
+
const cls = rules[ruleId];
|
|
9820
9837
|
const path = `/rules/${ruleId}/1`;
|
|
9821
9838
|
Rule.validateOptions(cls, ruleId, path, ruleOptions, filename, configData);
|
|
9822
9839
|
}
|
|
@@ -10040,7 +10057,7 @@ class Config {
|
|
|
10040
10057
|
loadConfigurations(plugins) {
|
|
10041
10058
|
const configs = new Map();
|
|
10042
10059
|
/* builtin presets */
|
|
10043
|
-
for (const [name, config] of Object.entries(
|
|
10060
|
+
for (const [name, config] of Object.entries(Presets)) {
|
|
10044
10061
|
Config.validate(config, name);
|
|
10045
10062
|
configs.set(name, config);
|
|
10046
10063
|
}
|
|
@@ -10089,7 +10106,7 @@ class Config {
|
|
|
10089
10106
|
* @public
|
|
10090
10107
|
*/
|
|
10091
10108
|
resolve() {
|
|
10092
|
-
return new ResolvedConfig(this.resolveData());
|
|
10109
|
+
return new ResolvedConfig(this.resolveData(), this.get());
|
|
10093
10110
|
}
|
|
10094
10111
|
/**
|
|
10095
10112
|
* Same as [[resolve]] but returns the raw configuration data instead of
|
|
@@ -11125,7 +11142,7 @@ class Engine {
|
|
|
11125
11142
|
/* initialize plugins and rules */
|
|
11126
11143
|
const result = this.initPlugins(this.config);
|
|
11127
11144
|
this.availableRules = {
|
|
11128
|
-
...
|
|
11145
|
+
...rules,
|
|
11129
11146
|
...result.availableRules,
|
|
11130
11147
|
};
|
|
11131
11148
|
}
|
|
@@ -11511,11 +11528,11 @@ class StaticConfigLoader extends ConfigLoader {
|
|
|
11511
11528
|
const override = this.loadFromObject(configOverride || {});
|
|
11512
11529
|
if (override.isRootFound()) {
|
|
11513
11530
|
override.init();
|
|
11514
|
-
return override;
|
|
11531
|
+
return override.resolve();
|
|
11515
11532
|
}
|
|
11516
11533
|
const merged = this.globalConfig.merge(override);
|
|
11517
11534
|
merged.init();
|
|
11518
|
-
return merged;
|
|
11535
|
+
return merged.resolve();
|
|
11519
11536
|
}
|
|
11520
11537
|
flushCache() {
|
|
11521
11538
|
/* do nothing */
|
|
@@ -11575,9 +11592,8 @@ class HtmlValidate {
|
|
|
11575
11592
|
*/
|
|
11576
11593
|
validateSource(input, configOverride) {
|
|
11577
11594
|
const config = this.getConfigFor(input.filename, configOverride);
|
|
11578
|
-
const
|
|
11579
|
-
const
|
|
11580
|
-
const engine = new Engine(resolved, Parser);
|
|
11595
|
+
const source = config.transformSource(input);
|
|
11596
|
+
const engine = new Engine(config, Parser);
|
|
11581
11597
|
return engine.lint(source);
|
|
11582
11598
|
}
|
|
11583
11599
|
/**
|
|
@@ -11589,9 +11605,8 @@ class HtmlValidate {
|
|
|
11589
11605
|
*/
|
|
11590
11606
|
validateFile(filename) {
|
|
11591
11607
|
const config = this.getConfigFor(filename);
|
|
11592
|
-
const
|
|
11593
|
-
const
|
|
11594
|
-
const engine = new Engine(resolved, Parser);
|
|
11608
|
+
const source = config.transformFilename(filename);
|
|
11609
|
+
const engine = new Engine(config, Parser);
|
|
11595
11610
|
return engine.lint(source);
|
|
11596
11611
|
}
|
|
11597
11612
|
/**
|
|
@@ -11621,8 +11636,7 @@ class HtmlValidate {
|
|
|
11621
11636
|
}
|
|
11622
11637
|
/* test if there is a matching transformer */
|
|
11623
11638
|
const config = this.getConfigFor(filename);
|
|
11624
|
-
|
|
11625
|
-
return resolved.canTransform(filename);
|
|
11639
|
+
return config.canTransform(filename);
|
|
11626
11640
|
}
|
|
11627
11641
|
/**
|
|
11628
11642
|
* Tokenize filename and output all tokens.
|
|
@@ -11634,9 +11648,8 @@ class HtmlValidate {
|
|
|
11634
11648
|
*/
|
|
11635
11649
|
dumpTokens(filename) {
|
|
11636
11650
|
const config = this.getConfigFor(filename);
|
|
11637
|
-
const
|
|
11638
|
-
const
|
|
11639
|
-
const engine = new Engine(resolved, Parser);
|
|
11651
|
+
const source = config.transformFilename(filename);
|
|
11652
|
+
const engine = new Engine(config, Parser);
|
|
11640
11653
|
return engine.dumpTokens(source);
|
|
11641
11654
|
}
|
|
11642
11655
|
/**
|
|
@@ -11649,9 +11662,8 @@ class HtmlValidate {
|
|
|
11649
11662
|
*/
|
|
11650
11663
|
dumpEvents(filename) {
|
|
11651
11664
|
const config = this.getConfigFor(filename);
|
|
11652
|
-
const
|
|
11653
|
-
const
|
|
11654
|
-
const engine = new Engine(resolved, Parser);
|
|
11665
|
+
const source = config.transformFilename(filename);
|
|
11666
|
+
const engine = new Engine(config, Parser);
|
|
11655
11667
|
return engine.dumpEvents(source);
|
|
11656
11668
|
}
|
|
11657
11669
|
/**
|
|
@@ -11664,9 +11676,8 @@ class HtmlValidate {
|
|
|
11664
11676
|
*/
|
|
11665
11677
|
dumpTree(filename) {
|
|
11666
11678
|
const config = this.getConfigFor(filename);
|
|
11667
|
-
const
|
|
11668
|
-
const
|
|
11669
|
-
const engine = new Engine(resolved, Parser);
|
|
11679
|
+
const source = config.transformFilename(filename);
|
|
11680
|
+
const engine = new Engine(config, Parser);
|
|
11670
11681
|
return engine.dumpTree(source);
|
|
11671
11682
|
}
|
|
11672
11683
|
/**
|
|
@@ -11679,8 +11690,7 @@ class HtmlValidate {
|
|
|
11679
11690
|
*/
|
|
11680
11691
|
dumpSource(filename) {
|
|
11681
11692
|
const config = this.getConfigFor(filename);
|
|
11682
|
-
const
|
|
11683
|
-
const sources = resolved.transformFilename(filename);
|
|
11693
|
+
const sources = config.transformFilename(filename);
|
|
11684
11694
|
return sources.reduce((result, source) => {
|
|
11685
11695
|
result.push(`Source ${source.filename}@${source.line}:${source.column} (offset: ${source.offset})`);
|
|
11686
11696
|
if (source.transformedBy) {
|
|
@@ -11744,7 +11754,7 @@ class HtmlValidate {
|
|
|
11744
11754
|
*/
|
|
11745
11755
|
getRuleDocumentation(ruleId, config = null, context = null) {
|
|
11746
11756
|
const c = config || this.getConfigFor("inline");
|
|
11747
|
-
const engine = new Engine(c
|
|
11757
|
+
const engine = new Engine(c, Parser);
|
|
11748
11758
|
return engine.getRuleDocumentation(ruleId, context);
|
|
11749
11759
|
}
|
|
11750
11760
|
/**
|
|
@@ -11755,7 +11765,7 @@ class HtmlValidate {
|
|
|
11755
11765
|
*/
|
|
11756
11766
|
getParserFor(source) {
|
|
11757
11767
|
const config = this.getConfigFor(source.filename);
|
|
11758
|
-
return new Parser(config
|
|
11768
|
+
return new Parser(config);
|
|
11759
11769
|
}
|
|
11760
11770
|
/**
|
|
11761
11771
|
* Get configuration for given filename.
|
|
@@ -11767,7 +11777,12 @@ class HtmlValidate {
|
|
|
11767
11777
|
* @param configOverride - Configuration to apply last.
|
|
11768
11778
|
*/
|
|
11769
11779
|
getConfigFor(filename, configOverride) {
|
|
11770
|
-
|
|
11780
|
+
const config = this.configLoader.getConfigFor(filename, configOverride);
|
|
11781
|
+
/* for backwards compatibility only */
|
|
11782
|
+
if (config instanceof Config) {
|
|
11783
|
+
return config.resolve();
|
|
11784
|
+
}
|
|
11785
|
+
return config;
|
|
11771
11786
|
}
|
|
11772
11787
|
/**
|
|
11773
11788
|
* Flush configuration cache. Clears full cache unless a filename is given.
|
|
@@ -11786,7 +11801,7 @@ class HtmlValidate {
|
|
|
11786
11801
|
/** @public */
|
|
11787
11802
|
const name = "html-validate";
|
|
11788
11803
|
/** @public */
|
|
11789
|
-
const version = "7.
|
|
11804
|
+
const version = "7.16.0";
|
|
11790
11805
|
/** @public */
|
|
11791
11806
|
const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
|
|
11792
11807
|
|
|
@@ -11832,7 +11847,7 @@ function compatibilityCheck(name, declared, options) {
|
|
|
11832
11847
|
return false;
|
|
11833
11848
|
}
|
|
11834
11849
|
|
|
11835
|
-
const ruleIds = new Set(Object.keys(
|
|
11850
|
+
const ruleIds = new Set(Object.keys(rules));
|
|
11836
11851
|
/**
|
|
11837
11852
|
* Returns true if given ruleId is an existing builtin rule. It does not handle
|
|
11838
11853
|
* rules loaded via plugins.
|
|
@@ -11904,19 +11919,19 @@ class FileSystemConfigLoader extends ConfigLoader {
|
|
|
11904
11919
|
const override = this.loadFromObject(configOverride || {});
|
|
11905
11920
|
if (override.isRootFound()) {
|
|
11906
11921
|
override.init();
|
|
11907
|
-
return override;
|
|
11922
|
+
return override.resolve();
|
|
11908
11923
|
}
|
|
11909
11924
|
/* special case when the global configuration is marked as root, should not
|
|
11910
11925
|
* try to load and more configuration files */
|
|
11911
11926
|
if (this.globalConfig.isRootFound()) {
|
|
11912
11927
|
const merged = this.globalConfig.merge(override);
|
|
11913
11928
|
merged.init();
|
|
11914
|
-
return merged;
|
|
11929
|
+
return merged.resolve();
|
|
11915
11930
|
}
|
|
11916
11931
|
const config = this.fromFilename(filename);
|
|
11917
11932
|
const merged = config ? config.merge(override) : this.globalConfig.merge(override);
|
|
11918
11933
|
merged.init();
|
|
11919
|
-
return merged;
|
|
11934
|
+
return merged.resolve();
|
|
11920
11935
|
}
|
|
11921
11936
|
/**
|
|
11922
11937
|
* Flush configuration cache.
|
|
@@ -12028,6 +12043,7 @@ function checkstyleFormatter(results) {
|
|
|
12028
12043
|
return output;
|
|
12029
12044
|
}
|
|
12030
12045
|
const formatter$3 = checkstyleFormatter;
|
|
12046
|
+
var checkstyle = formatter$3;
|
|
12031
12047
|
|
|
12032
12048
|
const defaults = {
|
|
12033
12049
|
showLink: true,
|
|
@@ -12163,6 +12179,7 @@ function jsonFormatter(results) {
|
|
|
12163
12179
|
return JSON.stringify(results);
|
|
12164
12180
|
}
|
|
12165
12181
|
const formatter$2 = jsonFormatter;
|
|
12182
|
+
var json = formatter$2;
|
|
12166
12183
|
|
|
12167
12184
|
function linkSummary(results) {
|
|
12168
12185
|
const urls = results.reduce((result, it) => {
|
|
@@ -12179,7 +12196,7 @@ function linkSummary(results) {
|
|
|
12179
12196
|
return `\n${kleur.bold("More information")}:\n${lines.join("")}\n`;
|
|
12180
12197
|
}
|
|
12181
12198
|
function stylish(results) {
|
|
12182
|
-
const errors =
|
|
12199
|
+
const errors = stylish$2(results.map((it) => ({
|
|
12183
12200
|
...it,
|
|
12184
12201
|
fixableErrorCount: 0,
|
|
12185
12202
|
fixableWarningCount: 0,
|
|
@@ -12188,6 +12205,7 @@ function stylish(results) {
|
|
|
12188
12205
|
return `${errors}${links}`;
|
|
12189
12206
|
}
|
|
12190
12207
|
const formatter$1 = stylish;
|
|
12208
|
+
var stylish$1 = formatter$1;
|
|
12191
12209
|
|
|
12192
12210
|
function textFormatter(results) {
|
|
12193
12211
|
let output = "";
|
|
@@ -12215,18 +12233,19 @@ function textFormatter(results) {
|
|
|
12215
12233
|
return total > 0 ? output : "";
|
|
12216
12234
|
}
|
|
12217
12235
|
const formatter = textFormatter;
|
|
12236
|
+
var text = formatter;
|
|
12218
12237
|
|
|
12219
12238
|
const availableFormatters = {
|
|
12220
|
-
checkstyle
|
|
12239
|
+
checkstyle,
|
|
12221
12240
|
codeframe,
|
|
12222
|
-
json
|
|
12223
|
-
stylish:
|
|
12224
|
-
text
|
|
12241
|
+
json,
|
|
12242
|
+
stylish: stylish$1,
|
|
12243
|
+
text,
|
|
12225
12244
|
};
|
|
12226
12245
|
function getFormatter(name) {
|
|
12227
12246
|
var _a;
|
|
12228
12247
|
return (_a = availableFormatters[name]) !== null && _a !== void 0 ? _a : null;
|
|
12229
12248
|
}
|
|
12230
12249
|
|
|
12231
|
-
export { Attribute as A, isTextNode as B, Config as C, DynamicValue as D, EventHandler as E, FileSystemConfigLoader as F, isElementNode as G, HtmlValidate as H, generateIdSelector as I, name as J, bugs as K, MetaTable as M, NodeClosed as N,
|
|
12250
|
+
export { Attribute as A, isTextNode as B, Config as C, DynamicValue as D, EventHandler as E, FileSystemConfigLoader as F, isElementNode as G, HtmlValidate as H, generateIdSelector as I, name as J, bugs as K, MetaTable as M, NodeClosed as N, Presets as P, ResolvedConfig as R, Severity as S, TextNode as T, UserError as U, Validator as V, WrappedError as W, ConfigError as a, ConfigLoader as b, StaticConfigLoader as c, DOMTokenList as d, HtmlElement as e, DOMNode as f, DOMTree as g, NodeType as h, SchemaValidationError as i, NestedError as j, TextContent$1 as k, MetaCopyableProperty as l, Rule as m, Reporter as n, TemplateExtractor as o, definePlugin as p, Parser as q, ruleExists as r, sliceLocation as s, getFormatter as t, legacyRequire as u, version as v, ensureError as w, configDataFromFile as x, compatibilityCheck as y, codeframe as z };
|
|
12232
12251
|
//# sourceMappingURL=core.js.map
|