html-validate 10.11.3 → 10.12.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.
Files changed (46) hide show
  1. package/dist/cjs/cli.js +1 -1
  2. package/dist/cjs/cli.js.map +1 -1
  3. package/dist/cjs/core-browser.js +4 -4
  4. package/dist/cjs/core-browser.js.map +1 -1
  5. package/dist/cjs/core-nodejs.js +19 -19
  6. package/dist/cjs/core-nodejs.js.map +1 -1
  7. package/dist/cjs/core.js +177 -170
  8. package/dist/cjs/core.js.map +1 -1
  9. package/dist/cjs/html-validate.js.map +1 -1
  10. package/dist/cjs/jest-diff.js.map +1 -1
  11. package/dist/cjs/jest.js +7 -6
  12. package/dist/cjs/jest.js.map +1 -1
  13. package/dist/cjs/matcher-utils.js +36 -0
  14. package/dist/cjs/matcher-utils.js.map +1 -1
  15. package/dist/cjs/matchers-jestonly.js +17 -39
  16. package/dist/cjs/matchers-jestonly.js.map +1 -1
  17. package/dist/cjs/matchers.js +14 -8
  18. package/dist/cjs/matchers.js.map +1 -1
  19. package/dist/cjs/tsdoc-metadata.json +1 -1
  20. package/dist/cjs/vitest.js +3 -3
  21. package/dist/esm/cli.js +1 -1
  22. package/dist/esm/cli.js.map +1 -1
  23. package/dist/esm/core-browser.js +4 -4
  24. package/dist/esm/core-browser.js.map +1 -1
  25. package/dist/esm/core-nodejs.js +19 -19
  26. package/dist/esm/core-nodejs.js.map +1 -1
  27. package/dist/esm/core.js +175 -170
  28. package/dist/esm/core.js.map +1 -1
  29. package/dist/esm/html-validate.js +1 -1
  30. package/dist/esm/html-validate.js.map +1 -1
  31. package/dist/esm/jest-diff.js.map +1 -1
  32. package/dist/esm/jest.js +3 -2
  33. package/dist/esm/jest.js.map +1 -1
  34. package/dist/esm/matcher-utils.js +36 -1
  35. package/dist/esm/matcher-utils.js.map +1 -1
  36. package/dist/esm/matchers-jestonly.js +18 -36
  37. package/dist/esm/matchers-jestonly.js.map +1 -1
  38. package/dist/esm/matchers.js +15 -9
  39. package/dist/esm/matchers.js.map +1 -1
  40. package/dist/esm/vitest.js +3 -3
  41. package/dist/tsdoc-metadata.json +1 -1
  42. package/dist/types/browser.d.ts +2 -2
  43. package/dist/types/index.d.ts +2 -2
  44. package/dist/types/jest.d.ts +4 -4
  45. package/dist/types/vitest.d.ts +1 -1
  46. package/package.json +7 -3
@@ -2,7 +2,7 @@ import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import kleur from 'kleur';
4
4
  import minimist from 'minimist';
5
- import { a2 as name, v as version, y as SchemaValidationError, O as isUserError, a3 as bugs } from './core.js';
5
+ import { a4 as name, v as version, y as SchemaValidationError, O as isUserError, a5 as bugs } from './core.js';
6
6
  import { M as Mode, m as modeToFlag, C as CLI, h as haveImportMetaResolve, I as ImportResolveMissingError, d as dump, p as printConfig, i as init, l as lint, a as handleSchemaValidationError } from './cli.js';
7
7
  import 'ajv';
8
8
  import './elements.js';
