html-validate 8.24.2 → 8.25.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/cli.js +17 -16
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/core-browser.js.map +1 -1
- package/dist/cjs/core-nodejs.js.map +1 -1
- package/dist/cjs/core.js +89 -13
- package/dist/cjs/core.js.map +1 -1
- package/dist/cjs/elements.js.map +1 -1
- package/dist/cjs/html-validate.js +17 -1
- package/dist/cjs/html-validate.js.map +1 -1
- package/dist/cjs/jest-diff.js.map +1 -1
- package/dist/cjs/jest.js.map +1 -1
- package/dist/cjs/matcher-utils.js.map +1 -1
- package/dist/cjs/matchers-jestonly.js.map +1 -1
- package/dist/cjs/matchers.js.map +1 -1
- package/dist/cjs/meta-helper.js.map +1 -1
- package/dist/cjs/test-utils.js.map +1 -1
- package/dist/cjs/tsdoc-metadata.json +1 -1
- package/dist/cjs/utils/natural-join.js.map +1 -1
- package/dist/cjs/vitest.js.map +1 -1
- package/dist/es/cli.js +18 -17
- package/dist/es/cli.js.map +1 -1
- package/dist/es/core-browser.js.map +1 -1
- package/dist/es/core-nodejs.js.map +1 -1
- package/dist/es/core.js +89 -13
- package/dist/es/core.js.map +1 -1
- package/dist/es/elements.js.map +1 -1
- package/dist/es/html-validate.js +17 -1
- package/dist/es/html-validate.js.map +1 -1
- package/dist/es/jest-diff.js.map +1 -1
- package/dist/es/jest.js.map +1 -1
- package/dist/es/matcher-utils.js.map +1 -1
- package/dist/es/matchers-jestonly.js.map +1 -1
- package/dist/es/matchers.js.map +1 -1
- package/dist/es/meta-helper.js.map +1 -1
- package/dist/es/test-utils.js.map +1 -1
- package/dist/es/utils/natural-join.js.map +1 -1
- package/dist/es/vitest.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/types/browser.d.ts +8 -2
- package/dist/types/index.d.ts +10 -2
- package/package.json +10 -9
package/dist/es/html-validate.js
CHANGED
|
@@ -86,7 +86,18 @@ function handleUnknownError(err) {
|
|
|
86
86
|
);
|
|
87
87
|
}
|
|
88
88
|
const argv = minimist(process.argv.slice(2), {
|
|
89
|
-
string: [
|
|
89
|
+
string: [
|
|
90
|
+
"c",
|
|
91
|
+
"config",
|
|
92
|
+
"ext",
|
|
93
|
+
"f",
|
|
94
|
+
"formatter",
|
|
95
|
+
"max-warnings",
|
|
96
|
+
"p",
|
|
97
|
+
"preset",
|
|
98
|
+
"rule",
|
|
99
|
+
"stdin-filename"
|
|
100
|
+
],
|
|
90
101
|
boolean: [
|
|
91
102
|
"init",
|
|
92
103
|
"dump-events",
|
|
@@ -102,6 +113,7 @@ const argv = minimist(process.argv.slice(2), {
|
|
|
102
113
|
alias: {
|
|
103
114
|
c: "config",
|
|
104
115
|
f: "formatter",
|
|
116
|
+
p: "preset",
|
|
105
117
|
h: "help"
|
|
106
118
|
},
|
|
107
119
|
default: {
|
|
@@ -125,6 +137,9 @@ Common options:
|
|
|
125
137
|
--ext=STRING specify file extensions (commaseparated).
|
|
126
138
|
-f, --formatter=FORMATTER specify the formatter to use.
|
|
127
139
|
--max-warnings=INT number of warnings to trigger nonzero exit code
|
|
140
|
+
-p, --preset=STRING configuration preset to use, use
|
|
141
|
+
comma-separator for multiple presets. (default:
|
|
142
|
+
"recommended")
|
|
128
143
|
--rule=RULE:SEVERITY set additional rule, use comma separator for
|
|
129
144
|
multiple.
|
|
130
145
|
--stdin process markup from stdin.
|
|
@@ -188,6 +203,7 @@ if (typeof argv.config !== "undefined") {
|
|
|
188
203
|
}
|
|
189
204
|
const cli = new CLI({
|
|
190
205
|
configFile: argv.config,
|
|
206
|
+
preset: argv.preset,
|
|
191
207
|
rules: argv.rule
|
|
192
208
|
});
|
|
193
209
|
const mode = getMode(argv);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-validate.js","sources":["../../src/cli/html-validate.ts"],"sourcesContent":["/* eslint-disable no-console, n/no-process-exit, sonarjs/no-duplicate-string -- as expected from a cli app */\nimport fs from \"fs\";\nimport path from \"node:path\";\nimport kleur from \"kleur\";\nimport minimist from \"minimist\";\nimport { SchemaValidationError, UserError } from \"..\";\nimport { name, version, bugs as pkgBugs } from \"../generated/package\";\nimport { CLI } from \"./cli\";\nimport { handleSchemaValidationError } from \"./errors\";\nimport { Mode, modeToFlag } from \"./mode\";\nimport { lint } from \"./actions/lint\";\nimport { init } from \"./actions/init\";\nimport { printConfig } from \"./actions/print-config\";\nimport { dump } from \"./actions/dump\";\n\ninterface ParsedArgs {\n\tconfig?: string;\n\t\"dump-events\": boolean;\n\t\"dump-source\": boolean;\n\t\"dump-tokens\": boolean;\n\t\"dump-tree\": boolean;\n\text: string;\n\tformatter: string;\n\thelp: boolean;\n\tinit: boolean;\n\t\"max-warnings\"?: string;\n\t\"print-config\": boolean;\n\trule?: string;\n\tstdin: boolean;\n\t\"stdin-filename\"?: string;\n\tversion: boolean;\n}\n\nfunction getMode(argv: Record<string, any>): Mode {\n\tif (argv.init) {\n\t\treturn Mode.INIT;\n\t}\n\n\tif (argv[\"dump-events\"]) {\n\t\treturn Mode.DUMP_EVENTS;\n\t}\n\n\tif (argv[\"dump-source\"]) {\n\t\treturn Mode.DUMP_SOURCE;\n\t}\n\n\tif (argv[\"dump-tokens\"]) {\n\t\treturn Mode.DUMP_TOKENS;\n\t}\n\n\tif (argv[\"dump-tree\"]) {\n\t\treturn Mode.DUMP_TREE;\n\t}\n\n\tif (argv[\"print-config\"]) {\n\t\treturn Mode.PRINT_CONFIG;\n\t}\n\n\treturn Mode.LINT;\n}\n\nfunction requiresFilename(mode: Mode): boolean {\n\tswitch (mode) {\n\t\tcase Mode.LINT:\n\t\t\treturn true;\n\t\tcase Mode.INIT:\n\t\t\treturn false;\n\t\tcase Mode.DUMP_EVENTS:\n\t\tcase Mode.DUMP_TOKENS:\n\t\tcase Mode.DUMP_TREE:\n\t\tcase Mode.DUMP_SOURCE:\n\t\tcase Mode.PRINT_CONFIG:\n\t\t\treturn true;\n\t}\n}\n\nfunction handleUserError(err: UserError): void {\n\tconst formatted = err.prettyFormat();\n\tif (formatted) {\n\t\tconsole.error(); /* blank line */\n\t\tconsole.error(formatted);\n\t\treturn;\n\t}\n\n\tconsole.error(kleur.red(\"Caught exception:\"));\n\tconsole.group();\n\t{\n\t\tconsole.error(err.prettyFormat() ?? err);\n\t}\n\tconsole.groupEnd();\n}\n\nfunction handleUnknownError(err: unknown): void {\n\tconsole.error(kleur.red(\"Caught exception:\"));\n\tconsole.group();\n\t{\n\t\tconsole.error(err);\n\t}\n\tconsole.groupEnd();\n\tconst bugUrl = `${pkgBugs}?issuable_template=Bug`;\n\tconsole.error(kleur.red(`This is a bug in ${name}-${version}.`));\n\tconsole.error(\n\t\tkleur.red(\n\t\t\t[\n\t\t\t\t`Please file a bug at ${bugUrl}`,\n\t\t\t\t`and include this message in full and if possible the content of the`,\n\t\t\t\t`file being parsed (or a reduced testcase).`,\n\t\t\t].join(\"\\n\"),\n\t\t),\n\t);\n}\n\nconst argv = minimist<ParsedArgs>(process.argv.slice(2), {\n\tstring: [\"c\", \"config\", \"ext\", \"f\", \"formatter\", \"max-warnings\", \"rule\", \"stdin-filename\"],\n\tboolean: [\n\t\t\"init\",\n\t\t\"dump-events\",\n\t\t\"dump-source\",\n\t\t\"dump-tokens\",\n\t\t\"dump-tree\",\n\t\t\"h\",\n\t\t\"help\",\n\t\t\"print-config\",\n\t\t\"stdin\",\n\t\t\"version\",\n\t],\n\talias: {\n\t\tc: \"config\",\n\t\tf: \"formatter\",\n\t\th: \"help\",\n\t},\n\tdefault: {\n\t\text: \"html\",\n\t\tformatter: \"stylish\",\n\t},\n\tunknown: (opt: string) => {\n\t\tif (opt.startsWith(\"-\")) {\n\t\t\tprocess.stderr.write(`unknown option ${opt}\\n`);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\treturn true;\n\t},\n});\n\nfunction showUsage(): void {\n\tprocess.stdout.write(`${name}-${version}\nUsage: html-validate [OPTIONS] [FILENAME..] [DIR..]\n\nCommon options:\n --ext=STRING specify file extensions (commaseparated).\n -f, --formatter=FORMATTER specify the formatter to use.\n --max-warnings=INT number of warnings to trigger nonzero exit code\n --rule=RULE:SEVERITY set additional rule, use comma separator for\n multiple.\n --stdin process markup from stdin.\n --stdin-filename=STRING specify filename to report when using stdin\n\nMiscellaneous:\n -c, --config=STRING use custom configuration file.\n --init initialize project with a new configuration\n --print-config output configuration for given file.\n -h, --help show help.\n --version show version.\n\nDebugging options:\n --dump-events output events during parsing.\n --dump-source output post-transformed source data.\n --dump-tokens output tokens from lexing stage.\n --dump-tree output nodes from the dom tree.\n\nFormatters:\n\nMultiple formatters can be specified with a comma-separated list,\ne.g. \"json,checkstyle\" to enable both.\n\nTo capture output to a file use \"formatter=/path/to/file\",\ne.g. \"checkstyle=dist/html-validate.xml\"\n`);\n}\n\nfunction showVersion(): void {\n\tprocess.stdout.write(`${name}-${version}\\n`);\n}\n\nif (argv.stdin) {\n\targv._.push(\"-\");\n}\n\nif (argv.version) {\n\tshowVersion();\n\tprocess.exit();\n}\n\nif (argv.help) {\n\tshowUsage();\n\tprocess.exit();\n}\n\nif (argv._.length === 0) {\n\tconst mode = getMode(argv);\n\tif (mode === Mode.LINT) {\n\t\tshowUsage();\n\t\tprocess.exit(0);\n\t} else if (requiresFilename(mode)) {\n\t\tconst flag = modeToFlag(mode);\n\t\tconsole.error(`\\`${flag}\\` requires a filename.`);\n\t\tprocess.exit(1);\n\t}\n}\n\n/* check that supplied config file exists before creating CLI */\nif (typeof argv.config !== \"undefined\") {\n\tconst checkPath = path.resolve(argv.config);\n\tif (!fs.existsSync(checkPath)) {\n\t\tconsole.log(`The file \"${String(argv.config)}\" was not found.`);\n\t\tconsole.log(`The location this file was checked for at was: \"${String(checkPath)}\"`);\n\t\tprocess.exit(1);\n\t}\n}\n\nconst cli = new CLI({\n\tconfigFile: argv.config,\n\trules: argv.rule,\n});\nconst mode = getMode(argv);\nconst formatter = cli.getFormatter(argv.formatter);\nconst maxWarnings = parseInt(argv[\"max-warnings\"] ?? \"-1\", 10);\nconst htmlvalidate = cli.getValidator();\n\n/* sanity check: ensure maxWarnings has a valid value */\nif (isNaN(maxWarnings)) {\n\tconsole.log(`Invalid value \"${String(argv[\"max-warnings\"])}\" given to --max-warnings`);\n\tprocess.exit(1);\n}\n\n/* parse extensions (used when expanding directories) */\nconst extensions = argv.ext.split(\",\").map((cur: string) => {\n\treturn cur.startsWith(\".\") ? cur.slice(1) : cur;\n});\n\nconst files = cli.expandFiles(argv._, { extensions });\nif (files.length === 0 && mode !== Mode.INIT) {\n\tconsole.error(\"No files matching patterns\", argv._);\n\tprocess.exit(1);\n}\n\nasync function run(): Promise<void> {\n\ttry {\n\t\tlet success: boolean;\n\t\tif (mode === Mode.LINT) {\n\t\t\tsuccess = await lint(htmlvalidate, process.stdout, files, {\n\t\t\t\tformatter,\n\t\t\t\tmaxWarnings,\n\t\t\t\tstdinFilename: argv[\"stdin-filename\"] ?? false,\n\t\t\t});\n\t\t} else if (mode === Mode.INIT) {\n\t\t\tsuccess = await init(cli, process.stdout, { cwd: process.cwd() });\n\t\t} else if (mode === Mode.PRINT_CONFIG) {\n\t\t\tsuccess = await printConfig(htmlvalidate, process.stdout, files);\n\t\t} else {\n\t\t\tsuccess = await dump(htmlvalidate, process.stdout, files, mode);\n\t\t}\n\t\tprocess.exit(success ? 0 : 1);\n\t} catch (err) {\n\t\tif (err instanceof SchemaValidationError) {\n\t\t\thandleSchemaValidationError(console, err);\n\t\t} else if (err instanceof UserError) {\n\t\t\thandleUserError(err);\n\t\t} else {\n\t\t\thandleUnknownError(err);\n\t\t}\n\t\tprocess.exit(1);\n\t}\n}\n\nrun().catch((err: unknown) => {\n\tconsole.error(err);\n\tprocess.exit(1);\n});\n"],"names":["argv","mode","pkgBugs"],"mappings":";;;;;;;;;;;;;;;;;;;AAiCA,SAAS,QAAQA,KAAiC,EAAA;AACjD,EAAA,IAAIA,MAAK,IAAM,EAAA;AACd,IAAA,OAAO,IAAK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AAA,CAAmB,GAAG,CAAA,CAAA;AAAA,KACvB;AACA,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA,CAAA;AAAA,GACf;AACD,CAAA;AAEA,GAAI,EAAA,CAAE,KAAM,CAAA,CAAC,GAAiB,KAAA;AAC7B,EAAA,OAAA,CAAQ,MAAM,GAAG,CAAA,CAAA;AACjB,EAAA,OAAA,CAAQ,KAAK,CAAC,CAAA,CAAA;AACf,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"html-validate.js","sources":["../../src/cli/html-validate.ts"],"sourcesContent":["/* eslint-disable no-console, n/no-process-exit, sonarjs/no-duplicate-string -- as expected from a cli app */\nimport fs from \"fs\";\nimport path from \"node:path\";\nimport kleur from \"kleur\";\nimport minimist from \"minimist\";\nimport { SchemaValidationError, UserError } from \"..\";\nimport { name, version, bugs as pkgBugs } from \"../generated/package\";\nimport { CLI } from \"./cli\";\nimport { handleSchemaValidationError } from \"./errors\";\nimport { Mode, modeToFlag } from \"./mode\";\nimport { lint } from \"./actions/lint\";\nimport { init } from \"./actions/init\";\nimport { printConfig } from \"./actions/print-config\";\nimport { dump } from \"./actions/dump\";\n\ninterface ParsedArgs {\n\tconfig?: string;\n\t\"dump-events\": boolean;\n\t\"dump-source\": boolean;\n\t\"dump-tokens\": boolean;\n\t\"dump-tree\": boolean;\n\text: string;\n\tformatter: string;\n\thelp: boolean;\n\tinit: boolean;\n\t\"max-warnings\"?: string;\n\tpreset?: string;\n\t\"print-config\": boolean;\n\trule?: string;\n\tstdin: boolean;\n\t\"stdin-filename\"?: string;\n\tversion: boolean;\n}\n\nfunction getMode(argv: Record<string, any>): Mode {\n\tif (argv.init) {\n\t\treturn Mode.INIT;\n\t}\n\n\tif (argv[\"dump-events\"]) {\n\t\treturn Mode.DUMP_EVENTS;\n\t}\n\n\tif (argv[\"dump-source\"]) {\n\t\treturn Mode.DUMP_SOURCE;\n\t}\n\n\tif (argv[\"dump-tokens\"]) {\n\t\treturn Mode.DUMP_TOKENS;\n\t}\n\n\tif (argv[\"dump-tree\"]) {\n\t\treturn Mode.DUMP_TREE;\n\t}\n\n\tif (argv[\"print-config\"]) {\n\t\treturn Mode.PRINT_CONFIG;\n\t}\n\n\treturn Mode.LINT;\n}\n\nfunction requiresFilename(mode: Mode): boolean {\n\tswitch (mode) {\n\t\tcase Mode.LINT:\n\t\t\treturn true;\n\t\tcase Mode.INIT:\n\t\t\treturn false;\n\t\tcase Mode.DUMP_EVENTS:\n\t\tcase Mode.DUMP_TOKENS:\n\t\tcase Mode.DUMP_TREE:\n\t\tcase Mode.DUMP_SOURCE:\n\t\tcase Mode.PRINT_CONFIG:\n\t\t\treturn true;\n\t}\n}\n\nfunction handleUserError(err: UserError): void {\n\tconst formatted = err.prettyFormat();\n\tif (formatted) {\n\t\tconsole.error(); /* blank line */\n\t\tconsole.error(formatted);\n\t\treturn;\n\t}\n\n\tconsole.error(kleur.red(\"Caught exception:\"));\n\tconsole.group();\n\t{\n\t\tconsole.error(err.prettyFormat() ?? err);\n\t}\n\tconsole.groupEnd();\n}\n\nfunction handleUnknownError(err: unknown): void {\n\tconsole.error(kleur.red(\"Caught exception:\"));\n\tconsole.group();\n\t{\n\t\tconsole.error(err);\n\t}\n\tconsole.groupEnd();\n\tconst bugUrl = `${pkgBugs}?issuable_template=Bug`;\n\tconsole.error(kleur.red(`This is a bug in ${name}-${version}.`));\n\tconsole.error(\n\t\tkleur.red(\n\t\t\t[\n\t\t\t\t`Please file a bug at ${bugUrl}`,\n\t\t\t\t`and include this message in full and if possible the content of the`,\n\t\t\t\t`file being parsed (or a reduced testcase).`,\n\t\t\t].join(\"\\n\"),\n\t\t),\n\t);\n}\n\nconst argv = minimist<ParsedArgs>(process.argv.slice(2), {\n\tstring: [\n\t\t\"c\",\n\t\t\"config\",\n\t\t\"ext\",\n\t\t\"f\",\n\t\t\"formatter\",\n\t\t\"max-warnings\",\n\t\t\"p\",\n\t\t\"preset\",\n\t\t\"rule\",\n\t\t\"stdin-filename\",\n\t],\n\tboolean: [\n\t\t\"init\",\n\t\t\"dump-events\",\n\t\t\"dump-source\",\n\t\t\"dump-tokens\",\n\t\t\"dump-tree\",\n\t\t\"h\",\n\t\t\"help\",\n\t\t\"print-config\",\n\t\t\"stdin\",\n\t\t\"version\",\n\t],\n\talias: {\n\t\tc: \"config\",\n\t\tf: \"formatter\",\n\t\tp: \"preset\",\n\t\th: \"help\",\n\t},\n\tdefault: {\n\t\text: \"html\",\n\t\tformatter: \"stylish\",\n\t},\n\tunknown: (opt: string) => {\n\t\tif (opt.startsWith(\"-\")) {\n\t\t\tprocess.stderr.write(`unknown option ${opt}\\n`);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\treturn true;\n\t},\n});\n\nfunction showUsage(): void {\n\tprocess.stdout.write(`${name}-${version}\nUsage: html-validate [OPTIONS] [FILENAME..] [DIR..]\n\nCommon options:\n --ext=STRING specify file extensions (commaseparated).\n -f, --formatter=FORMATTER specify the formatter to use.\n --max-warnings=INT number of warnings to trigger nonzero exit code\n -p, --preset=STRING configuration preset to use, use\n comma-separator for multiple presets. (default:\n \"recommended\")\n --rule=RULE:SEVERITY set additional rule, use comma separator for\n multiple.\n --stdin process markup from stdin.\n --stdin-filename=STRING specify filename to report when using stdin\n\nMiscellaneous:\n -c, --config=STRING use custom configuration file.\n --init initialize project with a new configuration\n --print-config output configuration for given file.\n -h, --help show help.\n --version show version.\n\nDebugging options:\n --dump-events output events during parsing.\n --dump-source output post-transformed source data.\n --dump-tokens output tokens from lexing stage.\n --dump-tree output nodes from the dom tree.\n\nFormatters:\n\nMultiple formatters can be specified with a comma-separated list,\ne.g. \"json,checkstyle\" to enable both.\n\nTo capture output to a file use \"formatter=/path/to/file\",\ne.g. \"checkstyle=dist/html-validate.xml\"\n`);\n}\n\nfunction showVersion(): void {\n\tprocess.stdout.write(`${name}-${version}\\n`);\n}\n\nif (argv.stdin) {\n\targv._.push(\"-\");\n}\n\nif (argv.version) {\n\tshowVersion();\n\tprocess.exit();\n}\n\nif (argv.help) {\n\tshowUsage();\n\tprocess.exit();\n}\n\nif (argv._.length === 0) {\n\tconst mode = getMode(argv);\n\tif (mode === Mode.LINT) {\n\t\tshowUsage();\n\t\tprocess.exit(0);\n\t} else if (requiresFilename(mode)) {\n\t\tconst flag = modeToFlag(mode);\n\t\tconsole.error(`\\`${flag}\\` requires a filename.`);\n\t\tprocess.exit(1);\n\t}\n}\n\n/* check that supplied config file exists before creating CLI */\nif (typeof argv.config !== \"undefined\") {\n\tconst checkPath = path.resolve(argv.config);\n\tif (!fs.existsSync(checkPath)) {\n\t\tconsole.log(`The file \"${String(argv.config)}\" was not found.`);\n\t\tconsole.log(`The location this file was checked for at was: \"${String(checkPath)}\"`);\n\t\tprocess.exit(1);\n\t}\n}\n\nconst cli = new CLI({\n\tconfigFile: argv.config,\n\tpreset: argv.preset,\n\trules: argv.rule,\n});\nconst mode = getMode(argv);\nconst formatter = cli.getFormatter(argv.formatter);\nconst maxWarnings = parseInt(argv[\"max-warnings\"] ?? \"-1\", 10);\nconst htmlvalidate = cli.getValidator();\n\n/* sanity check: ensure maxWarnings has a valid value */\nif (isNaN(maxWarnings)) {\n\tconsole.log(`Invalid value \"${String(argv[\"max-warnings\"])}\" given to --max-warnings`);\n\tprocess.exit(1);\n}\n\n/* parse extensions (used when expanding directories) */\nconst extensions = argv.ext.split(\",\").map((cur: string) => {\n\treturn cur.startsWith(\".\") ? cur.slice(1) : cur;\n});\n\nconst files = cli.expandFiles(argv._, { extensions });\nif (files.length === 0 && mode !== Mode.INIT) {\n\tconsole.error(\"No files matching patterns\", argv._);\n\tprocess.exit(1);\n}\n\nasync function run(): Promise<void> {\n\ttry {\n\t\tlet success: boolean;\n\t\tif (mode === Mode.LINT) {\n\t\t\tsuccess = await lint(htmlvalidate, process.stdout, files, {\n\t\t\t\tformatter,\n\t\t\t\tmaxWarnings,\n\t\t\t\tstdinFilename: argv[\"stdin-filename\"] ?? false,\n\t\t\t});\n\t\t} else if (mode === Mode.INIT) {\n\t\t\tsuccess = await init(cli, process.stdout, { cwd: process.cwd() });\n\t\t} else if (mode === Mode.PRINT_CONFIG) {\n\t\t\tsuccess = await printConfig(htmlvalidate, process.stdout, files);\n\t\t} else {\n\t\t\tsuccess = await dump(htmlvalidate, process.stdout, files, mode);\n\t\t}\n\t\tprocess.exit(success ? 0 : 1);\n\t} catch (err) {\n\t\tif (err instanceof SchemaValidationError) {\n\t\t\thandleSchemaValidationError(console, err);\n\t\t} else if (err instanceof UserError) {\n\t\t\thandleUserError(err);\n\t\t} else {\n\t\t\thandleUnknownError(err);\n\t\t}\n\t\tprocess.exit(1);\n\t}\n}\n\nrun().catch((err: unknown) => {\n\tconsole.error(err);\n\tprocess.exit(1);\n});\n"],"names":["argv","mode","pkgBugs"],"mappings":";;;;;;;;;;;;;;;;;;;AAkCA,SAAS,QAAQA,KAAiC,EAAA;AACjD,EAAA,IAAIA,MAAK,IAAM,EAAA;AACd,IAAA,OAAO,IAAK,CAAA,IAAA;AAAA;AAGb,EAAIA,IAAAA,KAAAA,CAAK,aAAa,CAAG,EAAA;AACxB,IAAA,OAAO,IAAK,CAAA,WAAA;AAAA;AAGb,EAAIA,IAAAA,KAAAA,CAAK,aAAa,CAAG,EAAA;AACxB,IAAA,OAAO,IAAK,CAAA,WAAA;AAAA;AAGb,EAAIA,IAAAA,KAAAA,CAAK,aAAa,CAAG,EAAA;AACxB,IAAA,OAAO,IAAK,CAAA,WAAA;AAAA;AAGb,EAAIA,IAAAA,KAAAA,CAAK,WAAW,CAAG,EAAA;AACtB,IAAA,OAAO,IAAK,CAAA,SAAA;AAAA;AAGb,EAAIA,IAAAA,KAAAA,CAAK,cAAc,CAAG,EAAA;AACzB,IAAA,OAAO,IAAK,CAAA,YAAA;AAAA;AAGb,EAAA,OAAO,IAAK,CAAA,IAAA;AACb;AAEA,SAAS,iBAAiBC,KAAqB,EAAA;AAC9C,EAAA,QAAQA,KAAM;AAAA,IACb,KAAK,IAAK,CAAA,IAAA;AACT,MAAO,OAAA,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AAe,SAAW,EAAA;AACpC,MAAA,eAAA,CAAgB,GAAG,CAAA;AAAA,KACb,MAAA;AACN,MAAA,kBAAA,CAAmB,GAAG,CAAA;AAAA;AAEvB,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA;AAEhB;AAEA,GAAI,EAAA,CAAE,KAAM,CAAA,CAAC,GAAiB,KAAA;AAC7B,EAAA,OAAA,CAAQ,MAAM,GAAG,CAAA;AACjB,EAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AACf,CAAC,CAAA"}
|
package/dist/es/jest-diff.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jest-diff.js","sources":["../../src/jest/utils/diff.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unnecessary-condition --\n * this code needs to work with multiple different versions of jest and it does\n * verification of which one is actually present but the other variants will\n * cause errors, as is expected */\n\nimport jestDiffDefault, * as jestDiff from \"jest-diff\";\n\n/**\n * @internal\n */\nexport interface DiffOptions {\n\taAnnotation?: string;\n\tbAnnotation?: string;\n\texpand?: boolean;\n}\n\n/**\n * @internal\n */\nexport type DiffFunction = (a: any, b: any, options?: DiffOptions) => string | null;\n\n/* ignore typing for compatibility so it will seem \"impossible\" but different\n * version will yield different source */\n/* istanbul ignore next: this is covered by integration tests */\nconst diffCandidates: Array<DiffFunction | undefined> = [\n\t// @ts-ignore\n\tjestDiffDefault?.diff,\n\t// @ts-ignore\n\tjestDiffDefault,\n\t// @ts-ignore\n\tjestDiff?.diff,\n\t// @ts-ignore\n\tjestDiff,\n];\n\nconst isFunction = (fn: unknown): boolean => typeof fn === \"function\";\n\n/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- assume\n * one of the candidate matches, there will be a reasonable error later on if\n * not */\nexport const diff: DiffFunction = diffCandidates.find(isFunction)!;\n"],"names":["jestDiffDefault"],"mappings":";;;AAAA,IAAA,EAAA
|
|
1
|
+
{"version":3,"file":"jest-diff.js","sources":["../../src/jest/utils/diff.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unnecessary-condition --\n * this code needs to work with multiple different versions of jest and it does\n * verification of which one is actually present but the other variants will\n * cause errors, as is expected */\n\nimport jestDiffDefault, * as jestDiff from \"jest-diff\";\n\n/**\n * @internal\n */\nexport interface DiffOptions {\n\taAnnotation?: string;\n\tbAnnotation?: string;\n\texpand?: boolean;\n}\n\n/**\n * @internal\n */\nexport type DiffFunction = (a: any, b: any, options?: DiffOptions) => string | null;\n\n/* ignore typing for compatibility so it will seem \"impossible\" but different\n * version will yield different source */\n/* istanbul ignore next: this is covered by integration tests */\nconst diffCandidates: Array<DiffFunction | undefined> = [\n\t// @ts-ignore\n\tjestDiffDefault?.diff,\n\t// @ts-ignore\n\tjestDiffDefault,\n\t// @ts-ignore\n\tjestDiff?.diff,\n\t// @ts-ignore\n\tjestDiff,\n];\n\nconst isFunction = (fn: unknown): boolean => typeof fn === \"function\";\n\n/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- assume\n * one of the candidate matches, there will be a reasonable error later on if\n * not */\nexport const diff: DiffFunction = diffCandidates.find(isFunction)!;\n"],"names":["jestDiffDefault"],"mappings":";;;AAAA,IAAA,EAAA;AAwBA,MAAM,cAAkD,GAAA;AAAA;AAAA,EAAA,CAEvD,EAAiB,GAAAA,iBAAA,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAA;AAAA;AAAA,EAEjBA,iBAAA;AAAA;AAAA,EAEA,QAAU,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,QAAA,CAAA,IAAA;AAAA;AAAA,EAEV;AACD,CAAA;AAEA,MAAM,UAAa,GAAA,CAAC,EAAyB,KAAA,OAAO,EAAO,KAAA,UAAA;AAK9C,MAAA,IAAA,GAAqB,cAAe,CAAA,IAAA,CAAK,UAAU;;;;"}
|
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":";;;;;;;;;;;;;;;;;;;;;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
|
|
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"}
|
|
@@ -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
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchers-jestonly.js","sources":["../../src/jest/matchers/to-match-codeframe.ts","../../src/jest/matchers/to-match-inline-codeframe.ts"],"sourcesContent":["import kleur from \"kleur\";\nimport { toMatchSnapshot } from \"jest-snapshot\";\nimport { codeframe, type CodeframeOptions } from \"../../formatters/codeframe\";\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype MatcherContext,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n} from \"../utils\";\nimport { getResults } from \"./get-results\";\n\nconst options: CodeframeOptions = {\n\tshowLink: false,\n\tshowSummary: false,\n\tshowSelector: true,\n};\n\nfunction createMatcher(): MaybeAsyncCallback<Report | string, [Array<string | object>]> {\n\tfunction toMatchCodeframe(\n\t\tthis: MatcherContext,\n\t\tactual: Report | string,\n\t\t...rest: Array<string | object>\n\t): MatcherResult {\n\t\t/* istanbul ignore next: cant figure out when this would be unset */\n\t\tconst filename = this.testPath ?? \"inline\";\n\t\tconst results = getResults(filename, actual);\n\t\tconst enabled = kleur.enabled;\n\t\tkleur.enabled = false;\n\t\tconst snapshot = codeframe(results, options).replace(/\\s+$/gm, \"\");\n\t\tkleur.enabled = enabled;\n\n\t\t/* eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call --\n\t\t * the implementation works but the declarations doesn't allow it */\n\t\treturn (toMatchSnapshot as any).call(this, snapshot, ...rest);\n\t}\n\treturn diverge(toMatchCodeframe);\n}\n\nexport { createMatcher as toMatchCodeframe };\n","import kleur from \"kleur\";\nimport { toMatchInlineSnapshot } from \"jest-snapshot\";\nimport { codeframe, type CodeframeOptions } from \"../../formatters/codeframe\";\nimport { type Report } from \"../../reporter\";\nimport { type MatcherContext, type MatcherResult, isThenable } from \"../utils\";\nimport { getResults } from \"./get-results\";\n\nconst options: CodeframeOptions = {\n\tshowLink: false,\n\tshowSummary: false,\n\tshowSelector: true,\n};\n\nfunction toMatchInlineCodeframeImpl(\n\tcontext: MatcherContext,\n\tactual: Report | string,\n\t...rest: Array<string | object>\n): MatcherResult {\n\t/* istanbul ignore next: cant figure out when this would be unset */\n\tconst filename = context.testPath ?? \"inline\";\n\tconst results = getResults(filename, actual);\n\tconst enabled = kleur.enabled;\n\tkleur.enabled = false;\n\tconst snapshot = codeframe(results, options).replace(/\\s+$/gm, \"\");\n\tkleur.enabled = enabled;\n\n\t/* eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call --\n\t * the implementation works but the declarations doesn't allow it */\n\treturn (toMatchInlineSnapshot as any).call(context, snapshot, ...rest);\n}\n\ntype ToMatchInlineCodeframeMatcher = (\n\tthis: MatcherContext,\n\tactual: Report | Promise<Report> | string,\n\t...rest: Array<string | object>\n) => MatcherResult | Promise<MatcherResult>;\n\nfunction createMatcher(): ToMatchInlineCodeframeMatcher {\n\tfunction toMatchInlineCodeframe(\n\t\tthis: MatcherContext,\n\t\tactual: Report | Promise<Report> | string,\n\t\t...rest: Array<string | object>\n\t): MatcherResult | Promise<MatcherResult> {\n\t\tconst context = {\n\t\t\t...this,\n\n\t\t\t/* Capture the original stack frames as they are needed by \"jest-snapshot\"\n\t\t\t * to determine where to write the inline snapshots. When resolving the\n\t\t\t * promise the original stack frames are lost and the snapshot will be\n\t\t\t * written in this files instaed. */\n\t\t\terror: new Error(),\n\t\t};\n\n\t\tif (isThenable(actual)) {\n\t\t\treturn actual.then((resolved) => toMatchInlineCodeframeImpl(context, resolved, ...rest));\n\t\t} else {\n\t\t\treturn toMatchInlineCodeframeImpl(context, actual, ...rest);\n\t\t}\n\t}\n\n\treturn toMatchInlineCodeframe;\n}\n\nexport { createMatcher as toMatchInlineCodeframe };\n"],"names":["options","createMatcher"],"mappings":";;;;;;AAYA,MAAMA,SAA4B,GAAA;AAAA,EACjC,QAAU,EAAA,KAAA;AAAA,EACV,WAAa,EAAA,KAAA;AAAA,EACb,YAAc,EAAA
|
|
1
|
+
{"version":3,"file":"matchers-jestonly.js","sources":["../../src/jest/matchers/to-match-codeframe.ts","../../src/jest/matchers/to-match-inline-codeframe.ts"],"sourcesContent":["import kleur from \"kleur\";\nimport { toMatchSnapshot } from \"jest-snapshot\";\nimport { codeframe, type CodeframeOptions } from \"../../formatters/codeframe\";\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype MatcherContext,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n} from \"../utils\";\nimport { getResults } from \"./get-results\";\n\nconst options: CodeframeOptions = {\n\tshowLink: false,\n\tshowSummary: false,\n\tshowSelector: true,\n};\n\nfunction createMatcher(): MaybeAsyncCallback<Report | string, [Array<string | object>]> {\n\tfunction toMatchCodeframe(\n\t\tthis: MatcherContext,\n\t\tactual: Report | string,\n\t\t...rest: Array<string | object>\n\t): MatcherResult {\n\t\t/* istanbul ignore next: cant figure out when this would be unset */\n\t\tconst filename = this.testPath ?? \"inline\";\n\t\tconst results = getResults(filename, actual);\n\t\tconst enabled = kleur.enabled;\n\t\tkleur.enabled = false;\n\t\tconst snapshot = codeframe(results, options).replace(/\\s+$/gm, \"\");\n\t\tkleur.enabled = enabled;\n\n\t\t/* eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call --\n\t\t * the implementation works but the declarations doesn't allow it */\n\t\treturn (toMatchSnapshot as any).call(this, snapshot, ...rest);\n\t}\n\treturn diverge(toMatchCodeframe);\n}\n\nexport { createMatcher as toMatchCodeframe };\n","import kleur from \"kleur\";\nimport { toMatchInlineSnapshot } from \"jest-snapshot\";\nimport { codeframe, type CodeframeOptions } from \"../../formatters/codeframe\";\nimport { type Report } from \"../../reporter\";\nimport { type MatcherContext, type MatcherResult, isThenable } from \"../utils\";\nimport { getResults } from \"./get-results\";\n\nconst options: CodeframeOptions = {\n\tshowLink: false,\n\tshowSummary: false,\n\tshowSelector: true,\n};\n\nfunction toMatchInlineCodeframeImpl(\n\tcontext: MatcherContext,\n\tactual: Report | string,\n\t...rest: Array<string | object>\n): MatcherResult {\n\t/* istanbul ignore next: cant figure out when this would be unset */\n\tconst filename = context.testPath ?? \"inline\";\n\tconst results = getResults(filename, actual);\n\tconst enabled = kleur.enabled;\n\tkleur.enabled = false;\n\tconst snapshot = codeframe(results, options).replace(/\\s+$/gm, \"\");\n\tkleur.enabled = enabled;\n\n\t/* eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call --\n\t * the implementation works but the declarations doesn't allow it */\n\treturn (toMatchInlineSnapshot as any).call(context, snapshot, ...rest);\n}\n\ntype ToMatchInlineCodeframeMatcher = (\n\tthis: MatcherContext,\n\tactual: Report | Promise<Report> | string,\n\t...rest: Array<string | object>\n) => MatcherResult | Promise<MatcherResult>;\n\nfunction createMatcher(): ToMatchInlineCodeframeMatcher {\n\tfunction toMatchInlineCodeframe(\n\t\tthis: MatcherContext,\n\t\tactual: Report | Promise<Report> | string,\n\t\t...rest: Array<string | object>\n\t): MatcherResult | Promise<MatcherResult> {\n\t\tconst context = {\n\t\t\t...this,\n\n\t\t\t/* Capture the original stack frames as they are needed by \"jest-snapshot\"\n\t\t\t * to determine where to write the inline snapshots. When resolving the\n\t\t\t * promise the original stack frames are lost and the snapshot will be\n\t\t\t * written in this files instaed. */\n\t\t\terror: new Error(),\n\t\t};\n\n\t\tif (isThenable(actual)) {\n\t\t\treturn actual.then((resolved) => toMatchInlineCodeframeImpl(context, resolved, ...rest));\n\t\t} else {\n\t\t\treturn toMatchInlineCodeframeImpl(context, actual, ...rest);\n\t\t}\n\t}\n\n\treturn toMatchInlineCodeframe;\n}\n\nexport { createMatcher as toMatchInlineCodeframe };\n"],"names":["options","createMatcher"],"mappings":";;;;;;AAYA,MAAMA,SAA4B,GAAA;AAAA,EACjC,QAAU,EAAA,KAAA;AAAA,EACV,WAAa,EAAA,KAAA;AAAA,EACb,YAAc,EAAA;AACf,CAAA;AAEA,SAASC,eAA+E,GAAA;AACvF,EAAS,SAAA,gBAAA,CAER,WACG,IACa,EAAA;AAEhB,IAAM,MAAA,QAAA,GAAW,KAAK,QAAY,IAAA,QAAA;AAClC,IAAM,MAAA,OAAA,GAAU,UAAW,CAAA,QAAA,EAAU,MAAM,CAAA;AAC3C,IAAA,MAAM,UAAU,KAAM,CAAA,OAAA;AACtB,IAAA,KAAA,CAAM,OAAU,GAAA,KAAA;AAChB,IAAA,MAAM,WAAW,SAAU,CAAA,OAAA,EAASD,SAAO,CAAE,CAAA,OAAA,CAAQ,UAAU,EAAE,CAAA;AACjE,IAAA,KAAA,CAAM,OAAU,GAAA,OAAA;AAIhB,IAAA,OAAQ,eAAwB,CAAA,IAAA,CAAK,IAAM,EAAA,QAAA,EAAU,GAAG,IAAI,CAAA;AAAA;AAE7D,EAAA,OAAO,QAAQ,gBAAgB,CAAA;AAChC;;AC9BA,MAAM,OAA4B,GAAA;AAAA,EACjC,QAAU,EAAA,KAAA;AAAA,EACV,WAAa,EAAA,KAAA;AAAA,EACb,YAAc,EAAA;AACf,CAAA;AAEA,SAAS,0BAAA,CACR,OACA,EAAA,MAAA,EAAA,GACG,IACa,EAAA;AAEhB,EAAM,MAAA,QAAA,GAAW,QAAQ,QAAY,IAAA,QAAA;AACrC,EAAM,MAAA,OAAA,GAAU,UAAW,CAAA,QAAA,EAAU,MAAM,CAAA;AAC3C,EAAA,MAAM,UAAU,KAAM,CAAA,OAAA;AACtB,EAAA,KAAA,CAAM,OAAU,GAAA,KAAA;AAChB,EAAA,MAAM,WAAW,SAAU,CAAA,OAAA,EAAS,OAAO,CAAE,CAAA,OAAA,CAAQ,UAAU,EAAE,CAAA;AACjE,EAAA,KAAA,CAAM,OAAU,GAAA,OAAA;AAIhB,EAAA,OAAQ,qBAA8B,CAAA,IAAA,CAAK,OAAS,EAAA,QAAA,EAAU,GAAG,IAAI,CAAA;AACtE;AAQA,SAAS,aAA+C,GAAA;AACvD,EAAS,SAAA,sBAAA,CAER,WACG,IACsC,EAAA;AACzC,IAAA,MAAM,OAAU,GAAA;AAAA,MACf,GAAG,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMH,KAAA,EAAO,IAAI,KAAM;AAAA,KAClB;AAEA,IAAI,IAAA,UAAA,CAAW,MAAM,CAAG,EAAA;AACvB,MAAO,OAAA,MAAA,CAAO,KAAK,CAAC,QAAA,KAAa,2BAA2B,OAAS,EAAA,QAAA,EAAU,GAAG,IAAI,CAAC,CAAA;AAAA,KACjF,MAAA;AACN,MAAA,OAAO,0BAA2B,CAAA,OAAA,EAAS,MAAQ,EAAA,GAAG,IAAI,CAAA;AAAA;AAC3D;AAGD,EAAO,OAAA,sBAAA;AACR;;;;"}
|
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\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,iCAAA;AAAA,SAAA;AAAA,OAC3C,CAAA;AAAA,KACM,MAAA;AACN,MAAA,MAAM,aAAa,MAAO,CAAA,OAAA,CAAQ,CAAC,CAAA,CAAE,SAAS,CAAC,CAAA,CAAA;AAC/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/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\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,C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AAA;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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta-helper.js","sources":["../../src/meta/define-metadata.ts","../../src/meta/helper.ts"],"sourcesContent":["import { type MetaDataTable } from \"./element\";\n\n/**\n * Helper function to assist IDE with completion and type-checking.\n *\n * @public\n */\nexport function defineMetadata(metatable: MetaDataTable): MetaDataTable {\n\treturn metatable;\n}\n","import { naturalJoin } from \"../utils/natural-join\";\nimport { type MetaAttributeAllowedCallback } from \"./element\";\nimport { type HtmlElementLike } from \"./html-element-like\";\n\n/**\n * Helpers when writing element metadata.\n *\n * @public\n */\nexport interface MetadataHelper {\n\t/** Returns an error if another attribute is omitted, i.e. it requires another attribute to be present to pass. */\n\tallowedIfAttributeIsPresent(this: void, ...attr: string[]): MetaAttributeAllowedCallback;\n\n\t/** Returns an error if another attribute is present, i.e. it requires another attribute to be omitted to pass. */\n\tallowedIfAttributeIsAbsent(this: void, ...attr: string[]): MetaAttributeAllowedCallback;\n\n\t/** Returns an error if another attribute does not have one of the listed values */\n\tallowedIfAttributeHasValue(\n\t\tthis: void,\n\t\tattr: string,\n\t\tvalue: string[],\n\t\toptions?: { defaultValue?: string | null },\n\t): MetaAttributeAllowedCallback;\n\n\t/**\n\t * Returns an error if the node doesn't have any of the given elements as parent\n\t *\n\t * @since 8.2.0\n\t **/\n\tallowedIfParentIsPresent(this: void, ...tags: string[]): MetaAttributeAllowedCallback;\n}\n\n/**\n * @internal\n */\nexport function allowedIfAttributeIsPresent(...attr: string[]) {\n\treturn (node: HtmlElementLike) => {\n\t\tif (attr.some((it) => node.hasAttribute(it))) {\n\t\t\treturn null;\n\t\t}\n\t\tconst expected = naturalJoin(attr.map((it) => `\"${it}\"`));\n\t\treturn `requires ${expected} attribute to be present`;\n\t};\n}\n\n/**\n * @internal\n */\nexport function allowedIfAttributeIsAbsent(...attr: string[]): MetaAttributeAllowedCallback {\n\treturn (node: HtmlElementLike) => {\n\t\tconst present = attr.filter((it) => node.hasAttribute(it));\n\t\tif (present.length === 0) {\n\t\t\treturn null;\n\t\t}\n\t\tconst expected = naturalJoin(present.map((it) => `\"${it}\"`));\n\t\treturn `cannot be used at the same time as ${expected}`;\n\t};\n}\n\n/**\n * @internal\n */\nexport function allowedIfAttributeHasValue(\n\tkey: string,\n\texpectedValue: string[],\n\t{ defaultValue }: { defaultValue?: string | null } = {},\n): MetaAttributeAllowedCallback {\n\treturn (node: HtmlElementLike) => {\n\t\tconst attr = node.getAttribute(key);\n\t\tif (attr && typeof attr !== \"string\") {\n\t\t\treturn null;\n\t\t}\n\t\tconst actualValue = attr ? attr : defaultValue;\n\t\tif (actualValue && expectedValue.includes(actualValue.toLocaleLowerCase())) {\n\t\t\treturn null;\n\t\t}\n\t\tconst expected = naturalJoin(expectedValue.map((it) => `\"${it}\"`));\n\t\treturn `\"${key}\" attribute must be ${expected}`;\n\t};\n}\n\n/**\n * @internal\n */\nexport function allowedIfParentIsPresent(\n\tthis: void,\n\t...tags: string[]\n): MetaAttributeAllowedCallback {\n\treturn (node: HtmlElementLike) => {\n\t\tconst match = tags.some((it) => node.closest(it));\n\t\tif (match) {\n\t\t\treturn null;\n\t\t}\n\t\tconst expected = naturalJoin(tags.map((it) => `<${it}>`));\n\t\treturn `requires ${expected} as parent`;\n\t};\n}\n\n/**\n * @public\n */\nexport const metadataHelper: MetadataHelper = {\n\tallowedIfAttributeIsPresent,\n\tallowedIfAttributeIsAbsent,\n\tallowedIfAttributeHasValue,\n\tallowedIfParentIsPresent,\n};\n"],"names":[],"mappings":";;AAOO,SAAS,eAAe,SAAyC,EAAA;AACvE,EAAO,OAAA,SAAA
|
|
1
|
+
{"version":3,"file":"meta-helper.js","sources":["../../src/meta/define-metadata.ts","../../src/meta/helper.ts"],"sourcesContent":["import { type MetaDataTable } from \"./element\";\n\n/**\n * Helper function to assist IDE with completion and type-checking.\n *\n * @public\n */\nexport function defineMetadata(metatable: MetaDataTable): MetaDataTable {\n\treturn metatable;\n}\n","import { naturalJoin } from \"../utils/natural-join\";\nimport { type MetaAttributeAllowedCallback } from \"./element\";\nimport { type HtmlElementLike } from \"./html-element-like\";\n\n/**\n * Helpers when writing element metadata.\n *\n * @public\n */\nexport interface MetadataHelper {\n\t/** Returns an error if another attribute is omitted, i.e. it requires another attribute to be present to pass. */\n\tallowedIfAttributeIsPresent(this: void, ...attr: string[]): MetaAttributeAllowedCallback;\n\n\t/** Returns an error if another attribute is present, i.e. it requires another attribute to be omitted to pass. */\n\tallowedIfAttributeIsAbsent(this: void, ...attr: string[]): MetaAttributeAllowedCallback;\n\n\t/** Returns an error if another attribute does not have one of the listed values */\n\tallowedIfAttributeHasValue(\n\t\tthis: void,\n\t\tattr: string,\n\t\tvalue: string[],\n\t\toptions?: { defaultValue?: string | null },\n\t): MetaAttributeAllowedCallback;\n\n\t/**\n\t * Returns an error if the node doesn't have any of the given elements as parent\n\t *\n\t * @since 8.2.0\n\t **/\n\tallowedIfParentIsPresent(this: void, ...tags: string[]): MetaAttributeAllowedCallback;\n}\n\n/**\n * @internal\n */\nexport function allowedIfAttributeIsPresent(...attr: string[]) {\n\treturn (node: HtmlElementLike) => {\n\t\tif (attr.some((it) => node.hasAttribute(it))) {\n\t\t\treturn null;\n\t\t}\n\t\tconst expected = naturalJoin(attr.map((it) => `\"${it}\"`));\n\t\treturn `requires ${expected} attribute to be present`;\n\t};\n}\n\n/**\n * @internal\n */\nexport function allowedIfAttributeIsAbsent(...attr: string[]): MetaAttributeAllowedCallback {\n\treturn (node: HtmlElementLike) => {\n\t\tconst present = attr.filter((it) => node.hasAttribute(it));\n\t\tif (present.length === 0) {\n\t\t\treturn null;\n\t\t}\n\t\tconst expected = naturalJoin(present.map((it) => `\"${it}\"`));\n\t\treturn `cannot be used at the same time as ${expected}`;\n\t};\n}\n\n/**\n * @internal\n */\nexport function allowedIfAttributeHasValue(\n\tkey: string,\n\texpectedValue: string[],\n\t{ defaultValue }: { defaultValue?: string | null } = {},\n): MetaAttributeAllowedCallback {\n\treturn (node: HtmlElementLike) => {\n\t\tconst attr = node.getAttribute(key);\n\t\tif (attr && typeof attr !== \"string\") {\n\t\t\treturn null;\n\t\t}\n\t\tconst actualValue = attr ? attr : defaultValue;\n\t\tif (actualValue && expectedValue.includes(actualValue.toLocaleLowerCase())) {\n\t\t\treturn null;\n\t\t}\n\t\tconst expected = naturalJoin(expectedValue.map((it) => `\"${it}\"`));\n\t\treturn `\"${key}\" attribute must be ${expected}`;\n\t};\n}\n\n/**\n * @internal\n */\nexport function allowedIfParentIsPresent(\n\tthis: void,\n\t...tags: string[]\n): MetaAttributeAllowedCallback {\n\treturn (node: HtmlElementLike) => {\n\t\tconst match = tags.some((it) => node.closest(it));\n\t\tif (match) {\n\t\t\treturn null;\n\t\t}\n\t\tconst expected = naturalJoin(tags.map((it) => `<${it}>`));\n\t\treturn `requires ${expected} as parent`;\n\t};\n}\n\n/**\n * @public\n */\nexport const metadataHelper: MetadataHelper = {\n\tallowedIfAttributeIsPresent,\n\tallowedIfAttributeIsAbsent,\n\tallowedIfAttributeHasValue,\n\tallowedIfParentIsPresent,\n};\n"],"names":[],"mappings":";;AAOO,SAAS,eAAe,SAAyC,EAAA;AACvE,EAAO,OAAA,SAAA;AACR;;AC0B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iBAAA,EAAmB,CAAG,EAAA;AAC3E,MAAO,OAAA,IAAA;AAAA;AAER,IAAM,MAAA,QAAA,GAAW,YAAY,aAAc,CAAA,GAAA,CAAI,CAAC,EAAO,KAAA,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,CAAG,CAAC,CAAA;AACjE,IAAO,OAAA,CAAA,CAAA,EAAI,GAAG,CAAA,oBAAA,EAAuB,QAAQ,CAAA,CAAA;AAAA,GAC9C;AACD;AAKO,SAAS,4BAEZ,IAC4B,EAAA;AAC/B,EAAA,OAAO,CAAC,IAA0B,KAAA;AACjC,IAAM,MAAA,KAAA,GAAQ,KAAK,IAAK,CAAA,CAAC,OAAO,IAAK,CAAA,OAAA,CAAQ,EAAE,CAAC,CAAA;AAChD,IAAA,IAAI,KAAO,EAAA;AACV,MAAO,OAAA,IAAA;AAAA;AAER,IAAM,MAAA,QAAA,GAAW,YAAY,IAAK,CAAA,GAAA,CAAI,CAAC,EAAO,KAAA,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,CAAG,CAAC,CAAA;AACxD,IAAA,OAAO,YAAY,QAAQ,CAAA,UAAA,CAAA;AAAA,GAC5B;AACD;AAKO,MAAM,cAAiC,GAAA;AAAA,EAC7C,2BAAA;AAAA,EACA,0BAAA;AAAA,EACA,0BAAA;AAAA,EACA;AACD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.js","sources":["../../src/transform/test-utils.ts"],"sourcesContent":["import fs from \"fs\";\nimport { type Source, type TransformContext } from \"html-validate\";\n\n/**\n * @public\n */\nexport type Transformer = (this: TransformContext, source: Source) => Iterable<Source>;\n\n/**\n * Helper function to call a transformer function in test-cases.\n *\n * @public\n * @param fn - Transformer function to call.\n * @param filename - Filename to read data from. Must be readable.\n * @param chain - If set this function is called when chaining transformers. Default is pass-thru.\n */\nexport function transformFile(\n\tfn: Transformer,\n\tfilename: string,\n\tchain?: (source: Source, filename: string) => Iterable<Source>,\n): Source[] {\n\tconst data = fs.readFileSync(filename, \"utf-8\");\n\tconst source: Source = {\n\t\tfilename,\n\t\tline: 1,\n\t\tcolumn: 1,\n\t\toffset: 0,\n\t\tdata,\n\t};\n\treturn transformSource(fn, source, chain);\n}\n\n/**\n * Helper function to call a transformer function in test-cases.\n *\n * @public\n * @param fn - Transformer function to call.\n * @param data - String to transform.\n * @param chain - If set this function is called when chaining transformers. Default is pass-thru.\n */\nexport function transformString(\n\tfn: Transformer,\n\tdata: string,\n\tchain?: (source: Source, filename: string) => Iterable<Source>,\n): Source[] {\n\tconst source: Source = {\n\t\tfilename: \"inline\",\n\t\tline: 1,\n\t\tcolumn: 1,\n\t\toffset: 0,\n\t\tdata,\n\t};\n\treturn transformSource(fn, source, chain);\n}\n\n/**\n * Helper function to call a transformer function in test-cases.\n *\n * @public\n * @param fn - Transformer function to call.\n * @param data - Source to transform.\n * @param chain - If set this function is called when chaining transformers. Default is pass-thru.\n */\nexport function transformSource(\n\tfn: Transformer,\n\tsource: Source,\n\tchain?: (source: Source, filename: string) => Iterable<Source>,\n): Source[] {\n\tconst defaultChain = (source: Source): Iterable<Source> => [source];\n\tconst context: TransformContext = {\n\t\thasChain: /* istanbul ignore next */ () => true,\n\t\tchain: chain ?? defaultChain,\n\t};\n\treturn Array.from(fn.call(context, source));\n}\n"],"names":["source"],"mappings":";;AAgBgB,SAAA,aAAA,CACf,EACA,EAAA,QAAA,EACA,KACW,EAAA;AACX,EAAA,MAAM,IAAO,GAAA,EAAA,CAAG,YAAa,CAAA,QAAA,EAAU,OAAO,CAAA
|
|
1
|
+
{"version":3,"file":"test-utils.js","sources":["../../src/transform/test-utils.ts"],"sourcesContent":["import fs from \"fs\";\nimport { type Source, type TransformContext } from \"html-validate\";\n\n/**\n * @public\n */\nexport type Transformer = (this: TransformContext, source: Source) => Iterable<Source>;\n\n/**\n * Helper function to call a transformer function in test-cases.\n *\n * @public\n * @param fn - Transformer function to call.\n * @param filename - Filename to read data from. Must be readable.\n * @param chain - If set this function is called when chaining transformers. Default is pass-thru.\n */\nexport function transformFile(\n\tfn: Transformer,\n\tfilename: string,\n\tchain?: (source: Source, filename: string) => Iterable<Source>,\n): Source[] {\n\tconst data = fs.readFileSync(filename, \"utf-8\");\n\tconst source: Source = {\n\t\tfilename,\n\t\tline: 1,\n\t\tcolumn: 1,\n\t\toffset: 0,\n\t\tdata,\n\t};\n\treturn transformSource(fn, source, chain);\n}\n\n/**\n * Helper function to call a transformer function in test-cases.\n *\n * @public\n * @param fn - Transformer function to call.\n * @param data - String to transform.\n * @param chain - If set this function is called when chaining transformers. Default is pass-thru.\n */\nexport function transformString(\n\tfn: Transformer,\n\tdata: string,\n\tchain?: (source: Source, filename: string) => Iterable<Source>,\n): Source[] {\n\tconst source: Source = {\n\t\tfilename: \"inline\",\n\t\tline: 1,\n\t\tcolumn: 1,\n\t\toffset: 0,\n\t\tdata,\n\t};\n\treturn transformSource(fn, source, chain);\n}\n\n/**\n * Helper function to call a transformer function in test-cases.\n *\n * @public\n * @param fn - Transformer function to call.\n * @param data - Source to transform.\n * @param chain - If set this function is called when chaining transformers. Default is pass-thru.\n */\nexport function transformSource(\n\tfn: Transformer,\n\tsource: Source,\n\tchain?: (source: Source, filename: string) => Iterable<Source>,\n): Source[] {\n\tconst defaultChain = (source: Source): Iterable<Source> => [source];\n\tconst context: TransformContext = {\n\t\thasChain: /* istanbul ignore next */ () => true,\n\t\tchain: chain ?? defaultChain,\n\t};\n\treturn Array.from(fn.call(context, source));\n}\n"],"names":["source"],"mappings":";;AAgBgB,SAAA,aAAA,CACf,EACA,EAAA,QAAA,EACA,KACW,EAAA;AACX,EAAA,MAAM,IAAO,GAAA,EAAA,CAAG,YAAa,CAAA,QAAA,EAAU,OAAO,CAAA;AAC9C,EAAA,MAAM,MAAiB,GAAA;AAAA,IACtB,QAAA;AAAA,IACA,IAAM,EAAA,CAAA;AAAA,IACN,MAAQ,EAAA,CAAA;AAAA,IACR,MAAQ,EAAA,CAAA;AAAA,IACR;AAAA,GACD;AACA,EAAO,OAAA,eAAA,CAAgB,EAAI,EAAA,MAAA,EAAQ,KAAK,CAAA;AACzC;AAUgB,SAAA,eAAA,CACf,EACA,EAAA,IAAA,EACA,KACW,EAAA;AACX,EAAA,MAAM,MAAiB,GAAA;AAAA,IACtB,QAAU,EAAA,QAAA;AAAA,IACV,IAAM,EAAA,CAAA;AAAA,IACN,MAAQ,EAAA,CAAA;AAAA,IACR,MAAQ,EAAA,CAAA;AAAA,IACR;AAAA,GACD;AACA,EAAO,OAAA,eAAA,CAAgB,EAAI,EAAA,MAAA,EAAQ,KAAK,CAAA;AACzC;AAUgB,SAAA,eAAA,CACf,EACA,EAAA,MAAA,EACA,KACW,EAAA;AACX,EAAA,MAAM,YAAe,GAAA,CAACA,OAAqC,KAAA,CAACA,OAAM,CAAA;AAClE,EAAA,MAAM,OAA4B,GAAA;AAAA,IACjC,QAAA;AAAA;AAAA,MAAqC,MAAM;AAAA,KAAA;AAAA,IAC3C,OAAO,KAAS,IAAA;AAAA,GACjB;AACA,EAAA,OAAO,MAAM,IAAK,CAAA,EAAA,CAAG,IAAK,CAAA,OAAA,EAAS,MAAM,CAAC,CAAA;AAC3C;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"natural-join.js","sources":["../../../src/utils/natural-join.ts"],"sourcesContent":["/**\n * Joins a list of words into natural language.\n *\n * - `[\"foo\"]` becomes `\"foo\"`\n * - `[\"foo\", \"bar\"]` becomes `\"foo or bar\"`\n * - `[\"foo\", \"bar\", \"baz\"]` becomes `\"foo, bar or baz\"`\n * - and so on...\n *\n * @internal\n * @param values - List of words to join\n * @param conjunction - Conjunction for the last element.\n * @returns String with the words naturally joined with a conjunction.\n */\nexport function naturalJoin(values: string[], conjunction: string = \"or\"): string {\n\tswitch (values.length) {\n\t\tcase 0:\n\t\t\treturn \"\";\n\t\tcase 1:\n\t\t\treturn values[0];\n\t\tcase 2:\n\t\t\treturn `${values[0]} ${conjunction} ${values[1]}`;\n\t\tdefault:\n\t\t\treturn `${values.slice(0, -1).join(\", \")} ${conjunction} ${values.slice(-1)[0]}`;\n\t}\n}\n"],"names":[],"mappings":"AAagB,SAAA,WAAA,CAAY,MAAkB,EAAA,WAAA,GAAsB,IAAc,EAAA;AACjF,EAAA,QAAQ,OAAO,MAAQ;AAAA,IACtB,KAAK,CAAA;AACJ,MAAO,OAAA,EAAA
|
|
1
|
+
{"version":3,"file":"natural-join.js","sources":["../../../src/utils/natural-join.ts"],"sourcesContent":["/**\n * Joins a list of words into natural language.\n *\n * - `[\"foo\"]` becomes `\"foo\"`\n * - `[\"foo\", \"bar\"]` becomes `\"foo or bar\"`\n * - `[\"foo\", \"bar\", \"baz\"]` becomes `\"foo, bar or baz\"`\n * - and so on...\n *\n * @internal\n * @param values - List of words to join\n * @param conjunction - Conjunction for the last element.\n * @returns String with the words naturally joined with a conjunction.\n */\nexport function naturalJoin(values: string[], conjunction: string = \"or\"): string {\n\tswitch (values.length) {\n\t\tcase 0:\n\t\t\treturn \"\";\n\t\tcase 1:\n\t\t\treturn values[0];\n\t\tcase 2:\n\t\t\treturn `${values[0]} ${conjunction} ${values[1]}`;\n\t\tdefault:\n\t\t\treturn `${values.slice(0, -1).join(\", \")} ${conjunction} ${values.slice(-1)[0]}`;\n\t}\n}\n"],"names":[],"mappings":"AAagB,SAAA,WAAA,CAAY,MAAkB,EAAA,WAAA,GAAsB,IAAc,EAAA;AACjF,EAAA,QAAQ,OAAO,MAAQ;AAAA,IACtB,KAAK,CAAA;AACJ,MAAO,OAAA,EAAA;AAAA,IACR,KAAK,CAAA;AACJ,MAAA,OAAO,OAAO,CAAC,CAAA;AAAA,IAChB,KAAK,CAAA;AACJ,MAAO,OAAA,CAAA,EAAG,OAAO,CAAC,CAAC,IAAI,WAAW,CAAA,CAAA,EAAI,MAAO,CAAA,CAAC,CAAC,CAAA,CAAA;AAAA,IAChD;AACC,MAAA,OAAO,GAAG,MAAO,CAAA,KAAA,CAAM,CAAG,EAAA,CAAA,CAAE,EAAE,IAAK,CAAA,IAAI,CAAC,CAAA,CAAA,EAAI,WAAW,CAAI,CAAA,EAAA,MAAA,CAAO,MAAM,CAAE,CAAA,CAAA,CAAE,CAAC,CAAC,CAAA,CAAA;AAAA;AAEjF;;;;"}
|
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":";;;;;;;;;;;;;;;;;;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
|
|
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
|
@@ -559,6 +559,7 @@ export declare class DOMNode {
|
|
|
559
559
|
*/
|
|
560
560
|
get textContent(): string;
|
|
561
561
|
append(node: DOMNode): void;
|
|
562
|
+
/* Excluded from this release type: insertBefore */
|
|
562
563
|
isRootElement(): boolean;
|
|
563
564
|
/**
|
|
564
565
|
* Tests if two nodes are the same (references the same object).
|
|
@@ -576,6 +577,7 @@ export declare class DOMNode {
|
|
|
576
577
|
* node has no children.
|
|
577
578
|
*/
|
|
578
579
|
get lastChild(): DOMNode;
|
|
580
|
+
/* Excluded from this release type: removeChild */
|
|
579
581
|
/* Excluded from this release type: blockRule */
|
|
580
582
|
/* Excluded from this release type: blockRules */
|
|
581
583
|
/* Excluded from this release type: disableRule */
|
|
@@ -591,6 +593,8 @@ export declare class DOMNode {
|
|
|
591
593
|
/* Excluded from this release type: ruleEnabled */
|
|
592
594
|
/* Excluded from this release type: ruleBlockers */
|
|
593
595
|
generateSelector(): string | null;
|
|
596
|
+
/* Excluded from this release type: _setParent */
|
|
597
|
+
private _removeChild;
|
|
594
598
|
}
|
|
595
599
|
|
|
596
600
|
/**
|
|
@@ -758,13 +762,13 @@ export declare interface FormAssociated {
|
|
|
758
762
|
*/
|
|
759
763
|
export declare class HtmlElement extends DOMNode {
|
|
760
764
|
readonly tagName: string;
|
|
761
|
-
readonly parent: HtmlElement | null;
|
|
762
765
|
readonly voidElement: boolean;
|
|
763
766
|
readonly depth: number;
|
|
764
767
|
closed: NodeClosed;
|
|
765
768
|
protected readonly attr: Record<string, Attribute[]>;
|
|
766
769
|
private metaElement;
|
|
767
770
|
private annotation;
|
|
771
|
+
private _parent;
|
|
768
772
|
/* Excluded from this release type: _adapter */
|
|
769
773
|
private constructor();
|
|
770
774
|
/**
|
|
@@ -861,6 +865,7 @@ export declare class HtmlElement extends DOMNode {
|
|
|
861
865
|
*/
|
|
862
866
|
matches(selector: string): boolean;
|
|
863
867
|
get meta(): MetaElement | null;
|
|
868
|
+
get parent(): HtmlElement | null;
|
|
864
869
|
/**
|
|
865
870
|
* Get current role for this element (explicit with `role` attribute or mapped
|
|
866
871
|
* with implicit role).
|
|
@@ -971,6 +976,7 @@ export declare class HtmlElement extends DOMNode {
|
|
|
971
976
|
/* Excluded from this release type: someChildren */
|
|
972
977
|
/* Excluded from this release type: everyChildren */
|
|
973
978
|
/* Excluded from this release type: find */
|
|
979
|
+
/* Excluded from this release type: _setParent */
|
|
974
980
|
}
|
|
975
981
|
|
|
976
982
|
/**
|
|
@@ -2324,7 +2330,7 @@ export declare type RuleOptions = string | number | Record<string, any>;
|
|
|
2324
2330
|
/**
|
|
2325
2331
|
* @public
|
|
2326
2332
|
*/
|
|
2327
|
-
export declare type RuleSeverity = "off" | "warn" | "error" |
|
|
2333
|
+
export declare type RuleSeverity = "off" | "warn" | "error" | 0 | 1 | 2;
|
|
2328
2334
|
|
|
2329
2335
|
export { SchemaObject }
|
|
2330
2336
|
|
package/dist/types/index.d.ts
CHANGED
|
@@ -215,6 +215,8 @@ export declare class CLI {
|
|
|
215
215
|
*/
|
|
216
216
|
export declare interface CLIOptions {
|
|
217
217
|
configFile?: string;
|
|
218
|
+
/** Comma-separated list of presets to use */
|
|
219
|
+
preset?: string;
|
|
218
220
|
rules?: string | string[];
|
|
219
221
|
}
|
|
220
222
|
|
|
@@ -655,6 +657,7 @@ export declare class DOMNode {
|
|
|
655
657
|
*/
|
|
656
658
|
get textContent(): string;
|
|
657
659
|
append(node: DOMNode): void;
|
|
660
|
+
/* Excluded from this release type: insertBefore */
|
|
658
661
|
isRootElement(): boolean;
|
|
659
662
|
/**
|
|
660
663
|
* Tests if two nodes are the same (references the same object).
|
|
@@ -672,6 +675,7 @@ export declare class DOMNode {
|
|
|
672
675
|
* node has no children.
|
|
673
676
|
*/
|
|
674
677
|
get lastChild(): DOMNode;
|
|
678
|
+
/* Excluded from this release type: removeChild */
|
|
675
679
|
/* Excluded from this release type: blockRule */
|
|
676
680
|
/* Excluded from this release type: blockRules */
|
|
677
681
|
/* Excluded from this release type: disableRule */
|
|
@@ -687,6 +691,8 @@ export declare class DOMNode {
|
|
|
687
691
|
/* Excluded from this release type: ruleEnabled */
|
|
688
692
|
/* Excluded from this release type: ruleBlockers */
|
|
689
693
|
generateSelector(): string | null;
|
|
694
|
+
/* Excluded from this release type: _setParent */
|
|
695
|
+
private _removeChild;
|
|
690
696
|
}
|
|
691
697
|
|
|
692
698
|
/**
|
|
@@ -976,13 +982,13 @@ export declare interface FSLike {
|
|
|
976
982
|
*/
|
|
977
983
|
export declare class HtmlElement extends DOMNode {
|
|
978
984
|
readonly tagName: string;
|
|
979
|
-
readonly parent: HtmlElement | null;
|
|
980
985
|
readonly voidElement: boolean;
|
|
981
986
|
readonly depth: number;
|
|
982
987
|
closed: NodeClosed;
|
|
983
988
|
protected readonly attr: Record<string, Attribute[]>;
|
|
984
989
|
private metaElement;
|
|
985
990
|
private annotation;
|
|
991
|
+
private _parent;
|
|
986
992
|
/* Excluded from this release type: _adapter */
|
|
987
993
|
private constructor();
|
|
988
994
|
/**
|
|
@@ -1079,6 +1085,7 @@ export declare class HtmlElement extends DOMNode {
|
|
|
1079
1085
|
*/
|
|
1080
1086
|
matches(selector: string): boolean;
|
|
1081
1087
|
get meta(): MetaElement | null;
|
|
1088
|
+
get parent(): HtmlElement | null;
|
|
1082
1089
|
/**
|
|
1083
1090
|
* Get current role for this element (explicit with `role` attribute or mapped
|
|
1084
1091
|
* with implicit role).
|
|
@@ -1189,6 +1196,7 @@ export declare class HtmlElement extends DOMNode {
|
|
|
1189
1196
|
/* Excluded from this release type: someChildren */
|
|
1190
1197
|
/* Excluded from this release type: everyChildren */
|
|
1191
1198
|
/* Excluded from this release type: find */
|
|
1199
|
+
/* Excluded from this release type: _setParent */
|
|
1192
1200
|
}
|
|
1193
1201
|
|
|
1194
1202
|
/**
|
|
@@ -2574,7 +2582,7 @@ export declare type RuleOptions = string | number | Record<string, any>;
|
|
|
2574
2582
|
/**
|
|
2575
2583
|
* @public
|
|
2576
2584
|
*/
|
|
2577
|
-
export declare type RuleSeverity = "off" | "warn" | "error" |
|
|
2585
|
+
export declare type RuleSeverity = "off" | "warn" | "error" | 0 | 1 | 2;
|
|
2578
2586
|
|
|
2579
2587
|
export { SchemaObject }
|
|
2580
2588
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-validate",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.25.1",
|
|
4
4
|
"description": "Offline html5 validator",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"html",
|
|
@@ -157,6 +157,7 @@
|
|
|
157
157
|
"rules",
|
|
158
158
|
"schema",
|
|
159
159
|
"transform",
|
|
160
|
+
"types",
|
|
160
161
|
"utils"
|
|
161
162
|
]
|
|
162
163
|
]
|
|
@@ -211,7 +212,7 @@
|
|
|
211
212
|
"semver": "^7.0.0"
|
|
212
213
|
},
|
|
213
214
|
"devDependencies": {
|
|
214
|
-
"@babel/code-frame": "7.
|
|
215
|
+
"@babel/code-frame": "7.26.2",
|
|
215
216
|
"@html-validate/commitlint-config": "3.2.5",
|
|
216
217
|
"@html-validate/eslint-config": "5.21.8",
|
|
217
218
|
"@html-validate/eslint-config-jest": "5.21.7",
|
|
@@ -220,17 +221,17 @@
|
|
|
220
221
|
"@html-validate/jest-config": "3.10.0",
|
|
221
222
|
"@html-validate/prettier-config": "2.5.6",
|
|
222
223
|
"@html-validate/release-scripts": "6.7.0",
|
|
223
|
-
"@microsoft/api-extractor": "7.47.
|
|
224
|
-
"@rollup/plugin-commonjs": "28.0.
|
|
224
|
+
"@microsoft/api-extractor": "7.47.11",
|
|
225
|
+
"@rollup/plugin-commonjs": "28.0.1",
|
|
225
226
|
"@rollup/plugin-json": "6.1.0",
|
|
226
227
|
"@rollup/plugin-node-resolve": "15.3.0",
|
|
227
228
|
"@rollup/plugin-replace": "6.0.1",
|
|
228
229
|
"@rollup/plugin-virtual": "3.0.2",
|
|
229
230
|
"@types/babar": "0.2.4",
|
|
230
231
|
"@types/babel__code-frame": "7.0.6",
|
|
231
|
-
"@types/jest": "29.5.
|
|
232
|
+
"@types/jest": "29.5.14",
|
|
232
233
|
"@types/minimist": "1.2.5",
|
|
233
|
-
"@types/node": "16.18.
|
|
234
|
+
"@types/node": "16.18.119",
|
|
234
235
|
"@types/prompts": "2.4.9",
|
|
235
236
|
"@types/semver": "7.5.8",
|
|
236
237
|
"@types/stream-buffers": "3.0.7",
|
|
@@ -243,9 +244,9 @@
|
|
|
243
244
|
"jest-snapshot": "29.7.0",
|
|
244
245
|
"jsdom": "25.0.1",
|
|
245
246
|
"memfs": "4.14.0",
|
|
246
|
-
"npm-pkg-lint": "3.
|
|
247
|
-
"npm-run-all2": "
|
|
248
|
-
"rollup": "4.
|
|
247
|
+
"npm-pkg-lint": "3.10.2",
|
|
248
|
+
"npm-run-all2": "7.0.1",
|
|
249
|
+
"rollup": "4.26.0",
|
|
249
250
|
"rollup-plugin-esbuild": "6.1.1",
|
|
250
251
|
"stream-buffers": "3.0.3",
|
|
251
252
|
"ts-jest": "29.2.5",
|