html-validate 8.26.0 → 8.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/cjs/browser.js +1 -1
- package/dist/cjs/cli.js +1 -2
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/core-nodejs.js +2 -8
- package/dist/cjs/core-nodejs.js.map +1 -1
- package/dist/cjs/core.js +6618 -6603
- package/dist/cjs/core.js.map +1 -1
- package/dist/cjs/html-validate.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/jest-worker.js +60 -0
- package/dist/cjs/jest-worker.js.map +1 -0
- package/dist/cjs/jest.js +3 -2
- package/dist/cjs/jest.js.map +1 -1
- package/dist/cjs/matcher-utils.js +65 -0
- package/dist/cjs/matcher-utils.js.map +1 -1
- package/dist/cjs/matchers.js +2 -5
- package/dist/cjs/matchers.js.map +1 -1
- package/dist/cjs/tsdoc-metadata.json +1 -1
- package/dist/cjs/vitest.js +3 -2
- package/dist/cjs/vitest.js.map +1 -1
- package/dist/es/browser.js +1 -1
- package/dist/es/cli.js +1 -2
- package/dist/es/cli.js.map +1 -1
- package/dist/es/core-nodejs.js +2 -8
- package/dist/es/core-nodejs.js.map +1 -1
- package/dist/es/core.js +6618 -6604
- package/dist/es/core.js.map +1 -1
- package/dist/es/html-validate.js +2 -2
- package/dist/es/index.js +1 -1
- package/dist/es/jest-worker.js +59 -0
- package/dist/es/jest-worker.js.map +1 -0
- package/dist/es/jest.js +3 -2
- package/dist/es/jest.js.map +1 -1
- package/dist/es/matcher-utils.js +65 -1
- package/dist/es/matcher-utils.js.map +1 -1
- package/dist/es/matchers-jestonly.js +1 -1
- package/dist/es/matchers.js +4 -7
- package/dist/es/matchers.js.map +1 -1
- package/dist/es/vitest.js +3 -2
- package/dist/es/vitest.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/types/browser.d.ts +8 -52
- package/dist/types/index.d.ts +8 -52
- package/package.json +1 -1
package/dist/es/html-validate.js
CHANGED
|
@@ -2,17 +2,17 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import kleur from 'kleur';
|
|
4
4
|
import minimist from 'minimist';
|
|
5
|
-
import {
|
|
5
|
+
import { O as name, v as version, o as SchemaValidationError, U as UserError, Q as bugs } from './core.js';
|
|
6
6
|
import { M as Mode, m as modeToFlag, C as CLI, l as lint, i as init, p as printConfig, d as dump, h as handleSchemaValidationError } from './cli.js';
|
|
7
7
|
import 'ajv';
|
|
8
8
|
import './elements.js';
|
|
9
9
|
import './meta-helper.js';
|
|
10
10
|
import './utils/natural-join.js';
|
|
11
11
|
import '@sidvind/better-ajv-errors';
|
|
12
|
+
import 'node:fs';
|
|
12
13
|
import '@html-validate/stylish';
|
|
13
14
|
import 'semver';
|
|
14
15
|
import './core-nodejs.js';
|
|
15
|
-
import 'node:fs';
|
|
16
16
|
import 'node:module';
|
|
17
17
|
import 'glob';
|
|
18
18
|
import 'prompts';
|
package/dist/es/index.js
CHANGED
|
@@ -10,9 +10,9 @@ import 'ajv';
|
|
|
10
10
|
import './elements.js';
|
|
11
11
|
import '@sidvind/better-ajv-errors';
|
|
12
12
|
import './utils/natural-join.js';
|
|
13
|
-
import 'fs';
|
|
14
13
|
import '@html-validate/stylish';
|
|
15
14
|
import 'semver';
|
|
15
|
+
import 'fs';
|
|
16
16
|
import 'glob';
|
|
17
17
|
import 'prompts';
|
|
18
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { workerData, parentPort } from 'node:worker_threads';
|
|
2
|
+
import { F as FileSystemConfigLoader } from './core-nodejs.js';
|
|
3
|
+
import { H as HtmlValidate } from './core.js';
|
|
4
|
+
import 'node:fs';
|
|
5
|
+
import 'node:path';
|
|
6
|
+
import 'node:module';
|
|
7
|
+
import 'kleur';
|
|
8
|
+
import 'ajv';
|
|
9
|
+
import './elements.js';
|
|
10
|
+
import './meta-helper.js';
|
|
11
|
+
import './utils/natural-join.js';
|
|
12
|
+
import '@sidvind/better-ajv-errors';
|
|
13
|
+
import '@html-validate/stylish';
|
|
14
|
+
import 'semver';
|
|
15
|
+
|
|
16
|
+
function runAsWorker(fn) {
|
|
17
|
+
if (!workerData) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const { workerPort, sharedBuffer } = workerData;
|
|
21
|
+
const sharedBufferView = new Int32Array(sharedBuffer, 0, 1);
|
|
22
|
+
parentPort.on("message", ({ id, args }) => {
|
|
23
|
+
async function inner() {
|
|
24
|
+
let isAborted = false;
|
|
25
|
+
const handleAbortMessage = (msg2) => {
|
|
26
|
+
if (msg2.id === id && msg2.cmd === "abort") {
|
|
27
|
+
isAborted = true;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
workerPort.on("message", handleAbortMessage);
|
|
31
|
+
let msg;
|
|
32
|
+
try {
|
|
33
|
+
msg = { id, result: await fn(...args) };
|
|
34
|
+
} catch (error) {
|
|
35
|
+
msg = {
|
|
36
|
+
id,
|
|
37
|
+
error: error instanceof Error ? error.message : String(error)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
workerPort.off("message", handleAbortMessage);
|
|
41
|
+
if (isAborted) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
workerPort.postMessage(msg);
|
|
45
|
+
Atomics.add(sharedBufferView, 0, 1);
|
|
46
|
+
Atomics.notify(sharedBufferView, 0);
|
|
47
|
+
}
|
|
48
|
+
inner();
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function validateString(markup, filename, config) {
|
|
52
|
+
const loader = new FileSystemConfigLoader({
|
|
53
|
+
extends: ["html-validate:recommended"]
|
|
54
|
+
});
|
|
55
|
+
const htmlvalidate = new HtmlValidate(loader);
|
|
56
|
+
return htmlvalidate.validateString(markup, filename, config);
|
|
57
|
+
}
|
|
58
|
+
runAsWorker(validateString);
|
|
59
|
+
//# sourceMappingURL=jest-worker.js.map
|
|
@@ -0,0 +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":["msg"],"mappings":";;;;;;;;;;;;;;;AAiBA,SAAS,YAAkE,EAAa,EAAA;AACvF,EAAA,IAAI,CAAC,UAAY,EAAA;AAChB,IAAA;AAAA;AAGD,EAAM,MAAA,EAAE,UAAY,EAAA,YAAA,EAAiB,GAAA,UAAA;AACrC,EAAA,MAAM,gBAAmB,GAAA,IAAI,UAAW,CAAA,YAAA,EAAc,GAAG,CAAC,CAAA;AAG1D,EAAA,UAAA,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,CAACA,IAA0C,KAAA;AACrE,QAAA,IAAIA,IAAI,CAAA,EAAA,KAAO,EAAMA,IAAAA,IAAAA,CAAI,QAAQ,OAAS,EAAA;AACzC,UAAY,SAAA,GAAA,IAAA;AAAA;AACb,OACD;AACA,MAAW,UAAA,CAAA,EAAA,CAAG,WAAW,kBAAkB,CAAA;AAC3C,MAAI,IAAA,GAAA;AACJ,MAAI,IAAA;AACH,QAAA,GAAA,GAAM,EAAE,EAAI,EAAA,MAAA,EAAQ,MAAM,EAAG,CAAA,GAAG,IAAI,CAAE,EAAA;AAAA,eAC9B,KAAgB,EAAA;AACxB,QAAM,GAAA,GAAA;AAAA,UACL,EAAA;AAAA,UACA,OAAO,KAAiB,YAAA,KAAA,GAAQ,KAAM,CAAA,OAAA,GAAU,OAAO,KAAK;AAAA,SAC7D;AAAA;AAED,MAAW,UAAA,CAAA,GAAA,CAAI,WAAW,kBAAkB,CAAA;AAE5C,MAAA,IAAI,SAAW,EAAA;AACd,QAAA;AAAA;AAED,MAAA,UAAA,CAAW,YAAY,GAAG,CAAA;AAC1B,MAAQ,OAAA,CAAA,GAAA,CAAI,gBAAkB,EAAA,CAAA,EAAG,CAAC,CAAA;AAClC,MAAQ,OAAA,CAAA,MAAA,CAAO,kBAAkB,CAAC,CAAA;AAAA;AAGnC,IAAM,KAAA,EAAA;AAAA,GACN,CAAA;AACF;AAEA,SAAS,cAAA,CAAe,MAAgB,EAAA,QAAA,EAAkB,MAAqC,EAAA;AAC9F,EAAM,MAAA,MAAA,GAAS,IAAI,sBAAuB,CAAA;AAAA,IACzC,OAAA,EAAS,CAAC,2BAA2B;AAAA,GACrC,CAAA;AACD,EAAM,MAAA,YAAA,GAAe,IAAI,YAAA,CAAa,MAAM,CAAA;AAC5C,EAAA,OAAO,YAAa,CAAA,cAAA,CAAe,MAAQ,EAAA,QAAA,EAAU,MAAM,CAAA;AAC5D;AAIA,WAAA,CAAY,cAAc,CAAA"}
|
package/dist/es/jest.js
CHANGED
|
@@ -2,18 +2,19 @@ import { c as createMatcher, a as createMatcher$1, b as createMatcher$2, d as cr
|
|
|
2
2
|
import { c as createMatcher$5, a as createMatcher$6 } from './matchers-jestonly.js';
|
|
3
3
|
import { d as diff } from './jest-diff.js';
|
|
4
4
|
import './matcher-utils.js';
|
|
5
|
+
import 'node:url';
|
|
6
|
+
import 'node:worker_threads';
|
|
5
7
|
import './core.js';
|
|
6
8
|
import 'ajv';
|
|
7
9
|
import './elements.js';
|
|
8
10
|
import './meta-helper.js';
|
|
9
11
|
import './utils/natural-join.js';
|
|
10
12
|
import '@sidvind/better-ajv-errors';
|
|
11
|
-
import 'fs';
|
|
13
|
+
import 'node:fs';
|
|
12
14
|
import 'kleur';
|
|
13
15
|
import '@html-validate/stylish';
|
|
14
16
|
import 'semver';
|
|
15
17
|
import './core-nodejs.js';
|
|
16
|
-
import 'node:fs';
|
|
17
18
|
import 'node:path';
|
|
18
19
|
import 'node:module';
|
|
19
20
|
import 'jest-snapshot';
|
package/dist/es/jest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jest.js","sources":["../../src/jest/jest.ts"],"sourcesContent":["import \"./augmentation\";\n\nimport {\n\ttoBeValid,\n\ttoBeInvalid,\n\ttoHTMLValidate,\n\ttoHaveError,\n\ttoHaveErrors,\n\ttoMatchCodeframe,\n\ttoMatchInlineCodeframe,\n} from \"./matchers\";\nimport { diff } from \"./utils\";\n\nexpect.extend({\n\ttoBeValid: toBeValid(),\n\ttoBeInvalid: toBeInvalid(),\n\ttoHTMLValidate: toHTMLValidate(expect, diff),\n\ttoHaveError: toHaveError(expect, diff),\n\ttoHaveErrors: toHaveErrors(expect, diff),\n\ttoMatchCodeframe: toMatchCodeframe(),\n\ttoMatchInlineCodeframe: toMatchInlineCodeframe(),\n});\n"],"names":["toBeValid","toBeInvalid","toHTMLValidate","toHaveError","toHaveErrors","toMatchCodeframe","toMatchInlineCodeframe"],"mappings":"
|
|
1
|
+
{"version":3,"file":"jest.js","sources":["../../src/jest/jest.ts"],"sourcesContent":["import \"./augmentation\";\n\nimport {\n\ttoBeValid,\n\ttoBeInvalid,\n\ttoHTMLValidate,\n\ttoHaveError,\n\ttoHaveErrors,\n\ttoMatchCodeframe,\n\ttoMatchInlineCodeframe,\n} from \"./matchers\";\nimport { diff } from \"./utils\";\n\nexpect.extend({\n\ttoBeValid: toBeValid(),\n\ttoBeInvalid: toBeInvalid(),\n\ttoHTMLValidate: toHTMLValidate(expect, diff),\n\ttoHaveError: toHaveError(expect, diff),\n\ttoHaveErrors: toHaveErrors(expect, diff),\n\ttoMatchCodeframe: toMatchCodeframe(),\n\ttoMatchInlineCodeframe: toMatchInlineCodeframe(),\n});\n"],"names":["toBeValid","toBeInvalid","toHTMLValidate","toHaveError","toHaveErrors","toMatchCodeframe","toMatchInlineCodeframe"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAaA,MAAA,CAAO,MAAO,CAAA;AAAA,EACb,WAAWA,aAAU,EAAA;AAAA,EACrB,aAAaC,eAAY,EAAA;AAAA,EACzB,cAAA,EAAgBC,eAAe,CAAA,MAAA,EAAQ,IAAI,CAAA;AAAA,EAC3C,WAAA,EAAaC,eAAY,CAAA,MAAA,EAAQ,IAAI,CAAA;AAAA,EACrC,YAAA,EAAcC,eAAa,CAAA,MAAA,EAAQ,IAAI,CAAA;AAAA,EACvC,kBAAkBC,eAAiB,EAAA;AAAA,EACnC,wBAAwBC,eAAuB;AAChD,CAAC,CAAA"}
|
package/dist/es/matcher-utils.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { pathToFileURL } from 'node:url';
|
|
2
|
+
import { MessageChannel, Worker, receiveMessageOnPort } from 'node:worker_threads';
|
|
3
|
+
|
|
1
4
|
function isThenable(value) {
|
|
2
5
|
return value && typeof value === "object" && "then" in value && typeof value.then === "function";
|
|
3
6
|
}
|
|
@@ -19,5 +22,66 @@ function flattenMessages(report) {
|
|
|
19
22
|
}, []);
|
|
20
23
|
}
|
|
21
24
|
|
|
22
|
-
|
|
25
|
+
const INT32_BYTES = 4;
|
|
26
|
+
const syncFnCache = /* @__PURE__ */ new Map();
|
|
27
|
+
const sharedBuffer = new SharedArrayBuffer(INT32_BYTES);
|
|
28
|
+
const sharedBufferView = new Int32Array(sharedBuffer, 0, 1);
|
|
29
|
+
function isWorkerError(value) {
|
|
30
|
+
return "error" in value;
|
|
31
|
+
}
|
|
32
|
+
function receiveMessageWithId(port, expectedId) {
|
|
33
|
+
const timeout = 1e4;
|
|
34
|
+
const status = Atomics.wait(sharedBufferView, 0, 0, timeout);
|
|
35
|
+
Atomics.store(sharedBufferView, 0, 0);
|
|
36
|
+
if (!["ok", "not-equal"].includes(status)) {
|
|
37
|
+
const abortMsg = {
|
|
38
|
+
id: expectedId,
|
|
39
|
+
cmd: "abort"
|
|
40
|
+
};
|
|
41
|
+
port.postMessage(abortMsg);
|
|
42
|
+
throw new Error(`Internal error: Atomics.wait() failed: ${status}`);
|
|
43
|
+
}
|
|
44
|
+
const reply = receiveMessageOnPort(port);
|
|
45
|
+
const { id, ...message } = reply.message;
|
|
46
|
+
if (id < expectedId) {
|
|
47
|
+
return receiveMessageWithId(port, expectedId);
|
|
48
|
+
}
|
|
49
|
+
if (expectedId !== id) {
|
|
50
|
+
throw new Error(`Internal error: Expected id ${String(expectedId)} but got id ${String(id)}`);
|
|
51
|
+
}
|
|
52
|
+
return { id, ...message };
|
|
53
|
+
}
|
|
54
|
+
function startWorkerThread(workerPath) {
|
|
55
|
+
const { port1: mainPort, port2: workerPort } = new MessageChannel();
|
|
56
|
+
const workerPathUrl = pathToFileURL(require.resolve(workerPath));
|
|
57
|
+
const worker = new Worker(workerPathUrl, {
|
|
58
|
+
eval: false,
|
|
59
|
+
workerData: { sharedBuffer, workerPort },
|
|
60
|
+
transferList: [workerPort]
|
|
61
|
+
});
|
|
62
|
+
let nextID = 0;
|
|
63
|
+
const syncFn = (...args) => {
|
|
64
|
+
const id = nextID++;
|
|
65
|
+
const msg = { id, args };
|
|
66
|
+
worker.postMessage(msg);
|
|
67
|
+
const reply = receiveMessageWithId(mainPort, id);
|
|
68
|
+
if (isWorkerError(reply)) {
|
|
69
|
+
throw new Error(reply.error);
|
|
70
|
+
}
|
|
71
|
+
return reply.result;
|
|
72
|
+
};
|
|
73
|
+
worker.unref();
|
|
74
|
+
return syncFn;
|
|
75
|
+
}
|
|
76
|
+
function createSyncFn(workerPath) {
|
|
77
|
+
const cachedSyncFn = syncFnCache.get(workerPath);
|
|
78
|
+
if (cachedSyncFn) {
|
|
79
|
+
return cachedSyncFn;
|
|
80
|
+
}
|
|
81
|
+
const syncFn = startWorkerThread(workerPath);
|
|
82
|
+
syncFnCache.set(workerPath, syncFn);
|
|
83
|
+
return syncFn;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { createSyncFn as c, diverge as d, flattenMessages as f, isThenable as i };
|
|
23
87
|
//# sourceMappingURL=matcher-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matcher-utils.js","sources":["../../src/jest/utils/is-thenable.ts","../../src/jest/utils/diverge.ts","../../src/jest/utils/flatten-messages.ts"],"sourcesContent":["/**\n * @internal\n */\nexport function isThenable<T>(value: T | Promise<T>): value is Promise<T> {\n\treturn value && typeof value === \"object\" && \"then\" in value && typeof value.then === \"function\";\n}\n","import { isThenable } from \"./is-thenable\";\nimport { type MatcherContext } from \"./matcher-context\";\nimport { type MatcherResult } from \"./matcher-result\";\n\ntype SyncCallback<T, TArgs extends any[]> = (\n\tthis: MatcherContext,\n\tactual: T,\n\t...args: TArgs\n) => MatcherResult;\n\n/**\n * @internal\n */\nexport interface MaybeAsyncCallback<TActual, TArgs extends any[]> {\n\t(this: MatcherContext, actual: TActual, ...args: TArgs): MatcherResult;\n\t(this: MatcherContext, actual: Promise<TActual>, ...args: TArgs): Promise<MatcherResult>;\n}\n\n/**\n * Creates a wrapped function based on the passed function.\n *\n * The returned function takes either a `T` or `Promise<T>`. If `T` the result\n * will be synchronous or if `Promise<T>` the result will be asynchronous.\n *\n * In practice this means that if you pass a synchronous object into it you will\n * maintain synchronous code but if you pass an asynchronous object you must\n * await the result.\n *\n * @internal\n */\nexport function diverge<T, TArgs extends any[]>(\n\tfn: SyncCallback<T, TArgs>,\n): MaybeAsyncCallback<T, TArgs> {\n\tfunction diverged(this: MatcherContext, actual: T, ...args: TArgs): MatcherResult;\n\tfunction diverged(\n\t\tthis: MatcherContext,\n\t\tactual: Promise<T>,\n\t\t...args: TArgs\n\t): Promise<MatcherResult>;\n\tfunction diverged(\n\t\tthis: MatcherContext,\n\t\tactual: T | Promise<T>,\n\t\t...args: TArgs\n\t): MatcherResult | Promise<MatcherResult> {\n\t\tif (isThenable(actual)) {\n\t\t\treturn actual.then((resolved) => fn.call(this, resolved, ...args));\n\t\t} else {\n\t\t\treturn fn.call(this, actual, ...args);\n\t\t}\n\t}\n\treturn diverged;\n}\n","import { type Message } from \"../../message\";\nimport { type Report, type Result } from \"../../reporter\";\n\n/**\n * Takes all messages from all files and flattens to a single array.\n */\nexport function flattenMessages(report: Report): Message[] {\n\treturn report.results.reduce((aggregated: Message[], result: Result) => {\n\t\treturn aggregated.concat(result.messages);\n\t}, []);\n}\n"],"names":[],"mappings":"AAGO,SAAS,WAAc,KAA4C,EAAA;AACzE,EAAO,OAAA,KAAA,IAAS,OAAO,KAAU,KAAA,QAAA,IAAY,UAAU,KAAS,IAAA,OAAO,MAAM,IAAS,KAAA,UAAA;AACvF;;ACyBO,SAAS,QACf,EAC+B,EAAA;AAO/B,EAAS,SAAA,QAAA,CAER,WACG,IACsC,EAAA;AACzC,IAAI,IAAA,UAAA,CAAW,MAAM,CAAG,EAAA;AACvB,MAAO,OAAA,MAAA,CAAO,IAAK,CAAA,CAAC,QAAa,KAAA,EAAA,CAAG,KAAK,IAAM,EAAA,QAAA,EAAU,GAAG,IAAI,CAAC,CAAA;AAAA,KAC3D,MAAA;AACN,MAAA,OAAO,EAAG,CAAA,IAAA,CAAK,IAAM,EAAA,MAAA,EAAQ,GAAG,IAAI,CAAA;AAAA;AACrC;AAED,EAAO,OAAA,QAAA;AACR;;AC7CO,SAAS,gBAAgB,MAA2B,EAAA;AAC1D,EAAA,OAAO,MAAO,CAAA,OAAA,CAAQ,MAAO,CAAA,CAAC,YAAuB,MAAmB,KAAA;AACvE,IAAO,OAAA,UAAA,CAAW,MAAO,CAAA,MAAA,CAAO,QAAQ,CAAA;AAAA,GACzC,EAAG,EAAE,CAAA;AACN;;;;"}
|
|
1
|
+
{"version":3,"file":"matcher-utils.js","sources":["../../src/jest/utils/is-thenable.ts","../../src/jest/utils/diverge.ts","../../src/jest/utils/flatten-messages.ts","../../src/jest/worker/create-sync-fn.ts"],"sourcesContent":["/**\n * @internal\n */\nexport function isThenable<T>(value: T | Promise<T>): value is Promise<T> {\n\treturn value && typeof value === \"object\" && \"then\" in value && typeof value.then === \"function\";\n}\n","import { isThenable } from \"./is-thenable\";\nimport { type MatcherContext } from \"./matcher-context\";\nimport { type MatcherResult } from \"./matcher-result\";\n\ntype SyncCallback<T, TArgs extends any[]> = (\n\tthis: MatcherContext,\n\tactual: T,\n\t...args: TArgs\n) => MatcherResult;\n\n/**\n * @internal\n */\nexport interface MaybeAsyncCallback<TActual, TArgs extends any[]> {\n\t(this: MatcherContext, actual: TActual, ...args: TArgs): MatcherResult;\n\t(this: MatcherContext, actual: Promise<TActual>, ...args: TArgs): Promise<MatcherResult>;\n}\n\n/**\n * Creates a wrapped function based on the passed function.\n *\n * The returned function takes either a `T` or `Promise<T>`. If `T` the result\n * will be synchronous or if `Promise<T>` the result will be asynchronous.\n *\n * In practice this means that if you pass a synchronous object into it you will\n * maintain synchronous code but if you pass an asynchronous object you must\n * await the result.\n *\n * @internal\n */\nexport function diverge<T, TArgs extends any[]>(\n\tfn: SyncCallback<T, TArgs>,\n): MaybeAsyncCallback<T, TArgs> {\n\tfunction diverged(this: MatcherContext, actual: T, ...args: TArgs): MatcherResult;\n\tfunction diverged(\n\t\tthis: MatcherContext,\n\t\tactual: Promise<T>,\n\t\t...args: TArgs\n\t): Promise<MatcherResult>;\n\tfunction diverged(\n\t\tthis: MatcherContext,\n\t\tactual: T | Promise<T>,\n\t\t...args: TArgs\n\t): MatcherResult | Promise<MatcherResult> {\n\t\tif (isThenable(actual)) {\n\t\t\treturn actual.then((resolved) => fn.call(this, resolved, ...args));\n\t\t} else {\n\t\t\treturn fn.call(this, actual, ...args);\n\t\t}\n\t}\n\treturn diverged;\n}\n","import { type Message } from \"../../message\";\nimport { type Report, type Result } from \"../../reporter\";\n\n/**\n * Takes all messages from all files and flattens to a single array.\n */\nexport function flattenMessages(report: Report): Message[] {\n\treturn report.results.reduce((aggregated: Message[], result: Result) => {\n\t\treturn aggregated.concat(result.messages);\n\t}, []);\n}\n","import { pathToFileURL } from \"node:url\";\nimport {\n\ttype MessagePort,\n\tMessageChannel,\n\tWorker,\n\treceiveMessageOnPort,\n} from \"node:worker_threads\";\nimport {\n\ttype AnyAsyncFn,\n\ttype AnyFn,\n\ttype MainToWorkerCommandMessage,\n\ttype MainToWorkerMessage,\n\ttype Syncify,\n\ttype WorkerToMainError,\n\ttype WorkerToMainMessage,\n} from \"./types\";\n\n/**\n * This is all based on the synckit library but without all the extra stuff such\n * as typescript, esbuld, pnp etc.\n */\n\nconst INT32_BYTES = 4;\nconst syncFnCache = new Map<string, AnyFn>();\nconst sharedBuffer = new SharedArrayBuffer(INT32_BYTES);\nconst sharedBufferView = new Int32Array(sharedBuffer, 0, 1);\n\nfunction isWorkerError<T>(value: WorkerToMainMessage<T>): value is WorkerToMainError {\n\treturn \"error\" in value;\n}\n\nfunction receiveMessageWithId<R>(port: MessagePort, expectedId: number): WorkerToMainMessage<R> {\n\tconst timeout = 10000;\n\tconst status = Atomics.wait(sharedBufferView, 0, 0, timeout);\n\tAtomics.store(sharedBufferView, 0, 0);\n\n\tif (![\"ok\", \"not-equal\"].includes(status)) {\n\t\tconst abortMsg: MainToWorkerCommandMessage = {\n\t\t\tid: expectedId,\n\t\t\tcmd: \"abort\",\n\t\t};\n\t\tport.postMessage(abortMsg);\n\t\tthrow new Error(`Internal error: Atomics.wait() failed: ${status}`);\n\t}\n\n\tconst reply = receiveMessageOnPort(port) as { message: WorkerToMainMessage<R> };\n\tconst { id, ...message } = reply.message;\n\n\tif (id < expectedId) {\n\t\treturn receiveMessageWithId(port, expectedId);\n\t}\n\n\tif (expectedId !== id) {\n\t\tthrow new Error(`Internal error: Expected id ${String(expectedId)} but got id ${String(id)}`);\n\t}\n\n\treturn { id, ...message };\n}\n\nfunction startWorkerThread<R, T extends AnyAsyncFn<R>>(\n\tworkerPath: string,\n): (...args: Parameters<T>) => R {\n\tconst { port1: mainPort, port2: workerPort } = new MessageChannel();\n\tconst workerPathUrl = pathToFileURL(require.resolve(workerPath));\n\tconst worker = new Worker(workerPathUrl, {\n\t\teval: false,\n\t\tworkerData: { sharedBuffer, workerPort },\n\t\ttransferList: [workerPort],\n\t});\n\n\tlet nextID = 0;\n\n\tconst syncFn = (...args: Parameters<T>): R => {\n\t\tconst id = nextID++;\n\t\tconst msg: MainToWorkerMessage<Parameters<T>> = { id, args };\n\n\t\tworker.postMessage(msg);\n\n\t\tconst reply = receiveMessageWithId<R>(mainPort, id);\n\n\t\tif (isWorkerError(reply)) {\n\t\t\tthrow new Error(reply.error);\n\t\t}\n\n\t\treturn reply.result;\n\t};\n\n\tworker.unref();\n\n\treturn syncFn;\n}\n\nexport function createSyncFn<T extends AnyAsyncFn<R>, R = unknown>(workerPath: string): Syncify<T> {\n\tconst cachedSyncFn = syncFnCache.get(workerPath);\n\tif (cachedSyncFn) {\n\t\treturn cachedSyncFn as Syncify<T>;\n\t}\n\n\tconst syncFn = startWorkerThread<R, T>(workerPath);\n\tsyncFnCache.set(workerPath, syncFn);\n\treturn syncFn as Syncify<T>;\n}\n"],"names":[],"mappings":";;;AAGO,SAAS,WAAc,KAA4C,EAAA;AACzE,EAAO,OAAA,KAAA,IAAS,OAAO,KAAU,KAAA,QAAA,IAAY,UAAU,KAAS,IAAA,OAAO,MAAM,IAAS,KAAA,UAAA;AACvF;;ACyBO,SAAS,QACf,EAC+B,EAAA;AAO/B,EAAS,SAAA,QAAA,CAER,WACG,IACsC,EAAA;AACzC,IAAI,IAAA,UAAA,CAAW,MAAM,CAAG,EAAA;AACvB,MAAO,OAAA,MAAA,CAAO,IAAK,CAAA,CAAC,QAAa,KAAA,EAAA,CAAG,KAAK,IAAM,EAAA,QAAA,EAAU,GAAG,IAAI,CAAC,CAAA;AAAA,KAC3D,MAAA;AACN,MAAA,OAAO,EAAG,CA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G5B,IAAA,OAAO,KAAM,CAAA,MAAA;AAAA,GACd;AAEA,EAAA,MAAA,CAAO,KAAM,EAAA;AAEb,EAAO,OAAA,MAAA;AACR;AAEO,SAAS,aAAmD,UAAgC,EAAA;AAClG,EAAM,MAAA,YAAA,GAAe,WAAY,CAAA,GAAA,CAAI,UAAU,CAAA;AAC/C,EAAA,IAAI,YAAc,EAAA;AACjB,IAAO,OAAA,YAAA;AAAA;AAGR,EAAM,MAAA,MAAA,GAAS,kBAAwB,UAAU,CAAA;AACjD,EAAY,WAAA,CAAA,GAAA,CAAI,YAAY,MAAM,CAAA;AAClC,EAAO,OAAA,MAAA;AACR;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import kleur from 'kleur';
|
|
2
2
|
import { toMatchSnapshot, toMatchInlineSnapshot } from 'jest-snapshot';
|
|
3
|
-
import {
|
|
3
|
+
import { L as codeframe } from './core.js';
|
|
4
4
|
import { g as getResults } from './matchers.js';
|
|
5
5
|
import { d as diverge, i as isThenable } from './matcher-utils.js';
|
|
6
6
|
|
package/dist/es/matchers.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as diverge, f as flattenMessages } from './matcher-utils.js';
|
|
2
|
-
import { d as deepmerge, H as HtmlValidate } from './core.js';
|
|
1
|
+
import { d as diverge, c as createSyncFn, f as flattenMessages } from './matcher-utils.js';
|
|
2
|
+
import { d as deepmerge, K as workerPath, H as HtmlValidate } from './core.js';
|
|
3
3
|
import { F as FileSystemConfigLoader } from './core-nodejs.js';
|
|
4
4
|
|
|
5
5
|
function createMatcher$4() {
|
|
@@ -92,11 +92,8 @@ function toHTMLValidateImpl(expect, diff, actual, expectedError, userConfig, fil
|
|
|
92
92
|
};
|
|
93
93
|
const config = deepmerge(defaultConfig, userConfig ?? {});
|
|
94
94
|
const actualFilename = filename ?? this.testPath ?? "inline";
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
});
|
|
98
|
-
const htmlvalidate = new HtmlValidate(loader);
|
|
99
|
-
const report = htmlvalidate.validateStringSync(actual, actualFilename, config);
|
|
95
|
+
const syncFn = createSyncFn(workerPath);
|
|
96
|
+
const report = syncFn(actual, actualFilename, config);
|
|
100
97
|
const pass = report.valid;
|
|
101
98
|
const result = report.results[0];
|
|
102
99
|
if (pass) {
|
package/dist/es/matchers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchers.js","sources":["../../src/jest/matchers/to-be-valid.ts","../../src/jest/matchers/to-be-invalid.ts","../../src/jest/matchers/to-htmlvalidate.ts","../../src/jest/matchers/to-have-error.ts","../../src/jest/matchers/to-have-errors.ts","../../src/jest/matchers/get-results.ts"],"sourcesContent":["import { type Report } from \"../../reporter\";\nimport { type MatcherResult, type MaybeAsyncCallback, diverge } from \"../utils\";\n\nfunction createMatcher(): MaybeAsyncCallback<Report, []> {\n\tfunction toBeValid(report: Report): MatcherResult {\n\t\tif (report.valid) {\n\t\t\treturn {\n\t\t\t\tpass: true,\n\t\t\t\tmessage: /* istanbul ignore next */ () => \"Result should not contain error\",\n\t\t\t};\n\t\t} else {\n\t\t\tconst firstError = report.results[0].messages[0];\n\t\t\treturn {\n\t\t\t\tpass: false,\n\t\t\t\tmessage: () => `Result should be valid but had error \"${firstError.message}\"`,\n\t\t\t};\n\t\t}\n\t}\n\treturn diverge(toBeValid);\n}\n\nexport { createMatcher as toBeValid };\n","import { type Report } from \"../../reporter\";\nimport { type MatcherResult, type MaybeAsyncCallback, diverge } from \"../utils\";\n\nfunction createMatcher(): MaybeAsyncCallback<Report, []> {\n\tfunction toBeInvalid(report: Report): MatcherResult {\n\t\tif (report.valid) {\n\t\t\treturn {\n\t\t\t\tpass: false,\n\t\t\t\tmessage: () => \"Result should be invalid but had no errors\",\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tpass: true,\n\t\t\t\tmessage: /* istanbul ignore next */ () => \"Result should not contain error\",\n\t\t\t};\n\t\t}\n\t}\n\treturn diverge(toBeInvalid);\n}\n\nexport { createMatcher as toBeInvalid };\n","import deepmerge from \"deepmerge\";\nimport { type ConfigData } from \"../../config\";\nimport { FileSystemConfigLoader } from \"../../config/loaders/file-system\";\nimport { HtmlValidate } from \"../../htmlvalidate\";\nimport { type Message } from \"../../message\";\nimport {\n\ttype DiffFunction,\n\ttype MatcherContext,\n\ttype MatcherExpect,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n} from \"../utils\";\n\nfunction isMessage(arg: any): arg is Partial<Message> {\n\tif (!arg) {\n\t\treturn false;\n\t}\n\treturn Boolean(\n\t\targ.ruleId ||\n\t\t\targ.severity ||\n\t\t\targ.message ||\n\t\t\targ.offset ||\n\t\t\targ.line ||\n\t\t\targ.column ||\n\t\t\targ.size ||\n\t\t\targ.selector ||\n\t\t\targ.context,\n\t);\n}\n\nfunction isConfig(arg: any): arg is ConfigData {\n\tif (!arg) {\n\t\treturn false;\n\t}\n\treturn Boolean(\n\t\targ.root || arg.extends || arg.elements || arg.plugin || arg.transform || arg.rules,\n\t);\n}\n\nfunction isString(arg: any): arg is string {\n\treturn typeof arg === \"string\";\n}\n\nfunction getMarkup(src: unknown): string {\n\tif (typeof HTMLElement !== \"undefined\" && src instanceof HTMLElement) {\n\t\treturn (src as { outerHTML: string }).outerHTML;\n\t}\n\t/* istanbul ignore else: prototype only allows string or HTMLElement */\n\tif (typeof src === \"string\") {\n\t\treturn src;\n\t} else {\n\t\tthrow new Error(`Failed to get markup from \"${typeof src}\" argument`);\n\t}\n}\n\ntype Arg1 = Partial<Message> | ConfigData | string;\ntype Arg2 = ConfigData | string;\ntype Arg3 = string;\n\nfunction createMatcher(\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n): MaybeAsyncCallback<unknown, [Arg1?, Arg2?, Arg3?]> {\n\tfunction toHTMLValidate(\n\t\tthis: MatcherContext,\n\t\tactual: unknown,\n\t\targ0?: Arg1,\n\t\targ1?: Arg2,\n\t\targ2?: Arg3,\n\t): MatcherResult {\n\t\tconst markup = getMarkup(actual);\n\t\tconst message = isMessage(arg0) ? arg0 : undefined;\n\t\tconst config = isConfig(arg0) ? arg0 : isConfig(arg1) ? arg1 : undefined;\n\t\tconst filename = isString(arg0) ? arg0 : isString(arg1) ? arg1 : arg2;\n\t\treturn toHTMLValidateImpl.call(this, expect, diff, markup, message, config, filename);\n\t}\n\treturn diverge(toHTMLValidate);\n}\n\nfunction toHTMLValidateImpl(\n\tthis: MatcherContext,\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n\tactual: string,\n\texpectedError?: Partial<Message>,\n\tuserConfig?: ConfigData,\n\tfilename?: string,\n): MatcherResult {\n\tconst defaultConfig = {\n\t\trules: {\n\t\t\t/* jsdom normalizes style so disabling rule when using this matcher or it\n\t\t\t * gets quite noisy when configured with self-closing */\n\t\t\t\"void-style\": \"off\",\n\t\t},\n\t};\n\tconst config = deepmerge(defaultConfig, userConfig ?? {});\n\t/* istanbul ignore next: cant figure out when this would be unset */\n\tconst actualFilename = filename ?? this.testPath ?? \"inline\";\n\tconst loader = new FileSystemConfigLoader({\n\t\textends: [\"html-validate:recommended\"],\n\t});\n\tconst htmlvalidate = new HtmlValidate(loader);\n\tconst report = htmlvalidate.validateStringSync(actual, actualFilename, config);\n\tconst pass = report.valid;\n\tconst result = report.results[0];\n\tif (pass) {\n\t\treturn { pass, message: () => \"HTML is valid when an error was expected\" };\n\t} else {\n\t\tif (expectedError) {\n\t\t\tconst actual = result.messages;\n\t\t\tconst expected = expect.arrayContaining([expect.objectContaining(expectedError)]);\n\t\t\tconst errorPass = this.equals(actual, expected);\n\t\t\tconst diffString = diff\n\t\t\t\t? diff(expected, actual, {\n\t\t\t\t\t\texpand: this.expand,\n\t\t\t\t\t\taAnnotation: \"Expected error\",\n\t\t\t\t\t\tbAnnotation: \"Actual error\",\n\t\t\t\t\t})\n\t\t\t\t: /* istanbul ignore next */ undefined;\n\t\t\tconst hint = this.utils.matcherHint(\".not.toHTMLValidate\", undefined, undefined, {\n\t\t\t\tcomment: \"expected error\",\n\t\t\t});\n\t\t\tconst expectedErrorMessage = (): string =>\n\t\t\t\t[\n\t\t\t\t\thint,\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"Expected error to be present:\",\n\t\t\t\t\tthis.utils.printExpected(expectedError),\n\t\t\t\t\t/* istanbul ignore next */ diffString ? `\\n${diffString}` : \"\",\n\t\t\t\t].join(\"\\n\");\n\t\t\treturn { pass: !errorPass, message: expectedErrorMessage, actual, expected };\n\t\t}\n\n\t\tconst errors = result.messages.map((message) => ` ${message.message} [${message.ruleId}]`);\n\t\treturn {\n\t\t\tpass,\n\t\t\tmessage: () =>\n\t\t\t\t[\"Expected HTML to be valid but had the following errors:\", \"\"].concat(errors).join(\"\\n\"),\n\t\t};\n\t}\n}\n\nexport { createMatcher as toHTMLValidate };\n","import { type Message } from \"../../message\";\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype DiffFunction,\n\ttype MatcherContext,\n\ttype MatcherExpect,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n} from \"../utils\";\nimport { flattenMessages } from \"../utils/flatten-messages\";\n\nfunction toHaveErrorImpl(\n\tcontext: MatcherContext,\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n\tactual: Report,\n\texpected: Partial<Message>,\n): MatcherResult {\n\tconst flattened = flattenMessages(actual);\n\tconst matcher = [expect.objectContaining(expected)];\n\tconst pass = context.equals(flattened, matcher);\n\tconst diffString = diff\n\t\t? diff(matcher, flattened, { expand: context.expand })\n\t\t: /* istanbul ignore next */ undefined;\n\tconst hint = context.utils.matcherHint(\".toHaveError\");\n\tconst prettyExpected = context.utils.printExpected(matcher);\n\tconst prettyReceived = context.utils.printReceived(flattened);\n\tconst resultMessage = (): string => {\n\t\treturn [\n\t\t\thint,\n\t\t\t\"\",\n\t\t\t\"Expected error to equal:\",\n\t\t\t` ${prettyExpected}`,\n\t\t\t\"Received:\",\n\t\t\t` ${prettyReceived}`,\n\t\t\t/* istanbul ignore next */ diffString ? `\\nDifference:\\n\\n${diffString}` : \"\",\n\t\t].join(\"\\n\");\n\t};\n\treturn { pass, message: resultMessage, actual: flattened, expected: matcher };\n}\n\nfunction createMatcher(\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n):\n\t| MaybeAsyncCallback<Report, [Partial<Message>]>\n\t| MaybeAsyncCallback<Report, [string, string, any?]> {\n\tfunction toHaveError(\n\t\tthis: MatcherContext,\n\t\tactual: Report,\n\t\terror: Partial<Message>,\n\t): MatcherResult;\n\tfunction toHaveError(\n\t\tthis: MatcherContext,\n\t\tactual: Report,\n\t\truleId: string,\n\t\tmessage: string,\n\t\tcontext?: any,\n\t): MatcherResult;\n\tfunction toHaveError(\n\t\tthis: MatcherContext,\n\t\tactual: Report,\n\t\targ1: string | Partial<Message>,\n\t\targ2?: string,\n\t\targ3?: any,\n\t): MatcherResult {\n\t\tif (typeof arg1 === \"string\") {\n\t\t\tconst expected: Partial<Message> = {\n\t\t\t\truleId: arg1,\n\t\t\t\tmessage: arg2,\n\t\t\t};\n\t\t\tif (arg3) {\n\t\t\t\t/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- this is supposed to accept anything */\n\t\t\t\texpected.context = arg3;\n\t\t\t}\n\t\t\treturn toHaveErrorImpl(this, expect, diff, actual, expected);\n\t\t} else {\n\t\t\treturn toHaveErrorImpl(this, expect, diff, actual, arg1);\n\t\t}\n\t}\n\treturn diverge(toHaveError);\n}\n\nexport { createMatcher as toHaveError };\n","/* eslint-disable prefer-template -- technical debt, should be refactored */\n\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype DiffFunction,\n\ttype MatcherContext,\n\ttype MatcherExpect,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n\tflattenMessages,\n} from \"../utils\";\n\nfunction createMatcher(\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n): MaybeAsyncCallback<Report, [Array<[string, string] | Record<string, unknown>>]> {\n\tfunction toHaveErrors(\n\t\tthis: MatcherContext,\n\t\treport: Report,\n\t\terrors: Array<[string, string] | Record<string, unknown>>,\n\t): MatcherResult {\n\t\tconst flattened = flattenMessages(report);\n\t\tconst matcher = errors.map((entry) => {\n\t\t\tif (Array.isArray(entry)) {\n\t\t\t\tconst [ruleId, message] = entry;\n\t\t\t\treturn expect.objectContaining({ ruleId, message });\n\t\t\t} else {\n\t\t\t\treturn expect.objectContaining(entry);\n\t\t\t}\n\t\t});\n\t\tconst pass = this.equals(flattened, matcher);\n\t\tconst diffString = diff\n\t\t\t? diff(matcher, flattened, { expand: this.expand })\n\t\t\t: /* istanbul ignore next */ undefined;\n\t\tconst resultMessage = (): string =>\n\t\t\tthis.utils.matcherHint(\".toHaveErrors\") +\n\t\t\t\"\\n\\n\" +\n\t\t\t\"Expected error to equal:\\n\" +\n\t\t\t` ${this.utils.printExpected(matcher)}\\n` +\n\t\t\t\"Received:\\n\" +\n\t\t\t` ${this.utils.printReceived(flattened)}` +\n\t\t\t/* istanbul ignore next */ (diffString ? `\\n\\nDifference:\\n\\n${diffString}` : \"\");\n\n\t\treturn { pass, message: resultMessage };\n\t}\n\treturn diverge(toHaveErrors);\n}\n\nexport { createMatcher as toHaveErrors };\n","import { FileSystemConfigLoader } from \"../../config/loaders/file-system\";\nimport { type Report, type Result } from \"../../reporter\";\nimport { HtmlValidate } from \"../../htmlvalidate\";\n\n/**\n * @internal\n */\nexport function getResults(filename: string, value: Report | string): Result[] {\n\tif (typeof value === \"string\") {\n\t\tconst loader = new FileSystemConfigLoader({\n\t\t\textends: [\"html-validate:recommended\"],\n\t\t});\n\t\tconst htmlvalidate = new HtmlValidate(loader);\n\t\tconst report = htmlvalidate.validateStringSync(value, filename, {\n\t\t\trules: {\n\t\t\t\t\"void-style\": \"off\",\n\t\t\t},\n\t\t});\n\t\treturn report.results.map((it) => {\n\t\t\treturn { ...it, filePath: \"inline\" };\n\t\t});\n\t} else {\n\t\tre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GAAA;;AAAA;;AAAA,EAAsB,UAAU,CAAK,CAAA,GAAA,EAAA,CAAA;AAE/E,IAAO,OAAA,EAAE,IAAM,EAAA,OAAA,EAAS,aAAc,EAAA;AAAA;AAEvC,EAAA,OAAO,QAAQ,YAAY,CAAA;AAC5B;;ACxCgB,SAAA,UAAA,CAAW,UAAkB,KAAkC,EAAA;AAC9E,EAAI,IAAA,OAAO,UAAU,QAAU,EAAA;AAC9B,IAAM,MAAA,MAAA,GAAS,IAAI,sBAAuB,CAAA;AAAA,MACzC,OAAA,EAAS,CAAC,2BAA2B;AAAA,KACrC,CAAA;AACD,IAAM,MAAA,YAAA,GAAe,IAAI,YAAA,CAAa,MAAM,CAAA;AAC5C,IAAA,MAAM,MAAS,GAAA,YAAA,CAAa,kBAAmB,CAAA,KAAA,EAAO,QAAU,EAAA;AAAA,MAC/D,KAAO,EAAA;AAAA,QACN,YAAc,EAAA;AAAA;AACf,KACA,CAAA;AACD,IAAA,OAAO,MAAO,CAAA,OAAA,CAAQ,GAAI,CAAA,CAAC,EAAO,KAAA;AACjC,MAAA,OAAO,EAAE,GAAG,EAAI,EAAA,QAAA,EAAU,QAAS,EAAA;AAAA,KACnC,CAAA;AAAA,GACK,MAAA;AACN,IAAA,OAAO,KAAM,CAAA,OAAA;AAAA;AAEf;;;;"}
|
|
1
|
+
{"version":3,"file":"matchers.js","sources":["../../src/jest/matchers/to-be-valid.ts","../../src/jest/matchers/to-be-invalid.ts","../../src/jest/matchers/to-htmlvalidate.ts","../../src/jest/matchers/to-have-error.ts","../../src/jest/matchers/to-have-errors.ts","../../src/jest/matchers/get-results.ts"],"sourcesContent":["import { type Report } from \"../../reporter\";\nimport { type MatcherResult, type MaybeAsyncCallback, diverge } from \"../utils\";\n\nfunction createMatcher(): MaybeAsyncCallback<Report, []> {\n\tfunction toBeValid(report: Report): MatcherResult {\n\t\tif (report.valid) {\n\t\t\treturn {\n\t\t\t\tpass: true,\n\t\t\t\tmessage: /* istanbul ignore next */ () => \"Result should not contain error\",\n\t\t\t};\n\t\t} else {\n\t\t\tconst firstError = report.results[0].messages[0];\n\t\t\treturn {\n\t\t\t\tpass: false,\n\t\t\t\tmessage: () => `Result should be valid but had error \"${firstError.message}\"`,\n\t\t\t};\n\t\t}\n\t}\n\treturn diverge(toBeValid);\n}\n\nexport { createMatcher as toBeValid };\n","import { type Report } from \"../../reporter\";\nimport { type MatcherResult, type MaybeAsyncCallback, diverge } from \"../utils\";\n\nfunction createMatcher(): MaybeAsyncCallback<Report, []> {\n\tfunction toBeInvalid(report: Report): MatcherResult {\n\t\tif (report.valid) {\n\t\t\treturn {\n\t\t\t\tpass: false,\n\t\t\t\tmessage: () => \"Result should be invalid but had no errors\",\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tpass: true,\n\t\t\t\tmessage: /* istanbul ignore next */ () => \"Result should not contain error\",\n\t\t\t};\n\t\t}\n\t}\n\treturn diverge(toBeInvalid);\n}\n\nexport { createMatcher as toBeInvalid };\n","import deepmerge from \"deepmerge\";\nimport { type ConfigData } from \"../../config\";\nimport { type Message } from \"../../message\";\nimport {\n\ttype DiffFunction,\n\ttype MatcherContext,\n\ttype MatcherExpect,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n} from \"../utils\";\nimport { type ValidateStringFn, createSyncFn, workerPath } from \"../worker\";\n\nfunction isMessage(arg: any): arg is Partial<Message> {\n\tif (!arg) {\n\t\treturn false;\n\t}\n\treturn Boolean(\n\t\targ.ruleId ||\n\t\t\targ.severity ||\n\t\t\targ.message ||\n\t\t\targ.offset ||\n\t\t\targ.line ||\n\t\t\targ.column ||\n\t\t\targ.size ||\n\t\t\targ.selector ||\n\t\t\targ.context,\n\t);\n}\n\nfunction isConfig(arg: any): arg is ConfigData {\n\tif (!arg) {\n\t\treturn false;\n\t}\n\treturn Boolean(\n\t\targ.root || arg.extends || arg.elements || arg.plugin || arg.transform || arg.rules,\n\t);\n}\n\nfunction isString(arg: any): arg is string {\n\treturn typeof arg === \"string\";\n}\n\nfunction getMarkup(src: unknown): string {\n\tif (typeof HTMLElement !== \"undefined\" && src instanceof HTMLElement) {\n\t\treturn (src as { outerHTML: string }).outerHTML;\n\t}\n\t/* istanbul ignore else: prototype only allows string or HTMLElement */\n\tif (typeof src === \"string\") {\n\t\treturn src;\n\t} else {\n\t\tthrow new Error(`Failed to get markup from \"${typeof src}\" argument`);\n\t}\n}\n\ntype Arg1 = Partial<Message> | ConfigData | string;\ntype Arg2 = ConfigData | string;\ntype Arg3 = string;\n\nfunction createMatcher(\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n): MaybeAsyncCallback<unknown, [Arg1?, Arg2?, Arg3?]> {\n\tfunction toHTMLValidate(\n\t\tthis: MatcherContext,\n\t\tactual: unknown,\n\t\targ0?: Arg1,\n\t\targ1?: Arg2,\n\t\targ2?: Arg3,\n\t): MatcherResult {\n\t\tconst markup = getMarkup(actual);\n\t\tconst message = isMessage(arg0) ? arg0 : undefined;\n\t\tconst config = isConfig(arg0) ? arg0 : isConfig(arg1) ? arg1 : undefined;\n\t\tconst filename = isString(arg0) ? arg0 : isString(arg1) ? arg1 : arg2;\n\t\treturn toHTMLValidateImpl.call(this, expect, diff, markup, message, config, filename);\n\t}\n\treturn diverge(toHTMLValidate);\n}\n\nfunction toHTMLValidateImpl(\n\tthis: MatcherContext,\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n\tactual: string,\n\texpectedError?: Partial<Message>,\n\tuserConfig?: ConfigData,\n\tfilename?: string,\n): MatcherResult {\n\tconst defaultConfig = {\n\t\trules: {\n\t\t\t/* jsdom normalizes style so disabling rule when using this matcher or it\n\t\t\t * gets quite noisy when configured with self-closing */\n\t\t\t\"void-style\": \"off\",\n\t\t},\n\t};\n\tconst config = deepmerge(defaultConfig, userConfig ?? {});\n\t/* istanbul ignore next: cant figure out when this would be unset */\n\tconst actualFilename = filename ?? this.testPath ?? \"inline\";\n\n\tconst syncFn = createSyncFn<ValidateStringFn>(workerPath);\n\tconst report = syncFn(actual, actualFilename, config);\n\tconst pass = report.valid;\n\tconst result = report.results[0];\n\tif (pass) {\n\t\treturn { pass, message: () => \"HTML is valid when an error was expected\" };\n\t} else {\n\t\tif (expectedError) {\n\t\t\tconst actual = result.messages;\n\t\t\tconst expected = expect.arrayContaining([expect.objectContaining(expectedError)]);\n\t\t\tconst errorPass = this.equals(actual, expected);\n\t\t\tconst diffString = diff\n\t\t\t\t? diff(expected, actual, {\n\t\t\t\t\t\texpand: this.expand,\n\t\t\t\t\t\taAnnotation: \"Expected error\",\n\t\t\t\t\t\tbAnnotation: \"Actual error\",\n\t\t\t\t\t})\n\t\t\t\t: /* istanbul ignore next */ undefined;\n\t\t\tconst hint = this.utils.matcherHint(\".not.toHTMLValidate\", undefined, undefined, {\n\t\t\t\tcomment: \"expected error\",\n\t\t\t});\n\t\t\tconst expectedErrorMessage = (): string =>\n\t\t\t\t[\n\t\t\t\t\thint,\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"Expected error to be present:\",\n\t\t\t\t\tthis.utils.printExpected(expectedError),\n\t\t\t\t\t/* istanbul ignore next */ diffString ? `\\n${diffString}` : \"\",\n\t\t\t\t].join(\"\\n\");\n\t\t\treturn { pass: !errorPass, message: expectedErrorMessage, actual, expected };\n\t\t}\n\n\t\tconst errors = result.messages.map((message) => ` ${message.message} [${message.ruleId}]`);\n\t\treturn {\n\t\t\tpass,\n\t\t\tmessage: () =>\n\t\t\t\t[\"Expected HTML to be valid but had the following errors:\", \"\"].concat(errors).join(\"\\n\"),\n\t\t};\n\t}\n}\n\nexport { createMatcher as toHTMLValidate };\n","import { type Message } from \"../../message\";\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype DiffFunction,\n\ttype MatcherContext,\n\ttype MatcherExpect,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n} from \"../utils\";\nimport { flattenMessages } from \"../utils/flatten-messages\";\n\nfunction toHaveErrorImpl(\n\tcontext: MatcherContext,\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n\tactual: Report,\n\texpected: Partial<Message>,\n): MatcherResult {\n\tconst flattened = flattenMessages(actual);\n\tconst matcher = [expect.objectContaining(expected)];\n\tconst pass = context.equals(flattened, matcher);\n\tconst diffString = diff\n\t\t? diff(matcher, flattened, { expand: context.expand })\n\t\t: /* istanbul ignore next */ undefined;\n\tconst hint = context.utils.matcherHint(\".toHaveError\");\n\tconst prettyExpected = context.utils.printExpected(matcher);\n\tconst prettyReceived = context.utils.printReceived(flattened);\n\tconst resultMessage = (): string => {\n\t\treturn [\n\t\t\thint,\n\t\t\t\"\",\n\t\t\t\"Expected error to equal:\",\n\t\t\t` ${prettyExpected}`,\n\t\t\t\"Received:\",\n\t\t\t` ${prettyReceived}`,\n\t\t\t/* istanbul ignore next */ diffString ? `\\nDifference:\\n\\n${diffString}` : \"\",\n\t\t].join(\"\\n\");\n\t};\n\treturn { pass, message: resultMessage, actual: flattened, expected: matcher };\n}\n\nfunction createMatcher(\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n):\n\t| MaybeAsyncCallback<Report, [Partial<Message>]>\n\t| MaybeAsyncCallback<Report, [string, string, any?]> {\n\tfunction toHaveError(\n\t\tthis: MatcherContext,\n\t\tactual: Report,\n\t\terror: Partial<Message>,\n\t): MatcherResult;\n\tfunction toHaveError(\n\t\tthis: MatcherContext,\n\t\tactual: Report,\n\t\truleId: string,\n\t\tmessage: string,\n\t\tcontext?: any,\n\t): MatcherResult;\n\tfunction toHaveError(\n\t\tthis: MatcherContext,\n\t\tactual: Report,\n\t\targ1: string | Partial<Message>,\n\t\targ2?: string,\n\t\targ3?: any,\n\t): MatcherResult {\n\t\tif (typeof arg1 === \"string\") {\n\t\t\tconst expected: Partial<Message> = {\n\t\t\t\truleId: arg1,\n\t\t\t\tmessage: arg2,\n\t\t\t};\n\t\t\tif (arg3) {\n\t\t\t\t/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- this is supposed to accept anything */\n\t\t\t\texpected.context = arg3;\n\t\t\t}\n\t\t\treturn toHaveErrorImpl(this, expect, diff, actual, expected);\n\t\t} else {\n\t\t\treturn toHaveErrorImpl(this, expect, diff, actual, arg1);\n\t\t}\n\t}\n\treturn diverge(toHaveError);\n}\n\nexport { createMatcher as toHaveError };\n","/* eslint-disable prefer-template -- technical debt, should be refactored */\n\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype DiffFunction,\n\ttype MatcherContext,\n\ttype MatcherExpect,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n\tflattenMessages,\n} from \"../utils\";\n\nfunction createMatcher(\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n): MaybeAsyncCallback<Report, [Array<[string, string] | Record<string, unknown>>]> {\n\tfunction toHaveErrors(\n\t\tthis: MatcherContext,\n\t\treport: Report,\n\t\terrors: Array<[string, string] | Record<string, unknown>>,\n\t): MatcherResult {\n\t\tconst flattened = flattenMessages(report);\n\t\tconst matcher = errors.map((entry) => {\n\t\t\tif (Array.isArray(entry)) {\n\t\t\t\tconst [ruleId, message] = entry;\n\t\t\t\treturn expect.objectContaining({ ruleId, message });\n\t\t\t} else {\n\t\t\t\treturn expect.objectContaining(entry);\n\t\t\t}\n\t\t});\n\t\tconst pass = this.equals(flattened, matcher);\n\t\tconst diffString = diff\n\t\t\t? diff(matcher, flattened, { expand: this.expand })\n\t\t\t: /* istanbul ignore next */ undefined;\n\t\tconst resultMessage = (): string =>\n\t\t\tthis.utils.matcherHint(\".toHaveErrors\") +\n\t\t\t\"\\n\\n\" +\n\t\t\t\"Expected error to equal:\\n\" +\n\t\t\t` ${this.utils.printExpected(matcher)}\\n` +\n\t\t\t\"Received:\\n\" +\n\t\t\t` ${this.utils.printReceived(flattened)}` +\n\t\t\t/* istanbul ignore next */ (diffString ? `\\n\\nDifference:\\n\\n${diffString}` : \"\");\n\n\t\treturn { pass, message: resultMessage };\n\t}\n\treturn diverge(toHaveErrors);\n}\n\nexport { createMatcher as toHaveErrors };\n","import { FileSystemConfigLoader } from \"../../config/loaders/file-system\";\nimport { type Report, type Result } from \"../../reporter\";\nimport { HtmlValidate } from \"../../htmlvalidate\";\n\n/**\n * @internal\n */\nexport function getResults(filename: string, value: Report | string): Result[] {\n\tif (typeof value === \"string\") {\n\t\tconst loader = new FileSystemConfigLoader({\n\t\t\textends: [\"html-validate:recommended\"],\n\t\t});\n\t\tconst htmlvalidate = new HtmlValidate(loader);\n\t\tconst report = htmlvalidate.validateStringSync(value, filename, {\n\t\t\trules: {\n\t\t\t\t\"void-style\": \"off\",\n\t\t\t},\n\t\t});\n\t\treturn report.results.map((it) => {\n\t\t\treturn { ...it, filePath: \"inline\" };\n\t\t});\n\t} else {\n\t\treturn value.results;\n\t}\n}\n"],"names":["createMatcher","actual"],"mappings":";;;;AAGA,SAASA,eAAgD,GAAA;AACxD,EAAA,SAAS,UAAU,MAA+B,EAAA;AACjD,IAAA,IAAI,OAAO,KAAO,EAAA;AACjB,MAAO,OAAA;AAAA,QACN,IAAM,EAAA,IAAA;AAAA,QACN,OAAA;AAAA;AAAA,UAAoC,MAAM;AAAA;AAAA,OAC3C;AAAA,KACM,MAAA;AACN,MAAA,MAAM,aAAa,MAAO,CAAA,OAAA,CAAQ,CAAC,CAAA,CAAE,SAAS,CAAC,CAAA;AAC/C,MAAO,OAAA;AAAA,QACN,IAAM,EAAA,KAAA;AAAA,QACN,OAAS,EAAA,MAAM,CAAyC,sCAAA,EAAA,UAAA,CAAW,OAAO,CAAA,CAAA;AAAA,OAC3E;AAAA;AACD;AAED,EAAA,OAAO,QAAQ,SAAS,CAAA;AACzB;;AChBA,SAASA,eAAgD,GAAA;AACxD,EAAA,SAAS,YAAY,MAA+B,EAAA;AACnD,IAAA,IAAI,OAAO,KAAO,EAAA;AACjB,MAAO,OAAA;AAAA,QACN,IAAM,EAAA,KAAA;AAAA,QACN,SAAS,MAAM;AAAA,OAChB;AAAA,KACM,MAAA;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{ expect } from 'vitest';
|
|
2
2
|
import { c as createMatcher, a as createMatcher$1, b as createMatcher$2, d as createMatcher$3, e as createMatcher$4 } from './matchers.js';
|
|
3
3
|
import './matcher-utils.js';
|
|
4
|
+
import 'node:url';
|
|
5
|
+
import 'node:worker_threads';
|
|
4
6
|
import './core.js';
|
|
5
7
|
import 'ajv';
|
|
6
8
|
import './elements.js';
|
|
7
9
|
import './meta-helper.js';
|
|
8
10
|
import './utils/natural-join.js';
|
|
9
11
|
import '@sidvind/better-ajv-errors';
|
|
10
|
-
import 'fs';
|
|
12
|
+
import 'node:fs';
|
|
11
13
|
import 'kleur';
|
|
12
14
|
import '@html-validate/stylish';
|
|
13
15
|
import 'semver';
|
|
14
16
|
import './core-nodejs.js';
|
|
15
|
-
import 'node:fs';
|
|
16
17
|
import 'node:path';
|
|
17
18
|
import 'node:module';
|
|
18
19
|
|
package/dist/es/vitest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.js","sources":["../../src/vitest/vitest.ts"],"sourcesContent":["import \"./augmentation\";\n\nimport { expect } from \"vitest\";\nimport {\n\ttoBeValid,\n\ttoBeInvalid,\n\ttoHTMLValidate,\n\ttoHaveError,\n\ttoHaveErrors,\n} from \"../jest/matchers\";\n\nexpect.extend({\n\ttoBeValid: toBeValid(),\n\ttoBeInvalid: toBeInvalid(),\n\ttoHTMLValidate: toHTMLValidate(expect, undefined),\n\ttoHaveError: toHaveError(expect, undefined),\n\ttoHaveErrors: toHaveErrors(expect, undefined),\n});\n"],"names":["toBeValid","toBeInvalid","toHTMLValidate","toHaveError","toHaveErrors"],"mappings":"
|
|
1
|
+
{"version":3,"file":"vitest.js","sources":["../../src/vitest/vitest.ts"],"sourcesContent":["import \"./augmentation\";\n\nimport { expect } from \"vitest\";\nimport {\n\ttoBeValid,\n\ttoBeInvalid,\n\ttoHTMLValidate,\n\ttoHaveError,\n\ttoHaveErrors,\n} from \"../jest/matchers\";\n\nexpect.extend({\n\ttoBeValid: toBeValid(),\n\ttoBeInvalid: toBeInvalid(),\n\ttoHTMLValidate: toHTMLValidate(expect, undefined),\n\ttoHaveError: toHaveError(expect, undefined),\n\ttoHaveErrors: toHaveErrors(expect, undefined),\n});\n"],"names":["toBeValid","toBeInvalid","toHTMLValidate","toHaveError","toHaveErrors"],"mappings":";;;;;;;;;;;;;;;;;;;AAWA,MAAA,CAAO,MAAO,CAAA;AAAA,EACb,WAAWA,aAAU,EAAA;AAAA,EACrB,aAAaC,eAAY,EAAA;AAAA,EACzB,cAAA,EAAgBC,eAAe,CAAA,MAAA,EAAQ,KAAS,CAAA,CAAA;AAAA,EAChD,WAAA,EAAaC,eAAY,CAAA,MAAA,EAAQ,KAAS,CAAA,CAAA;AAAA,EAC1C,YAAA,EAAcC,eAAa,CAAA,MAAA,EAAQ,KAAS,CAAA;AAC7C,CAAC,CAAA"}
|
package/dist/tsdoc-metadata.json
CHANGED
package/dist/types/browser.d.ts
CHANGED
|
@@ -184,7 +184,6 @@ export declare interface ConditionalEvent extends Event_2 {
|
|
|
184
184
|
export declare class Config {
|
|
185
185
|
private config;
|
|
186
186
|
private configurations;
|
|
187
|
-
private initialized;
|
|
188
187
|
private resolvers;
|
|
189
188
|
private metaTable;
|
|
190
189
|
private plugins;
|
|
@@ -206,12 +205,8 @@ export declare class Config {
|
|
|
206
205
|
/* Excluded from this release type: create */
|
|
207
206
|
/* Excluded from this release type: __constructor */
|
|
208
207
|
/**
|
|
209
|
-
* Initialize plugins, transforms etc.
|
|
210
|
-
*
|
|
211
|
-
* Must be called before trying to use config. Can safely be called multiple
|
|
212
|
-
* times.
|
|
213
|
-
*
|
|
214
208
|
* @public
|
|
209
|
+
* @deprecated Not needed any longer, this is a dummy noop method.
|
|
215
210
|
*/
|
|
216
211
|
init(): void;
|
|
217
212
|
/**
|
|
@@ -232,6 +227,7 @@ export declare class Config {
|
|
|
232
227
|
/* Excluded from this release type: getRules */
|
|
233
228
|
private static getRulesObject;
|
|
234
229
|
/* Excluded from this release type: getPlugins */
|
|
230
|
+
/* Excluded from this release type: getTransformers */
|
|
235
231
|
private loadPlugins;
|
|
236
232
|
private loadConfigurations;
|
|
237
233
|
private extendMeta;
|
|
@@ -245,31 +241,6 @@ export declare class Config {
|
|
|
245
241
|
*/
|
|
246
242
|
resolve(): ResolvedConfig;
|
|
247
243
|
/* Excluded from this release type: resolveData */
|
|
248
|
-
private precompileTransformers;
|
|
249
|
-
/**
|
|
250
|
-
* Get transformation function requested by configuration.
|
|
251
|
-
*
|
|
252
|
-
* Searches:
|
|
253
|
-
*
|
|
254
|
-
* - Named transformers from plugins.
|
|
255
|
-
* - Unnamed transformer from plugin.
|
|
256
|
-
* - Standalone modules (local or node_modules)
|
|
257
|
-
*
|
|
258
|
-
* @param name - Key from configuration
|
|
259
|
-
*/
|
|
260
|
-
private getTransformFunction;
|
|
261
|
-
/**
|
|
262
|
-
* @param name - Original name from configuration
|
|
263
|
-
* @param pluginName - Name of plugin
|
|
264
|
-
* @param key - Name of transform (from plugin)
|
|
265
|
-
*/
|
|
266
|
-
private getNamedTransformerFromPlugin;
|
|
267
|
-
/**
|
|
268
|
-
* @param name - Original name from configuration
|
|
269
|
-
* @param plugin - Plugin instance
|
|
270
|
-
*/
|
|
271
|
-
private getUnnamedTransformerFromPlugin;
|
|
272
|
-
private getTransformerFromModule;
|
|
273
244
|
}
|
|
274
245
|
|
|
275
246
|
/**
|
|
@@ -365,6 +336,7 @@ export declare abstract class ConfigLoader {
|
|
|
365
336
|
* @param configOverride - Optional configuration to merge final results with.
|
|
366
337
|
*/
|
|
367
338
|
abstract getConfigFor(handle: string, configOverride?: ConfigData): ResolvedConfig;
|
|
339
|
+
/* Excluded from this release type: getResolvers */
|
|
368
340
|
/**
|
|
369
341
|
* Flush configuration cache.
|
|
370
342
|
*
|
|
@@ -2055,6 +2027,7 @@ export declare class ResolvedConfig {
|
|
|
2055
2027
|
private plugins;
|
|
2056
2028
|
private rules;
|
|
2057
2029
|
private transformers;
|
|
2030
|
+
private cache;
|
|
2058
2031
|
/** The original data this resolved configuration was created from */
|
|
2059
2032
|
private original;
|
|
2060
2033
|
/* Excluded from this release type: __constructor */
|
|
@@ -2066,28 +2039,12 @@ export declare class ResolvedConfig {
|
|
|
2066
2039
|
getMetaTable(): MetaTable;
|
|
2067
2040
|
getPlugins(): Plugin_2[];
|
|
2068
2041
|
getRules(): Map<string, [Severity, RuleOptions]>;
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
*
|
|
2072
|
-
* When transforming zero or more new sources will be generated.
|
|
2073
|
-
*
|
|
2074
|
-
* @param source - Current source to transform.
|
|
2075
|
-
* @param filename - If set it is the filename used to match
|
|
2076
|
-
* transformer. Default is to use filename from source.
|
|
2077
|
-
* @returns A list of transformed sources ready for validation.
|
|
2078
|
-
*/
|
|
2079
|
-
transformSource(source: Source, filename?: string): Source[];
|
|
2080
|
-
/**
|
|
2081
|
-
* Wrapper around [[transformSource]] which reads a file before passing it
|
|
2082
|
-
* as-is to transformSource.
|
|
2083
|
-
*
|
|
2084
|
-
* @param filename - Filename to transform (according to configured
|
|
2085
|
-
* transformations)
|
|
2086
|
-
* @returns A list of transformed sources ready for validation.
|
|
2087
|
-
*/
|
|
2088
|
-
transformFilename(filename: string): Source[];
|
|
2042
|
+
/* Excluded from this release type: transformSource */
|
|
2043
|
+
/* Excluded from this release type: transformFilename */
|
|
2089
2044
|
/**
|
|
2090
2045
|
* Returns true if a transformer matches given filename.
|
|
2046
|
+
*
|
|
2047
|
+
* @public
|
|
2091
2048
|
*/
|
|
2092
2049
|
canTransform(filename: string): boolean;
|
|
2093
2050
|
private findTransformer;
|
|
@@ -2736,7 +2693,6 @@ export { Transformer_2 as Transformer }
|
|
|
2736
2693
|
export declare interface TransformerEntry {
|
|
2737
2694
|
pattern: RegExp;
|
|
2738
2695
|
name: string;
|
|
2739
|
-
fn: Transformer_2;
|
|
2740
2696
|
}
|
|
2741
2697
|
|
|
2742
2698
|
/**
|
package/dist/types/index.d.ts
CHANGED
|
@@ -282,7 +282,6 @@ export declare interface ConditionalEvent extends Event_2 {
|
|
|
282
282
|
export declare class Config {
|
|
283
283
|
private config;
|
|
284
284
|
private configurations;
|
|
285
|
-
private initialized;
|
|
286
285
|
private resolvers;
|
|
287
286
|
private metaTable;
|
|
288
287
|
private plugins;
|
|
@@ -304,12 +303,8 @@ export declare class Config {
|
|
|
304
303
|
/* Excluded from this release type: create */
|
|
305
304
|
/* Excluded from this release type: __constructor */
|
|
306
305
|
/**
|
|
307
|
-
* Initialize plugins, transforms etc.
|
|
308
|
-
*
|
|
309
|
-
* Must be called before trying to use config. Can safely be called multiple
|
|
310
|
-
* times.
|
|
311
|
-
*
|
|
312
306
|
* @public
|
|
307
|
+
* @deprecated Not needed any longer, this is a dummy noop method.
|
|
313
308
|
*/
|
|
314
309
|
init(): void;
|
|
315
310
|
/**
|
|
@@ -330,6 +325,7 @@ export declare class Config {
|
|
|
330
325
|
/* Excluded from this release type: getRules */
|
|
331
326
|
private static getRulesObject;
|
|
332
327
|
/* Excluded from this release type: getPlugins */
|
|
328
|
+
/* Excluded from this release type: getTransformers */
|
|
333
329
|
private loadPlugins;
|
|
334
330
|
private loadConfigurations;
|
|
335
331
|
private extendMeta;
|
|
@@ -343,31 +339,6 @@ export declare class Config {
|
|
|
343
339
|
*/
|
|
344
340
|
resolve(): ResolvedConfig;
|
|
345
341
|
/* Excluded from this release type: resolveData */
|
|
346
|
-
private precompileTransformers;
|
|
347
|
-
/**
|
|
348
|
-
* Get transformation function requested by configuration.
|
|
349
|
-
*
|
|
350
|
-
* Searches:
|
|
351
|
-
*
|
|
352
|
-
* - Named transformers from plugins.
|
|
353
|
-
* - Unnamed transformer from plugin.
|
|
354
|
-
* - Standalone modules (local or node_modules)
|
|
355
|
-
*
|
|
356
|
-
* @param name - Key from configuration
|
|
357
|
-
*/
|
|
358
|
-
private getTransformFunction;
|
|
359
|
-
/**
|
|
360
|
-
* @param name - Original name from configuration
|
|
361
|
-
* @param pluginName - Name of plugin
|
|
362
|
-
* @param key - Name of transform (from plugin)
|
|
363
|
-
*/
|
|
364
|
-
private getNamedTransformerFromPlugin;
|
|
365
|
-
/**
|
|
366
|
-
* @param name - Original name from configuration
|
|
367
|
-
* @param plugin - Plugin instance
|
|
368
|
-
*/
|
|
369
|
-
private getUnnamedTransformerFromPlugin;
|
|
370
|
-
private getTransformerFromModule;
|
|
371
342
|
}
|
|
372
343
|
|
|
373
344
|
/**
|
|
@@ -463,6 +434,7 @@ export declare abstract class ConfigLoader {
|
|
|
463
434
|
* @param configOverride - Optional configuration to merge final results with.
|
|
464
435
|
*/
|
|
465
436
|
abstract getConfigFor(handle: string, configOverride?: ConfigData): ResolvedConfig;
|
|
437
|
+
/* Excluded from this release type: getResolvers */
|
|
466
438
|
/**
|
|
467
439
|
* Flush configuration cache.
|
|
468
440
|
*
|
|
@@ -2307,6 +2279,7 @@ export declare class ResolvedConfig {
|
|
|
2307
2279
|
private plugins;
|
|
2308
2280
|
private rules;
|
|
2309
2281
|
private transformers;
|
|
2282
|
+
private cache;
|
|
2310
2283
|
/** The original data this resolved configuration was created from */
|
|
2311
2284
|
private original;
|
|
2312
2285
|
/* Excluded from this release type: __constructor */
|
|
@@ -2318,28 +2291,12 @@ export declare class ResolvedConfig {
|
|
|
2318
2291
|
getMetaTable(): MetaTable;
|
|
2319
2292
|
getPlugins(): Plugin_2[];
|
|
2320
2293
|
getRules(): Map<string, [Severity, RuleOptions]>;
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
*
|
|
2324
|
-
* When transforming zero or more new sources will be generated.
|
|
2325
|
-
*
|
|
2326
|
-
* @param source - Current source to transform.
|
|
2327
|
-
* @param filename - If set it is the filename used to match
|
|
2328
|
-
* transformer. Default is to use filename from source.
|
|
2329
|
-
* @returns A list of transformed sources ready for validation.
|
|
2330
|
-
*/
|
|
2331
|
-
transformSource(source: Source, filename?: string): Source[];
|
|
2332
|
-
/**
|
|
2333
|
-
* Wrapper around [[transformSource]] which reads a file before passing it
|
|
2334
|
-
* as-is to transformSource.
|
|
2335
|
-
*
|
|
2336
|
-
* @param filename - Filename to transform (according to configured
|
|
2337
|
-
* transformations)
|
|
2338
|
-
* @returns A list of transformed sources ready for validation.
|
|
2339
|
-
*/
|
|
2340
|
-
transformFilename(filename: string): Source[];
|
|
2294
|
+
/* Excluded from this release type: transformSource */
|
|
2295
|
+
/* Excluded from this release type: transformFilename */
|
|
2341
2296
|
/**
|
|
2342
2297
|
* Returns true if a transformer matches given filename.
|
|
2298
|
+
*
|
|
2299
|
+
* @public
|
|
2343
2300
|
*/
|
|
2344
2301
|
canTransform(filename: string): boolean;
|
|
2345
2302
|
private findTransformer;
|
|
@@ -2988,7 +2945,6 @@ export { Transformer_2 as Transformer }
|
|
|
2988
2945
|
export declare interface TransformerEntry {
|
|
2989
2946
|
pattern: RegExp;
|
|
2990
2947
|
name: string;
|
|
2991
|
-
fn: Transformer_2;
|
|
2992
2948
|
}
|
|
2993
2949
|
|
|
2994
2950
|
/**
|