@@ -1 +1 @@
1
- {"version":3,"file":"html-validate.js","sources":["../../src/cli/html-validate.ts"],"sourcesContent":["/* eslint-disable no-console, n/no-process-exit -- as expected from a cli app */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport kleur from \"kleur\";\nimport minimist from \"minimist\";\nimport { type UserErrorData, SchemaValidationError, isUserError } from \"..\";\nimport { bugs as pkgBugs, name, version } from \"../generated/package\";\nimport { dump } from \"./actions/dump\";\nimport { init } from \"./actions/init\";\nimport { lint } from \"./actions/lint\";\nimport { printConfig } from \"./actions/print-config\";\nimport { CLI } from \"./cli\";\nimport { ImportResolveMissingError, handleSchemaValidationError } from \"./errors\";\nimport { haveImportMetaResolve } from \"./have-import-meta-resolve\";\nimport { Mode, modeToFlag } from \"./mode\";\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: UserErrorData): 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 (argv.config !== undefined) {\n\tconst checkPath = path.resolve(argv.config);\n\tif (!fs.existsSync(checkPath)) {\n\t\tconsole.error(`The file \"${argv.config}\" was not found.`);\n\t\tconsole.error(`The location this file was checked for at was: \"${checkPath}\"`);\n\t\tprocess.exit(1);\n\t}\n}\n\n/* eslint-disable-next-line complexity -- for now */\nasync function run(): Promise<void> {\n\tconst cli = new CLI({\n\t\tconfigFile: argv.config,\n\t\tpreset: argv.preset,\n\t\trules: argv.rule,\n\t});\n\tconst mode = getMode(argv);\n\tconst formatter = await cli.getFormatter(argv.formatter);\n\tconst maxWarnings = Number.parseInt(argv[\"max-warnings\"] ?? \"-1\", 10);\n\tconst htmlvalidate = await cli.getValidator();\n\n\t/* sanity check: ensure maxWarnings has a valid value */\n\tif (Number.isNaN(maxWarnings)) {\n\t\tconsole.error(`Invalid value \"${String(argv[\"max-warnings\"])}\" given to --max-warnings`);\n\t\tprocess.exit(1);\n\t}\n\n\t/* parse extensions (used when expanding directories) */\n\tconst extensions = argv.ext.split(\",\").map((cur: string) => {\n\t\treturn cur.startsWith(\".\") ? cur.slice(1) : cur;\n\t});\n\n\tconst files = await cli.expandFiles(argv._, { extensions });\n\tif (files.length === 0 && mode !== Mode.INIT) {\n\t\tconsole.error(\"No files matching patterns\", argv._);\n\t\tprocess.exit(1);\n\t}\n\n\ttry {\n\t\t/* istanbul ignore next -- not tested with unittests */\n\t\tif (!haveImportMetaResolve()) {\n\t\t\tthrow new ImportResolveMissingError();\n\t\t}\n\n\t\tlet success: boolean;\n\t\tswitch (mode) {\n\t\t\tcase Mode.LINT: {\n\t\t\t\tsuccess = await lint(htmlvalidate, process.stdout, files, {\n\t\t\t\t\tformatter,\n\t\t\t\t\tmaxWarnings,\n\t\t\t\t\tstdinFilename: argv[\"stdin-filename\"] ?? false,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase Mode.INIT: {\n\t\t\t\tsuccess = await init(cli, process.stdout, { cwd: process.cwd() });\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase Mode.PRINT_CONFIG: {\n\t\t\t\tsuccess = await printConfig(htmlvalidate, process.stdout, files);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tsuccess = await dump(htmlvalidate, process.stdout, files, mode);\n\t\t\t}\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 (isUserError(err)) {\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","pkgBugs"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmCA,SAAS,QAAQA,KAAAA,EAAiC;AACjD,EAAA,IAAIA,KAAAA,CAAK,MAAM,C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AA;AACjB,EAAA,OAAA,CAAQ,KAAK,CAAC,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 -- as expected from a cli app */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport kleur from \"kleur\";\nimport minimist from \"minimist\";\nimport { type UserErrorData, SchemaValidationError, isUserError } from \"..\";\nimport { bugs as pkgBugs, name, version } from \"../generated/package-json\";\nimport { dump } from \"./actions/dump\";\nimport { init } from \"./actions/init\";\nimport { lint } from \"./actions/lint\";\nimport { printConfig } from \"./actions/print-config\";\nimport { CLI } from \"./cli\";\nimport { ImportResolveMissingError, handleSchemaValidationError } from \"./errors\";\nimport { haveImportMetaResolve } from \"./have-import-meta-resolve\";\nimport { Mode, modeToFlag } from \"./mode\";\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, unknown>): 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: UserErrorData): 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 (argv.config !== undefined) {\n\tconst checkPath = path.resolve(argv.config);\n\tif (!fs.existsSync(checkPath)) {\n\t\tconsole.error(`The file \"${argv.config}\" was not found.`);\n\t\tconsole.error(`The location this file was checked for at was: \"${checkPath}\"`);\n\t\tprocess.exit(1);\n\t}\n}\n\n/* eslint-disable-next-line complexity -- for now */\nasync function run(): Promise<void> {\n\tconst cli = new CLI({\n\t\tconfigFile: argv.config,\n\t\tpreset: argv.preset,\n\t\trules: argv.rule,\n\t});\n\tconst mode = getMode(argv);\n\tconst formatter = await cli.getFormatter(argv.formatter);\n\tconst maxWarnings = Number.parseInt(argv[\"max-warnings\"] ?? \"-1\", 10);\n\tconst htmlvalidate = await cli.getValidator();\n\n\t/* sanity check: ensure maxWarnings has a valid value */\n\tif (Number.isNaN(maxWarnings)) {\n\t\tconsole.error(`Invalid value \"${String(argv[\"max-warnings\"])}\" given to --max-warnings`);\n\t\tprocess.exit(1);\n\t}\n\n\t/* parse extensions (used when expanding directories) */\n\tconst extensions = argv.ext.split(\",\").map((cur: string) => {\n\t\treturn cur.startsWith(\".\") ? cur.slice(1) : cur;\n\t});\n\n\tconst files = await cli.expandFiles(argv._, { extensions });\n\tif (files.length === 0 && mode !== Mode.INIT) {\n\t\tconsole.error(\"No files matching patterns\", argv._);\n\t\tprocess.exit(1);\n\t}\n\n\ttry {\n\t\t/* istanbul ignore next -- not tested with unittests */\n\t\tif (!haveImportMetaResolve()) {\n\t\t\tthrow new ImportResolveMissingError();\n\t\t}\n\n\t\tlet success: boolean;\n\t\tswitch (mode) {\n\t\t\tcase Mode.LINT: {\n\t\t\t\tsuccess = await lint(htmlvalidate, process.stdout, files, {\n\t\t\t\t\tformatter,\n\t\t\t\t\tmaxWarnings,\n\t\t\t\t\tstdinFilename: argv[\"stdin-filename\"] ?? false,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase Mode.INIT: {\n\t\t\t\tsuccess = await init(cli, process.stdout, { cwd: process.cwd() });\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase Mode.PRINT_CONFIG: {\n\t\t\t\tsuccess = await printConfig(htmlvalidate, process.stdout, files);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tsuccess = await dump(htmlvalidate, process.stdout, files, mode);\n\t\t\t}\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 (isUserError(err)) {\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\n/* eslint-disable-next-line unicorn/prefer-top-level-await -- technical debt, as long as we bundle and ship commonjs we cannot use TLA here */\nrun().catch((err: unknown) => {\n\tconsole.error(err);\n\tprocess.exit(1);\n});\n"],"names":["argv","pkgBugs"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmCA,SAAS,QAAQA,KAAAA,EAAqC;AACrD,EAAA,IAAIA,KAAAA,CAAK,MAAM,CAAA,EAAG;AACjB,IAAA,OAAO,IAAA,CAAK,IAAA;AAAA,EACb;AAEA,EAAA,IAAIA,KAAAA,CAAK,aAAa,CAAA,EAAG;AACxB,IAAA,OAAO,IAAA,CAAK,WAAA;AAAA,EACb;AAEA,EAAA,IAAIA,KAAAA,CAAK,aAAa,CAAA,EAAG;AACxB,IAAA,OAAO,IAAA,CAAK,WAAA;AAAA,EACb;AAEA,EAAA,IAAIA,KAAAA,CAAK,aAAa,CAAA,EAAG;AACxB,IAAA,OAAO,IAAA,CAAK,WAAA;AAAA,EACb;AAEA,EAAA,IAAIA,KAAAA,CAAK,WAAW,CAAA,EAAG;AACtB,IAAA,OAAO,IAAA,CAAK,SAAA;AAAA,EACb;AAEA,EAA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,KAAK,YAAA,EAAc;AACvB,QAAA,OAAA,GAAU,MAAM,WAAA,CAAY,YAAA,EAAc,OAAA,CAAQ,QAAQ,KAAK,CAAA;AAC/D,QAAA;AAAA,MACD;AAAA,MACA,SAAS;AACR,QAAA,OAAA,GAAU,MAAM,IAAA,CAAK,YAAA,EAAc,OAAA,CAAQ,MAAA,EAAQ,OAAO,IAAI,CAAA;AAAA,MAC/D;AAAA;AAED,IAAA,OAAA,CAAQ,IAAA,CAAK,OAAA,GAAU,CAAA,GAAI,CAAC,CAAA;AAAA,EAC7B,SAAS,GAAA,EAAK;AACb,IAAA,IAAI,eAAe,qBAAA,EAAuB;AACzC,MAAA,2BAAA,CAA4B,SAAS,GAAG,CAAA;AAAA,IACzC,CAAA,MAAA,IAAW,WAAA,CAAY,GAAG,CAAA,EAAG;AAC5B,MAAA,eAAA,CAAgB,GAAG,CAAA;AAAA,IACpB,CAAA,MAAO;AACN,MAAA,kBAAA,CAAmB,GAAG,CAAA;AAAA,IACvB;AACA,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EACf;AACD;AAGA,GAAA,EAAI,CAAE,KAAA,CAAM,CAAC,GAAA,KAAiB;AAC7B,EAAA,OAAA,CAAQ,MAAM,GAAG,CAAA;AACjB,EAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AACf,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"jest-diff.js","sources":["../../src/jest/utils/diff.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment --\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, // eslint-disable-line @typescript-eslint/no-unnecessary-condition -- for compatibility\n\t// @ts-ignore\n\tjestDiffDefault,\n\t// @ts-ignore\n\tjestDiff?.diff, // eslint-disable-line @typescript-eslint/no-unnecessary-condition -- for compatibility\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","jestDiff"],"mappings":";;;AAwBA,MAAM,cAAA,GAAkD;AAAA;AAAA,EAEvDA,wBAAA,EAAiB,IAAA;AAAA;AAAA;AAAA,EAEjBA,wBAAA;AAAA;AAAA,EAEAC,eAAA,EAAU,IAAA;AAAA;AAAA;AAAA,EAEVA;AACD,CAAA;AAEA,MAAM,UAAA,GAAa,CAAC,EAAA,KAAyB,OAAO,EAAA,KAAO,UAAA;AAKpD,MAAM,IAAA,GAAqB,cAAA,CAAe,IAAA,CAAK,UAAU;;;;"}
1
+ {"version":3,"file":"jest-diff.js","sources":["../../src/jest/utils/diff.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment --\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: unknown, b: unknown, 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, // eslint-disable-line @typescript-eslint/no-unnecessary-condition -- for compatibility\n\t// @ts-ignore\n\tjestDiffDefault,\n\t// @ts-ignore\n\tjestDiff?.diff, // eslint-disable-line @typescript-eslint/no-unnecessary-condition -- for compatibility\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","jestDiff"],"mappings":";;;AAwBA,MAAM,cAAA,GAAkD;AAAA;AAAA,EAEvDA,wBAAA,EAAiB,IAAA;AAAA;AAAA;AAAA,EAEjBA,wBAAA;AAAA;AAAA,EAEAC,eAAA,EAAU,IAAA;AAAA;AAAA;AAAA,EAEVA;AACD,CAAA;AAEA,MAAM,UAAA,GAAa,CAAC,EAAA,KAAyB,OAAO,EAAA,KAAO,UAAA;AAKpD,MAAM,IAAA,GAAqB,cAAA,CAAe,IAAA,CAAK,UAAU;;;;"}
package/dist/esm/jest.js CHANGED
@@ -1,17 +1,18 @@
1
+ import { expect } from '@jest/globals';
1
2
  import { c as createMatcher, a as createMatcher$1 } from './matchers-jestonly.js';
2
3
  import { c as createMatcher$2, a as createMatcher$3, b as createMatcher$4, d as createMatcher$5, e as createMatcher$6 } from './matchers.js';
3
4
  import { d as diff } from './jest-diff.js';
4
5
  import 'jest-snapshot';
5
- import 'kleur';
6
+ import './matcher-utils.js';
6
7
  import './core.js';
7
8
  import 'ajv';
8
9
  import './elements.js';
9
10
  import './meta-helper.js';
10
11
  import './utils/natural-join.js';
11
12
  import '@sidvind/better-ajv-errors';
13
+ import 'kleur';
12
14
  import '@html-validate/stylish';
13
15
  import 'semver';
14
- import './matcher-utils.js';
15
16
  import 'node:worker_threads';
16
17
  import './core-nodejs.js';
17
18
  import 'node:fs';
@@ -1 +1 @@
1
- {"version":3,"file":"jest.js","sources":["../../src/jest/jest.ts"],"sourcesContent":["import \"./augmentation\";\n\nimport {\n\ttoBeInvalid,\n\ttoBeValid,\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,MAAA,CAAO;AAAA,EACb,WAAWA,eAAA,EAAU;AAAA,EACrB,aAAaC,eAAA,EAAY;AAAA,EACzB,cAAA,EAAgBC,eAAA,CAAe,MAAA,EAAQ,IAAI,CAAA;AAAA,EAC3C,WAAA,EAAaC,eAAA,CAAY,MAAA,EAAQ,IAAI,CAAA;AAAA,EACrC,YAAA,EAAcC,eAAA,CAAa,MAAA,EAAQ,IAAI,CAAA;AAAA,EACvC,kBAAkBC,eAAA,EAAiB;AAAA,EACnC,wBAAwBC,aAAA;AACzB,CAAC,CAAA"}
1
+ {"version":3,"file":"jest.js","sources":["../../src/jest/jest.ts"],"sourcesContent":["import { expect } from \"@jest/globals\";\nimport \"./augmentation\";\n\nimport {\n\ttoBeInvalid,\n\ttoBeValid,\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":";;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAA,CAAO,MAAA,CAAO;AAAA,EACb,WAAWA,eAAA,EAAU;AAAA,EACrB,aAAaC,eAAA,EAAY;AAAA,EACzB,cAAA,EAAgBC,eAAA,CAAe,MAAA,EAAQ,IAAI,CAAA;AAAA,EAC3C,WAAA,EAAaC,eAAA,CAAY,MAAA,EAAQ,IAAI,CAAA;AAAA,EACrC,YAAA,EAAcC,eAAA,CAAa,MAAA,EAAQ,IAAI,CAAA;AAAA,EACvC,kBAAkBC,eAAA,EAAiB;AAAA,EACnC,wBAAwBC,aAAA;AACzB,CAAC,CAAA"}
@@ -1,6 +1,41 @@
1
+ import { a0 as codeFrameColumns, a1 as getEndLocation, a2 as getStartLocation } from './core.js';
1
2
  import { MessageChannel, Worker, receiveMessageOnPort } from 'node:worker_threads';
2
3
  import { l as legacyRequire } from './core-nodejs.js';
3
4
 
5
+ function formatMessage(message, parentResult) {
6
+ const type = message.severity === 2 ? "error" : "warning";
7
+ const msg = message.message.replace(/([^ ])\.$/, "$1");
8
+ const ruleId = `(${message.ruleId})`;
9
+ const sourceCode = parentResult.source;
10
+ const firstLine = [`${type}:`, msg, ruleId].join(" ");
11
+ const result = [firstLine];
12
+ if (sourceCode) {
13
+ const output = codeFrameColumns(sourceCode, {
14
+ start: getStartLocation(message),
15
+ end: getEndLocation(message, sourceCode)
16
+ });
17
+ result.push(output);
18
+ }
19
+ result.push(`Selector: ${message.selector ?? "-"}`);
20
+ return result.join("\n");
21
+ }
22
+ function codeframe(results) {
23
+ let errors = 0;
24
+ let warnings = 0;
25
+ const resultsWithMessages = results.filter((result) => result.messages.length > 0);
26
+ const output = resultsWithMessages.reduce((resultsOutput, result) => {
27
+ const messages = result.messages.map((message) => {
28
+ return `${formatMessage(message, result)}
29
+
30
+ `;
31
+ });
32
+ errors += result.errorCount;
33
+ warnings += result.warningCount;
34
+ return resultsOutput.concat(messages);
35
+ }, []).join("\n");
36
+ return errors + warnings > 0 ? output : "";
37
+ }
38
+
4
39
  function isThenable(value) {
5
40
  return value && typeof value === "object" && "then" in value && typeof value.then === "function";
6
41
  }
@@ -83,5 +118,5 @@ function createSyncFn(workerPath) {
83
118
  return syncFn;
84
119
  }
85
120
 
86
- export { createSyncFn as c, diverge as d, flattenMessages as f, isThenable as i };
121
+ export { codeframe as a, createSyncFn as c, diverge as d, flattenMessages as f, isThenable as i };
87
122
  //# sourceMappingURL=matcher-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"matcher-utils.js","sources":["../../src/jest/utils/is-thenable.ts","../../src/jest/utils/diverge.ts","../../src/jest/utils/flatten-messages.ts","../../src/jest/worker/create-sync-fn.ts"],"sourcesContent":["/**\n * @internal\n */\nexport function isThenable<T>(value: T | Promise<T>): value is Promise<T> {\n\treturn value && typeof value === \"object\" && \"then\" in value && typeof value.then === \"function\";\n}\n","import { isThenable } from \"./is-thenable\";\nimport { type MatcherContext } from \"./matcher-context\";\nimport { type MatcherResult } from \"./matcher-result\";\n\ntype SyncCallback<T, TArgs extends any[]> = (\n\tthis: MatcherContext,\n\tactual: T,\n\t...args: TArgs\n) => MatcherResult;\n\n/**\n * @internal\n */\nexport interface MaybeAsyncCallback<TActual, TArgs extends any[]> {\n\t(this: MatcherContext, actual: TActual, ...args: TArgs): MatcherResult;\n\t(this: MatcherContext, actual: Promise<TActual>, ...args: TArgs): Promise<MatcherResult>;\n}\n\n/**\n * Creates a wrapped function based on the passed function.\n *\n * The returned function takes either a `T` or `Promise<T>`. If `T` the result\n * will be synchronous or if `Promise<T>` the result will be asynchronous.\n *\n * In practice this means that if you pass a synchronous object into it you will\n * maintain synchronous code but if you pass an asynchronous object you must\n * await the result.\n *\n * @internal\n */\nexport function diverge<T, TArgs extends any[]>(\n\tfn: SyncCallback<T, TArgs>,\n): MaybeAsyncCallback<T, TArgs> {\n\tfunction diverged(this: MatcherContext, actual: T, ...args: TArgs): MatcherResult;\n\tfunction diverged(\n\t\tthis: MatcherContext,\n\t\tactual: Promise<T>,\n\t\t...args: TArgs\n\t): Promise<MatcherResult>;\n\tfunction diverged(\n\t\tthis: MatcherContext,\n\t\tactual: T | Promise<T>,\n\t\t...args: TArgs\n\t): MatcherResult | Promise<MatcherResult> {\n\t\tif (isThenable(actual)) {\n\t\t\treturn actual.then((resolved) => fn.call(this, resolved, ...args));\n\t\t} else {\n\t\t\treturn fn.call(this, actual, ...args);\n\t\t}\n\t}\n\treturn diverged;\n}\n","import { type Message } from \"../../message\";\nimport { type Report, type Result } from \"../../reporter\";\n\n/**\n * Takes all messages from all files and flattens to a single array.\n */\nexport function flattenMessages(report: Report): Message[] {\n\treturn report.results.reduce((aggregated: Message[], result: Result) => {\n\t\treturn aggregated.concat(result.messages);\n\t}, []);\n}\n","import {\n\ttype MessagePort,\n\tMessageChannel,\n\tWorker,\n\treceiveMessageOnPort,\n} from \"node:worker_threads\";\nimport { legacyRequire } from \"../../resolve\";\nimport {\n\ttype AnyAsyncFn,\n\ttype AnyFn,\n\ttype MainToWorkerCommandMessage,\n\ttype MainToWorkerMessage,\n\ttype Syncify,\n\ttype WorkerToMainError,\n\ttype WorkerToMainMessage,\n} from \"./types\";\n\n/**\n * This is all based on the synckit library but without all the extra stuff such\n * as typescript, esbuld, pnp etc.\n */\n\nconst INT32_BYTES = 4;\nconst syncFnCache = new Map<string, AnyFn>();\nconst sharedBuffer = new SharedArrayBuffer(INT32_BYTES);\nconst sharedBufferView = new Int32Array(sharedBuffer, 0, 1);\n\nfunction isWorkerError<T>(value: WorkerToMainMessage<T>): value is WorkerToMainError {\n\treturn \"error\" in value;\n}\n\nfunction receiveMessageWithId<R>(port: MessagePort, expectedId: number): WorkerToMainMessage<R> {\n\tconst timeout = 30000;\n\tconst status = Atomics.wait(sharedBufferView, 0, 0, timeout);\n\tAtomics.store(sharedBufferView, 0, 0);\n\n\tif (![\"ok\", \"not-equal\"].includes(status)) {\n\t\tconst abortMsg: MainToWorkerCommandMessage = {\n\t\t\tid: expectedId,\n\t\t\tcmd: \"abort\",\n\t\t};\n\t\tport.postMessage(abortMsg);\n\t\tthrow new Error(`Internal error: Atomics.wait() failed: ${status}`);\n\t}\n\n\tconst reply = receiveMessageOnPort(port) as { message: WorkerToMainMessage<R> };\n\tconst { id, ...message } = reply.message;\n\n\tif (id < expectedId) {\n\t\treturn receiveMessageWithId(port, expectedId);\n\t}\n\n\tif (expectedId !== id) {\n\t\tthrow new Error(`Internal error: Expected id ${String(expectedId)} but got id ${String(id)}`);\n\t}\n\n\treturn { id, ...message };\n}\n\nfunction startWorkerThread<R, T extends AnyAsyncFn<R>>(\n\tworkerPath: string,\n): (...args: Parameters<T>) => R {\n\tconst { port1: mainPort, port2: workerPort } = new MessageChannel();\n\tconst workerPathUrl = legacyRequire.resolve(workerPath);\n\tconst worker = new Worker(workerPathUrl, {\n\t\teval: false,\n\t\tworkerData: { sharedBuffer, workerPort },\n\t\ttransferList: [workerPort],\n\t});\n\n\tlet nextID = 0;\n\n\tconst syncFn = (...args: Parameters<T>): R => {\n\t\tconst id = nextID++;\n\t\tconst msg: MainToWorkerMessage<Parameters<T>> = { id, args };\n\n\t\tworker.postMessage(msg);\n\n\t\tconst reply = receiveMessageWithId<R>(mainPort, id);\n\n\t\tif (isWorkerError(reply)) {\n\t\t\tthrow new Error(reply.error);\n\t\t}\n\n\t\treturn reply.result;\n\t};\n\n\tworker.unref();\n\n\treturn syncFn;\n}\n\nexport function createSyncFn<T extends AnyAsyncFn<R>, R = unknown>(workerPath: string): Syncify<T> {\n\tconst cachedSyncFn = syncFnCache.get(workerPath);\n\tif (cachedSyncFn) {\n\t\treturn cachedSyncFn as Syncify<T>;\n\t}\n\n\tconst syncFn = startWorkerThread<R, T>(workerPath);\n\tsyncFnCache.set(workerPath, syncFn);\n\treturn syncFn as Syncify<T>;\n}\n"],"names":[],"mappings":";;;AAGO,SAAS,WAAc,KAAA,EAA4C;AACzE,EAAA,OAAO,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,IAAY,UAAU,KAAA,IAAS,OAAO,MAAM,IAAA,KAAS,UAAA;AACvF;;ACyBO,SAAS,QACf,EAAA,EAC+B;AAO/B,EAAA,SAAS,QAAA,CAER,WACG,IAAA,EACsC;AACzC,IAAA,IAAI,UAAA,CAAW,MAAM,CAAA,EAAG;AACvB,MAAA,OAAO,MAAA,CAAO,IAAA,CAAK,CAAC,QAAA,KAAa,EAAA,CAAG,KAAK,IAAA,EAAM,QAAA,EAAU,GAAG,IAAI,CAAC,CAAA;AAAA,IAClE,CAAA,MAAO;AACN,MAAA,OAAO,EAAA,CAAG,IAAA,CAAK,IAAA,EAAM,MAAA,EAAQ,GAAG,IAAI,CAAA;AAAA,IACrC;AAAA,EACD;AACA,EAAA,OAAO,QAAA;AACR;;AC7CO,SAAS,gBAAgB,MAAA,EAA2B;AAC1D,EAAA,OAAO,MAAA,CAAO,OAAA,CAAQ,MAAA,CAAO,CAAC,YAAuB,MAAA,KAAmB;AACvE,IAAA,OAAO,UAAA,CAAW,MAAA,CAAO,MAAA,CAAO,QAAQ,CAAA;AAAA,EACzC,CAAA,EAAG,EAAE,CAAA;AACN;;ACYA,MAAM,WAAA,GAAc,CAAA;AACpB,MAAM,WAAA,uBAAkB,GAAA,EAAmB;AAC3C,MAAM,YAAA,GAAe,IAAI,iBAAA,CAAkB,WAAW,CAAA;AACtD,MAAM,gBAAA,GAAmB,IAAI,UAAA,CAAW,YAAA,EAAc,GAAG,CAAC,CAAA;AAE1D,SAAS,cAAiB,KAAA,EAA2D;AACpF,EAAA,OAAO,OAAA,IAAW,KAAA;A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AAQ,UAAU,CAAA;AACtD,EAAA,MAAM,MAAA,GAAS,IAAI,MAAA,CAAO,aAAA,EAAe;AAAA,IACxC,IAAA,EAAM,KAAA;AAAA,IACN,UAAA,EAAY,EAAE,YAAA,EAAc,UAAA,EAAW;AAAA,IACvC,YAAA,EAAc,CAAC,UAAU;AAAA,GACzB,CAAA;AAED,EAAA,IAAI,MAAA,GAAS,CAAA;AAEb,EAAA,MAAM,MAAA,GAAS,IAAI,IAAA,KAA2B;AAC7C,IAAA,MAAM,EAAA,GAAK,MAAA,EAAA;AACX,IAAA,MAAM,GAAA,GAA0C,EAAE,EAAA,EAAI,IAAA,EAAK;AAE3D,IAAA,MAAA,CAAO,YAAY,GAAG,CAAA;AAEtB,IAAA,MAAM,KAAA,GAAQ,oBAAA,CAAwB,QAAA,EAAU,EAAE,CAAA;AAElD,IAAA,IAAI,aAAA,CAAc,KAAK,CAAA,EAAG;AACzB,MAAA,MAAM,IAAI,KAAA,CAAM,KAAA,CAAM,KAAK,CAAA;AAAA,IAC5B;AAEA,IAAA,OAAO,KAAA,CAAM,MAAA;AAAA,EACd,CAAA;AAEA,EAAA,MAAA,CAAO,KAAA,EAAM;AAEb,EAAA,OAAO,MAAA;AACR;AAEO,SAAS,aAAmD,UAAA,EAAgC;AAClG,EAAA,MAAM,YAAA,GAAe,WAAA,CAAY,GAAA,CAAI,UAAU,CAAA;AAC/C,EAAA,IAAI,YAAA,EAAc;AACjB,IAAA,OAAO,YAAA;AAAA,EACR;AAEA,EAAA,MAAM,MAAA,GAAS,kBAAwB,UAAU,CAAA;AACjD,EAAA,WAAA,CAAY,GAAA,CAAI,YAAY,MAAM,CAAA;AAClC,EAAA,OAAO,MAAA;AACR;;;;"}
1
+ {"version":3,"file":"matcher-utils.js","sources":["../../src/jest/utils/codeframe.ts","../../src/jest/utils/is-thenable.ts","../../src/jest/utils/diverge.ts","../../src/jest/utils/flatten-messages.ts","../../src/jest/worker/create-sync-fn.ts"],"sourcesContent":["import { type Message } from \"../../message\";\nimport { type Result } from \"../../reporter\";\nimport { codeFrameColumns } from \"../../utils/code-frame-columns\";\nimport { getEndLocation, getStartLocation } from \"../../utils/message-location\";\n\n/**\n * Gets the formatted output for a given message.\n * @param message - The object that represents this message.\n * @param parentResult - The result object that this message belongs to.\n * @returns The formatted output.\n */\nfunction formatMessage(message: Message, parentResult: Result): string {\n\tconst type = message.severity === 2 ? \"error\" : \"warning\";\n\tconst msg = message.message.replace(/([^ ])\\.$/, \"$1\");\n\tconst ruleId = `(${message.ruleId})`;\n\tconst sourceCode = parentResult.source;\n\tconst firstLine = [`${type}:`, msg, ruleId].join(\" \");\n\tconst result = [firstLine];\n\n\t/* istanbul ignore next: safety check from original implementation */\n\tif (sourceCode) {\n\t\tconst output = codeFrameColumns(sourceCode, {\n\t\t\tstart: getStartLocation(message),\n\t\t\tend: getEndLocation(message, sourceCode),\n\t\t});\n\t\tresult.push(output);\n\t}\n\n\tresult.push(`Selector: ${message.selector ?? \"-\"}`);\n\n\treturn result.join(\"\\n\");\n}\n\n/**\n * Codeframe formatter based on ESLint codeframe.\n *\n * @internal\n */\nexport function codeframe(results: Result[]): string {\n\tlet errors = 0;\n\tlet warnings = 0;\n\n\tconst resultsWithMessages = results.filter((result) => result.messages.length > 0);\n\n\tconst output = resultsWithMessages\n\t\t.reduce<string[]>((resultsOutput, result) => {\n\t\t\tconst messages = result.messages.map((message) => {\n\t\t\t\treturn `${formatMessage(message, result)}\\n\\n`;\n\t\t\t});\n\n\t\t\terrors += result.errorCount;\n\t\t\twarnings += result.warningCount;\n\n\t\t\treturn resultsOutput.concat(messages);\n\t\t}, [])\n\t\t.join(\"\\n\");\n\n\treturn errors + warnings > 0 ? output : \"\";\n}\n","/**\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 unknown[]> = (\n\tthis: MatcherContext,\n\tactual: T,\n\t...args: TArgs\n) => MatcherResult;\n\n/**\n * @internal\n */\nexport interface MaybeAsyncCallback<TActual, TArgs extends unknown[]> {\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 unknown[]>(\n\tfn: SyncCallback<T, TArgs>,\n): MaybeAsyncCallback<T, TArgs> {\n\tfunction diverged(this: MatcherContext, actual: T, ...args: TArgs): MatcherResult;\n\tfunction diverged(\n\t\tthis: MatcherContext,\n\t\tactual: Promise<T>,\n\t\t...args: TArgs\n\t): Promise<MatcherResult>;\n\tfunction diverged(\n\t\tthis: MatcherContext,\n\t\tactual: T | Promise<T>,\n\t\t...args: TArgs\n\t): MatcherResult | Promise<MatcherResult> {\n\t\tif (isThenable(actual)) {\n\t\t\treturn actual.then((resolved) => fn.call(this, resolved, ...args));\n\t\t} else {\n\t\t\treturn fn.call(this, actual, ...args);\n\t\t}\n\t}\n\treturn diverged;\n}\n","import { type Message } from \"../../message\";\nimport { type Report, type Result } from \"../../reporter\";\n\n/**\n * Takes all messages from all files and flattens to a single array.\n */\nexport function flattenMessages(report: Report): Message[] {\n\treturn report.results.reduce((aggregated: Message[], result: Result) => {\n\t\treturn aggregated.concat(result.messages);\n\t}, []);\n}\n","import {\n\ttype MessagePort,\n\tMessageChannel,\n\tWorker,\n\treceiveMessageOnPort,\n} from \"node:worker_threads\";\nimport { legacyRequire } from \"../../resolve\";\nimport {\n\ttype AnyAsyncFn,\n\ttype AnyFn,\n\ttype MainToWorkerCommandMessage,\n\ttype MainToWorkerMessage,\n\ttype Syncify,\n\ttype WorkerToMainError,\n\ttype WorkerToMainMessage,\n} from \"./types\";\n\n/**\n * This is all based on the synckit library but without all the extra stuff such\n * as typescript, esbuld, pnp etc.\n */\n\nconst INT32_BYTES = 4;\nconst syncFnCache = new Map<string, AnyFn>();\nconst sharedBuffer = new SharedArrayBuffer(INT32_BYTES);\nconst sharedBufferView = new Int32Array(sharedBuffer, 0, 1);\n\nfunction isWorkerError<T>(value: WorkerToMainMessage<T>): value is WorkerToMainError {\n\treturn \"error\" in value;\n}\n\nfunction receiveMessageWithId<R>(port: MessagePort, expectedId: number): WorkerToMainMessage<R> {\n\tconst timeout = 30000;\n\tconst status = Atomics.wait(sharedBufferView, 0, 0, timeout);\n\tAtomics.store(sharedBufferView, 0, 0);\n\n\tif (![\"ok\", \"not-equal\"].includes(status)) {\n\t\tconst abortMsg: MainToWorkerCommandMessage = {\n\t\t\tid: expectedId,\n\t\t\tcmd: \"abort\",\n\t\t};\n\t\tport.postMessage(abortMsg);\n\t\tthrow new Error(`Internal error: Atomics.wait() failed: ${status}`);\n\t}\n\n\tconst reply = receiveMessageOnPort(port) as { message: WorkerToMainMessage<R> };\n\tconst { id, ...message } = reply.message;\n\n\tif (id < expectedId) {\n\t\treturn receiveMessageWithId(port, expectedId);\n\t}\n\n\tif (expectedId !== id) {\n\t\tthrow new Error(`Internal error: Expected id ${String(expectedId)} but got id ${String(id)}`);\n\t}\n\n\treturn { id, ...message };\n}\n\nfunction startWorkerThread<R, T extends AnyAsyncFn<R>>(\n\tworkerPath: string,\n): (...args: Parameters<T>) => R {\n\tconst { port1: mainPort, port2: workerPort } = new MessageChannel();\n\tconst workerPathUrl = legacyRequire.resolve(workerPath);\n\tconst worker = new Worker(workerPathUrl, {\n\t\teval: false,\n\t\tworkerData: { sharedBuffer, workerPort },\n\t\ttransferList: [workerPort],\n\t});\n\n\tlet nextID = 0;\n\n\tconst syncFn = (...args: Parameters<T>): R => {\n\t\tconst id = nextID++;\n\t\tconst msg: MainToWorkerMessage<Parameters<T>> = { id, args };\n\n\t\tworker.postMessage(msg);\n\n\t\tconst reply = receiveMessageWithId<R>(mainPort, id);\n\n\t\tif (isWorkerError(reply)) {\n\t\t\tthrow new Error(reply.error);\n\t\t}\n\n\t\treturn reply.result;\n\t};\n\n\tworker.unref();\n\n\treturn syncFn;\n}\n\nexport function createSyncFn<T extends AnyAsyncFn<R>, R = unknown>(workerPath: string): Syncify<T> {\n\tconst cachedSyncFn = syncFnCache.get(workerPath);\n\tif (cachedSyncFn) {\n\t\treturn cachedSyncFn as Syncify<T>;\n\t}\n\n\tconst syncFn = startWorkerThread<R, T>(workerPath);\n\tsyncFnCache.set(workerPath, syncFn);\n\treturn syncFn as Syncify<T>;\n}\n"],"names":[],"mappings":";;;;AAWA,SAAS,aAAA,CAAc,SAAkB,YAAA,EAA8B;AACtE,EAAA,MAAM,IAAA,GAAO,OAAA,CAAQ,QAAA,KAAa,CAAA,GAAI,OAAA,GAAU,SAAA;AAChD,EAAA,MAAM,GAAA,GAAM,OAAA,CAAQ,OAAA,CAAQ,OAAA,CAAQ,aAAa,IAAI,CAAA;AACrD,EAAA,MAAM,MAAA,GAAS,CAAA,CAAA,EAAI,OAAA,CAAQ,MAAM,CAAA,CAAA,CAAA;AACjC,EAAA,MAAM,aAAa,YAAA,CAAa,MAAA;AAChC,EAAA,MAAM,SAAA,GAAY,CAAC,CAAA,EAAG,IAAI,KAAK,GAAA,EAAK,MAAM,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AACpD,EAAA,MAAM,MAAA,GAAS,CAAC,SAAS,CAAA;AAGzB,EAAA,IAAI,UAAA,EAAY;AACf,IAAA,MAAM,MAAA,GAAS,iBAAiB,UAAA,EAAY;AAAA,MAC3C,KAAA,EAAO,iBAAiB,OAAO,CAAA;AAAA,MAC/B,GAAA,EAAK,cAAA,CAAe,OAAA,EAAS,UAAU;AAAA,KACvC,CAA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,CAAA;AAEtB,IAAA,MAAM,KAAA,GAAQ,oBAAA,CAAwB,QAAA,EAAU,EAAE,CAAA;AAElD,IAAA,IAAI,aAAA,CAAc,KAAK,CAAA,EAAG;AACzB,MAAA,MAAM,IAAI,KAAA,CAAM,KAAA,CAAM,KAAK,CAAA;AAAA,IAC5B;AAEA,IAAA,OAAO,KAAA,CAAM,MAAA;AAAA,EACd,CAAA;AAEA,EAAA,MAAA,CAAO,KAAA,EAAM;AAEb,EAAA,OAAO,MAAA;AACR;AAEO,SAAS,aAAmD,UAAA,EAAgC;AAClG,EAAA,MAAM,YAAA,GAAe,WAAA,CAAY,GAAA,CAAI,UAAU,CAAA;AAC/C,EAAA,IAAI,YAAA,EAAc;AACjB,IAAA,OAAO,YAAA;AAAA,EACR;AAEA,EAAA,MAAM,MAAA,GAAS,kBAAwB,UAAU,CAAA;AACjD,EAAA,WAAA,CAAY,GAAA,CAAI,YAAY,MAAM,CAAA;AAClC,EAAA,OAAO,MAAA;AACR;;;;"}
@@ -1,57 +1,39 @@
1
1
  import { toMatchSnapshot, toMatchInlineSnapshot } from 'jest-snapshot';
2
- import kleur from 'kleur';
3
- import { a1 as codeframe } from './core.js';
4
2
  import { g as getResults } from './matchers.js';
5
- import { d as diverge, i as isThenable } from './matcher-utils.js';
3
+ import { d as diverge, a as codeframe, i as isThenable } from './matcher-utils.js';
6
4
 
7
- const options$1 = {
8
- showLink: false,
9
- showSummary: false,
10
- showSelector: true
11
- };
12
5
  function createMatcher$1() {
13
6
  function toMatchCodeframe(actual, ...rest) {
14
7
  const filename = this.testPath ?? "inline";
15
8
  const results = getResults(filename, actual);
16
- const enabled = kleur.enabled;
17
- kleur.enabled = false;
18
- const snapshot = codeframe(results, options$1).replaceAll(/\s+$/gm, "");
19
- kleur.enabled = enabled;
9
+ const snapshot = codeframe(results).replaceAll(/\s+$/gm, "");
20
10
  return toMatchSnapshot.call(this, snapshot, ...rest);
21
11
  }
22
12
  return diverge(toMatchCodeframe);
23
13
  }
24
14
 
25
- const options = {
26
- showLink: false,
27
- showSummary: false,
28
- showSelector: true
29
- };
30
15
  function toMatchInlineCodeframeImpl(context, actual, ...rest) {
31
16
  const filename = context.testPath ?? "inline";
32
17
  const results = getResults(filename, actual);
33
- const enabled = kleur.enabled;
34
- kleur.enabled = false;
35
- const snapshot = codeframe(results, options).replaceAll(/\s+$/gm, "");
36
- kleur.enabled = enabled;
18
+ const snapshot = codeframe(results).replaceAll(/\s+$/gm, "");
37
19
  return toMatchInlineSnapshot.call(context, snapshot, ...rest);
38
20
  }
39
- function createMatcher() {
40
- function toMatchInlineCodeframe(actual, ...rest) {
41
- const context = {
42
- ...this,
43
- /* Capture the original stack frames as they are needed by "jest-snapshot"
44
- * to determine where to write the inline snapshots. When resolving the
45
- * promise the original stack frames are lost and the snapshot will be
46
- * written in this files instaed. */
47
- error: new Error()
48
- };
49
- if (isThenable(actual)) {
50
- return actual.then((resolved) => toMatchInlineCodeframeImpl(context, resolved, ...rest));
51
- } else {
52
- return toMatchInlineCodeframeImpl(context, actual, ...rest);
53
- }
21
+ function toMatchInlineCodeframe(actual, ...rest) {
22
+ const context = {
23
+ ...this,
24
+ /* Capture the original stack frames as they are needed by "jest-snapshot"
25
+ * to determine where to write the inline snapshots. When resolving the
26
+ * promise the original stack frames are lost and the snapshot will be
27
+ * written in this files instaed. */
28
+ error: new Error("stacktrace")
29
+ };
30
+ if (isThenable(actual)) {
31
+ return actual.then((resolved) => toMatchInlineCodeframeImpl(context, resolved, ...rest));
32
+ } else {
33
+ return toMatchInlineCodeframeImpl(context, actual, ...rest);
54
34
  }
35
+ }
36
+ function createMatcher() {
55
37
  return toMatchInlineCodeframe;
56
38
  }
57
39
 
@@ -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 { toMatchSnapshot } from \"jest-snapshot\";\nimport kleur from \"kleur\";\nimport { type CodeframeOptions, codeframe } 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).replaceAll(/\\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 { toMatchInlineSnapshot } from \"jest-snapshot\";\nimport kleur from \"kleur\";\nimport { type CodeframeOptions, codeframe } 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).replaceAll(/\\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,SAAA,GAA4B;AAAA,EACjC,QAAA,EAAU,KAAA;AAAA,EACV,WAAA,EAAa,KAAA;AAAA,EACb,YAAA,EAAc;AACf,CAAA;AAEA,SAASC,eAAA,GAA+E;AACvF,EAAA,SAAS,gBAAA,CAER,WACG,IAAA,EACa;AAEhB,IAAA,MAAM,QAAA,GAAW,KAAK,QAAA,IAAY,QAAA;AAClC,IAAA,MAAM,OAAA,GAAU,UAAA,CAAW,QAAA,EAAU,MAAM,CAAA;AAC3C,IAAA,M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AAA,OAAO,MAAA,CAAO,KAAK,CAAC,QAAA,KAAa,2BAA2B,OAAA,EAAS,QAAA,EAAU,GAAG,IAAI,CAAC,CAAA;AAAA,IACxF,CAAA,MAAO;AACN,MAAA,OAAO,0BAAA,CAA2B,OAAA,EAAS,MAAA,EAAQ,GAAG,IAAI,CAAA;AAAA,IAC3D;AAAA,EACD;AAEA,EAAA,OAAO,sBAAA;AACR;;;;"}
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 { toMatchSnapshot } from \"jest-snapshot\";\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype MatcherContext,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tcodeframe,\n\tdiverge,\n} from \"../utils\";\nimport { getResults } from \"./get-results\";\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 snapshot = codeframe(results).replaceAll(/\\s+$/gm, \"\");\n\n\t\t/* eslint-disable-next-line @typescript-eslint/no-explicit-any, @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 { toMatchInlineSnapshot } from \"jest-snapshot\";\nimport { type Report } from \"../../reporter\";\nimport { type MatcherContext, type MatcherResult, codeframe, isThenable } from \"../utils\";\nimport { getResults } from \"./get-results\";\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 snapshot = codeframe(results).replaceAll(/\\s+$/gm, \"\");\n\n\t/* eslint-disable-next-line @typescript-eslint/no-explicit-any, @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 toMatchInlineCodeframe(\n\tthis: MatcherContext,\n\tactual: Report | Promise<Report> | string,\n\t...rest: Array<string | object>\n): MatcherResult | Promise<MatcherResult> {\n\tconst context = {\n\t\t...this,\n\n\t\t/* Capture the original stack frames as they are needed by \"jest-snapshot\"\n\t\t * to determine where to write the inline snapshots. When resolving the\n\t\t * promise the original stack frames are lost and the snapshot will be\n\t\t * written in this files instaed. */\n\t\terror: new Error(\"stacktrace\"),\n\t};\n\n\tif (isThenable(actual)) {\n\t\treturn actual.then((resolved) => toMatchInlineCodeframeImpl(context, resolved, ...rest));\n\t} else {\n\t\treturn toMatchInlineCodeframeImpl(context, actual, ...rest);\n\t}\n}\n\nfunction createMatcher(): ToMatchInlineCodeframeMatcher {\n\treturn toMatchInlineCodeframe;\n}\n\nexport { createMatcher as toMatchInlineCodeframe };\n"],"names":["createMatcher"],"mappings":";;;;AAWA,SAASA,eAAA,GAA+E;AACvF,EAAA,SAAS,gBAAA,CAER,WACG,IAAA,EACa;AAEhB,IAAA,MAAM,QAAA,GAAW,KAAK,QAAA,IAAY,QAAA;AAClC,IAAA,MAAM,OAAA,GAAU,UAAA,CAAW,QAAA,EAAU,MAAM,CAAA;AAC3C,IAAA,MAAM,WAAW,SAAA,CAAU,OAAO,CAAA,CAAE,UAAA,CAAW,UAAU,EAAE,CAAA;AAI3D,IAAA,OAAQ,eAAA,CAAwB,IAAA,CAAK,IAAA,EAAM,QAAA,EAAU,GAAG,IAAI,CAAA;AAAA,EAC7D;AACA,EAAA,OAAO,QAAQ,gBAAgB,CAAA;AAChC;;ACtBA,SAAS,0BAAA,CACR,OAAA,EACA,MAAA,EAAA,GACG,IAAA,EACa;AAEhB,EAAA,MAAM,QAAA,GAAW,QAAQ,QAAA,IAAY,QAAA;AACrC,EAAA,MAAM,OAAA,GAAU,UAAA,CAAW,QAAA,EAAU,MAAM,CAAA;AAC3C,EAAA,MAAM,WAAW,SAAA,CAAU,OAAO,CAAA,CAAE,UAAA,CAAW,UAAU,EAAE,CAAA;AAI3D,EAAA,OAAQ,qBAAA,CAA8B,IAAA,CAAK,OAAA,EAAS,QAAA,EAAU,GAAG,IAAI,CAAA;AACtE;AAQA,SAAS,sBAAA,CAER,WACG,IAAA,EACsC;AACzC,EAAA,MAAM,OAAA,GAAU;AAAA,IACf,GAAG,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMH,KAAA,EAAO,IAAI,KAAA,CAAM,YAAY;AAAA,GAC9B;AAEA,EAAA,IAAI,UAAA,CAAW,MAAM,CAAA,EAAG;AACvB,IAAA,OAAO,MAAA,CAAO,KAAK,CAAC,QAAA,KAAa,2BAA2B,OAAA,EAAS,QAAA,EAAU,GAAG,IAAI,CAAC,CAAA;AAAA,EACxF,CAAA,MAAO;AACN,IAAA,OAAO,0BAAA,CAA2B,OAAA,EAAS,MAAA,EAAQ,GAAG,IAAI,CAAA;AAAA,EAC3D;AACD;AAEA,SAAS,aAAA,GAA+C;AACvD,EAAA,OAAO,sBAAA;AACR;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { d as diverge, c as createSyncFn, f as flattenMessages } from './matcher-utils.js';
2
- import { k as deepmerge, a0 as workerPath } from './core.js';
2
+ import { k as deepmerge, a3 as workerPath } from './core.js';
3
3
 
4
4
  function createMatcher$4() {
5
5
  function toBeValid(report) {
@@ -43,20 +43,26 @@ function createMatcher$3() {
43
43
  }
44
44
 
45
45
  function isMessage(arg) {
46
- if (!arg) {
46
+ if (!arg || typeof arg !== "object") {
47
47
  return false;
48
48
  }
49
- return Boolean(
50
- arg.ruleId ?? arg.severity ?? arg.message ?? arg.offset ?? arg.line ?? arg.column ?? arg.size ?? arg.selector ?? arg.context
51
- );
49
+ return [
50
+ "ruleId",
51
+ "severity",
52
+ "message",
53
+ "offset",
54
+ "line",
55
+ "column",
56
+ "size",
57
+ "selector",
58
+ "context"
59
+ ].some((key) => key in arg);
52
60
  }
53
61
  function isConfig(arg) {
54
- if (!arg) {
62
+ if (!arg || typeof arg !== "object") {
55
63
  return false;
56
64
  }
57
- return Boolean(
58
- arg.root ?? arg.extends ?? arg.elements ?? arg.plugin ?? arg.transform ?? arg.rules
59
- );
65
+ return ["root", "extends", "elements", "plugin", "transform", "rules"].some((key) => key in arg);
60
66
  }
61
67
  function isString(arg) {
62
68
  return typeof arg === "string";
@@ -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 { type Message } from \"../../message\";\nimport {\n\ttype DiffFunction,\n\ttype MatcherContext,\n\ttype MatcherExpect,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n} from \"../utils\";\nimport { type ValidateStringFn, createSyncFn, workerPath } from \"../worker\";\n\nfunction isMessage(arg: any): arg is Partial<Message> {\n\tif (!arg) {\n\t\treturn false;\n\t}\n\treturn Boolean(\n\t\targ.ruleId ??\n\t\targ.severity ??\n\t\targ.message ??\n\t\targ.offset ??\n\t\targ.line ??\n\t\targ.column ??\n\t\targ.size ??\n\t\targ.selector ??\n\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 TypeError(`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; // eslint-disable-line sonarjs/no-nested-conditional -- easier to read than the alternative */\n\t\tconst filename = isString(arg0) ? arg0 : isString(arg1) ? arg1 : arg2; // eslint-disable-line sonarjs/no-nested-conditional -- easier to read than the alternative */\n\t\treturn toHTMLValidateImpl.call(this, expect, diff, markup, message, config, filename);\n\t}\n\treturn diverge(toHTMLValidate);\n}\n\n/* eslint-disable-next-line @typescript-eslint/max-params -- technical debt */\nfunction toHTMLValidateImpl(\n\tthis: MatcherContext,\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n\tactual: string,\n\texpectedError?: Partial<Message>,\n\tuserConfig?: ConfigData,\n\tfilename?: string,\n): MatcherResult {\n\tconst defaultConfig = {\n\t\trules: {\n\t\t\t/* jsdom normalizes style so disabling rule when using this matcher or it\n\t\t\t * gets quite noisy when configured with self-closing */\n\t\t\t\"void-style\": \"off\",\n\t\t},\n\t};\n\tconst config = deepmerge(defaultConfig, userConfig ?? {});\n\t/* istanbul ignore next: cant figure out when this would be unset */\n\tconst actualFilename = filename ?? this.testPath ?? \"inline\";\n\n\tconst syncFn = createSyncFn<ValidateStringFn>(workerPath);\n\tconst report = syncFn(actual, actualFilename, config);\n\tconst pass = report.valid;\n\tconst result = report.results[0];\n\tif (pass) {\n\t\treturn { pass, message: () => \"HTML is valid when an error was expected\" };\n\t} else {\n\t\tif (expectedError) {\n\t\t\tconst actual = result.messages;\n\t\t\tconst expected = expect.arrayContaining([expect.objectContaining(expectedError)]);\n\t\t\tconst errorPass = this.equals(actual, expected);\n\t\t\tconst diffString = diff\n\t\t\t\t? diff(expected, actual, {\n\t\t\t\t\t\texpand: this.expand,\n\t\t\t\t\t\taAnnotation: \"Expected error\",\n\t\t\t\t\t\tbAnnotation: \"Actual error\",\n\t\t\t\t\t})\n\t\t\t\t: /* istanbul ignore next */ undefined;\n\t\t\tconst hint = this.utils.matcherHint(\".not.toHTMLValidate\", undefined, undefined, {\n\t\t\t\tcomment: \"expected error\",\n\t\t\t});\n\t\t\tconst expectedErrorMessage = (): string =>\n\t\t\t\t[\n\t\t\t\t\thint,\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"Expected error to be present:\",\n\t\t\t\t\tthis.utils.printExpected(expectedError),\n\t\t\t\t\t/* istanbul ignore next */ diffString ? `\\n${diffString}` : \"\",\n\t\t\t\t].join(\"\\n\");\n\t\t\treturn { pass: !errorPass, message: expectedErrorMessage, actual, expected };\n\t\t}\n\n\t\tconst errors = result.messages.map((message) => ` ${message.message} [${message.ruleId}]`);\n\t\treturn {\n\t\t\tpass,\n\t\t\tmessage: () =>\n\t\t\t\t[\"Expected HTML to be valid but had the following errors:\", \"\"].concat(errors).join(\"\\n\"),\n\t\t};\n\t}\n}\n\nexport { createMatcher as toHTMLValidate };\n","import { type Message } from \"../../message\";\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype DiffFunction,\n\ttype MatcherContext,\n\ttype MatcherExpect,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n} from \"../utils\";\nimport { flattenMessages } from \"../utils/flatten-messages\";\n\nfunction toHaveErrorImpl(\n\tcontext: MatcherContext,\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n\tactual: Report,\n\texpected: Partial<Message>,\n): MatcherResult {\n\tconst flattened = flattenMessages(actual);\n\tconst matcher = [expect.objectContaining(expected)];\n\tconst pass = context.equals(flattened, matcher);\n\tconst diffString = diff\n\t\t? diff(matcher, flattened, { expand: context.expand })\n\t\t: /* istanbul ignore next */ undefined;\n\tconst hint = context.utils.matcherHint(\".toHaveError\");\n\tconst prettyExpected = context.utils.printExpected(matcher);\n\tconst prettyReceived = context.utils.printReceived(flattened);\n\tconst resultMessage = (): string => {\n\t\treturn [\n\t\t\thint,\n\t\t\t\"\",\n\t\t\t\"Expected error to equal:\",\n\t\t\t` ${prettyExpected}`,\n\t\t\t\"Received:\",\n\t\t\t` ${prettyReceived}`,\n\t\t\t/* istanbul ignore next */ diffString ? `\\nDifference:\\n\\n${diffString}` : \"\",\n\t\t].join(\"\\n\");\n\t};\n\treturn { pass, message: resultMessage, actual: flattened, expected: matcher };\n}\n\nfunction createMatcher(\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n):\n\t| MaybeAsyncCallback<Report, [Partial<Message>]>\n\t| MaybeAsyncCallback<Report, [string, string, any?]> {\n\tfunction toHaveError(\n\t\tthis: MatcherContext,\n\t\tactual: Report,\n\t\terror: Partial<Message>,\n\t): MatcherResult;\n\tfunction toHaveError(\n\t\tthis: MatcherContext,\n\t\tactual: Report,\n\t\truleId: string,\n\t\tmessage: string,\n\t\tcontext?: any,\n\t): MatcherResult;\n\tfunction toHaveError(\n\t\tthis: MatcherContext,\n\t\tactual: Report,\n\t\targ1: string | Partial<Message>,\n\t\targ2?: string,\n\t\targ3?: any,\n\t): MatcherResult {\n\t\tif (typeof arg1 === \"string\") {\n\t\t\tconst expected: Partial<Message> = {\n\t\t\t\truleId: arg1,\n\t\t\t\tmessage: arg2,\n\t\t\t};\n\t\t\tif (arg3) {\n\t\t\t\t/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- this is supposed to accept anything */\n\t\t\t\texpected.context = arg3;\n\t\t\t}\n\t\t\treturn toHaveErrorImpl(this, expect, diff, actual, expected);\n\t\t} else {\n\t\t\treturn toHaveErrorImpl(this, expect, diff, actual, arg1);\n\t\t}\n\t}\n\treturn diverge(toHaveError);\n}\n\nexport { createMatcher as toHaveError };\n","/* eslint-disable prefer-template -- technical debt, should be refactored */\n\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype DiffFunction,\n\ttype MatcherContext,\n\ttype MatcherExpect,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n\tflattenMessages,\n} from \"../utils\";\n\nfunction createMatcher(\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n): MaybeAsyncCallback<Report, [Array<[string, string] | Record<string, unknown>>]> {\n\tfunction toHaveErrors(\n\t\tthis: MatcherContext,\n\t\treport: Report,\n\t\terrors: Array<[string, string] | Record<string, unknown>>,\n\t): MatcherResult {\n\t\tconst flattened = flattenMessages(report);\n\t\tconst matcher = errors.map((entry) => {\n\t\t\tif (Array.isArray(entry)) {\n\t\t\t\tconst [ruleId, message] = entry;\n\t\t\t\treturn expect.objectContaining({ ruleId, message });\n\t\t\t} else {\n\t\t\t\treturn expect.objectContaining(entry);\n\t\t\t}\n\t\t});\n\t\tconst pass = this.equals(flattened, matcher);\n\t\tconst diffString = diff\n\t\t\t? diff(matcher, flattened, { expand: this.expand })\n\t\t\t: /* istanbul ignore next */ undefined;\n\t\tconst resultMessage = (): string =>\n\t\t\tthis.utils.matcherHint(\".toHaveErrors\") +\n\t\t\t\"\\n\\n\" +\n\t\t\t\"Expected error to equal:\\n\" +\n\t\t\t` ${this.utils.printExpected(matcher)}\\n` +\n\t\t\t\"Received:\\n\" +\n\t\t\t` ${this.utils.printReceived(flattened)}` +\n\t\t\t/* istanbul ignore next */ (diffString ? `\\n\\nDifference:\\n\\n${diffString}` : \"\");\n\n\t\treturn { pass, message: resultMessage };\n\t}\n\treturn diverge(toHaveErrors);\n}\n\nexport { createMatcher as toHaveErrors };\n","import { type Report, type Result } from \"../../reporter\";\nimport { type ValidateStringFn, createSyncFn, workerPath } from \"../worker\";\n\n/**\n * @internal\n */\nexport function getResults(filename: string, value: Report | string): Result[] {\n\tif (typeof value === \"string\") {\n\t\tconst syncFn = createSyncFn<ValidateStringFn>(workerPath);\n\t\tconst report = syncFn(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,eAAA,GAAgD;AACxD,EAAA,SAAS,UAAU,MAAA,EAA+B;AACjD,IAAA,IAAI,OAAO,KAAA,EAAO;AACjB,MAAA,OAAO;AAAA,QACN,IAAA,EAAM,IAAA;AAAA,QACN,OAAA;AAAA;AAAA,UAAoC,MAAM;AAAA;AAAA,OAC3C;AAAA,IACD,CAAA,MAAO;AACN,MAAA,MAAM,aAAa,MAAA,CAAO,OAAA,CAAQ,CAAC,CAAA,CAAE,SAAS,CAAC,CAAA;AAC/C,MAAA,OAAO;AAAA,QACN,IAAA,EAAM,KAAA;AAAA,QACN,OAAA,EAAS,MAAM,CAAA,sCAAA,EAAyC,UAAA,CAAW,OAAO,CAAA,CAAA;AAAA,OAC3E;AAAA,IACD;AAAA,EACD;AACA,EAAA,OAAO,QAAQ,SAAS,CAAA;AACzB;;AChBA,SAASA,eAAA,GAAgD;AACxD,EAAA,SAAS,YAAY,MAAA,EAA+B;AACnD,IAAA,IAAI,OAAO,KAAA,EAAO;AACjB,MAAA,OAAO;AAAA,QACN,IAAA,EAAM,KAAA;AAAA,QACN,SAAS,MAAM;AAAA,OAChB;AAAA,IACD,CAAA,MAAO;AACN,MAAA,OAAO;AAAA,QACN,IAAA,EAAM,IAAA;AAAA,QACN,OAAA;AAAA;AAAA,UAAoC,MAAM;AAAA;AAAA,OAC3C;AAAA,IACD;AAAA,EACD;AACA,EAAA,OAAO,QA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A,KAAA;AAC9B,IAAA,MAAM,gBAAgB,MACrB,IAAA,CAAK,KAAA,CAAM,WAAA,CAAY,eAAe,CAAA,GACtC;;AAAA;AAAA,EAAA,EAEK,IAAA,CAAK,KAAA,CAAM,aAAA,CAAc,OAAO,CAAC;AAAA;AAAA,EAAA,EAEjC,IAAA,CAAK,KAAA,CAAM,aAAA,CAAc,SAAS,CAAC,CAAA,CAAA;AAAA,KACZ,UAAA,GAAa;;AAAA;;AAAA,EAAsB,UAAU,CAAA,CAAA,GAAK,EAAA,CAAA;AAE/E,IAAA,OAAO,EAAE,IAAA,EAAM,OAAA,EAAS,aAAA,EAAc;AAAA,EACvC;AACA,EAAA,OAAO,QAAQ,YAAY,CAAA;AAC5B;;ACzCO,SAAS,UAAA,CAAW,UAAkB,KAAA,EAAkC;AAC9E,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC9B,IAAA,MAAM,MAAA,GAAS,aAA+B,UAAU,CAAA;AACxD,IAAA,MAAM,MAAA,GAAS,MAAA,CAAO,KAAA,EAAO,QAAA,EAAU;AAAA,MACtC,KAAA,EAAO;AAAA,QACN,YAAA,EAAc;AAAA;AACf,KACA,CAAA;AACD,IAAA,OAAO,MAAA,CAAO,OAAA,CAAQ,GAAA,CAAI,CAAC,EAAA,KAAO;AACjC,MAAA,OAAO,EAAE,GAAG,EAAA,EAAI,QAAA,EAAU,QAAA,EAAS;AAAA,IACpC,CAAC,CAAA;AAAA,EACF,CAAA,MAAO;AACN,IAAA,OAAO,KAAA,CAAM,OAAA;AAAA,EACd;AACD;;;;"}
1
+ {"version":3,"file":"matchers.js","sources":["../../src/jest/matchers/to-be-valid.ts","../../src/jest/matchers/to-be-invalid.ts","../../src/jest/matchers/to-htmlvalidate.ts","../../src/jest/matchers/to-have-error.ts","../../src/jest/matchers/to-have-errors.ts","../../src/jest/matchers/get-results.ts"],"sourcesContent":["import { type Report } from \"../../reporter\";\nimport { type MatcherResult, type MaybeAsyncCallback, diverge } from \"../utils\";\n\nfunction createMatcher(): MaybeAsyncCallback<Report, []> {\n\tfunction toBeValid(report: Report): MatcherResult {\n\t\tif (report.valid) {\n\t\t\treturn {\n\t\t\t\tpass: true,\n\t\t\t\tmessage: /* istanbul ignore next */ () => \"Result should not contain error\",\n\t\t\t};\n\t\t} else {\n\t\t\tconst firstError = report.results[0].messages[0];\n\t\t\treturn {\n\t\t\t\tpass: false,\n\t\t\t\tmessage: () => `Result should be valid but had error \"${firstError.message}\"`,\n\t\t\t};\n\t\t}\n\t}\n\treturn diverge(toBeValid);\n}\n\nexport { createMatcher as toBeValid };\n","import { type Report } from \"../../reporter\";\nimport { type MatcherResult, type MaybeAsyncCallback, diverge } from \"../utils\";\n\nfunction createMatcher(): MaybeAsyncCallback<Report, []> {\n\tfunction toBeInvalid(report: Report): MatcherResult {\n\t\tif (report.valid) {\n\t\t\treturn {\n\t\t\t\tpass: false,\n\t\t\t\tmessage: () => \"Result should be invalid but had no errors\",\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tpass: true,\n\t\t\t\tmessage: /* istanbul ignore next */ () => \"Result should not contain error\",\n\t\t\t};\n\t\t}\n\t}\n\treturn diverge(toBeInvalid);\n}\n\nexport { createMatcher as toBeInvalid };\n","import deepmerge from \"deepmerge\";\nimport { type ConfigData } from \"../../config\";\nimport { type Message } from \"../../message\";\nimport {\n\ttype DiffFunction,\n\ttype MatcherContext,\n\ttype MatcherExpect,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n} from \"../utils\";\nimport { type ValidateStringFn, createSyncFn, workerPath } from \"../worker\";\n\nfunction isMessage(arg: Arg1 | undefined): arg is Partial<Message> {\n\tif (!arg || typeof arg !== \"object\") {\n\t\treturn false;\n\t}\n\treturn [\n\t\t\"ruleId\",\n\t\t\"severity\",\n\t\t\"message\",\n\t\t\"offset\",\n\t\t\"line\",\n\t\t\"column\",\n\t\t\"size\",\n\t\t\"selector\",\n\t\t\"context\",\n\t].some((key) => key in arg);\n}\n\nfunction isConfig(arg: Arg1 | undefined): arg is ConfigData {\n\tif (!arg || typeof arg !== \"object\") {\n\t\treturn false;\n\t}\n\treturn [\"root\", \"extends\", \"elements\", \"plugin\", \"transform\", \"rules\"].some((key) => key in arg);\n}\n\nfunction isString(arg: Arg1 | undefined): 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 TypeError(`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; // eslint-disable-line sonarjs/no-nested-conditional -- easier to read than the alternative */\n\t\tconst filename = isString(arg0) ? arg0 : isString(arg1) ? arg1 : arg2; // eslint-disable-line sonarjs/no-nested-conditional -- easier to read than the alternative */\n\t\treturn toHTMLValidateImpl.call(this, expect, diff, markup, message, config, filename);\n\t}\n\treturn diverge(toHTMLValidate);\n}\n\n/* eslint-disable-next-line @typescript-eslint/max-params -- technical debt */\nfunction toHTMLValidateImpl(\n\tthis: MatcherContext,\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n\tactual: string,\n\texpectedError?: Partial<Message>,\n\tuserConfig?: ConfigData,\n\tfilename?: string,\n): MatcherResult {\n\tconst defaultConfig = {\n\t\trules: {\n\t\t\t/* jsdom normalizes style so disabling rule when using this matcher or it\n\t\t\t * gets quite noisy when configured with self-closing */\n\t\t\t\"void-style\": \"off\",\n\t\t},\n\t};\n\tconst config = deepmerge(defaultConfig, userConfig ?? {});\n\t/* istanbul ignore next: cant figure out when this would be unset */\n\tconst actualFilename = filename ?? this.testPath ?? \"inline\";\n\n\tconst syncFn = createSyncFn<ValidateStringFn>(workerPath);\n\tconst report = syncFn(actual, actualFilename, config);\n\tconst pass = report.valid;\n\tconst result = report.results[0];\n\tif (pass) {\n\t\treturn { pass, message: () => \"HTML is valid when an error was expected\" };\n\t} else {\n\t\tif (expectedError) {\n\t\t\tconst actual = result.messages;\n\t\t\tconst expected = expect.arrayContaining([expect.objectContaining(expectedError)]);\n\t\t\tconst errorPass = this.equals(actual, expected);\n\t\t\tconst diffString = diff\n\t\t\t\t? diff(expected, actual, {\n\t\t\t\t\t\texpand: this.expand,\n\t\t\t\t\t\taAnnotation: \"Expected error\",\n\t\t\t\t\t\tbAnnotation: \"Actual error\",\n\t\t\t\t\t})\n\t\t\t\t: /* istanbul ignore next */ undefined;\n\t\t\tconst hint = this.utils.matcherHint(\".not.toHTMLValidate\", undefined, undefined, {\n\t\t\t\tcomment: \"expected error\",\n\t\t\t});\n\t\t\tconst expectedErrorMessage = (): string =>\n\t\t\t\t[\n\t\t\t\t\thint,\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"Expected error to be present:\",\n\t\t\t\t\tthis.utils.printExpected(expectedError),\n\t\t\t\t\t/* istanbul ignore next */ diffString ? `\\n${diffString}` : \"\",\n\t\t\t\t].join(\"\\n\");\n\t\t\treturn { pass: !errorPass, message: expectedErrorMessage, actual, expected };\n\t\t}\n\n\t\tconst errors = result.messages.map((message) => ` ${message.message} [${message.ruleId}]`);\n\t\treturn {\n\t\t\tpass,\n\t\t\tmessage: () =>\n\t\t\t\t[\"Expected HTML to be valid but had the following errors:\", \"\"].concat(errors).join(\"\\n\"),\n\t\t};\n\t}\n}\n\nexport { createMatcher as toHTMLValidate };\n","import { type Message } from \"../../message\";\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype DiffFunction,\n\ttype MatcherContext,\n\ttype MatcherExpect,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n} from \"../utils\";\nimport { flattenMessages } from \"../utils/flatten-messages\";\n\nfunction toHaveErrorImpl(\n\tcontext: MatcherContext,\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n\tactual: Report,\n\texpected: Partial<Message>,\n): MatcherResult {\n\tconst flattened = flattenMessages(actual);\n\tconst matcher = [expect.objectContaining(expected)];\n\tconst pass = context.equals(flattened, matcher);\n\tconst diffString = diff\n\t\t? diff(matcher, flattened, { expand: context.expand })\n\t\t: /* istanbul ignore next */ undefined;\n\tconst hint = context.utils.matcherHint(\".toHaveError\");\n\tconst prettyExpected = context.utils.printExpected(matcher);\n\tconst prettyReceived = context.utils.printReceived(flattened);\n\tconst resultMessage = (): string => {\n\t\treturn [\n\t\t\thint,\n\t\t\t\"\",\n\t\t\t\"Expected error to equal:\",\n\t\t\t` ${prettyExpected}`,\n\t\t\t\"Received:\",\n\t\t\t` ${prettyReceived}`,\n\t\t\t/* istanbul ignore next */ diffString ? `\\nDifference:\\n\\n${diffString}` : \"\",\n\t\t].join(\"\\n\");\n\t};\n\treturn { pass, message: resultMessage, actual: flattened, expected: matcher };\n}\n\nfunction createMatcher(\n\texpect: MatcherExpect,\n\tdiff: DiffFunction | undefined,\n):\n\t| MaybeAsyncCallback<Report, [Partial<Message>]>\n\t| MaybeAsyncCallback<Report, [string, string, unknown?]> {\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?: unknown,\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?: unknown,\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\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 { type Report, type Result } from \"../../reporter\";\nimport { type ValidateStringFn, createSyncFn, workerPath } from \"../worker\";\n\n/**\n * @internal\n */\nexport function getResults(filename: string, value: Report | string): Result[] {\n\tif (typeof value === \"string\") {\n\t\tconst syncFn = createSyncFn<ValidateStringFn>(workerPath);\n\t\tconst report = syncFn(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,eAAA,GAAgD;AACxD,EAAA,SAAS,UAAU,MAAA,EAA+B;AACjD,IAAA,IAAI,OAAO,KAAA,EAAO;AACjB,MAAA,OAAO;AAAA,QACN,IAAA,EAAM,IAAA;AAAA,QACN,OAAA;AAAA;AAAA,UAAoC,MAAM;AAAA;AAAA,OAC3C;AAAA,IACD,CAAA,MAAO;AACN,MAAA,MAAM,aAAa,MAAA,CAAO,OAAA,CAAQ,CAAC,CAAA,CAAE,SAAS,CAAC,CAAA;AAC/C,MAAA,OAAO;AAAA,QACN,IAAA,EAAM,KAAA;AAAA,QACN,OAAA,EAAS,MAAM,CAAA,sCAAA,EAAyC,UAAA,CAAW,OAAO,CAAA,CAAA;AAAA,OAC3E;AAAA,IACD;AAAA,EACD;AACA,EAAA,OAAO,QAAQ,SAAS,CAAA;AACzB;;AChBA,SAASA,eAAA,G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AA,EAAU,QAAA,EAAS;AAAA,IACpC,CAAC,CAAA;AAAA,EACF,CAAA,MAAO;AACN,IAAA,OAAO,KAAA,CAAM,OAAA;AAAA,EACd;AACD;;;;"}
@@ -1,9 +1,6 @@
1
1
  import { expect } from 'vitest';
2
2
  import { c as createMatcher, a as createMatcher$1, b as createMatcher$2, d as createMatcher$3, e as createMatcher$4 } from './matchers.js';
3
3
  import './matcher-utils.js';
4
- import 'node:worker_threads';
5
- import './core-nodejs.js';
6
- import 'node:fs';
7
4
  import './core.js';
8
5
  import 'ajv';
9
6
  import './elements.js';
@@ -13,6 +10,9 @@ import '@sidvind/better-ajv-errors';
13
10
  import 'kleur';
14
11
  import '@html-validate/stylish';
15
12
  import 'semver';
13
+ import 'node:worker_threads';
14
+ import './core-nodejs.js';
15
+ import 'node:fs';
16
16
  import 'node:path';
17
17
  import 'node:fs/promises';
18
18
  import 'node:url';
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.58.0"
8
+ "packageVersion": "7.58.2"
9
9
  }
10
10
  ]
11
11
  }
@@ -521,7 +521,7 @@ export declare class DOMNode {
521
521
  * @returns value or `undefined` if the value doesn't exist.
522
522
  */
523
523
  cacheGet<K extends keyof DOMNodeCache>(key: K): DOMNodeCache[K] | undefined;
524
- cacheGet(key: string | number | symbol): any | undefined;
524
+ cacheGet(key: string | number | symbol): unknown;
525
525
  /**
526
526
  * Store a value in cache.
527
527
  *
@@ -1436,7 +1436,7 @@ export declare interface Message {
1436
1436
  *
1437
1437
  * This context can be passed to [[HtmlValidate#getRuleDocumentation]].
1438
1438
  */
1439
- context?: any;
1439
+ context?: unknown;
1440
1440
  }
1441
1441
 
1442
1442
  /**
@@ -619,7 +619,7 @@ export declare class DOMNode {
619
619
  * @returns value or `undefined` if the value doesn't exist.
620
620
  */
621
621
  cacheGet<K extends keyof DOMNodeCache>(key: K): DOMNodeCache[K] | undefined;
622
- cacheGet(key: string | number | symbol): any | undefined;
622
+ cacheGet(key: string | number | symbol): unknown;
623
623
  /**
624
624
  * Store a value in cache.
625
625
  *
@@ -1679,7 +1679,7 @@ export declare interface Message {
1679
1679
  *
1680
1680
  * This context can be passed to [[HtmlValidate#getRuleDocumentation]].
1681
1681
  */
1682
- context?: any;
1682
+ context?: unknown;
1683
1683
  }
1684
1684
 
1685
1685
  /**
@@ -9,8 +9,8 @@ declare module "expect" {
9
9
  toBeValid(): R;
10
10
  toBeInvalid(): R;
11
11
  toHaveError(error: Partial<Message>): R;
12
- toHaveError(ruleId: string, message: string, context?: any): R;
13
- toHaveErrors(errors: Array<[string, string] | Record<string, unknown>>): R;
12
+ toHaveError(ruleId: string, message: unknown, context?: unknown): R;
13
+ toHaveErrors(errors: Array<[string, unknown] | Record<string, unknown>>): R;
14
14
  /**
15
15
  * Validate string or HTMLElement.
16
16
  *
@@ -42,8 +42,8 @@ declare global {
42
42
  toBeValid(): R;
43
43
  toBeInvalid(): R;
44
44
  toHaveError(error: Partial<Message>): R;
45
- toHaveError(ruleId: string, message: string, context?: any): R;
46
- toHaveErrors(errors: Array<[string, string] | Record<string, unknown>>): R;
45
+ toHaveError(ruleId: string, message: unknown, context?: unknown): R;
46
+ toHaveErrors(errors: Array<[string, unknown] | Record<string, unknown>>): R;
47
47
  /**
48
48
  * Validate string or HTMLElement.
49
49
  *
@@ -22,7 +22,7 @@ declare module "vitest" {
22
22
  /**
23
23
  * @since 8.5.0
24
24
  */
25
- toHaveError(ruleId: string, message: string, context?: any): T;
25
+ toHaveError(ruleId: string, message: string, context?: unknown): T;
26
26
  /**
27
27
  * @since 8.5.0
28
28
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "html-validate",
3
- "version": "10.11.3",
3
+ "version": "10.12.1",
4
4
  "description": "Offline HTML5 validator and linter",
5
5
  "keywords": [
6
6
  "html",
@@ -89,7 +89,7 @@
89
89
  "dist"
90
90
  ],
91
91
  "dependencies": {
92
- "@html-validate/stylish": "^5.0.0",
92
+ "@html-validate/stylish": "^5.2.0",
93
93
  "@sidvind/better-ajv-errors": "4.0.1",
94
94
  "ajv": "^8.0.0",
95
95
  "glob": "^13.0.0",
@@ -99,12 +99,16 @@
99
99
  "semver": "^7.0.0"
100
100
  },
101
101
  "peerDependencies": {
102
+ "@jest/globals": "^28.1.3 || ^29.0.3 || ^30.0.0",
102
103
  "jest": "^28.1.3 || ^29.0.3 || ^30.0.0",
103
104
  "jest-diff": "^28.1.3 || ^29.0.3 || ^30.0.0",
104
105
  "jest-snapshot": "^28.1.3 || ^29.0.3 || ^30.0.0",
105
106
  "vitest": "^1.0.0 || ^2.0.0 || ^3.0.0 || ^4.0.1"
106
107
  },
107
108
  "peerDependenciesMeta": {
109
+ "@jest/globals": {
110
+ "optional": true
111
+ },
108
112
  "jest": {
109
113
  "optional": true
110
114
  },
@@ -119,6 +123,6 @@
119
123
  }
120
124
  },
121
125
  "engines": {
122
- "node": "^20.19.0 || >= 22.16.0"
126
+ "node": "^20.19.0 || ^22.16.0 || >= 24.0.0"
123
127
  }
124
128
  }