html-validate 7.18.1 → 8.0.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/dist/cjs/browser.js +4 -6
- package/dist/cjs/browser.js.map +1 -1
- package/dist/cjs/cli.js +26 -11
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/core.js +448 -726
- package/dist/cjs/core.js.map +1 -1
- package/dist/cjs/html-validate.js +4 -3
- package/dist/cjs/html-validate.js.map +1 -1
- package/dist/cjs/index.js +9 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/jest-lib.js +5 -4
- package/dist/cjs/jest-lib.js.map +1 -1
- package/dist/cjs/jest.js +6 -5
- package/dist/cjs/jest.js.map +1 -1
- package/dist/cjs/nodejs.js +320 -0
- package/dist/cjs/nodejs.js.map +1 -0
- package/dist/cjs/tsdoc-metadata.json +1 -1
- package/dist/es/browser.js +4 -7
- package/dist/es/browser.js.map +1 -1
- package/dist/es/cli.js +25 -10
- package/dist/es/cli.js.map +1 -1
- package/dist/es/core.js +410 -666
- package/dist/es/core.js.map +1 -1
- package/dist/es/html-validate.js +6 -5
- package/dist/es/html-validate.js.map +1 -1
- package/dist/es/index.js +8 -7
- package/dist/es/index.js.map +1 -1
- package/dist/es/jest-lib.js +4 -3
- package/dist/es/jest-lib.js.map +1 -1
- package/dist/es/jest.js +7 -6
- package/dist/es/jest.js.map +1 -1
- package/dist/es/nodejs.js +312 -0
- package/dist/es/nodejs.js.map +1 -0
- package/dist/es/rules-helper.js +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/types/browser.d.ts +343 -91
- package/dist/types/index.d.ts +402 -94
- package/package.json +12 -15
package/dist/es/core.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import * as espree from 'espree';
|
|
3
|
-
import * as walk from 'acorn-walk';
|
|
4
1
|
import path from 'path';
|
|
5
|
-
import semver from 'semver';
|
|
6
|
-
import kleur from 'kleur';
|
|
7
2
|
import Ajv from 'ajv';
|
|
8
3
|
import deepmerge from 'deepmerge';
|
|
9
4
|
import { e as entities$1, h as html5, b as bundledElements } from './elements.js';
|
|
10
|
-
import
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import semver from 'semver';
|
|
7
|
+
import kleur from 'kleur';
|
|
11
8
|
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
9
|
import betterAjvErrors from '@sidvind/better-ajv-errors';
|
|
13
10
|
import { codeFrameColumns } from '@babel/code-frame';
|
|
@@ -3157,232 +3154,11 @@ var configurationSchema = {
|
|
|
3157
3154
|
properties: properties
|
|
3158
3155
|
};
|
|
3159
3156
|
|
|
3160
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion -- declarations say
|
|
3161
|
-
* location fields are optional but they are always present when `{loc: true}` */
|
|
3162
|
-
function joinTemplateLiteral(nodes) {
|
|
3163
|
-
let offset = nodes[0].start + 1;
|
|
3164
|
-
let output = "";
|
|
3165
|
-
for (const node of nodes) {
|
|
3166
|
-
output += " ".repeat(node.start + 1 - offset);
|
|
3167
|
-
output += node.value.raw;
|
|
3168
|
-
offset = node.end - 2;
|
|
3169
|
-
}
|
|
3170
|
-
return output;
|
|
3171
|
-
}
|
|
3172
|
-
/**
|
|
3173
|
-
* Compute source offset from line and column and the given markup.
|
|
3174
|
-
*
|
|
3175
|
-
* @param position - Line and column.
|
|
3176
|
-
* @param data - Source markup.
|
|
3177
|
-
* @returns The byte offset into the markup which line and column corresponds to.
|
|
3178
|
-
*/
|
|
3179
|
-
function computeOffset(position, data) {
|
|
3180
|
-
let line = position.line;
|
|
3181
|
-
let column = position.column + 1;
|
|
3182
|
-
for (let i = 0; i < data.length; i++) {
|
|
3183
|
-
if (line > 1) {
|
|
3184
|
-
/* not yet on the correct line */
|
|
3185
|
-
if (data[i] === "\n") {
|
|
3186
|
-
line--;
|
|
3187
|
-
}
|
|
3188
|
-
}
|
|
3189
|
-
else if (column > 1) {
|
|
3190
|
-
/* not yet on the correct column */
|
|
3191
|
-
column--;
|
|
3192
|
-
}
|
|
3193
|
-
else {
|
|
3194
|
-
/* line/column found, return current position */
|
|
3195
|
-
return i;
|
|
3196
|
-
}
|
|
3197
|
-
}
|
|
3198
|
-
/* istanbul ignore next: should never reach this line unless espree passes bad
|
|
3199
|
-
* positions, no sane way to test */
|
|
3200
|
-
throw new Error("Failed to compute location offset from position");
|
|
3201
|
-
}
|
|
3202
|
-
function extractLiteral(node, filename, data) {
|
|
3203
|
-
switch (node.type) {
|
|
3204
|
-
/* ignored nodes */
|
|
3205
|
-
case "FunctionExpression":
|
|
3206
|
-
case "Identifier":
|
|
3207
|
-
return null;
|
|
3208
|
-
case "Literal":
|
|
3209
|
-
if (typeof node.value !== "string") {
|
|
3210
|
-
return null;
|
|
3211
|
-
}
|
|
3212
|
-
return {
|
|
3213
|
-
data: node.value.toString(),
|
|
3214
|
-
filename,
|
|
3215
|
-
line: node.loc.start.line,
|
|
3216
|
-
column: node.loc.start.column + 1,
|
|
3217
|
-
offset: computeOffset(node.loc.start, data) + 1,
|
|
3218
|
-
};
|
|
3219
|
-
case "TemplateLiteral":
|
|
3220
|
-
return {
|
|
3221
|
-
data: joinTemplateLiteral(node.quasis),
|
|
3222
|
-
filename,
|
|
3223
|
-
line: node.loc.start.line,
|
|
3224
|
-
column: node.loc.start.column + 1,
|
|
3225
|
-
offset: computeOffset(node.loc.start, data) + 1,
|
|
3226
|
-
};
|
|
3227
|
-
case "TaggedTemplateExpression":
|
|
3228
|
-
return {
|
|
3229
|
-
data: joinTemplateLiteral(node.quasi.quasis),
|
|
3230
|
-
filename,
|
|
3231
|
-
line: node.quasi.loc.start.line,
|
|
3232
|
-
column: node.quasi.loc.start.column + 1,
|
|
3233
|
-
offset: computeOffset(node.quasi.loc.start, data) + 1,
|
|
3234
|
-
};
|
|
3235
|
-
case "ArrowFunctionExpression": {
|
|
3236
|
-
const whitelist = ["Literal", "TemplateLiteral"];
|
|
3237
|
-
if (whitelist.includes(node.body.type)) {
|
|
3238
|
-
return extractLiteral(node.body, filename, data);
|
|
3239
|
-
}
|
|
3240
|
-
else {
|
|
3241
|
-
return null;
|
|
3242
|
-
}
|
|
3243
|
-
}
|
|
3244
|
-
/* istanbul ignore next: this only provides a better error, all currently known nodes are tested */
|
|
3245
|
-
default: {
|
|
3246
|
-
const loc = node.loc.start;
|
|
3247
|
-
const context = `${filename}:${loc.line}:${loc.column}`;
|
|
3248
|
-
throw new Error(`Unhandled node type "${node.type}" at "${context}" in extractLiteral`);
|
|
3249
|
-
}
|
|
3250
|
-
}
|
|
3251
|
-
}
|
|
3252
|
-
function compareKey(node, key, filename) {
|
|
3253
|
-
switch (node.type) {
|
|
3254
|
-
case "Identifier":
|
|
3255
|
-
return node.name === key;
|
|
3256
|
-
case "Literal":
|
|
3257
|
-
return node.value === key;
|
|
3258
|
-
/* istanbul ignore next: this only provides a better error, all currently known nodes are tested */
|
|
3259
|
-
default: {
|
|
3260
|
-
const loc = node.loc.start;
|
|
3261
|
-
const context = `${filename}:${loc.line}:${loc.column}`;
|
|
3262
|
-
throw new Error(`Unhandled node type "${node.type}" at "${context}" in compareKey`);
|
|
3263
|
-
}
|
|
3264
|
-
}
|
|
3265
|
-
}
|
|
3266
|
-
/**
|
|
3267
|
-
* @public
|
|
3268
|
-
*/
|
|
3269
|
-
class TemplateExtractor {
|
|
3270
|
-
constructor(ast, filename, data) {
|
|
3271
|
-
this.ast = ast;
|
|
3272
|
-
this.filename = filename;
|
|
3273
|
-
this.data = data;
|
|
3274
|
-
}
|
|
3275
|
-
static fromFilename(filename) {
|
|
3276
|
-
const source = fs.readFileSync(filename, "utf-8");
|
|
3277
|
-
const ast = espree.parse(source, {
|
|
3278
|
-
ecmaVersion: 2017,
|
|
3279
|
-
sourceType: "module",
|
|
3280
|
-
loc: true,
|
|
3281
|
-
});
|
|
3282
|
-
return new TemplateExtractor(ast, filename, source);
|
|
3283
|
-
}
|
|
3284
|
-
/**
|
|
3285
|
-
* Create a new [[TemplateExtractor]] from javascript source code.
|
|
3286
|
-
*
|
|
3287
|
-
* `Source` offsets will be relative to the string, i.e. offset 0 is the first
|
|
3288
|
-
* character of the string. If the string is only a subset of a larger string
|
|
3289
|
-
* the offsets must be adjusted manually.
|
|
3290
|
-
*
|
|
3291
|
-
* @param source - Source code.
|
|
3292
|
-
* @param filename - Optional filename to set in the resulting
|
|
3293
|
-
* `Source`. Defauls to `"inline"`.
|
|
3294
|
-
*/
|
|
3295
|
-
static fromString(source, filename) {
|
|
3296
|
-
const ast = espree.parse(source, {
|
|
3297
|
-
ecmaVersion: 2017,
|
|
3298
|
-
sourceType: "module",
|
|
3299
|
-
loc: true,
|
|
3300
|
-
});
|
|
3301
|
-
return new TemplateExtractor(ast, filename || "inline", source);
|
|
3302
|
-
}
|
|
3303
|
-
/**
|
|
3304
|
-
* Convenience function to create a [[Source]] instance from an existing file.
|
|
3305
|
-
*
|
|
3306
|
-
* @param filename - Filename with javascript source code. The file must exist
|
|
3307
|
-
* and be readable by the user.
|
|
3308
|
-
* @returns An array of Source's suitable for passing to [[Engine]] linting
|
|
3309
|
-
* functions.
|
|
3310
|
-
*/
|
|
3311
|
-
static createSource(filename) {
|
|
3312
|
-
const data = fs.readFileSync(filename, "utf-8");
|
|
3313
|
-
return [
|
|
3314
|
-
{
|
|
3315
|
-
column: 1,
|
|
3316
|
-
data,
|
|
3317
|
-
filename,
|
|
3318
|
-
line: 1,
|
|
3319
|
-
offset: 0,
|
|
3320
|
-
},
|
|
3321
|
-
];
|
|
3322
|
-
}
|
|
3323
|
-
/**
|
|
3324
|
-
* Extract object properties.
|
|
3325
|
-
*
|
|
3326
|
-
* Given a key `"template"` this method finds all objects literals with a
|
|
3327
|
-
* `"template"` property and creates a [[Source]] instance with proper offsets
|
|
3328
|
-
* with the value of the property. For instance:
|
|
3329
|
-
*
|
|
3330
|
-
* ```
|
|
3331
|
-
* const myObj = {
|
|
3332
|
-
* foo: 'bar',
|
|
3333
|
-
* };
|
|
3334
|
-
* ```
|
|
3335
|
-
*
|
|
3336
|
-
* The above snippet would yield a `Source` with the content `bar`.
|
|
3337
|
-
*
|
|
3338
|
-
*/
|
|
3339
|
-
extractObjectProperty(key) {
|
|
3340
|
-
const result = [];
|
|
3341
|
-
const { filename, data } = this;
|
|
3342
|
-
const node = this.ast;
|
|
3343
|
-
walk.simple(node, {
|
|
3344
|
-
Property(node) {
|
|
3345
|
-
if (compareKey(node.key, key, filename)) {
|
|
3346
|
-
const source = extractLiteral(node.value, filename, data);
|
|
3347
|
-
if (source) {
|
|
3348
|
-
source.filename = filename;
|
|
3349
|
-
result.push(source);
|
|
3350
|
-
}
|
|
3351
|
-
}
|
|
3352
|
-
},
|
|
3353
|
-
});
|
|
3354
|
-
return result;
|
|
3355
|
-
}
|
|
3356
|
-
}
|
|
3357
|
-
|
|
3358
3157
|
var TRANSFORMER_API;
|
|
3359
3158
|
(function (TRANSFORMER_API) {
|
|
3360
3159
|
TRANSFORMER_API[TRANSFORMER_API["VERSION"] = 1] = "VERSION";
|
|
3361
3160
|
})(TRANSFORMER_API || (TRANSFORMER_API = {}));
|
|
3362
3161
|
|
|
3363
|
-
/**
|
|
3364
|
-
* Similar to `require(..)` but removes the cached copy first.
|
|
3365
|
-
*/
|
|
3366
|
-
function requireUncached(require, moduleId) {
|
|
3367
|
-
const filename = require.resolve(moduleId);
|
|
3368
|
-
/* remove references from the parent module to prevent memory leak */
|
|
3369
|
-
const m = require.cache[filename];
|
|
3370
|
-
if (m && m.parent) {
|
|
3371
|
-
const { parent } = m;
|
|
3372
|
-
for (let i = parent.children.length - 1; i >= 0; i--) {
|
|
3373
|
-
if (parent.children[i].id === filename) {
|
|
3374
|
-
parent.children.splice(i, 1);
|
|
3375
|
-
}
|
|
3376
|
-
}
|
|
3377
|
-
}
|
|
3378
|
-
/* remove old module from cache */
|
|
3379
|
-
delete require.cache[filename];
|
|
3380
|
-
/* eslint-disable-next-line import/no-dynamic-require, security/detect-non-literal-require -- as expected but should be moved to upcoming resolver class */
|
|
3381
|
-
return require(filename);
|
|
3382
|
-
}
|
|
3383
|
-
|
|
3384
|
-
const legacyRequire = createRequire(import.meta.url);
|
|
3385
|
-
|
|
3386
3162
|
/**
|
|
3387
3163
|
* @public
|
|
3388
3164
|
*/
|
|
@@ -3400,11 +3176,6 @@ function parseSeverity(value) {
|
|
|
3400
3176
|
case 0:
|
|
3401
3177
|
case "off":
|
|
3402
3178
|
return Severity.DISABLED;
|
|
3403
|
-
/* istanbul ignore next: deprecated code which will be removed later */
|
|
3404
|
-
case "disable":
|
|
3405
|
-
// eslint-disable-next-line no-console -- expected to log
|
|
3406
|
-
console.warn(`Deprecated alias "disabled" will be removed, replace with severity "off"`);
|
|
3407
|
-
return Severity.DISABLED;
|
|
3408
3179
|
case 1:
|
|
3409
3180
|
case "warn":
|
|
3410
3181
|
return Severity.WARN;
|
|
@@ -3739,6 +3510,8 @@ class Rule {
|
|
|
3739
3510
|
* Called when requesting additional documentation for a rule. Some rules
|
|
3740
3511
|
* provide additional context to provide context-aware suggestions.
|
|
3741
3512
|
*
|
|
3513
|
+
* @public
|
|
3514
|
+
* @virtual
|
|
3742
3515
|
* @param context - Error context given by a reported error.
|
|
3743
3516
|
* @returns Rule documentation and url with additional details or `null` if no
|
|
3744
3517
|
* additional documentation is available.
|
|
@@ -3749,15 +3522,15 @@ class Rule {
|
|
|
3749
3522
|
}
|
|
3750
3523
|
}
|
|
3751
3524
|
|
|
3752
|
-
var Style$
|
|
3525
|
+
var Style$1;
|
|
3753
3526
|
(function (Style) {
|
|
3754
3527
|
Style["EXTERNAL"] = "external";
|
|
3755
3528
|
Style["RELATIVE_BASE"] = "relative-base";
|
|
3756
3529
|
Style["RELATIVE_PATH"] = "relative-path";
|
|
3757
3530
|
Style["ABSOLUTE"] = "absolute";
|
|
3758
3531
|
Style["ANCHOR"] = "anchor";
|
|
3759
|
-
})(Style$
|
|
3760
|
-
const defaults$
|
|
3532
|
+
})(Style$1 || (Style$1 = {}));
|
|
3533
|
+
const defaults$v = {
|
|
3761
3534
|
allowExternal: true,
|
|
3762
3535
|
allowRelative: true,
|
|
3763
3536
|
allowAbsolute: true,
|
|
@@ -3770,11 +3543,11 @@ const mapping$1 = {
|
|
|
3770
3543
|
script: "src",
|
|
3771
3544
|
};
|
|
3772
3545
|
const description = {
|
|
3773
|
-
[Style$
|
|
3774
|
-
[Style$
|
|
3775
|
-
[Style$
|
|
3776
|
-
[Style$
|
|
3777
|
-
[Style$
|
|
3546
|
+
[Style$1.EXTERNAL]: "External links are not allowed by current configuration.",
|
|
3547
|
+
[Style$1.RELATIVE_BASE]: "Links relative to <base> are not allowed by current configuration.",
|
|
3548
|
+
[Style$1.RELATIVE_PATH]: "Relative links are not allowed by current configuration.",
|
|
3549
|
+
[Style$1.ABSOLUTE]: "Absolute links are not allowed by current configuration.",
|
|
3550
|
+
[Style$1.ANCHOR]: null,
|
|
3778
3551
|
};
|
|
3779
3552
|
function parseAllow(value) {
|
|
3780
3553
|
if (typeof value === "boolean") {
|
|
@@ -3801,7 +3574,7 @@ function matchList(value, list) {
|
|
|
3801
3574
|
}
|
|
3802
3575
|
class AllowedLinks extends Rule {
|
|
3803
3576
|
constructor(options) {
|
|
3804
|
-
super({ ...defaults$
|
|
3577
|
+
super({ ...defaults$v, ...options });
|
|
3805
3578
|
this.allowExternal = parseAllow(this.options.allowExternal);
|
|
3806
3579
|
this.allowRelative = parseAllow(this.options.allowRelative);
|
|
3807
3580
|
this.allowAbsolute = parseAllow(this.options.allowAbsolute);
|
|
@@ -3847,19 +3620,19 @@ class AllowedLinks extends Rule {
|
|
|
3847
3620
|
const link = event.value.toString();
|
|
3848
3621
|
const style = this.getStyle(link);
|
|
3849
3622
|
switch (style) {
|
|
3850
|
-
case Style$
|
|
3623
|
+
case Style$1.ANCHOR:
|
|
3851
3624
|
/* anchor links are always allowed by this rule */
|
|
3852
3625
|
break;
|
|
3853
|
-
case Style$
|
|
3626
|
+
case Style$1.ABSOLUTE:
|
|
3854
3627
|
this.handleAbsolute(link, event, style);
|
|
3855
3628
|
break;
|
|
3856
|
-
case Style$
|
|
3629
|
+
case Style$1.EXTERNAL:
|
|
3857
3630
|
this.handleExternal(link, event, style);
|
|
3858
3631
|
break;
|
|
3859
|
-
case Style$
|
|
3632
|
+
case Style$1.RELATIVE_BASE:
|
|
3860
3633
|
this.handleRelativeBase(link, event, style);
|
|
3861
3634
|
break;
|
|
3862
|
-
case Style$
|
|
3635
|
+
case Style$1.RELATIVE_PATH:
|
|
3863
3636
|
this.handleRelativePath(link, event, style);
|
|
3864
3637
|
break;
|
|
3865
3638
|
}
|
|
@@ -3877,21 +3650,21 @@ class AllowedLinks extends Rule {
|
|
|
3877
3650
|
getStyle(value) {
|
|
3878
3651
|
/* http://example.net or //example.net */
|
|
3879
3652
|
if (value.match(/^([a-z]+:)?\/\//g)) {
|
|
3880
|
-
return Style$
|
|
3653
|
+
return Style$1.EXTERNAL;
|
|
3881
3654
|
}
|
|
3882
3655
|
switch (value[0]) {
|
|
3883
3656
|
/* /foo/bar */
|
|
3884
3657
|
case "/":
|
|
3885
|
-
return Style$
|
|
3658
|
+
return Style$1.ABSOLUTE;
|
|
3886
3659
|
/* ../foo/bar */
|
|
3887
3660
|
case ".":
|
|
3888
|
-
return Style$
|
|
3661
|
+
return Style$1.RELATIVE_PATH;
|
|
3889
3662
|
/* #foo */
|
|
3890
3663
|
case "#":
|
|
3891
|
-
return Style$
|
|
3664
|
+
return Style$1.ANCHOR;
|
|
3892
3665
|
/* foo/bar */
|
|
3893
3666
|
default:
|
|
3894
|
-
return Style$
|
|
3667
|
+
return Style$1.RELATIVE_BASE;
|
|
3895
3668
|
}
|
|
3896
3669
|
}
|
|
3897
3670
|
handleAbsolute(target, event, style) {
|
|
@@ -3949,7 +3722,7 @@ var RuleContext$1;
|
|
|
3949
3722
|
RuleContext["MISSING_ALT"] = "missing-alt";
|
|
3950
3723
|
RuleContext["MISSING_HREF"] = "missing-href";
|
|
3951
3724
|
})(RuleContext$1 || (RuleContext$1 = {}));
|
|
3952
|
-
const defaults$
|
|
3725
|
+
const defaults$u = {
|
|
3953
3726
|
accessible: true,
|
|
3954
3727
|
};
|
|
3955
3728
|
function findByTarget(target, siblings) {
|
|
@@ -3987,7 +3760,7 @@ function getDescription$1(context) {
|
|
|
3987
3760
|
}
|
|
3988
3761
|
class AreaAlt extends Rule {
|
|
3989
3762
|
constructor(options) {
|
|
3990
|
-
super({ ...defaults$
|
|
3763
|
+
super({ ...defaults$u, ...options });
|
|
3991
3764
|
}
|
|
3992
3765
|
static schema() {
|
|
3993
3766
|
return {
|
|
@@ -4167,13 +3940,13 @@ class ConfigError extends UserError {
|
|
|
4167
3940
|
}
|
|
4168
3941
|
}
|
|
4169
3942
|
|
|
4170
|
-
const defaults$
|
|
3943
|
+
const defaults$t = {
|
|
4171
3944
|
style: "lowercase",
|
|
4172
3945
|
ignoreForeign: true,
|
|
4173
3946
|
};
|
|
4174
3947
|
class AttrCase extends Rule {
|
|
4175
3948
|
constructor(options) {
|
|
4176
|
-
super({ ...defaults$
|
|
3949
|
+
super({ ...defaults$t, ...options });
|
|
4177
3950
|
this.style = new CaseStyle(this.options.style, "attr-case");
|
|
4178
3951
|
}
|
|
4179
3952
|
static schema() {
|
|
@@ -4521,7 +4294,7 @@ class AttrDelimiter extends Rule {
|
|
|
4521
4294
|
}
|
|
4522
4295
|
|
|
4523
4296
|
const DEFAULT_PATTERN = "[a-z0-9-:]+";
|
|
4524
|
-
const defaults$
|
|
4297
|
+
const defaults$s = {
|
|
4525
4298
|
pattern: DEFAULT_PATTERN,
|
|
4526
4299
|
ignoreForeign: true,
|
|
4527
4300
|
};
|
|
@@ -4558,7 +4331,7 @@ function generateDescription(name, pattern) {
|
|
|
4558
4331
|
}
|
|
4559
4332
|
class AttrPattern extends Rule {
|
|
4560
4333
|
constructor(options) {
|
|
4561
|
-
super({ ...defaults$
|
|
4334
|
+
super({ ...defaults$s, ...options });
|
|
4562
4335
|
this.pattern = generateRegexp(this.options.pattern);
|
|
4563
4336
|
}
|
|
4564
4337
|
static schema() {
|
|
@@ -4619,7 +4392,7 @@ var QuoteStyle;
|
|
|
4619
4392
|
QuoteStyle["AUTO_QUOTE"] = "auto";
|
|
4620
4393
|
QuoteStyle["ANY_QUOTE"] = "any";
|
|
4621
4394
|
})(QuoteStyle || (QuoteStyle = {}));
|
|
4622
|
-
const defaults$
|
|
4395
|
+
const defaults$r = {
|
|
4623
4396
|
style: "auto",
|
|
4624
4397
|
unquoted: false,
|
|
4625
4398
|
};
|
|
@@ -4686,8 +4459,8 @@ class AttrQuotes extends Rule {
|
|
|
4686
4459
|
};
|
|
4687
4460
|
}
|
|
4688
4461
|
constructor(options) {
|
|
4689
|
-
super({ ...defaults$
|
|
4690
|
-
this.style = parseStyle$
|
|
4462
|
+
super({ ...defaults$r, ...options });
|
|
4463
|
+
this.style = parseStyle$3(this.options.style);
|
|
4691
4464
|
}
|
|
4692
4465
|
setup() {
|
|
4693
4466
|
this.on("attr", (event) => {
|
|
@@ -4734,7 +4507,7 @@ class AttrQuotes extends Rule {
|
|
|
4734
4507
|
}
|
|
4735
4508
|
}
|
|
4736
4509
|
}
|
|
4737
|
-
function parseStyle$
|
|
4510
|
+
function parseStyle$3(style) {
|
|
4738
4511
|
switch (style.toLowerCase()) {
|
|
4739
4512
|
case "auto":
|
|
4740
4513
|
return QuoteStyle.AUTO_QUOTE;
|
|
@@ -4856,13 +4629,13 @@ class AttributeAllowedValues extends Rule {
|
|
|
4856
4629
|
}
|
|
4857
4630
|
}
|
|
4858
4631
|
|
|
4859
|
-
const defaults$
|
|
4632
|
+
const defaults$q = {
|
|
4860
4633
|
style: "omit",
|
|
4861
4634
|
};
|
|
4862
4635
|
class AttributeBooleanStyle extends Rule {
|
|
4863
4636
|
constructor(options) {
|
|
4864
|
-
super({ ...defaults$
|
|
4865
|
-
this.hasInvalidStyle = parseStyle$
|
|
4637
|
+
super({ ...defaults$q, ...options });
|
|
4638
|
+
this.hasInvalidStyle = parseStyle$2(this.options.style);
|
|
4866
4639
|
}
|
|
4867
4640
|
static schema() {
|
|
4868
4641
|
return {
|
|
@@ -4910,7 +4683,7 @@ class AttributeBooleanStyle extends Rule {
|
|
|
4910
4683
|
return Boolean((_a = rules[attr.key]) === null || _a === void 0 ? void 0 : _a.boolean);
|
|
4911
4684
|
}
|
|
4912
4685
|
}
|
|
4913
|
-
function parseStyle$
|
|
4686
|
+
function parseStyle$2(style) {
|
|
4914
4687
|
switch (style.toLowerCase()) {
|
|
4915
4688
|
case "omit":
|
|
4916
4689
|
return (attr) => attr.value !== null;
|
|
@@ -4937,13 +4710,13 @@ function reportMessage$1(attr, style) {
|
|
|
4937
4710
|
return "";
|
|
4938
4711
|
}
|
|
4939
4712
|
|
|
4940
|
-
const defaults$
|
|
4713
|
+
const defaults$p = {
|
|
4941
4714
|
style: "omit",
|
|
4942
4715
|
};
|
|
4943
4716
|
class AttributeEmptyStyle extends Rule {
|
|
4944
4717
|
constructor(options) {
|
|
4945
|
-
super({ ...defaults$
|
|
4946
|
-
this.hasInvalidStyle = parseStyle$
|
|
4718
|
+
super({ ...defaults$p, ...options });
|
|
4719
|
+
this.hasInvalidStyle = parseStyle$1(this.options.style);
|
|
4947
4720
|
}
|
|
4948
4721
|
static schema() {
|
|
4949
4722
|
return {
|
|
@@ -5001,7 +4774,7 @@ function isEmptyValue(attr) {
|
|
|
5001
4774
|
}
|
|
5002
4775
|
return attr.value === null || attr.value === "";
|
|
5003
4776
|
}
|
|
5004
|
-
function parseStyle$
|
|
4777
|
+
function parseStyle$1(style) {
|
|
5005
4778
|
switch (style.toLowerCase()) {
|
|
5006
4779
|
case "omit":
|
|
5007
4780
|
return (attr) => attr.value !== null;
|
|
@@ -5098,12 +4871,12 @@ function describePattern(pattern) {
|
|
|
5098
4871
|
}
|
|
5099
4872
|
}
|
|
5100
4873
|
|
|
5101
|
-
const defaults$
|
|
4874
|
+
const defaults$o = {
|
|
5102
4875
|
pattern: "kebabcase",
|
|
5103
4876
|
};
|
|
5104
4877
|
class ClassPattern extends Rule {
|
|
5105
4878
|
constructor(options) {
|
|
5106
|
-
super({ ...defaults$
|
|
4879
|
+
super({ ...defaults$o, ...options });
|
|
5107
4880
|
this.pattern = parsePattern(this.options.pattern);
|
|
5108
4881
|
}
|
|
5109
4882
|
static schema() {
|
|
@@ -5212,13 +4985,13 @@ class CloseOrder extends Rule {
|
|
|
5212
4985
|
}
|
|
5213
4986
|
}
|
|
5214
4987
|
|
|
5215
|
-
const defaults$
|
|
4988
|
+
const defaults$n = {
|
|
5216
4989
|
include: null,
|
|
5217
4990
|
exclude: null,
|
|
5218
4991
|
};
|
|
5219
4992
|
class Deprecated extends Rule {
|
|
5220
4993
|
constructor(options) {
|
|
5221
|
-
super({ ...defaults$
|
|
4994
|
+
super({ ...defaults$n, ...options });
|
|
5222
4995
|
}
|
|
5223
4996
|
static schema() {
|
|
5224
4997
|
return {
|
|
@@ -5381,12 +5154,12 @@ let NoStyleTag$1 = class NoStyleTag extends Rule {
|
|
|
5381
5154
|
}
|
|
5382
5155
|
};
|
|
5383
5156
|
|
|
5384
|
-
const defaults$
|
|
5157
|
+
const defaults$m = {
|
|
5385
5158
|
style: "uppercase",
|
|
5386
5159
|
};
|
|
5387
5160
|
class DoctypeStyle extends Rule {
|
|
5388
5161
|
constructor(options) {
|
|
5389
|
-
super({ ...defaults$
|
|
5162
|
+
super({ ...defaults$m, ...options });
|
|
5390
5163
|
}
|
|
5391
5164
|
static schema() {
|
|
5392
5165
|
return {
|
|
@@ -5418,12 +5191,12 @@ class DoctypeStyle extends Rule {
|
|
|
5418
5191
|
}
|
|
5419
5192
|
}
|
|
5420
5193
|
|
|
5421
|
-
const defaults$
|
|
5194
|
+
const defaults$l = {
|
|
5422
5195
|
style: "lowercase",
|
|
5423
5196
|
};
|
|
5424
5197
|
class ElementCase extends Rule {
|
|
5425
5198
|
constructor(options) {
|
|
5426
|
-
super({ ...defaults$
|
|
5199
|
+
super({ ...defaults$l, ...options });
|
|
5427
5200
|
this.style = new CaseStyle(this.options.style, "element-case");
|
|
5428
5201
|
}
|
|
5429
5202
|
static schema() {
|
|
@@ -5489,14 +5262,14 @@ class ElementCase extends Rule {
|
|
|
5489
5262
|
}
|
|
5490
5263
|
}
|
|
5491
5264
|
|
|
5492
|
-
const defaults$
|
|
5265
|
+
const defaults$k = {
|
|
5493
5266
|
pattern: "^[a-z][a-z0-9\\-._]*-[a-z0-9\\-._]*$",
|
|
5494
5267
|
whitelist: [],
|
|
5495
5268
|
blacklist: [],
|
|
5496
5269
|
};
|
|
5497
5270
|
class ElementName extends Rule {
|
|
5498
5271
|
constructor(options) {
|
|
5499
|
-
super({ ...defaults$
|
|
5272
|
+
super({ ...defaults$k, ...options });
|
|
5500
5273
|
/* eslint-disable-next-line security/detect-non-literal-regexp -- expected to be a regexp */
|
|
5501
5274
|
this.pattern = new RegExp(this.options.pattern);
|
|
5502
5275
|
}
|
|
@@ -5537,7 +5310,7 @@ class ElementName extends Rule {
|
|
|
5537
5310
|
...context.blacklist.map((cur) => `- ${cur}`),
|
|
5538
5311
|
];
|
|
5539
5312
|
}
|
|
5540
|
-
if (context.pattern !== defaults$
|
|
5313
|
+
if (context.pattern !== defaults$k.pattern) {
|
|
5541
5314
|
return [
|
|
5542
5315
|
`<${context.tagName}> is not a valid element name. This project is configured to only allow names matching the following regular expression:`,
|
|
5543
5316
|
"",
|
|
@@ -6081,7 +5854,7 @@ class EmptyTitle extends Rule {
|
|
|
6081
5854
|
}
|
|
6082
5855
|
}
|
|
6083
5856
|
|
|
6084
|
-
const defaults$
|
|
5857
|
+
const defaults$j = {
|
|
6085
5858
|
allowArrayBrackets: true,
|
|
6086
5859
|
shared: ["radio", "button", "reset", "submit"],
|
|
6087
5860
|
};
|
|
@@ -6114,7 +5887,7 @@ function getDocumentation(context) {
|
|
|
6114
5887
|
}
|
|
6115
5888
|
class FormDupName extends Rule {
|
|
6116
5889
|
constructor(options) {
|
|
6117
|
-
super({ ...defaults$
|
|
5890
|
+
super({ ...defaults$j, ...options });
|
|
6118
5891
|
}
|
|
6119
5892
|
static schema() {
|
|
6120
5893
|
return {
|
|
@@ -6274,7 +6047,7 @@ class FormDupName extends Rule {
|
|
|
6274
6047
|
}
|
|
6275
6048
|
}
|
|
6276
6049
|
|
|
6277
|
-
const defaults$
|
|
6050
|
+
const defaults$i = {
|
|
6278
6051
|
allowMultipleH1: false,
|
|
6279
6052
|
minInitialRank: "h1",
|
|
6280
6053
|
sectioningRoots: ["dialog", '[role="dialog"]', '[role="alertdialog"]'],
|
|
@@ -6305,7 +6078,7 @@ function parseMaxInitial(value) {
|
|
|
6305
6078
|
}
|
|
6306
6079
|
class HeadingLevel extends Rule {
|
|
6307
6080
|
constructor(options) {
|
|
6308
|
-
super({ ...defaults$
|
|
6081
|
+
super({ ...defaults$i, ...options });
|
|
6309
6082
|
this.stack = [];
|
|
6310
6083
|
this.minInitialRank = parseMaxInitial(this.options.minInitialRank);
|
|
6311
6084
|
this.sectionRoots = this.options.sectioningRoots.map((it) => new Pattern(it));
|
|
@@ -6463,12 +6236,12 @@ class HeadingLevel extends Rule {
|
|
|
6463
6236
|
}
|
|
6464
6237
|
}
|
|
6465
6238
|
|
|
6466
|
-
const defaults$
|
|
6239
|
+
const defaults$h = {
|
|
6467
6240
|
pattern: "kebabcase",
|
|
6468
6241
|
};
|
|
6469
6242
|
class IdPattern extends Rule {
|
|
6470
6243
|
constructor(options) {
|
|
6471
|
-
super({ ...defaults$
|
|
6244
|
+
super({ ...defaults$h, ...options });
|
|
6472
6245
|
this.pattern = parsePattern(this.options.pattern);
|
|
6473
6246
|
}
|
|
6474
6247
|
static schema() {
|
|
@@ -6750,12 +6523,12 @@ function findLabelByParent(el) {
|
|
|
6750
6523
|
return [];
|
|
6751
6524
|
}
|
|
6752
6525
|
|
|
6753
|
-
const defaults$
|
|
6526
|
+
const defaults$g = {
|
|
6754
6527
|
maxlength: 70,
|
|
6755
6528
|
};
|
|
6756
6529
|
class LongTitle extends Rule {
|
|
6757
6530
|
constructor(options) {
|
|
6758
|
-
super({ ...defaults$
|
|
6531
|
+
super({ ...defaults$g, ...options });
|
|
6759
6532
|
this.maxlength = this.options.maxlength;
|
|
6760
6533
|
}
|
|
6761
6534
|
static schema() {
|
|
@@ -6981,13 +6754,13 @@ class MultipleLabeledControls extends Rule {
|
|
|
6981
6754
|
}
|
|
6982
6755
|
}
|
|
6983
6756
|
|
|
6984
|
-
const defaults$
|
|
6757
|
+
const defaults$f = {
|
|
6985
6758
|
include: null,
|
|
6986
6759
|
exclude: null,
|
|
6987
6760
|
};
|
|
6988
6761
|
class NoAutoplay extends Rule {
|
|
6989
6762
|
constructor(options) {
|
|
6990
|
-
super({ ...defaults$
|
|
6763
|
+
super({ ...defaults$f, ...options });
|
|
6991
6764
|
}
|
|
6992
6765
|
documentation(context) {
|
|
6993
6766
|
const tagName = context ? ` on <${context.tagName}>` : "";
|
|
@@ -7228,14 +7001,14 @@ Omitted end tags can be ambigious for humans to read and many editors have troub
|
|
|
7228
7001
|
}
|
|
7229
7002
|
}
|
|
7230
7003
|
|
|
7231
|
-
const defaults$
|
|
7004
|
+
const defaults$e = {
|
|
7232
7005
|
include: null,
|
|
7233
7006
|
exclude: null,
|
|
7234
7007
|
allowedProperties: ["display"],
|
|
7235
7008
|
};
|
|
7236
7009
|
class NoInlineStyle extends Rule {
|
|
7237
7010
|
constructor(options) {
|
|
7238
|
-
super({ ...defaults$
|
|
7011
|
+
super({ ...defaults$e, ...options });
|
|
7239
7012
|
}
|
|
7240
7013
|
static schema() {
|
|
7241
7014
|
return {
|
|
@@ -7437,7 +7210,7 @@ class NoMultipleMain extends Rule {
|
|
|
7437
7210
|
}
|
|
7438
7211
|
}
|
|
7439
7212
|
|
|
7440
|
-
const defaults$
|
|
7213
|
+
const defaults$d = {
|
|
7441
7214
|
relaxed: false,
|
|
7442
7215
|
};
|
|
7443
7216
|
const textRegexp = /([<>]|&(?![a-zA-Z0-9#]+;))/g;
|
|
@@ -7454,7 +7227,7 @@ const replacementTable = {
|
|
|
7454
7227
|
};
|
|
7455
7228
|
class NoRawCharacters extends Rule {
|
|
7456
7229
|
constructor(options) {
|
|
7457
|
-
super({ ...defaults$
|
|
7230
|
+
super({ ...defaults$d, ...options });
|
|
7458
7231
|
this.relaxed = this.options.relaxed;
|
|
7459
7232
|
}
|
|
7460
7233
|
static schema() {
|
|
@@ -7632,13 +7405,13 @@ class NoRedundantRole extends Rule {
|
|
|
7632
7405
|
}
|
|
7633
7406
|
|
|
7634
7407
|
const xmlns = /^(.+):.+$/;
|
|
7635
|
-
const defaults$
|
|
7408
|
+
const defaults$c = {
|
|
7636
7409
|
ignoreForeign: true,
|
|
7637
7410
|
ignoreXML: true,
|
|
7638
7411
|
};
|
|
7639
7412
|
class NoSelfClosing extends Rule {
|
|
7640
7413
|
constructor(options) {
|
|
7641
|
-
super({ ...defaults$
|
|
7414
|
+
super({ ...defaults$c, ...options });
|
|
7642
7415
|
}
|
|
7643
7416
|
static schema() {
|
|
7644
7417
|
return {
|
|
@@ -7727,13 +7500,13 @@ class NoTrailingWhitespace extends Rule {
|
|
|
7727
7500
|
}
|
|
7728
7501
|
}
|
|
7729
7502
|
|
|
7730
|
-
const defaults$
|
|
7503
|
+
const defaults$b = {
|
|
7731
7504
|
include: null,
|
|
7732
7505
|
exclude: null,
|
|
7733
7506
|
};
|
|
7734
7507
|
class NoUnknownElements extends Rule {
|
|
7735
7508
|
constructor(options) {
|
|
7736
|
-
super({ ...defaults$
|
|
7509
|
+
super({ ...defaults$b, ...options });
|
|
7737
7510
|
}
|
|
7738
7511
|
static schema() {
|
|
7739
7512
|
return {
|
|
@@ -7845,13 +7618,13 @@ const replacement = {
|
|
|
7845
7618
|
reset: '<button type="reset">',
|
|
7846
7619
|
image: '<button type="button">',
|
|
7847
7620
|
};
|
|
7848
|
-
const defaults$
|
|
7621
|
+
const defaults$a = {
|
|
7849
7622
|
include: null,
|
|
7850
7623
|
exclude: null,
|
|
7851
7624
|
};
|
|
7852
7625
|
class PreferButton extends Rule {
|
|
7853
7626
|
constructor(options) {
|
|
7854
|
-
super({ ...defaults$
|
|
7627
|
+
super({ ...defaults$a, ...options });
|
|
7855
7628
|
}
|
|
7856
7629
|
static schema() {
|
|
7857
7630
|
return {
|
|
@@ -7926,7 +7699,7 @@ class PreferButton extends Rule {
|
|
|
7926
7699
|
}
|
|
7927
7700
|
}
|
|
7928
7701
|
|
|
7929
|
-
const defaults$
|
|
7702
|
+
const defaults$9 = {
|
|
7930
7703
|
mapping: {
|
|
7931
7704
|
article: "article",
|
|
7932
7705
|
banner: "header",
|
|
@@ -7956,7 +7729,7 @@ const defaults$a = {
|
|
|
7956
7729
|
};
|
|
7957
7730
|
class PreferNativeElement extends Rule {
|
|
7958
7731
|
constructor(options) {
|
|
7959
|
-
super({ ...defaults$
|
|
7732
|
+
super({ ...defaults$9, ...options });
|
|
7960
7733
|
}
|
|
7961
7734
|
static schema() {
|
|
7962
7735
|
return {
|
|
@@ -8076,12 +7849,12 @@ class PreferTbody extends Rule {
|
|
|
8076
7849
|
}
|
|
8077
7850
|
}
|
|
8078
7851
|
|
|
8079
|
-
const defaults$
|
|
7852
|
+
const defaults$8 = {
|
|
8080
7853
|
tags: ["script", "style"],
|
|
8081
7854
|
};
|
|
8082
7855
|
class RequireCSPNonce extends Rule {
|
|
8083
7856
|
constructor(options) {
|
|
8084
|
-
super({ ...defaults$
|
|
7857
|
+
super({ ...defaults$8, ...options });
|
|
8085
7858
|
}
|
|
8086
7859
|
static schema() {
|
|
8087
7860
|
return {
|
|
@@ -8132,7 +7905,7 @@ class RequireCSPNonce extends Rule {
|
|
|
8132
7905
|
}
|
|
8133
7906
|
}
|
|
8134
7907
|
|
|
8135
|
-
const defaults$
|
|
7908
|
+
const defaults$7 = {
|
|
8136
7909
|
target: "all",
|
|
8137
7910
|
include: null,
|
|
8138
7911
|
exclude: null,
|
|
@@ -8144,7 +7917,7 @@ const supportSri = {
|
|
|
8144
7917
|
};
|
|
8145
7918
|
class RequireSri extends Rule {
|
|
8146
7919
|
constructor(options) {
|
|
8147
|
-
super({ ...defaults$
|
|
7920
|
+
super({ ...defaults$7, ...options });
|
|
8148
7921
|
this.target = this.options.target;
|
|
8149
7922
|
}
|
|
8150
7923
|
static schema() {
|
|
@@ -8306,7 +8079,7 @@ class SvgFocusable extends Rule {
|
|
|
8306
8079
|
}
|
|
8307
8080
|
}
|
|
8308
8081
|
|
|
8309
|
-
const defaults$
|
|
8082
|
+
const defaults$6 = {
|
|
8310
8083
|
characters: [
|
|
8311
8084
|
{ pattern: " ", replacement: " ", description: "non-breaking space" },
|
|
8312
8085
|
{ pattern: "-", replacement: "‑", description: "non-breaking hyphen" },
|
|
@@ -8345,7 +8118,7 @@ function matchAll(text, regexp) {
|
|
|
8345
8118
|
}
|
|
8346
8119
|
class TelNonBreaking extends Rule {
|
|
8347
8120
|
constructor(options) {
|
|
8348
|
-
super({ ...defaults$
|
|
8121
|
+
super({ ...defaults$6, ...options });
|
|
8349
8122
|
this.regex = constructRegex(this.options.characters);
|
|
8350
8123
|
}
|
|
8351
8124
|
static schema() {
|
|
@@ -8633,7 +8406,7 @@ class TextContent extends Rule {
|
|
|
8633
8406
|
}
|
|
8634
8407
|
}
|
|
8635
8408
|
|
|
8636
|
-
const defaults$
|
|
8409
|
+
const defaults$5 = {
|
|
8637
8410
|
ignoreCase: false,
|
|
8638
8411
|
requireSemicolon: true,
|
|
8639
8412
|
};
|
|
@@ -8675,7 +8448,7 @@ function getDescription(context, options) {
|
|
|
8675
8448
|
}
|
|
8676
8449
|
class UnknownCharReference extends Rule {
|
|
8677
8450
|
constructor(options) {
|
|
8678
|
-
super({ ...defaults$
|
|
8451
|
+
super({ ...defaults$5, ...options });
|
|
8679
8452
|
}
|
|
8680
8453
|
static schema() {
|
|
8681
8454
|
return {
|
|
@@ -8792,12 +8565,12 @@ var RuleContext;
|
|
|
8792
8565
|
RuleContext[RuleContext["LEADING_CHARACTER"] = 3] = "LEADING_CHARACTER";
|
|
8793
8566
|
RuleContext[RuleContext["DISALLOWED_CHARACTER"] = 4] = "DISALLOWED_CHARACTER";
|
|
8794
8567
|
})(RuleContext || (RuleContext = {}));
|
|
8795
|
-
const defaults$
|
|
8568
|
+
const defaults$4 = {
|
|
8796
8569
|
relaxed: false,
|
|
8797
8570
|
};
|
|
8798
8571
|
class ValidID extends Rule {
|
|
8799
8572
|
constructor(options) {
|
|
8800
|
-
super({ ...defaults$
|
|
8573
|
+
super({ ...defaults$4, ...options });
|
|
8801
8574
|
}
|
|
8802
8575
|
static schema() {
|
|
8803
8576
|
return {
|
|
@@ -8874,86 +8647,6 @@ class ValidID extends Rule {
|
|
|
8874
8647
|
}
|
|
8875
8648
|
}
|
|
8876
8649
|
|
|
8877
|
-
var Style$1;
|
|
8878
|
-
(function (Style) {
|
|
8879
|
-
Style[Style["Any"] = 0] = "Any";
|
|
8880
|
-
Style[Style["AlwaysOmit"] = 1] = "AlwaysOmit";
|
|
8881
|
-
Style[Style["AlwaysSelfclose"] = 2] = "AlwaysSelfclose";
|
|
8882
|
-
})(Style$1 || (Style$1 = {}));
|
|
8883
|
-
const defaults$4 = {
|
|
8884
|
-
style: "omit",
|
|
8885
|
-
};
|
|
8886
|
-
class Void extends Rule {
|
|
8887
|
-
get deprecated() {
|
|
8888
|
-
return true;
|
|
8889
|
-
}
|
|
8890
|
-
static schema() {
|
|
8891
|
-
return {
|
|
8892
|
-
style: {
|
|
8893
|
-
enum: ["any", "omit", "selfclose", "selfclosing"],
|
|
8894
|
-
type: "string",
|
|
8895
|
-
},
|
|
8896
|
-
};
|
|
8897
|
-
}
|
|
8898
|
-
documentation() {
|
|
8899
|
-
return {
|
|
8900
|
-
description: "HTML void elements cannot have any content and must not have an end tag.",
|
|
8901
|
-
url: "https://html-validate.org/rules/void.html",
|
|
8902
|
-
};
|
|
8903
|
-
}
|
|
8904
|
-
constructor(options) {
|
|
8905
|
-
super({ ...defaults$4, ...options });
|
|
8906
|
-
this.style = parseStyle$1(this.options.style);
|
|
8907
|
-
}
|
|
8908
|
-
setup() {
|
|
8909
|
-
this.on("tag:end", (event) => {
|
|
8910
|
-
const current = event.target; // The current element being closed
|
|
8911
|
-
const active = event.previous; // The current active element (that is, the current element on the stack)
|
|
8912
|
-
if (current && current.meta) {
|
|
8913
|
-
this.validateCurrent(current);
|
|
8914
|
-
}
|
|
8915
|
-
if (active && active.meta) {
|
|
8916
|
-
this.validateActive(active, active.meta);
|
|
8917
|
-
}
|
|
8918
|
-
});
|
|
8919
|
-
}
|
|
8920
|
-
validateCurrent(node) {
|
|
8921
|
-
if (node.voidElement && node.closed === NodeClosed.EndTag) {
|
|
8922
|
-
this.report(null, `End tag for <${node.tagName}> must be omitted`, node.location);
|
|
8923
|
-
}
|
|
8924
|
-
}
|
|
8925
|
-
validateActive(node, meta) {
|
|
8926
|
-
/* ignore foreign elements, they may or may not be self-closed and both are
|
|
8927
|
-
* valid */
|
|
8928
|
-
if (meta.foreign) {
|
|
8929
|
-
return;
|
|
8930
|
-
}
|
|
8931
|
-
const selfOrOmitted = node.closed === NodeClosed.VoidOmitted || node.closed === NodeClosed.VoidSelfClosed;
|
|
8932
|
-
if (node.voidElement) {
|
|
8933
|
-
if (this.style === Style$1.AlwaysOmit && node.closed === NodeClosed.VoidSelfClosed) {
|
|
8934
|
-
this.report(node, `Expected omitted end tag <${node.tagName}> instead of self-closing element <${node.tagName}/>`);
|
|
8935
|
-
}
|
|
8936
|
-
if (this.style === Style$1.AlwaysSelfclose && node.closed === NodeClosed.VoidOmitted) {
|
|
8937
|
-
this.report(node, `Expected self-closing element <${node.tagName}/> instead of omitted end-tag <${node.tagName}>`);
|
|
8938
|
-
}
|
|
8939
|
-
}
|
|
8940
|
-
if (selfOrOmitted && node.voidElement === false) {
|
|
8941
|
-
this.report(node, `End tag for <${node.tagName}> must not be omitted`);
|
|
8942
|
-
}
|
|
8943
|
-
}
|
|
8944
|
-
}
|
|
8945
|
-
function parseStyle$1(name) {
|
|
8946
|
-
switch (name) {
|
|
8947
|
-
case "any":
|
|
8948
|
-
return Style$1.Any;
|
|
8949
|
-
case "omit":
|
|
8950
|
-
return Style$1.AlwaysOmit;
|
|
8951
|
-
case "selfclose":
|
|
8952
|
-
case "selfclosing":
|
|
8953
|
-
return Style$1.AlwaysSelfclose;
|
|
8954
|
-
}
|
|
8955
|
-
}
|
|
8956
|
-
|
|
8957
8650
|
class VoidContent extends Rule {
|
|
8958
8651
|
documentation(tagName) {
|
|
8959
8652
|
const doc = {
|
|
@@ -9455,7 +9148,6 @@ const bundledRules = {
|
|
|
9455
9148
|
"text-content": TextContent,
|
|
9456
9149
|
"unrecognized-char-ref": UnknownCharReference,
|
|
9457
9150
|
"valid-id": ValidID,
|
|
9458
|
-
void: Void,
|
|
9459
9151
|
"void-content": VoidContent,
|
|
9460
9152
|
"void-style": VoidStyle,
|
|
9461
9153
|
...WCAG,
|
|
@@ -9748,7 +9440,112 @@ class ResolvedConfig {
|
|
|
9748
9440
|
}
|
|
9749
9441
|
}
|
|
9750
9442
|
|
|
9751
|
-
|
|
9443
|
+
function haveResolver(key, value) {
|
|
9444
|
+
return key in value;
|
|
9445
|
+
}
|
|
9446
|
+
function haveConfigResolver(value) {
|
|
9447
|
+
return haveResolver("resolveConfig", value);
|
|
9448
|
+
}
|
|
9449
|
+
function haveElementsResolver(value) {
|
|
9450
|
+
return haveResolver("resolveElements", value);
|
|
9451
|
+
}
|
|
9452
|
+
function havePluginResolver(value) {
|
|
9453
|
+
return haveResolver("resolvePlugin", value);
|
|
9454
|
+
}
|
|
9455
|
+
function haveTransformerResolver(value) {
|
|
9456
|
+
return haveResolver("resolveTransformer", value);
|
|
9457
|
+
}
|
|
9458
|
+
/**
|
|
9459
|
+
* @internal
|
|
9460
|
+
*/
|
|
9461
|
+
function resolveConfig(resolvers, id, options) {
|
|
9462
|
+
for (const resolver of resolvers.filter(haveConfigResolver)) {
|
|
9463
|
+
const config = resolver.resolveConfig(id, options);
|
|
9464
|
+
if (config) {
|
|
9465
|
+
return config;
|
|
9466
|
+
}
|
|
9467
|
+
}
|
|
9468
|
+
throw new UserError(`Failed to load configuration from "${id}"`);
|
|
9469
|
+
}
|
|
9470
|
+
/**
|
|
9471
|
+
* @internal
|
|
9472
|
+
*/
|
|
9473
|
+
function resolveElements(resolvers, id, options) {
|
|
9474
|
+
for (const resolver of resolvers.filter(haveElementsResolver)) {
|
|
9475
|
+
const elements = resolver.resolveElements(id, options);
|
|
9476
|
+
if (elements) {
|
|
9477
|
+
return elements;
|
|
9478
|
+
}
|
|
9479
|
+
}
|
|
9480
|
+
throw new UserError(`Failed to load elements from "${id}"`);
|
|
9481
|
+
}
|
|
9482
|
+
/**
|
|
9483
|
+
* @internal
|
|
9484
|
+
*/
|
|
9485
|
+
function resolvePlugin(resolvers, id, options) {
|
|
9486
|
+
for (const resolver of resolvers.filter(havePluginResolver)) {
|
|
9487
|
+
const plugin = resolver.resolvePlugin(id, options);
|
|
9488
|
+
if (plugin) {
|
|
9489
|
+
return plugin;
|
|
9490
|
+
}
|
|
9491
|
+
}
|
|
9492
|
+
throw new UserError(`Failed to load plugin from "${id}"`);
|
|
9493
|
+
}
|
|
9494
|
+
/**
|
|
9495
|
+
* @internal
|
|
9496
|
+
*/
|
|
9497
|
+
function resolveTransformer(resolvers, id, options) {
|
|
9498
|
+
for (const resolver of resolvers.filter(haveTransformerResolver)) {
|
|
9499
|
+
const transformer = resolver.resolveTransformer(id, options);
|
|
9500
|
+
if (transformer) {
|
|
9501
|
+
return transformer;
|
|
9502
|
+
}
|
|
9503
|
+
}
|
|
9504
|
+
throw new UserError(`Failed to load transformer from "${id}"`);
|
|
9505
|
+
}
|
|
9506
|
+
|
|
9507
|
+
/**
|
|
9508
|
+
* Create a new resolver for static content, i.e. plugins or transformers known
|
|
9509
|
+
* at compile time.
|
|
9510
|
+
*
|
|
9511
|
+
* @public
|
|
9512
|
+
* @since 8.0.0
|
|
9513
|
+
*/
|
|
9514
|
+
function staticResolver(map = {}) {
|
|
9515
|
+
const { elements = {}, configs = {}, plugins = {}, transformers = {} } = map;
|
|
9516
|
+
return {
|
|
9517
|
+
name: "static-qresolver",
|
|
9518
|
+
addElements(id, value) {
|
|
9519
|
+
elements[id] = value;
|
|
9520
|
+
},
|
|
9521
|
+
addConfig(id, value) {
|
|
9522
|
+
configs[id] = value;
|
|
9523
|
+
},
|
|
9524
|
+
addPlugin(id, value) {
|
|
9525
|
+
plugins[id] = value;
|
|
9526
|
+
},
|
|
9527
|
+
addTransformer(id, value) {
|
|
9528
|
+
transformers[id] = value;
|
|
9529
|
+
},
|
|
9530
|
+
resolveElements(id) {
|
|
9531
|
+
var _a;
|
|
9532
|
+
return (_a = elements[id]) !== null && _a !== void 0 ? _a : null;
|
|
9533
|
+
},
|
|
9534
|
+
resolveConfig(id) {
|
|
9535
|
+
var _a;
|
|
9536
|
+
return (_a = configs[id]) !== null && _a !== void 0 ? _a : null;
|
|
9537
|
+
},
|
|
9538
|
+
resolvePlugin(id) {
|
|
9539
|
+
var _a;
|
|
9540
|
+
return (_a = plugins[id]) !== null && _a !== void 0 ? _a : null;
|
|
9541
|
+
},
|
|
9542
|
+
resolveTransformer(id) {
|
|
9543
|
+
var _a;
|
|
9544
|
+
return (_a = transformers[id]) !== null && _a !== void 0 ? _a : null;
|
|
9545
|
+
},
|
|
9546
|
+
};
|
|
9547
|
+
}
|
|
9548
|
+
|
|
9752
9549
|
const ajv = new Ajv({ strict: true, strictTuples: true, strictTypes: true });
|
|
9753
9550
|
ajv.addMetaSchema(ajvSchemaDraft);
|
|
9754
9551
|
const validator = ajv.compile(configurationSchema);
|
|
@@ -9771,30 +9568,13 @@ function mergeInternal(base, rhs) {
|
|
|
9771
9568
|
}
|
|
9772
9569
|
return dst;
|
|
9773
9570
|
}
|
|
9774
|
-
|
|
9775
|
-
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
-
|
|
9779
|
-
|
|
9780
|
-
/* load using require as it can process both js and json */
|
|
9781
|
-
/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- technical debt, should be refactored into something more typesafe */
|
|
9782
|
-
json = requireUncached(legacyRequire, filename);
|
|
9783
|
-
}
|
|
9784
|
-
catch (err) {
|
|
9785
|
-
throw new ConfigError(`Failed to read configuration from "${filename}"`, ensureError(err));
|
|
9786
|
-
}
|
|
9787
|
-
/* expand any relative paths */
|
|
9788
|
-
for (const key of ["extends", "elements", "plugins"]) {
|
|
9789
|
-
/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- technical debt, should be refactored into something more typesafe */
|
|
9790
|
-
const value = json[key];
|
|
9791
|
-
if (!value)
|
|
9792
|
-
continue;
|
|
9793
|
-
json[key] = value.map((ref) => {
|
|
9794
|
-
return Config.expandRelative(ref, path.dirname(filename));
|
|
9795
|
-
});
|
|
9571
|
+
function toArray(value) {
|
|
9572
|
+
if (Array.isArray(value)) {
|
|
9573
|
+
return value;
|
|
9574
|
+
}
|
|
9575
|
+
else {
|
|
9576
|
+
return [value];
|
|
9796
9577
|
}
|
|
9797
|
-
return json;
|
|
9798
9578
|
}
|
|
9799
9579
|
/**
|
|
9800
9580
|
* Configuration holder.
|
|
@@ -9808,7 +9588,7 @@ class Config {
|
|
|
9808
9588
|
* Create a new blank configuration. See also `Config.defaultConfig()`.
|
|
9809
9589
|
*/
|
|
9810
9590
|
static empty() {
|
|
9811
|
-
return new Config({
|
|
9591
|
+
return new Config([], {
|
|
9812
9592
|
extends: [],
|
|
9813
9593
|
rules: {},
|
|
9814
9594
|
plugins: [],
|
|
@@ -9818,9 +9598,9 @@ class Config {
|
|
|
9818
9598
|
/**
|
|
9819
9599
|
* Create configuration from object.
|
|
9820
9600
|
*/
|
|
9821
|
-
static fromObject(options, filename = null) {
|
|
9601
|
+
static fromObject(resolvers, options, filename = null) {
|
|
9822
9602
|
Config.validate(options, filename);
|
|
9823
|
-
return new Config(options);
|
|
9603
|
+
return new Config(resolvers, options);
|
|
9824
9604
|
}
|
|
9825
9605
|
/**
|
|
9826
9606
|
* Read configuration from filename.
|
|
@@ -9831,9 +9611,9 @@ class Config {
|
|
|
9831
9611
|
* @internal
|
|
9832
9612
|
* @param filename - The file to read from
|
|
9833
9613
|
*/
|
|
9834
|
-
static fromFile(filename) {
|
|
9835
|
-
const
|
|
9836
|
-
return Config.fromObject(
|
|
9614
|
+
static fromFile(resolvers, filename) {
|
|
9615
|
+
const configData = resolveConfig(toArray(resolvers), filename, { cache: false });
|
|
9616
|
+
return Config.fromObject(resolvers, configData, filename);
|
|
9837
9617
|
}
|
|
9838
9618
|
/**
|
|
9839
9619
|
* Validate configuration data.
|
|
@@ -9863,12 +9643,12 @@ class Config {
|
|
|
9863
9643
|
* Load a default configuration object.
|
|
9864
9644
|
*/
|
|
9865
9645
|
static defaultConfig() {
|
|
9866
|
-
return new Config(defaultConfig);
|
|
9646
|
+
return new Config([], defaultConfig);
|
|
9867
9647
|
}
|
|
9868
9648
|
/**
|
|
9869
9649
|
* @internal
|
|
9870
9650
|
*/
|
|
9871
|
-
constructor(options) {
|
|
9651
|
+
constructor(resolvers, options) {
|
|
9872
9652
|
var _a;
|
|
9873
9653
|
this.transformers = [];
|
|
9874
9654
|
const initial = {
|
|
@@ -9877,10 +9657,10 @@ class Config {
|
|
|
9877
9657
|
rules: {},
|
|
9878
9658
|
transform: {},
|
|
9879
9659
|
};
|
|
9880
|
-
this.config = mergeInternal(initial, options
|
|
9660
|
+
this.config = mergeInternal(initial, options);
|
|
9881
9661
|
this.metaTable = null;
|
|
9882
|
-
this.rootDir = this.findRootDir();
|
|
9883
9662
|
this.initialized = false;
|
|
9663
|
+
this.resolvers = toArray(resolvers);
|
|
9884
9664
|
/* load plugins */
|
|
9885
9665
|
this.plugins = this.loadPlugins(this.config.plugins || []);
|
|
9886
9666
|
this.configurations = this.loadConfigurations(this.plugins);
|
|
@@ -9926,8 +9706,8 @@ class Config {
|
|
|
9926
9706
|
* @public
|
|
9927
9707
|
* @param rhs - Configuration to merge with this one.
|
|
9928
9708
|
*/
|
|
9929
|
-
merge(rhs) {
|
|
9930
|
-
return new Config(mergeInternal(this.config, rhs.config));
|
|
9709
|
+
merge(resolvers, rhs) {
|
|
9710
|
+
return new Config(resolvers, mergeInternal(this.config, rhs.config));
|
|
9931
9711
|
}
|
|
9932
9712
|
extendConfig(entries) {
|
|
9933
9713
|
if (entries.length === 0) {
|
|
@@ -9941,7 +9721,7 @@ class Config {
|
|
|
9941
9721
|
extended = this.configurations.get(entry);
|
|
9942
9722
|
}
|
|
9943
9723
|
else {
|
|
9944
|
-
extended = Config.fromFile(entry).config;
|
|
9724
|
+
extended = Config.fromFile(this.resolvers, entry).config;
|
|
9945
9725
|
}
|
|
9946
9726
|
base = mergeInternal(base, extended);
|
|
9947
9727
|
}
|
|
@@ -9978,30 +9758,20 @@ class Config {
|
|
|
9978
9758
|
metaTable.loadFromObject(bundled);
|
|
9979
9759
|
continue;
|
|
9980
9760
|
}
|
|
9981
|
-
/*
|
|
9982
|
-
const id = entry.replace("<rootDir>", this.rootDir);
|
|
9761
|
+
/* load with resolver */
|
|
9983
9762
|
try {
|
|
9984
|
-
const data =
|
|
9985
|
-
metaTable.loadFromObject(data,
|
|
9763
|
+
const data = resolveElements(this.resolvers, entry, { cache: false });
|
|
9764
|
+
metaTable.loadFromObject(data, entry);
|
|
9986
9765
|
}
|
|
9987
9766
|
catch (err) {
|
|
9988
9767
|
/* istanbul ignore next: only used as a fallback */
|
|
9989
9768
|
const message = err instanceof Error ? err.message : String(err);
|
|
9990
|
-
throw new ConfigError(`Failed to load elements from "${
|
|
9769
|
+
throw new ConfigError(`Failed to load elements from "${entry}": ${message}`, ensureError(err));
|
|
9991
9770
|
}
|
|
9992
9771
|
}
|
|
9993
9772
|
metaTable.init();
|
|
9994
9773
|
return (this.metaTable = metaTable);
|
|
9995
9774
|
}
|
|
9996
|
-
/**
|
|
9997
|
-
* @internal exposed for testing only
|
|
9998
|
-
*/
|
|
9999
|
-
static expandRelative(src, currentPath) {
|
|
10000
|
-
if (src[0] === ".") {
|
|
10001
|
-
return path.normalize(`${currentPath}/${src}`);
|
|
10002
|
-
}
|
|
10003
|
-
return src;
|
|
10004
|
-
}
|
|
10005
9775
|
/**
|
|
10006
9776
|
* Get a copy of internal configuration data.
|
|
10007
9777
|
*
|
|
@@ -10053,7 +9823,7 @@ class Config {
|
|
|
10053
9823
|
return plugin;
|
|
10054
9824
|
}
|
|
10055
9825
|
try {
|
|
10056
|
-
const plugin =
|
|
9826
|
+
const plugin = resolvePlugin(this.resolvers, moduleName, { cache: true });
|
|
10057
9827
|
plugin.name = plugin.name || moduleName;
|
|
10058
9828
|
plugin.originalName = moduleName;
|
|
10059
9829
|
return plugin;
|
|
@@ -10226,57 +9996,7 @@ class Config {
|
|
|
10226
9996
|
return plugin.transformer;
|
|
10227
9997
|
}
|
|
10228
9998
|
getTransformerFromModule(name) {
|
|
10229
|
-
|
|
10230
|
-
const moduleName = name.replace("<rootDir>", this.rootDir);
|
|
10231
|
-
/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- technical debt, the code kinda does the right thing but it should be reflected in the typing too */
|
|
10232
|
-
const fn = legacyRequire(moduleName);
|
|
10233
|
-
/* sanity check */
|
|
10234
|
-
if (typeof fn !== "function") {
|
|
10235
|
-
/* this is not a proper transformer, is it a plugin exposing a transformer? */
|
|
10236
|
-
if (fn.transformer) {
|
|
10237
|
-
throw new ConfigError(`Module is not a valid transformer. This looks like a plugin, did you forget to load the plugin first?`);
|
|
10238
|
-
}
|
|
10239
|
-
throw new ConfigError(`Module is not a valid transformer.`);
|
|
10240
|
-
}
|
|
10241
|
-
return fn;
|
|
10242
|
-
}
|
|
10243
|
-
/**
|
|
10244
|
-
* @internal
|
|
10245
|
-
*/
|
|
10246
|
-
get rootDirCache() {
|
|
10247
|
-
/* return global instance */
|
|
10248
|
-
return rootDirCache;
|
|
10249
|
-
}
|
|
10250
|
-
set rootDirCache(value) {
|
|
10251
|
-
/* set global instance */
|
|
10252
|
-
rootDirCache = value;
|
|
10253
|
-
}
|
|
10254
|
-
/**
|
|
10255
|
-
* @internal
|
|
10256
|
-
*/
|
|
10257
|
-
findRootDir() {
|
|
10258
|
-
const cache = this.rootDirCache;
|
|
10259
|
-
if (cache !== null) {
|
|
10260
|
-
return cache;
|
|
10261
|
-
}
|
|
10262
|
-
/* try to locate package.json */
|
|
10263
|
-
let current = process.cwd();
|
|
10264
|
-
// eslint-disable-next-line no-constant-condition -- break outs when filesystem is traversed
|
|
10265
|
-
while (true) {
|
|
10266
|
-
const search = path.join(current, "package.json");
|
|
10267
|
-
if (fs.existsSync(search)) {
|
|
10268
|
-
return (this.rootDirCache = current);
|
|
10269
|
-
}
|
|
10270
|
-
/* get the parent directory */
|
|
10271
|
-
const child = current;
|
|
10272
|
-
current = path.dirname(current);
|
|
10273
|
-
/* stop if this is the root directory */
|
|
10274
|
-
if (current === child) {
|
|
10275
|
-
break;
|
|
10276
|
-
}
|
|
10277
|
-
}
|
|
10278
|
-
/* default to working directory if no package.json is found */
|
|
10279
|
-
return (this.rootDirCache = process.cwd());
|
|
9999
|
+
return resolveTransformer(this.resolvers, name, { cache: true });
|
|
10280
10000
|
}
|
|
10281
10001
|
}
|
|
10282
10002
|
|
|
@@ -10289,19 +10009,25 @@ class Config {
|
|
|
10289
10009
|
* @public
|
|
10290
10010
|
*/
|
|
10291
10011
|
class ConfigLoader {
|
|
10292
|
-
constructor(
|
|
10293
|
-
const defaults =
|
|
10294
|
-
this.
|
|
10295
|
-
this.globalConfig = defaults.merge(config ? this.loadFromObject(config) : this.defaultConfig());
|
|
10012
|
+
constructor(resolvers, config) {
|
|
10013
|
+
const defaults = Config.empty();
|
|
10014
|
+
this.resolvers = resolvers;
|
|
10015
|
+
this.globalConfig = defaults.merge(this.resolvers, config ? this.loadFromObject(config) : this.defaultConfig());
|
|
10016
|
+
}
|
|
10017
|
+
/**
|
|
10018
|
+
* @internal For testing only
|
|
10019
|
+
*/
|
|
10020
|
+
_getGlobalConfig() {
|
|
10021
|
+
return this.globalConfig.get();
|
|
10296
10022
|
}
|
|
10297
10023
|
empty() {
|
|
10298
|
-
return
|
|
10024
|
+
return Config.empty();
|
|
10299
10025
|
}
|
|
10300
10026
|
loadFromObject(options, filename) {
|
|
10301
|
-
return
|
|
10027
|
+
return Config.fromObject(this.resolvers, options, filename);
|
|
10302
10028
|
}
|
|
10303
10029
|
loadFromFile(filename) {
|
|
10304
|
-
return
|
|
10030
|
+
return Config.fromFile(this.resolvers, filename);
|
|
10305
10031
|
}
|
|
10306
10032
|
}
|
|
10307
10033
|
|
|
@@ -11289,7 +11015,7 @@ class Engine {
|
|
|
11289
11015
|
/**
|
|
11290
11016
|
* Get rule documentation.
|
|
11291
11017
|
*/
|
|
11292
|
-
getRuleDocumentation(ruleId, context) {
|
|
11018
|
+
getRuleDocumentation({ ruleId, context, }) {
|
|
11293
11019
|
const rules = this.config.getRules();
|
|
11294
11020
|
const ruleData = rules.get(ruleId);
|
|
11295
11021
|
if (ruleData) {
|
|
@@ -11526,6 +11252,10 @@ class Engine {
|
|
|
11526
11252
|
}
|
|
11527
11253
|
}
|
|
11528
11254
|
|
|
11255
|
+
const defaultResolvers = [];
|
|
11256
|
+
function hasResolver(value) {
|
|
11257
|
+
return Array.isArray(value[0]);
|
|
11258
|
+
}
|
|
11529
11259
|
/**
|
|
11530
11260
|
* The static configuration loader does not do any per-handle lookup. Only the
|
|
11531
11261
|
* global or per-call configuration is used.
|
|
@@ -11536,13 +11266,23 @@ class Engine {
|
|
|
11536
11266
|
* @public
|
|
11537
11267
|
*/
|
|
11538
11268
|
class StaticConfigLoader extends ConfigLoader {
|
|
11269
|
+
constructor(...args) {
|
|
11270
|
+
if (hasResolver(args)) {
|
|
11271
|
+
const [resolvers, config] = args;
|
|
11272
|
+
super(resolvers, config);
|
|
11273
|
+
}
|
|
11274
|
+
else {
|
|
11275
|
+
const [config] = args;
|
|
11276
|
+
super(defaultResolvers, config);
|
|
11277
|
+
}
|
|
11278
|
+
}
|
|
11539
11279
|
getConfigFor(_handle, configOverride) {
|
|
11540
11280
|
const override = this.loadFromObject(configOverride || {});
|
|
11541
11281
|
if (override.isRootFound()) {
|
|
11542
11282
|
override.init();
|
|
11543
11283
|
return override.resolve();
|
|
11544
11284
|
}
|
|
11545
|
-
const merged = this.globalConfig.merge(override);
|
|
11285
|
+
const merged = this.globalConfig.merge(this.resolvers, override);
|
|
11546
11286
|
merged.init();
|
|
11547
11287
|
return merged.resolve();
|
|
11548
11288
|
}
|
|
@@ -11595,6 +11335,33 @@ class HtmlValidate {
|
|
|
11595
11335
|
};
|
|
11596
11336
|
return this.validateSource(source, options);
|
|
11597
11337
|
}
|
|
11338
|
+
validateStringSync(str, arg1, arg2, arg3) {
|
|
11339
|
+
const filename = typeof arg1 === "string" ? arg1 : "inline";
|
|
11340
|
+
const options = isConfigData(arg1) ? arg1 : isConfigData(arg2) ? arg2 : undefined;
|
|
11341
|
+
const hooks = isSourceHooks(arg1) ? arg1 : isSourceHooks(arg2) ? arg2 : arg3;
|
|
11342
|
+
const source = {
|
|
11343
|
+
data: str,
|
|
11344
|
+
filename,
|
|
11345
|
+
line: 1,
|
|
11346
|
+
column: 1,
|
|
11347
|
+
offset: 0,
|
|
11348
|
+
hooks,
|
|
11349
|
+
};
|
|
11350
|
+
return this.validateSourceSync(source, options);
|
|
11351
|
+
}
|
|
11352
|
+
/**
|
|
11353
|
+
* Parse and validate HTML from [[Source]].
|
|
11354
|
+
*
|
|
11355
|
+
* @public
|
|
11356
|
+
* @param input - Source to parse.
|
|
11357
|
+
* @returns Report output.
|
|
11358
|
+
*/
|
|
11359
|
+
async validateSource(input, configOverride) {
|
|
11360
|
+
const config = await this.getConfigFor(input.filename, configOverride);
|
|
11361
|
+
const source = config.transformSource(input);
|
|
11362
|
+
const engine = new Engine(config, Parser);
|
|
11363
|
+
return engine.lint(source);
|
|
11364
|
+
}
|
|
11598
11365
|
/**
|
|
11599
11366
|
* Parse and validate HTML from [[Source]].
|
|
11600
11367
|
*
|
|
@@ -11602,8 +11369,8 @@ class HtmlValidate {
|
|
|
11602
11369
|
* @param input - Source to parse.
|
|
11603
11370
|
* @returns Report output.
|
|
11604
11371
|
*/
|
|
11605
|
-
|
|
11606
|
-
const config = this.
|
|
11372
|
+
validateSourceSync(input, configOverride) {
|
|
11373
|
+
const config = this.getConfigForSync(input.filename, configOverride);
|
|
11607
11374
|
const source = config.transformSource(input);
|
|
11608
11375
|
const engine = new Engine(config, Parser);
|
|
11609
11376
|
return engine.lint(source);
|
|
@@ -11615,8 +11382,21 @@ class HtmlValidate {
|
|
|
11615
11382
|
* @param filename - Filename to read and parse.
|
|
11616
11383
|
* @returns Report output.
|
|
11617
11384
|
*/
|
|
11618
|
-
validateFile(filename) {
|
|
11619
|
-
const config = this.getConfigFor(filename);
|
|
11385
|
+
async validateFile(filename) {
|
|
11386
|
+
const config = await this.getConfigFor(filename);
|
|
11387
|
+
const source = config.transformFilename(filename);
|
|
11388
|
+
const engine = new Engine(config, Parser);
|
|
11389
|
+
return Promise.resolve(engine.lint(source));
|
|
11390
|
+
}
|
|
11391
|
+
/**
|
|
11392
|
+
* Parse and validate HTML from file.
|
|
11393
|
+
*
|
|
11394
|
+
* @public
|
|
11395
|
+
* @param filename - Filename to read and parse.
|
|
11396
|
+
* @returns Report output.
|
|
11397
|
+
*/
|
|
11398
|
+
validateFileSync(filename) {
|
|
11399
|
+
const config = this.getConfigForSync(filename);
|
|
11620
11400
|
const source = config.transformFilename(filename);
|
|
11621
11401
|
const engine = new Engine(config, Parser);
|
|
11622
11402
|
return engine.lint(source);
|
|
@@ -11628,8 +11408,38 @@ class HtmlValidate {
|
|
|
11628
11408
|
* @param filenames - Filenames to read and parse.
|
|
11629
11409
|
* @returns Report output.
|
|
11630
11410
|
*/
|
|
11631
|
-
validateMultipleFiles(filenames) {
|
|
11632
|
-
|
|
11411
|
+
async validateMultipleFiles(filenames) {
|
|
11412
|
+
const report = Reporter.merge(filenames.map((filename) => this.validateFileSync(filename)));
|
|
11413
|
+
return Promise.resolve(report);
|
|
11414
|
+
}
|
|
11415
|
+
/**
|
|
11416
|
+
* Parse and validate HTML from multiple files. Result is merged together to a
|
|
11417
|
+
* single report.
|
|
11418
|
+
*
|
|
11419
|
+
* @param filenames - Filenames to read and parse.
|
|
11420
|
+
* @returns Report output.
|
|
11421
|
+
*/
|
|
11422
|
+
validateMultipleFilesSync(filenames) {
|
|
11423
|
+
return Reporter.merge(filenames.map((filename) => this.validateFileSync(filename)));
|
|
11424
|
+
}
|
|
11425
|
+
/**
|
|
11426
|
+
* Returns true if the given filename can be validated.
|
|
11427
|
+
*
|
|
11428
|
+
* A file is considered to be validatable if the extension is `.html` or if a
|
|
11429
|
+
* transformer matches the filename.
|
|
11430
|
+
*
|
|
11431
|
+
* This is mostly useful for tooling to determine whenever to validate the
|
|
11432
|
+
* file or not. CLI tools will run on all the given files anyway.
|
|
11433
|
+
*/
|
|
11434
|
+
async canValidate(filename) {
|
|
11435
|
+
/* .html is always supported */
|
|
11436
|
+
const extension = path.extname(filename).toLowerCase();
|
|
11437
|
+
if (extension === ".html") {
|
|
11438
|
+
return true;
|
|
11439
|
+
}
|
|
11440
|
+
/* test if there is a matching transformer */
|
|
11441
|
+
const config = await this.getConfigFor(filename);
|
|
11442
|
+
return config.canTransform(filename);
|
|
11633
11443
|
}
|
|
11634
11444
|
/**
|
|
11635
11445
|
* Returns true if the given filename can be validated.
|
|
@@ -11640,14 +11450,14 @@ class HtmlValidate {
|
|
|
11640
11450
|
* This is mostly useful for tooling to determine whenever to validate the
|
|
11641
11451
|
* file or not. CLI tools will run on all the given files anyway.
|
|
11642
11452
|
*/
|
|
11643
|
-
|
|
11453
|
+
canValidateSync(filename) {
|
|
11644
11454
|
/* .html is always supported */
|
|
11645
11455
|
const extension = path.extname(filename).toLowerCase();
|
|
11646
11456
|
if (extension === ".html") {
|
|
11647
11457
|
return true;
|
|
11648
11458
|
}
|
|
11649
11459
|
/* test if there is a matching transformer */
|
|
11650
|
-
const config = this.
|
|
11460
|
+
const config = this.getConfigForSync(filename);
|
|
11651
11461
|
return config.canTransform(filename);
|
|
11652
11462
|
}
|
|
11653
11463
|
/**
|
|
@@ -11660,7 +11470,7 @@ class HtmlValidate {
|
|
|
11660
11470
|
* @param filename - Filename to tokenize.
|
|
11661
11471
|
*/
|
|
11662
11472
|
dumpTokens(filename) {
|
|
11663
|
-
const config = this.
|
|
11473
|
+
const config = this.getConfigForSync(filename);
|
|
11664
11474
|
const source = config.transformFilename(filename);
|
|
11665
11475
|
const engine = new Engine(config, Parser);
|
|
11666
11476
|
return engine.dumpTokens(source);
|
|
@@ -11675,7 +11485,7 @@ class HtmlValidate {
|
|
|
11675
11485
|
* @param filename - Filename to dump events from.
|
|
11676
11486
|
*/
|
|
11677
11487
|
dumpEvents(filename) {
|
|
11678
|
-
const config = this.
|
|
11488
|
+
const config = this.getConfigForSync(filename);
|
|
11679
11489
|
const source = config.transformFilename(filename);
|
|
11680
11490
|
const engine = new Engine(config, Parser);
|
|
11681
11491
|
return engine.dumpEvents(source);
|
|
@@ -11690,7 +11500,7 @@ class HtmlValidate {
|
|
|
11690
11500
|
* @param filename - Filename to dump DOM tree from.
|
|
11691
11501
|
*/
|
|
11692
11502
|
dumpTree(filename) {
|
|
11693
|
-
const config = this.
|
|
11503
|
+
const config = this.getConfigForSync(filename);
|
|
11694
11504
|
const source = config.transformFilename(filename);
|
|
11695
11505
|
const engine = new Engine(config, Parser);
|
|
11696
11506
|
return engine.dumpTree(source);
|
|
@@ -11705,7 +11515,7 @@ class HtmlValidate {
|
|
|
11705
11515
|
* @param filename - Filename to dump source from.
|
|
11706
11516
|
*/
|
|
11707
11517
|
dumpSource(filename) {
|
|
11708
|
-
const config = this.
|
|
11518
|
+
const config = this.getConfigForSync(filename);
|
|
11709
11519
|
const sources = config.transformFilename(filename);
|
|
11710
11520
|
return sources.reduce((result, source) => {
|
|
11711
11521
|
result.push(`Source ${source.filename}@${source.line}:${source.column} (offset: ${source.offset})`);
|
|
@@ -11741,37 +11551,95 @@ class HtmlValidate {
|
|
|
11741
11551
|
* handled by html-validate but the path will be used when resolving
|
|
11742
11552
|
* configuration. As a rule-of-thumb, set it to the elements json file.
|
|
11743
11553
|
*/
|
|
11744
|
-
getElementsSchema(filename) {
|
|
11745
|
-
const config = this.getConfigFor(filename !== null && filename !== void 0 ? filename : "inline");
|
|
11554
|
+
async getElementsSchema(filename) {
|
|
11555
|
+
const config = await this.getConfigFor(filename !== null && filename !== void 0 ? filename : "inline");
|
|
11556
|
+
const metaTable = config.getMetaTable();
|
|
11557
|
+
return metaTable.getJSONSchema();
|
|
11558
|
+
}
|
|
11559
|
+
/**
|
|
11560
|
+
* Get effective metadata element schema.
|
|
11561
|
+
*
|
|
11562
|
+
* If a filename is given the configured plugins can extend the
|
|
11563
|
+
* schema. Filename must not be an existing file or a filetype normally
|
|
11564
|
+
* handled by html-validate but the path will be used when resolving
|
|
11565
|
+
* configuration. As a rule-of-thumb, set it to the elements json file.
|
|
11566
|
+
*/
|
|
11567
|
+
getElementsSchemaSync(filename) {
|
|
11568
|
+
const config = this.getConfigForSync(filename !== null && filename !== void 0 ? filename : "inline");
|
|
11746
11569
|
const metaTable = config.getMetaTable();
|
|
11747
11570
|
return metaTable.getJSONSchema();
|
|
11748
11571
|
}
|
|
11572
|
+
async getContextualDocumentation(message, filenameOrConfig = "inline") {
|
|
11573
|
+
const config = typeof filenameOrConfig === "string"
|
|
11574
|
+
? await this.getConfigFor(filenameOrConfig)
|
|
11575
|
+
: await filenameOrConfig;
|
|
11576
|
+
const engine = new Engine(config, Parser);
|
|
11577
|
+
return engine.getRuleDocumentation(message);
|
|
11578
|
+
}
|
|
11579
|
+
getContextualDocumentationSync(message, filenameOrConfig = "inline") {
|
|
11580
|
+
const config = typeof filenameOrConfig === "string"
|
|
11581
|
+
? this.getConfigForSync(filenameOrConfig)
|
|
11582
|
+
: filenameOrConfig;
|
|
11583
|
+
const engine = new Engine(config, Parser);
|
|
11584
|
+
return engine.getRuleDocumentation(message);
|
|
11585
|
+
}
|
|
11749
11586
|
/**
|
|
11750
11587
|
* Get contextual documentation for the given rule.
|
|
11751
11588
|
*
|
|
11752
11589
|
* Typical usage:
|
|
11753
11590
|
*
|
|
11754
11591
|
* ```js
|
|
11755
|
-
* const report = htmlvalidate.validateFile("my-file.html");
|
|
11592
|
+
* const report = await htmlvalidate.validateFile("my-file.html");
|
|
11756
11593
|
* for (const result of report.results){
|
|
11757
|
-
* const config = htmlvalidate.getConfigFor(result.filePath);
|
|
11594
|
+
* const config = await htmlvalidate.getConfigFor(result.filePath);
|
|
11758
11595
|
* for (const message of result.messages){
|
|
11759
|
-
* const documentation = htmlvalidate.getRuleDocumentation(message.ruleId, config, message.context);
|
|
11596
|
+
* const documentation = await htmlvalidate.getRuleDocumentation(message.ruleId, config, message.context);
|
|
11760
11597
|
* // do something with documentation
|
|
11761
11598
|
* }
|
|
11762
11599
|
* }
|
|
11763
11600
|
* ```
|
|
11764
11601
|
*
|
|
11602
|
+
* @public
|
|
11603
|
+
* @deprecated Deprecated since 8.0.0, use [[getContextualDocumentation]] instead.
|
|
11765
11604
|
* @param ruleId - Rule to get documentation for.
|
|
11766
11605
|
* @param config - If set it provides more accurate description by using the
|
|
11767
11606
|
* correct configuration for the file.
|
|
11768
11607
|
* @param context - If set to `Message.context` some rules can provide
|
|
11769
11608
|
* contextual details and suggestions.
|
|
11770
11609
|
*/
|
|
11771
|
-
getRuleDocumentation(ruleId, config = null, context = null) {
|
|
11610
|
+
async getRuleDocumentation(ruleId, config = null, context = null) {
|
|
11772
11611
|
const c = config || this.getConfigFor("inline");
|
|
11612
|
+
const engine = new Engine(await c, Parser);
|
|
11613
|
+
return engine.getRuleDocumentation({ ruleId, context });
|
|
11614
|
+
}
|
|
11615
|
+
/**
|
|
11616
|
+
* Get contextual documentation for the given rule.
|
|
11617
|
+
*
|
|
11618
|
+
* Typical usage:
|
|
11619
|
+
*
|
|
11620
|
+
* ```js
|
|
11621
|
+
* const report = htmlvalidate.validateFileSync("my-file.html");
|
|
11622
|
+
* for (const result of report.results){
|
|
11623
|
+
* const config = htmlvalidate.getConfigForSync(result.filePath);
|
|
11624
|
+
* for (const message of result.messages){
|
|
11625
|
+
* const documentation = htmlvalidate.getRuleDocumentationSync(message.ruleId, config, message.context);
|
|
11626
|
+
* // do something with documentation
|
|
11627
|
+
* }
|
|
11628
|
+
* }
|
|
11629
|
+
* ```
|
|
11630
|
+
*
|
|
11631
|
+
* @public
|
|
11632
|
+
* @deprecated Deprecated since 8.0.0, use [[getContextualDocumentationSync]] instead.
|
|
11633
|
+
* @param ruleId - Rule to get documentation for.
|
|
11634
|
+
* @param config - If set it provides more accurate description by using the
|
|
11635
|
+
* correct configuration for the file.
|
|
11636
|
+
* @param context - If set to `Message.context` some rules can provide
|
|
11637
|
+
* contextual details and suggestions.
|
|
11638
|
+
*/
|
|
11639
|
+
getRuleDocumentationSync(ruleId, config = null, context = null) {
|
|
11640
|
+
const c = config || this.getConfigForSync("inline");
|
|
11773
11641
|
const engine = new Engine(c, Parser);
|
|
11774
|
-
return engine.getRuleDocumentation(ruleId, context);
|
|
11642
|
+
return engine.getRuleDocumentation({ ruleId, context });
|
|
11775
11643
|
}
|
|
11776
11644
|
/**
|
|
11777
11645
|
* Create a parser configured for given filename.
|
|
@@ -11779,8 +11647,8 @@ class HtmlValidate {
|
|
|
11779
11647
|
* @internal
|
|
11780
11648
|
* @param source - Source to use.
|
|
11781
11649
|
*/
|
|
11782
|
-
getParserFor(source) {
|
|
11783
|
-
const config = this.getConfigFor(source.filename);
|
|
11650
|
+
async getParserFor(source) {
|
|
11651
|
+
const config = await this.getConfigFor(source.filename);
|
|
11784
11652
|
return new Parser(config);
|
|
11785
11653
|
}
|
|
11786
11654
|
/**
|
|
@@ -11794,11 +11662,19 @@ class HtmlValidate {
|
|
|
11794
11662
|
*/
|
|
11795
11663
|
getConfigFor(filename, configOverride) {
|
|
11796
11664
|
const config = this.configLoader.getConfigFor(filename, configOverride);
|
|
11797
|
-
|
|
11798
|
-
|
|
11799
|
-
|
|
11800
|
-
|
|
11801
|
-
|
|
11665
|
+
return Promise.resolve(config);
|
|
11666
|
+
}
|
|
11667
|
+
/**
|
|
11668
|
+
* Get configuration for given filename.
|
|
11669
|
+
*
|
|
11670
|
+
* See [[FileSystemConfigLoader]] for details.
|
|
11671
|
+
*
|
|
11672
|
+
* @public
|
|
11673
|
+
* @param filename - Filename to get configuration for.
|
|
11674
|
+
* @param configOverride - Configuration to apply last.
|
|
11675
|
+
*/
|
|
11676
|
+
getConfigForSync(filename, configOverride) {
|
|
11677
|
+
return this.configLoader.getConfigFor(filename, configOverride);
|
|
11802
11678
|
}
|
|
11803
11679
|
/**
|
|
11804
11680
|
* Flush configuration cache. Clears full cache unless a filename is given.
|
|
@@ -11817,7 +11693,7 @@ class HtmlValidate {
|
|
|
11817
11693
|
/** @public */
|
|
11818
11694
|
const name = "html-validate";
|
|
11819
11695
|
/** @public */
|
|
11820
|
-
const version = "
|
|
11696
|
+
const version = "8.0.1";
|
|
11821
11697
|
/** @public */
|
|
11822
11698
|
const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
|
|
11823
11699
|
|
|
@@ -11843,6 +11719,7 @@ const defaults$1 = {
|
|
|
11843
11719
|
* option is used a warning is displayed on the console.
|
|
11844
11720
|
*
|
|
11845
11721
|
* @public
|
|
11722
|
+
* @since v5.0.0
|
|
11846
11723
|
* @param name - Name of plugin
|
|
11847
11724
|
* @param declared - What library versions the plugin support (e.g. declared peerDependencies)
|
|
11848
11725
|
* @returns - `true` if version is compatible
|
|
@@ -11879,139 +11756,6 @@ function ruleExists(ruleId) {
|
|
|
11879
11756
|
return ruleIds.has(ruleId);
|
|
11880
11757
|
}
|
|
11881
11758
|
|
|
11882
|
-
/**
|
|
11883
|
-
* @internal
|
|
11884
|
-
*/
|
|
11885
|
-
function findConfigurationFiles(directory) {
|
|
11886
|
-
return ["json", "cjs", "js"]
|
|
11887
|
-
.map((extension) => path.join(directory, `.htmlvalidate.${extension}`))
|
|
11888
|
-
.filter((filePath) => fs.existsSync(filePath));
|
|
11889
|
-
}
|
|
11890
|
-
/**
|
|
11891
|
-
* Loads configuration by traversing filesystem.
|
|
11892
|
-
*
|
|
11893
|
-
* Configuration is read from three sources and in the following order:
|
|
11894
|
-
*
|
|
11895
|
-
* 1. Global configuration passed to constructor.
|
|
11896
|
-
* 2. Configuration files found when traversing the directory structure.
|
|
11897
|
-
* 3. Override passed to this function.
|
|
11898
|
-
*
|
|
11899
|
-
* The following configuration filenames are searched:
|
|
11900
|
-
*
|
|
11901
|
-
* - `.htmlvalidate.json`
|
|
11902
|
-
* - `.htmlvalidate.js`
|
|
11903
|
-
* - `.htmlvalidate.cjs`
|
|
11904
|
-
*
|
|
11905
|
-
* Global configuration is used when no configuration file is found. The
|
|
11906
|
-
* result is always merged with override if present.
|
|
11907
|
-
*
|
|
11908
|
-
* The `root` property set to `true` affects the configuration as following:
|
|
11909
|
-
*
|
|
11910
|
-
* 1. If set in override the override is returned as-is.
|
|
11911
|
-
* 2. If set in the global config the override is merged into global and
|
|
11912
|
-
* returned. No configuration files are searched.
|
|
11913
|
-
* 3. Setting `root` in configuration file only stops directory traversal.
|
|
11914
|
-
*
|
|
11915
|
-
* @public
|
|
11916
|
-
*/
|
|
11917
|
-
class FileSystemConfigLoader extends ConfigLoader {
|
|
11918
|
-
/**
|
|
11919
|
-
* @param config - Global configuration
|
|
11920
|
-
* @param configFactory - Optional configuration factory
|
|
11921
|
-
*/
|
|
11922
|
-
constructor(config, configFactory = Config) {
|
|
11923
|
-
super(config, configFactory);
|
|
11924
|
-
this.cache = new Map();
|
|
11925
|
-
}
|
|
11926
|
-
/**
|
|
11927
|
-
* Get configuration for given filename.
|
|
11928
|
-
*
|
|
11929
|
-
* @param filename - Filename to get configuration for.
|
|
11930
|
-
* @param configOverride - Configuration to merge final result with.
|
|
11931
|
-
*/
|
|
11932
|
-
getConfigFor(filename, configOverride) {
|
|
11933
|
-
/* special case when the overridden configuration is marked as root, should
|
|
11934
|
-
* not try to load any more configuration files */
|
|
11935
|
-
const override = this.loadFromObject(configOverride || {});
|
|
11936
|
-
if (override.isRootFound()) {
|
|
11937
|
-
override.init();
|
|
11938
|
-
return override.resolve();
|
|
11939
|
-
}
|
|
11940
|
-
/* special case when the global configuration is marked as root, should not
|
|
11941
|
-
* try to load and more configuration files */
|
|
11942
|
-
if (this.globalConfig.isRootFound()) {
|
|
11943
|
-
const merged = this.globalConfig.merge(override);
|
|
11944
|
-
merged.init();
|
|
11945
|
-
return merged.resolve();
|
|
11946
|
-
}
|
|
11947
|
-
const config = this.fromFilename(filename);
|
|
11948
|
-
const merged = config ? config.merge(override) : this.globalConfig.merge(override);
|
|
11949
|
-
merged.init();
|
|
11950
|
-
return merged.resolve();
|
|
11951
|
-
}
|
|
11952
|
-
/**
|
|
11953
|
-
* Flush configuration cache.
|
|
11954
|
-
*
|
|
11955
|
-
* @param filename - If given only the cache for that file is flushed.
|
|
11956
|
-
*/
|
|
11957
|
-
flushCache(filename) {
|
|
11958
|
-
if (filename) {
|
|
11959
|
-
this.cache.delete(filename);
|
|
11960
|
-
}
|
|
11961
|
-
else {
|
|
11962
|
-
this.cache.clear();
|
|
11963
|
-
}
|
|
11964
|
-
}
|
|
11965
|
-
/**
|
|
11966
|
-
* Load raw configuration from directory traversal.
|
|
11967
|
-
*
|
|
11968
|
-
* This configuration is not merged with global configuration and may return
|
|
11969
|
-
* `null` if no configuration files are found.
|
|
11970
|
-
*/
|
|
11971
|
-
fromFilename(filename) {
|
|
11972
|
-
if (filename === "inline") {
|
|
11973
|
-
return null;
|
|
11974
|
-
}
|
|
11975
|
-
const cache = this.cache.get(filename);
|
|
11976
|
-
if (cache) {
|
|
11977
|
-
return cache;
|
|
11978
|
-
}
|
|
11979
|
-
let found = false;
|
|
11980
|
-
let current = path.resolve(path.dirname(filename));
|
|
11981
|
-
let config = this.empty();
|
|
11982
|
-
// eslint-disable-next-line no-constant-condition -- it will break out when filesystem is traversed
|
|
11983
|
-
while (true) {
|
|
11984
|
-
/* search configuration files in current directory */
|
|
11985
|
-
for (const configFile of findConfigurationFiles(current)) {
|
|
11986
|
-
const local = this.loadFromFile(configFile);
|
|
11987
|
-
found = true;
|
|
11988
|
-
config = local.merge(config);
|
|
11989
|
-
}
|
|
11990
|
-
/* stop if a configuration with "root" is set to true */
|
|
11991
|
-
if (config.isRootFound()) {
|
|
11992
|
-
break;
|
|
11993
|
-
}
|
|
11994
|
-
/* get the parent directory */
|
|
11995
|
-
const child = current;
|
|
11996
|
-
current = path.dirname(current);
|
|
11997
|
-
/* stop if this is the root directory */
|
|
11998
|
-
if (current === child) {
|
|
11999
|
-
break;
|
|
12000
|
-
}
|
|
12001
|
-
}
|
|
12002
|
-
/* no config was found by loader, return null and let caller decide what to do */
|
|
12003
|
-
if (!found) {
|
|
12004
|
-
this.cache.set(filename, null);
|
|
12005
|
-
return null;
|
|
12006
|
-
}
|
|
12007
|
-
this.cache.set(filename, config);
|
|
12008
|
-
return config;
|
|
12009
|
-
}
|
|
12010
|
-
defaultConfig() {
|
|
12011
|
-
return this.configFactory.defaultConfig();
|
|
12012
|
-
}
|
|
12013
|
-
}
|
|
12014
|
-
|
|
12015
11759
|
const entities = {
|
|
12016
11760
|
">": ">",
|
|
12017
11761
|
"<": "<",
|
|
@@ -12263,5 +12007,5 @@ function getFormatter(name) {
|
|
|
12263
12007
|
return (_a = availableFormatters[name]) !== null && _a !== void 0 ? _a : null;
|
|
12264
12008
|
}
|
|
12265
12009
|
|
|
12266
|
-
export { Attribute as A,
|
|
12010
|
+
export { Attribute as A, generateIdSelector as B, Config as C, DynamicValue as D, EventHandler as E, name as F, bugs as G, HtmlValidate as H, 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, sliceLocation as n, Reporter as o, definePlugin as p, Parser as q, ruleExists as r, staticResolver as s, getFormatter as t, ensureError as u, version as v, compatibilityCheck as w, codeframe as x, isTextNode as y, isElementNode as z };
|
|
12267
12011
|
//# sourceMappingURL=core.js.map
|