html-validate 9.3.0 → 9.4.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 +1 -2
- package/dist/cjs/browser.js.map +1 -1
- package/dist/cjs/cli.js +1 -1
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/core-browser.js +417 -0
- package/dist/cjs/core-browser.js.map +1 -1
- package/dist/cjs/core-nodejs.js +424 -4
- package/dist/cjs/core-nodejs.js.map +1 -1
- package/dist/cjs/core.js +248 -658
- package/dist/cjs/core.js.map +1 -1
- package/dist/cjs/html-validate.js +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/jest-worker.js +6 -6
- package/dist/cjs/jest-worker.js.map +1 -1
- package/dist/cjs/jest.js +1 -1
- package/dist/cjs/vitest.js +2 -2
- package/dist/es/browser.js +2 -3
- package/dist/es/browser.js.map +1 -1
- package/dist/es/cli.js +2 -2
- package/dist/es/core-browser.js +418 -2
- package/dist/es/core-browser.js.map +1 -1
- package/dist/es/core-nodejs.js +424 -4
- package/dist/es/core-nodejs.js.map +1 -1
- package/dist/es/core.js +242 -657
- package/dist/es/core.js.map +1 -1
- package/dist/es/html-validate.js +3 -2
- package/dist/es/html-validate.js.map +1 -1
- package/dist/es/index.js +4 -3
- package/dist/es/index.js.map +1 -1
- package/dist/es/jest-worker.js +7 -6
- package/dist/es/jest-worker.js.map +1 -1
- package/dist/es/jest.js +2 -1
- package/dist/es/jest.js.map +1 -1
- package/dist/es/matchers-jestonly.js +1 -1
- package/dist/es/matchers.js +1 -1
- package/dist/es/vitest.js +3 -2
- package/dist/es/vitest.js.map +1 -1
- package/dist/types/browser.d.ts +25 -4
- package/dist/types/index.d.ts +25 -4
- package/package.json +1 -1
|
@@ -11,10 +11,10 @@ require('./elements.js');
|
|
|
11
11
|
require('./meta-helper.js');
|
|
12
12
|
require('./utils/natural-join.js');
|
|
13
13
|
require('@sidvind/better-ajv-errors');
|
|
14
|
-
require('node:fs');
|
|
15
14
|
require('@html-validate/stylish');
|
|
16
15
|
require('semver');
|
|
17
16
|
require('./core-nodejs.js');
|
|
17
|
+
require('node:fs');
|
|
18
18
|
require('node:fs/promises');
|
|
19
19
|
require('node:url');
|
|
20
20
|
require('node:path/posix');
|
package/dist/cjs/index.js
CHANGED
|
@@ -4,8 +4,8 @@ var coreNodejs = require('./core-nodejs.js');
|
|
|
4
4
|
var core = require('./core.js');
|
|
5
5
|
var cli = require('./cli.js');
|
|
6
6
|
var metaHelper = require('./meta-helper.js');
|
|
7
|
-
require('node:path');
|
|
8
7
|
require('node:fs');
|
|
8
|
+
require('node:path');
|
|
9
9
|
require('node:fs/promises');
|
|
10
10
|
require('node:url');
|
|
11
11
|
require('kleur');
|
|
@@ -23,6 +23,7 @@ require('prompts');
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
exports.FileSystemConfigLoader = coreNodejs.FileSystemConfigLoader;
|
|
26
|
+
exports.HtmlValidate = coreNodejs.HtmlValidate;
|
|
26
27
|
exports.cjsResolver = coreNodejs.cjsResolver;
|
|
27
28
|
exports.compatibilityCheck = coreNodejs.compatibilityCheck;
|
|
28
29
|
exports.esmResolver = coreNodejs.esmResolver;
|
|
@@ -37,7 +38,6 @@ exports.DOMTree = core.DOMTree;
|
|
|
37
38
|
exports.DynamicValue = core.DynamicValue;
|
|
38
39
|
exports.EventHandler = core.EventHandler;
|
|
39
40
|
exports.HtmlElement = core.HtmlElement;
|
|
40
|
-
exports.HtmlValidate = core.HtmlValidate;
|
|
41
41
|
exports.MetaCopyableProperty = core.MetaCopyableProperty;
|
|
42
42
|
exports.MetaTable = core.MetaTable;
|
|
43
43
|
exports.NestedError = core.NestedError;
|
package/dist/cjs/jest-worker.js
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
var node_worker_threads = require('node:worker_threads');
|
|
4
4
|
var coreNodejs = require('./core-nodejs.js');
|
|
5
|
-
var core = require('./core.js');
|
|
6
|
-
require('node:path');
|
|
7
5
|
require('node:fs');
|
|
8
|
-
require('
|
|
9
|
-
require('node:url');
|
|
10
|
-
require('kleur');
|
|
6
|
+
require('./core.js');
|
|
11
7
|
require('ajv');
|
|
12
8
|
require('./elements.js');
|
|
13
9
|
require('./meta-helper.js');
|
|
14
10
|
require('./utils/natural-join.js');
|
|
15
11
|
require('@sidvind/better-ajv-errors');
|
|
12
|
+
require('kleur');
|
|
16
13
|
require('@html-validate/stylish');
|
|
17
14
|
require('semver');
|
|
15
|
+
require('node:path');
|
|
16
|
+
require('node:fs/promises');
|
|
17
|
+
require('node:url');
|
|
18
18
|
|
|
19
19
|
function runAsWorker(fn) {
|
|
20
20
|
if (!node_worker_threads.workerData) {
|
|
@@ -55,7 +55,7 @@ function validateString(markup, filename, config) {
|
|
|
55
55
|
const loader = new coreNodejs.FileSystemConfigLoader({
|
|
56
56
|
extends: ["html-validate:recommended"]
|
|
57
57
|
});
|
|
58
|
-
const htmlvalidate = new
|
|
58
|
+
const htmlvalidate = new coreNodejs.HtmlValidate(loader);
|
|
59
59
|
return htmlvalidate.validateString(markup, filename, config);
|
|
60
60
|
}
|
|
61
61
|
runAsWorker(validateString);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jest-worker.js","sources":["../../src/jest/worker/worker.ts"],"sourcesContent":["import { type MessagePort, parentPort, workerData } from \"node:worker_threads\";\nimport { type ConfigData } from \"../../config\";\nimport { FileSystemConfigLoader } from \"../../config/loaders/file-system\";\nimport { HtmlValidate } from \"../../htmlvalidate\";\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype AnyAsyncFn,\n\ttype MainToWorkerCommandMessage,\n\ttype MainToWorkerMessage,\n\ttype WorkerToMainMessage,\n} from \"./types\";\n\ninterface WorkerData {\n\tsharedBuffer: SharedArrayBuffer;\n\tworkerPort: MessagePort;\n}\n\nfunction runAsWorker<R = unknown, T extends AnyAsyncFn<R> = AnyAsyncFn<R>>(fn: T): void {\n\tif (!workerData) {\n\t\treturn;\n\t}\n\n\tconst { workerPort, sharedBuffer } = workerData as WorkerData;\n\tconst sharedBufferView = new Int32Array(sharedBuffer, 0, 1);\n\n\t/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- better crash at runtime if not set */\n\tparentPort!.on(\"message\", ({ id, args }: MainToWorkerMessage<Parameters<T>>) => {\n\t\tasync function inner(): Promise<void> {\n\t\t\tlet isAborted = false;\n\t\t\tconst handleAbortMessage = (msg: MainToWorkerCommandMessage): void => {\n\t\t\t\tif (msg.id === id && msg.cmd === \"abort\") {\n\t\t\t\t\tisAborted = true;\n\t\t\t\t}\n\t\t\t};\n\t\t\tworkerPort.on(\"message\", handleAbortMessage);\n\t\t\tlet msg: WorkerToMainMessage<R>;\n\t\t\ttry {\n\t\t\t\tmsg = { id, result: await fn(...args) };\n\t\t\t} catch (error: unknown) {\n\t\t\t\tmsg = {\n\t\t\t\t\tid,\n\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t};\n\t\t\t}\n\t\t\tworkerPort.off(\"message\", handleAbortMessage);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- modified by handleAbortMessage\n\t\t\tif (isAborted) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tworkerPort.postMessage(msg);\n\t\t\tAtomics.add(sharedBufferView, 0, 1);\n\t\t\tAtomics.notify(sharedBufferView, 0);\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises -- should not happen\n\t\tinner();\n\t});\n}\n\nfunction validateString(markup: string, filename: string, config: ConfigData): Promise<Report> {\n\tconst loader = new FileSystemConfigLoader({\n\t\textends: [\"html-validate:recommended\"],\n\t});\n\tconst htmlvalidate = new HtmlValidate(loader);\n\treturn htmlvalidate.validateString(markup, filename, config);\n}\n\nexport type ValidateStringFn = typeof validateString;\n\nrunAsWorker(validateString);\n"],"names":["workerData","parentPort","msg","FileSystemConfigLoader","HtmlValidate"],"mappings":";;;;;;;;;;;;;;;;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,KAAA,EAAA;AAAA,GACN,CAAA;AACF;AAEA,SAAS,cAAA,CAAe,MAAgB,EAAA,QAAA,EAAkB,MAAqC,EAAA;AAC9F,EAAM,MAAA,MAAA,GAAS,IAAIC,iCAAuB,CAAA;AAAA,IACzC,OAAA,EAAS,CAAC,2BAA2B;AAAA,GACrC,CAAA;AACD,EAAM,MAAA,YAAA,GAAe,IAAIC,
|
|
1
|
+
{"version":3,"file":"jest-worker.js","sources":["../../src/jest/worker/worker.ts"],"sourcesContent":["import { type MessagePort, parentPort, workerData } from \"node:worker_threads\";\nimport { type ConfigData } from \"../../config\";\nimport { FileSystemConfigLoader } from \"../../config/loaders/file-system\";\nimport { HtmlValidate } from \"../../htmlvalidate\";\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype AnyAsyncFn,\n\ttype MainToWorkerCommandMessage,\n\ttype MainToWorkerMessage,\n\ttype WorkerToMainMessage,\n} from \"./types\";\n\ninterface WorkerData {\n\tsharedBuffer: SharedArrayBuffer;\n\tworkerPort: MessagePort;\n}\n\nfunction runAsWorker<R = unknown, T extends AnyAsyncFn<R> = AnyAsyncFn<R>>(fn: T): void {\n\tif (!workerData) {\n\t\treturn;\n\t}\n\n\tconst { workerPort, sharedBuffer } = workerData as WorkerData;\n\tconst sharedBufferView = new Int32Array(sharedBuffer, 0, 1);\n\n\t/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- better crash at runtime if not set */\n\tparentPort!.on(\"message\", ({ id, args }: MainToWorkerMessage<Parameters<T>>) => {\n\t\tasync function inner(): Promise<void> {\n\t\t\tlet isAborted = false;\n\t\t\tconst handleAbortMessage = (msg: MainToWorkerCommandMessage): void => {\n\t\t\t\tif (msg.id === id && msg.cmd === \"abort\") {\n\t\t\t\t\tisAborted = true;\n\t\t\t\t}\n\t\t\t};\n\t\t\tworkerPort.on(\"message\", handleAbortMessage);\n\t\t\tlet msg: WorkerToMainMessage<R>;\n\t\t\ttry {\n\t\t\t\tmsg = { id, result: await fn(...args) };\n\t\t\t} catch (error: unknown) {\n\t\t\t\tmsg = {\n\t\t\t\t\tid,\n\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t};\n\t\t\t}\n\t\t\tworkerPort.off(\"message\", handleAbortMessage);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- modified by handleAbortMessage\n\t\t\tif (isAborted) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tworkerPort.postMessage(msg);\n\t\t\tAtomics.add(sharedBufferView, 0, 1);\n\t\t\tAtomics.notify(sharedBufferView, 0);\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises -- should not happen\n\t\tinner();\n\t});\n}\n\nfunction validateString(markup: string, filename: string, config: ConfigData): Promise<Report> {\n\tconst loader = new FileSystemConfigLoader({\n\t\textends: [\"html-validate:recommended\"],\n\t});\n\tconst htmlvalidate = new HtmlValidate(loader);\n\treturn htmlvalidate.validateString(markup, filename, config);\n}\n\nexport type ValidateStringFn = typeof validateString;\n\nrunAsWorker(validateString);\n"],"names":["workerData","parentPort","msg","FileSystemConfigLoader","HtmlValidate"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,SAAS,YAAkE,EAAa,EAAA;AACvF,EAAA,IAAI,CAACA,8BAAY,EAAA;AAChB,IAAA;AAAA;AAGD,EAAM,MAAA,EAAE,UAAY,EAAA,YAAA,EAAiB,GAAAA,8BAAA;AACrC,EAAA,MAAM,gBAAmB,GAAA,IAAI,UAAW,CAAA,YAAA,EAAc,GAAG,CAAC,CAAA;AAG1D,EAAAC,8BAAA,CAAY,GAAG,SAAW,EAAA,CAAC,EAAE,EAAA,EAAI,MAA+C,KAAA;AAC/E,IAAA,eAAe,KAAuB,GAAA;AACrC,MAAA,IAAI,SAAY,GAAA,KAAA;AAChB,MAAM,MAAA,kBAAA,GAAqB,CAACC,IAA0C,KAAA;AACrE,QAAA,IAAIA,IAAI,CAAA,EAAA,KAAO,EAAMA,IAAAA,IAAAA,CAAI,QA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|
13
13
|
require('@sidvind/better-ajv-errors');
|
|
14
|
-
require('node:fs');
|
|
15
14
|
require('@html-validate/stylish');
|
|
16
15
|
require('semver');
|
|
17
16
|
require('./matcher-utils.js');
|
|
18
17
|
require('node:worker_threads');
|
|
19
18
|
require('./core-nodejs.js');
|
|
19
|
+
require('node:fs');
|
|
20
20
|
require('node:path');
|
|
21
21
|
require('node:fs/promises');
|
|
22
22
|
require('node:url');
|
package/dist/cjs/vitest.js
CHANGED
|
@@ -5,17 +5,17 @@ var matchers = require('./matchers.js');
|
|
|
5
5
|
require('./matcher-utils.js');
|
|
6
6
|
require('node:worker_threads');
|
|
7
7
|
require('./core-nodejs.js');
|
|
8
|
-
require('node:
|
|
8
|
+
require('node:fs');
|
|
9
9
|
require('./core.js');
|
|
10
10
|
require('ajv');
|
|
11
11
|
require('./elements.js');
|
|
12
12
|
require('./meta-helper.js');
|
|
13
13
|
require('./utils/natural-join.js');
|
|
14
14
|
require('@sidvind/better-ajv-errors');
|
|
15
|
-
require('node:fs');
|
|
16
15
|
require('kleur');
|
|
17
16
|
require('@html-validate/stylish');
|
|
18
17
|
require('semver');
|
|
18
|
+
require('node:path');
|
|
19
19
|
require('node:fs/promises');
|
|
20
20
|
require('node:url');
|
|
21
21
|
|
package/dist/es/browser.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
export { c as compatibilityCheck, e as esmResolver } from './core-browser.js';
|
|
2
|
-
export { A as Attribute, C as Config, a as ConfigError, b as ConfigLoader, D as DOMNode, h as DOMTokenList, j as DOMTree, k as DynamicValue,
|
|
1
|
+
export { H as HtmlValidate, c as compatibilityCheck, e as esmResolver } from './core-browser.js';
|
|
2
|
+
export { A as Attribute, C as Config, a as ConfigError, b as ConfigLoader, D as DOMNode, h as DOMTokenList, j as DOMTree, k as DynamicValue, I as EventHandler, H as HtmlElement, M as MetaCopyableProperty, q as MetaTable, m as NestedError, N as NodeClosed, l as NodeType, P as Parser, B as Reporter, R as ResolvedConfig, t as Rule, n as SchemaValidationError, S as Severity, f as StaticConfigLoader, w as TextClassification, r as TextContent, T as TextNode, U as UserError, V as Validator, W as WrappedError, u as ariaNaming, x as classifyNodeText, p as configPresets, c as defineConfig, E as definePlugin, o as isUserError, y as keywordPatternMatcher, F as ruleExists, z as sliceLocation, s as staticResolver, v as version, G as walk } from './core.js';
|
|
3
3
|
export { d as defineMetadata, m as metadataHelper } from './meta-helper.js';
|
|
4
4
|
import 'ajv';
|
|
5
5
|
import './elements.js';
|
|
6
6
|
import '@sidvind/better-ajv-errors';
|
|
7
7
|
import './utils/natural-join.js';
|
|
8
|
-
import 'node:fs';
|
|
9
8
|
import 'kleur';
|
|
10
9
|
import '@html-validate/stylish';
|
|
11
10
|
import 'semver';
|
package/dist/es/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"browser.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|
package/dist/es/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as legacyRequire, F as FileSystemConfigLoader, e as esmResolver } from './core-nodejs.js';
|
|
2
|
-
import { g as getFormatter$1, U as UserError, e as ensureError, i as ignore, d as deepmerge,
|
|
1
|
+
import { l as legacyRequire, F as FileSystemConfigLoader, e as esmResolver, H as HtmlValidate } from './core-nodejs.js';
|
|
2
|
+
import { g as getFormatter$1, U as UserError, e as ensureError, i as ignore, d as deepmerge, J as engines, B as Reporter } from './core.js';
|
|
3
3
|
import path$1 from 'node:path/posix';
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
import path from 'node:path';
|
package/dist/es/core-browser.js
CHANGED
|
@@ -1,4 +1,420 @@
|
|
|
1
|
-
import { U as UserError,
|
|
1
|
+
import { f as StaticConfigLoader, K as normalizeSource, L as transformSource, O as Engine, P as Parser, Q as transformSourceSync, X as transformFilename, Y as transformFilenameSync, B as Reporter, Z as configurationSchema, _ as isThenable, U as UserError, b as ConfigLoader, $ as compatibilityCheckImpl, v as version } from './core.js';
|
|
2
|
+
|
|
3
|
+
function isSourceHooks(value) {
|
|
4
|
+
if (!value || typeof value === "string") {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
return Boolean(value.processAttribute || value.processElement);
|
|
8
|
+
}
|
|
9
|
+
function isConfigData(value) {
|
|
10
|
+
if (!value || typeof value === "string") {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
return !(value.processAttribute || value.processElement);
|
|
14
|
+
}
|
|
15
|
+
class HtmlValidate {
|
|
16
|
+
configLoader;
|
|
17
|
+
constructor(arg) {
|
|
18
|
+
const [loader, config] = arg instanceof ConfigLoader ? [arg, void 0] : [void 0, arg];
|
|
19
|
+
this.configLoader = loader ?? new StaticConfigLoader(config);
|
|
20
|
+
}
|
|
21
|
+
/* eslint-enable @typescript-eslint/unified-signatures */
|
|
22
|
+
validateString(str, arg1, arg2, arg3) {
|
|
23
|
+
const filename = typeof arg1 === "string" ? arg1 : "inline";
|
|
24
|
+
const options = isConfigData(arg1) ? arg1 : isConfigData(arg2) ? arg2 : void 0;
|
|
25
|
+
const hooks = isSourceHooks(arg1) ? arg1 : isSourceHooks(arg2) ? arg2 : arg3;
|
|
26
|
+
const source = {
|
|
27
|
+
data: str,
|
|
28
|
+
filename,
|
|
29
|
+
line: 1,
|
|
30
|
+
column: 1,
|
|
31
|
+
offset: 0,
|
|
32
|
+
hooks
|
|
33
|
+
};
|
|
34
|
+
return this.validateSource(source, options);
|
|
35
|
+
}
|
|
36
|
+
/* eslint-enable @typescript-eslint/unified-signatures */
|
|
37
|
+
validateStringSync(str, arg1, arg2, arg3) {
|
|
38
|
+
const filename = typeof arg1 === "string" ? arg1 : "inline";
|
|
39
|
+
const options = isConfigData(arg1) ? arg1 : isConfigData(arg2) ? arg2 : void 0;
|
|
40
|
+
const hooks = isSourceHooks(arg1) ? arg1 : isSourceHooks(arg2) ? arg2 : arg3;
|
|
41
|
+
const source = {
|
|
42
|
+
data: str,
|
|
43
|
+
filename,
|
|
44
|
+
line: 1,
|
|
45
|
+
column: 1,
|
|
46
|
+
offset: 0,
|
|
47
|
+
hooks
|
|
48
|
+
};
|
|
49
|
+
return this.validateSourceSync(source, options);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Parse and validate HTML from [[Source]].
|
|
53
|
+
*
|
|
54
|
+
* @public
|
|
55
|
+
* @param input - Source to parse.
|
|
56
|
+
* @returns Report output.
|
|
57
|
+
*/
|
|
58
|
+
async validateSource(input, configOverride) {
|
|
59
|
+
const source = normalizeSource(input);
|
|
60
|
+
const config = await this.getConfigFor(source.filename, configOverride);
|
|
61
|
+
const resolvers = this.configLoader.getResolvers();
|
|
62
|
+
const transformedSource = await transformSource(resolvers, config, source);
|
|
63
|
+
const engine = new Engine(config, Parser);
|
|
64
|
+
return engine.lint(transformedSource);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Parse and validate HTML from [[Source]].
|
|
68
|
+
*
|
|
69
|
+
* @public
|
|
70
|
+
* @param input - Source to parse.
|
|
71
|
+
* @returns Report output.
|
|
72
|
+
*/
|
|
73
|
+
validateSourceSync(input, configOverride) {
|
|
74
|
+
const source = normalizeSource(input);
|
|
75
|
+
const config = this.getConfigForSync(source.filename, configOverride);
|
|
76
|
+
const resolvers = this.configLoader.getResolvers();
|
|
77
|
+
const transformedSource = transformSourceSync(resolvers, config, source);
|
|
78
|
+
const engine = new Engine(config, Parser);
|
|
79
|
+
return engine.lint(transformedSource);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Parse and validate HTML from file.
|
|
83
|
+
*
|
|
84
|
+
* @public
|
|
85
|
+
* @param filename - Filename to read and parse.
|
|
86
|
+
* @returns Report output.
|
|
87
|
+
*/
|
|
88
|
+
async validateFile(filename, fs) {
|
|
89
|
+
const config = await this.getConfigFor(filename);
|
|
90
|
+
const resolvers = this.configLoader.getResolvers();
|
|
91
|
+
const source = await transformFilename(resolvers, config, filename, fs);
|
|
92
|
+
const engine = new Engine(config, Parser);
|
|
93
|
+
return Promise.resolve(engine.lint(source));
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Parse and validate HTML from file.
|
|
97
|
+
*
|
|
98
|
+
* @public
|
|
99
|
+
* @param filename - Filename to read and parse.
|
|
100
|
+
* @returns Report output.
|
|
101
|
+
*/
|
|
102
|
+
validateFileSync(filename, fs) {
|
|
103
|
+
const config = this.getConfigForSync(filename);
|
|
104
|
+
const resolvers = this.configLoader.getResolvers();
|
|
105
|
+
const source = transformFilenameSync(resolvers, config, filename, fs);
|
|
106
|
+
const engine = new Engine(config, Parser);
|
|
107
|
+
return engine.lint(source);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Parse and validate HTML from multiple files. Result is merged together to a
|
|
111
|
+
* single report.
|
|
112
|
+
*
|
|
113
|
+
* @param filenames - Filenames to read and parse.
|
|
114
|
+
* @returns Report output.
|
|
115
|
+
*/
|
|
116
|
+
async validateMultipleFiles(filenames, fs) {
|
|
117
|
+
return Reporter.merge(filenames.map((filename) => this.validateFile(filename, fs)));
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Parse and validate HTML from multiple files. Result is merged together to a
|
|
121
|
+
* single report.
|
|
122
|
+
*
|
|
123
|
+
* @param filenames - Filenames to read and parse.
|
|
124
|
+
* @returns Report output.
|
|
125
|
+
*/
|
|
126
|
+
validateMultipleFilesSync(filenames, fs) {
|
|
127
|
+
return Reporter.merge(filenames.map((filename) => this.validateFileSync(filename, fs)));
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Returns true if the given filename can be validated.
|
|
131
|
+
*
|
|
132
|
+
* A file is considered to be validatable if the extension is `.html` or if a
|
|
133
|
+
* transformer matches the filename.
|
|
134
|
+
*
|
|
135
|
+
* This is mostly useful for tooling to determine whenever to validate the
|
|
136
|
+
* file or not. CLI tools will run on all the given files anyway.
|
|
137
|
+
*/
|
|
138
|
+
async canValidate(filename) {
|
|
139
|
+
if (filename.toLowerCase().endsWith(".html")) {
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
const config = await this.getConfigFor(filename);
|
|
143
|
+
return config.canTransform(filename);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Returns true if the given filename can be validated.
|
|
147
|
+
*
|
|
148
|
+
* A file is considered to be validatable if the extension is `.html` or if a
|
|
149
|
+
* transformer matches the filename.
|
|
150
|
+
*
|
|
151
|
+
* This is mostly useful for tooling to determine whenever to validate the
|
|
152
|
+
* file or not. CLI tools will run on all the given files anyway.
|
|
153
|
+
*/
|
|
154
|
+
canValidateSync(filename) {
|
|
155
|
+
if (filename.toLowerCase().endsWith(".html")) {
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
const config = this.getConfigForSync(filename);
|
|
159
|
+
return config.canTransform(filename);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Tokenize filename and output all tokens.
|
|
163
|
+
*
|
|
164
|
+
* Using CLI this is enabled with `--dump-tokens`. Mostly useful for
|
|
165
|
+
* debugging.
|
|
166
|
+
*
|
|
167
|
+
* @internal
|
|
168
|
+
* @param filename - Filename to tokenize.
|
|
169
|
+
*/
|
|
170
|
+
async dumpTokens(filename, fs) {
|
|
171
|
+
const config = await this.getConfigFor(filename);
|
|
172
|
+
const resolvers = this.configLoader.getResolvers();
|
|
173
|
+
const source = await transformFilename(resolvers, config, filename, fs);
|
|
174
|
+
const engine = new Engine(config, Parser);
|
|
175
|
+
return engine.dumpTokens(source);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Parse filename and output all events.
|
|
179
|
+
*
|
|
180
|
+
* Using CLI this is enabled with `--dump-events`. Mostly useful for
|
|
181
|
+
* debugging.
|
|
182
|
+
*
|
|
183
|
+
* @internal
|
|
184
|
+
* @param filename - Filename to dump events from.
|
|
185
|
+
*/
|
|
186
|
+
async dumpEvents(filename, fs) {
|
|
187
|
+
const config = await this.getConfigFor(filename);
|
|
188
|
+
const resolvers = this.configLoader.getResolvers();
|
|
189
|
+
const source = await transformFilename(resolvers, config, filename, fs);
|
|
190
|
+
const engine = new Engine(config, Parser);
|
|
191
|
+
return engine.dumpEvents(source);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Parse filename and output DOM tree.
|
|
195
|
+
*
|
|
196
|
+
* Using CLI this is enabled with `--dump-tree`. Mostly useful for
|
|
197
|
+
* debugging.
|
|
198
|
+
*
|
|
199
|
+
* @internal
|
|
200
|
+
* @param filename - Filename to dump DOM tree from.
|
|
201
|
+
*/
|
|
202
|
+
async dumpTree(filename, fs) {
|
|
203
|
+
const config = await this.getConfigFor(filename);
|
|
204
|
+
const resolvers = this.configLoader.getResolvers();
|
|
205
|
+
const source = await transformFilename(resolvers, config, filename, fs);
|
|
206
|
+
const engine = new Engine(config, Parser);
|
|
207
|
+
return engine.dumpTree(source);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Transform filename and output source data.
|
|
211
|
+
*
|
|
212
|
+
* Using CLI this is enabled with `--dump-source`. Mostly useful for
|
|
213
|
+
* debugging.
|
|
214
|
+
*
|
|
215
|
+
* @internal
|
|
216
|
+
* @param filename - Filename to dump source from.
|
|
217
|
+
*/
|
|
218
|
+
async dumpSource(filename, fs) {
|
|
219
|
+
const config = await this.getConfigFor(filename);
|
|
220
|
+
const resolvers = this.configLoader.getResolvers();
|
|
221
|
+
const sources = await transformFilename(resolvers, config, filename, fs);
|
|
222
|
+
return sources.reduce((result, source) => {
|
|
223
|
+
const line = String(source.line);
|
|
224
|
+
const column = String(source.column);
|
|
225
|
+
const offset = String(source.offset);
|
|
226
|
+
result.push(`Source ${source.filename}@${line}:${column} (offset: ${offset})`);
|
|
227
|
+
if (source.transformedBy) {
|
|
228
|
+
result.push("Transformed by:");
|
|
229
|
+
result = result.concat(source.transformedBy.reverse().map((name) => ` - ${name}`));
|
|
230
|
+
}
|
|
231
|
+
if (source.hooks && Object.keys(source.hooks).length > 0) {
|
|
232
|
+
result.push("Hooks");
|
|
233
|
+
for (const [key, present] of Object.entries(source.hooks)) {
|
|
234
|
+
if (present) {
|
|
235
|
+
result.push(` - ${key}`);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
result.push("---");
|
|
240
|
+
result = result.concat(source.data.split("\n"));
|
|
241
|
+
result.push("---");
|
|
242
|
+
return result;
|
|
243
|
+
}, []);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Get effective configuration schema.
|
|
247
|
+
*/
|
|
248
|
+
getConfigurationSchema() {
|
|
249
|
+
return Promise.resolve(configurationSchema);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Get effective metadata element schema.
|
|
253
|
+
*
|
|
254
|
+
* If a filename is given the configured plugins can extend the
|
|
255
|
+
* schema. Filename must not be an existing file or a filetype normally
|
|
256
|
+
* handled by html-validate but the path will be used when resolving
|
|
257
|
+
* configuration. As a rule-of-thumb, set it to the elements json file.
|
|
258
|
+
*/
|
|
259
|
+
async getElementsSchema(filename) {
|
|
260
|
+
const config = await this.getConfigFor(filename ?? "inline");
|
|
261
|
+
const metaTable = config.getMetaTable();
|
|
262
|
+
return metaTable.getJSONSchema();
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Get effective metadata element schema.
|
|
266
|
+
*
|
|
267
|
+
* If a filename is given the configured plugins can extend the
|
|
268
|
+
* schema. Filename must not be an existing file or a filetype normally
|
|
269
|
+
* handled by html-validate but the path will be used when resolving
|
|
270
|
+
* configuration. As a rule-of-thumb, set it to the elements json file.
|
|
271
|
+
*/
|
|
272
|
+
getElementsSchemaSync(filename) {
|
|
273
|
+
const config = this.getConfigForSync(filename ?? "inline");
|
|
274
|
+
const metaTable = config.getMetaTable();
|
|
275
|
+
return metaTable.getJSONSchema();
|
|
276
|
+
}
|
|
277
|
+
async getContextualDocumentation(message, filenameOrConfig = "inline") {
|
|
278
|
+
const config = typeof filenameOrConfig === "string" ? await this.getConfigFor(filenameOrConfig) : await filenameOrConfig;
|
|
279
|
+
const engine = new Engine(config, Parser);
|
|
280
|
+
return engine.getRuleDocumentation(message);
|
|
281
|
+
}
|
|
282
|
+
getContextualDocumentationSync(message, filenameOrConfig = "inline") {
|
|
283
|
+
const config = typeof filenameOrConfig === "string" ? this.getConfigForSync(filenameOrConfig) : filenameOrConfig;
|
|
284
|
+
const engine = new Engine(config, Parser);
|
|
285
|
+
return engine.getRuleDocumentation(message);
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Get contextual documentation for the given rule.
|
|
289
|
+
*
|
|
290
|
+
* Typical usage:
|
|
291
|
+
*
|
|
292
|
+
* ```js
|
|
293
|
+
* const report = await htmlvalidate.validateFile("my-file.html");
|
|
294
|
+
* for (const result of report.results){
|
|
295
|
+
* const config = await htmlvalidate.getConfigFor(result.filePath);
|
|
296
|
+
* for (const message of result.messages){
|
|
297
|
+
* const documentation = await htmlvalidate.getRuleDocumentation(message.ruleId, config, message.context);
|
|
298
|
+
* // do something with documentation
|
|
299
|
+
* }
|
|
300
|
+
* }
|
|
301
|
+
* ```
|
|
302
|
+
*
|
|
303
|
+
* @public
|
|
304
|
+
* @deprecated Deprecated since 8.0.0, use [[getContextualDocumentation]] instead.
|
|
305
|
+
* @param ruleId - Rule to get documentation for.
|
|
306
|
+
* @param config - If set it provides more accurate description by using the
|
|
307
|
+
* correct configuration for the file.
|
|
308
|
+
* @param context - If set to `Message.context` some rules can provide
|
|
309
|
+
* contextual details and suggestions.
|
|
310
|
+
*/
|
|
311
|
+
async getRuleDocumentation(ruleId, config = null, context = null) {
|
|
312
|
+
const c = config ?? this.getConfigFor("inline");
|
|
313
|
+
const engine = new Engine(await c, Parser);
|
|
314
|
+
return engine.getRuleDocumentation({ ruleId, context });
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Get contextual documentation for the given rule.
|
|
318
|
+
*
|
|
319
|
+
* Typical usage:
|
|
320
|
+
*
|
|
321
|
+
* ```js
|
|
322
|
+
* const report = htmlvalidate.validateFileSync("my-file.html");
|
|
323
|
+
* for (const result of report.results){
|
|
324
|
+
* const config = htmlvalidate.getConfigForSync(result.filePath);
|
|
325
|
+
* for (const message of result.messages){
|
|
326
|
+
* const documentation = htmlvalidate.getRuleDocumentationSync(message.ruleId, config, message.context);
|
|
327
|
+
* // do something with documentation
|
|
328
|
+
* }
|
|
329
|
+
* }
|
|
330
|
+
* ```
|
|
331
|
+
*
|
|
332
|
+
* @public
|
|
333
|
+
* @deprecated Deprecated since 8.0.0, use [[getContextualDocumentationSync]] instead.
|
|
334
|
+
* @param ruleId - Rule to get documentation for.
|
|
335
|
+
* @param config - If set it provides more accurate description by using the
|
|
336
|
+
* correct configuration for the file.
|
|
337
|
+
* @param context - If set to `Message.context` some rules can provide
|
|
338
|
+
* contextual details and suggestions.
|
|
339
|
+
*/
|
|
340
|
+
getRuleDocumentationSync(ruleId, config = null, context = null) {
|
|
341
|
+
const c = config ?? this.getConfigForSync("inline");
|
|
342
|
+
const engine = new Engine(c, Parser);
|
|
343
|
+
return engine.getRuleDocumentation({ ruleId, context });
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Create a parser configured for given filename.
|
|
347
|
+
*
|
|
348
|
+
* @internal
|
|
349
|
+
* @param source - Source to use.
|
|
350
|
+
*/
|
|
351
|
+
async getParserFor(source) {
|
|
352
|
+
const config = await this.getConfigFor(source.filename);
|
|
353
|
+
return new Parser(config);
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Get configuration for given filename.
|
|
357
|
+
*
|
|
358
|
+
* See [[FileSystemConfigLoader]] for details.
|
|
359
|
+
*
|
|
360
|
+
* @public
|
|
361
|
+
* @param filename - Filename to get configuration for.
|
|
362
|
+
* @param configOverride - Configuration to apply last.
|
|
363
|
+
*/
|
|
364
|
+
getConfigFor(filename, configOverride) {
|
|
365
|
+
const config = this.configLoader.getConfigFor(filename, configOverride);
|
|
366
|
+
return Promise.resolve(config);
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Get configuration for given filename.
|
|
370
|
+
*
|
|
371
|
+
* See [[FileSystemConfigLoader]] for details.
|
|
372
|
+
*
|
|
373
|
+
* @public
|
|
374
|
+
* @param filename - Filename to get configuration for.
|
|
375
|
+
* @param configOverride - Configuration to apply last.
|
|
376
|
+
*/
|
|
377
|
+
getConfigForSync(filename, configOverride) {
|
|
378
|
+
const config = this.configLoader.getConfigFor(filename, configOverride);
|
|
379
|
+
if (isThenable(config)) {
|
|
380
|
+
throw new UserError("Cannot use asynchronous config loader with synchronous api");
|
|
381
|
+
}
|
|
382
|
+
return config;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Get current configuration loader.
|
|
386
|
+
*
|
|
387
|
+
* @public
|
|
388
|
+
* @since %version%
|
|
389
|
+
* @returns Current configuration loader.
|
|
390
|
+
*/
|
|
391
|
+
/* istanbul ignore next -- not testing setters/getters */
|
|
392
|
+
getConfigLoader() {
|
|
393
|
+
return this.configLoader;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Set configuration loader.
|
|
397
|
+
*
|
|
398
|
+
* @public
|
|
399
|
+
* @since %version%
|
|
400
|
+
* @param loader - New configuration loader to use.
|
|
401
|
+
*/
|
|
402
|
+
/* istanbul ignore next -- not testing setters/getters */
|
|
403
|
+
setConfigLoader(loader) {
|
|
404
|
+
this.configLoader = loader;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Flush configuration cache. Clears full cache unless a filename is given.
|
|
408
|
+
*
|
|
409
|
+
* See [[FileSystemConfigLoader]] for details.
|
|
410
|
+
*
|
|
411
|
+
* @public
|
|
412
|
+
* @param filename - If set, only flush cache for given filename.
|
|
413
|
+
*/
|
|
414
|
+
flushConfigCache(filename) {
|
|
415
|
+
this.configLoader.flushCache(filename);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
2
418
|
|
|
3
419
|
function importFunction(id) {
|
|
4
420
|
return import(id);
|
|
@@ -43,5 +459,5 @@ function compatibilityCheck(name, declared, options) {
|
|
|
43
459
|
});
|
|
44
460
|
}
|
|
45
461
|
|
|
46
|
-
export { compatibilityCheck as c, esmResolver as e };
|
|
462
|
+
export { HtmlValidate as H, compatibilityCheck as c, esmResolver as e };
|
|
47
463
|
//# sourceMappingURL=core-browser.js.map
|