html-validate 9.6.1 → 9.7.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.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 +151 -77
- package/dist/cjs/core.js.map +1 -1
- package/dist/cjs/elements.js +1 -0
- package/dist/cjs/elements.js.map +1 -1
- package/dist/cjs/html-validate.js.map +1 -1
- package/dist/cjs/html5.js.map +1 -1
- package/dist/cjs/jest-diff.js.map +1 -1
- package/dist/cjs/jest-worker.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/utils/natural-join.js.map +1 -1
- package/dist/cjs/vitest.js.map +1 -1
- 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 +151 -77
- package/dist/es/core.js.map +1 -1
- package/dist/es/elements.js +1 -0
- package/dist/es/elements.js.map +1 -1
- package/dist/es/html-validate.js.map +1 -1
- package/dist/es/html5.js.map +1 -1
- package/dist/es/jest-diff.js.map +1 -1
- package/dist/es/jest-worker.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/utils/natural-join.js.map +1 -1
- package/dist/es/vitest.js.map +1 -1
- package/dist/schema/elements.json +6 -0
- package/dist/types/browser.d.ts +16 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/vitest.d.ts +1 -0
- package/elements/html5.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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 \"fs\";\nimport path from \"node:path\";\nimport kleur from \"kleur\";\nimport minimist from \"minimist\";\nimport { type UserErrorData, SchemaValidationError, isUserError } from \"..\";\nimport { name, version, bugs as pkgBugs } from \"../generated/package\";\nimport { CLI } from \"./cli\";\nimport { handleSchemaValidationError, ImportResolveMissingError } 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\";\nimport { haveImportMetaResolve } from \"./have-import-meta-resolve\";\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 (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\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 = 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 (isNaN(maxWarnings)) {\n\t\tconsole.log(`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\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 (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,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,iBAAiB,IAAqB,EAAA;AAC9C,EAAA,QAAQ,IAAM;AAAA,IACb,KAAK,IAAK,CAAA,IAAA;AACT,MAAO,OAAA,IAAA;AAAA,IACR,KAAK,IAAK,CAAA,IAAA;AACT,MAAO,O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b,IAAA,IAAI,eAAe,qBAAuB,EAAA;AACzC,MAAA,2BAAA,CAA4B,SAAS,GAAG,CAAA;AAAA,KACzC,MAAA,IAAW,WAAY,CAAA,GAAG,CAAG,EAAA;AAC5B,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"}
|
|
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 \"fs\";\nimport path from \"node:path\";\nimport kleur from \"kleur\";\nimport minimist from \"minimist\";\nimport { type UserErrorData, SchemaValidationError, isUserError } from \"..\";\nimport { name, version, bugs as pkgBugs } from \"../generated/package\";\nimport { CLI } from \"./cli\";\nimport { handleSchemaValidationError, ImportResolveMissingError } 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\";\nimport { haveImportMetaResolve } from \"./have-import-meta-resolve\";\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 (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\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 = 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 (isNaN(maxWarnings)) {\n\t\tconsole.log(`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\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 (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,MAAK,IAAA,EAAM;AACd,IAAA,OAAO,IAAA,CAAK,IAAA;AAAA;AAGb,EAAA,IAAIA,KAAAA,CAAK,aAAa,CAAA,EAAG;AACxB,IAAA,OAAO,IAAA,CAAK,WAAA;AAAA;AAGb,EAAA,IAAIA,KAAAA,CAAK,aAAa,CAAA,EAAG;AACxB,IAAA,OAAO,IAAA,CAAK,WAAA;AAAA;AAGb,EAAA,IAAIA,KAAAA,CAAK,aAAa,CAA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Q,MAAA,EAAQ,EAAE,GAAA,EAAK,OAAA,CAAQ,GAAA,EAAI,EAAG,CAAA;AAAA,KACjE,MAAA,IAAW,IAAA,KAAS,IAAA,CAAK,YAAA,EAAc;AACtC,MAAA,OAAA,GAAU,MAAM,WAAA,CAAY,YAAA,EAAc,OAAA,CAAQ,QAAQ,KAAK,CAAA;AAAA,KAChE,MAAO;AACN,MAAA,OAAA,GAAU,MAAM,IAAA,CAAK,YAAA,EAAc,OAAA,CAAQ,MAAA,EAAQ,OAAO,IAAI,CAAA;AAAA;AAE/D,IAAA,OAAA,CAAQ,IAAA,CAAK,OAAA,GAAU,CAAA,GAAI,CAAC,CAAA;AAAA,WACpB,GAAA,EAAK;AACb,IAAA,IAAI,eAAe,qBAAA,EAAuB;AACzC,MAAA,2BAAA,CAA4B,SAAS,GAAG,CAAA;AAAA,KACzC,MAAA,IAAW,WAAA,CAAY,GAAG,CAAA,EAAG;AAC5B,MAAA,eAAA,CAAgB,GAAG,CAAA;AAAA,KACpB,MAAO;AACN,MAAA,kBAAA,CAAmB,GAAG,CAAA;AAAA;AAEvB,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA;AAEhB;AAEA,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"}
|
package/dist/es/html5.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html5.js","sources":["../../src/html5.ts"],"sourcesContent":["import { bundledElements } from \"./elements\";\n\nexport default bundledElements.html5;\n"],"names":[],"mappings":";;;;AAEA,YAAe,
|
|
1
|
+
{"version":3,"file":"html5.js","sources":["../../src/html5.ts"],"sourcesContent":["import { bundledElements } from \"./elements\";\n\nexport default bundledElements.html5;\n"],"names":[],"mappings":";;;;AAEA,YAAe,eAAA,CAAgB,KAAA;;;;"}
|
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 --\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","jestDiff"],"mappings":";;;AAwBA,MAAM,
|
|
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,\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","jestDiff"],"mappings":";;;AAwBA,MAAM,cAAA,GAAkD;AAAA;AAAA,EAEvDA,wBAAA,EAAiB,IAAA;AAAA;AAAA,EAEjBA,wBAAA;AAAA;AAAA,EAEAC,eAAA,EAAU,IAAA;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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jest-worker.js","sources":["../../src/jest/worker/worker.ts"],"sourcesContent":["import { type MessagePort, parentPort, workerData } from \"node:worker_threads\";\nimport { type ConfigData } from \"../../config\";\nimport { FileSystemConfigLoader } from \"../../config/loaders/file-system\";\nimport { HtmlValidate } from \"../../htmlvalidate\";\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype AnyAsyncFn,\n\ttype MainToWorkerCommandMessage,\n\ttype MainToWorkerMessage,\n\ttype WorkerToMainMessage,\n} from \"./types\";\n\ninterface WorkerData {\n\tsharedBuffer: SharedArrayBuffer;\n\tworkerPort: MessagePort;\n}\n\n/* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- false positive, it is used in nested functions */\nfunction runAsWorker<R = unknown, T extends AnyAsyncFn<R> = AnyAsyncFn<R>>(fn: T): void {\n\tif (!workerData) {\n\t\treturn;\n\t}\n\n\tconst { workerPort, sharedBuffer } = workerData as WorkerData;\n\tconst sharedBufferView = new Int32Array(sharedBuffer, 0, 1);\n\n\t/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- better crash at runtime if not set */\n\tparentPort!.on(\"message\", ({ id, args }: MainToWorkerMessage<Parameters<T>>) => {\n\t\tasync function inner(): Promise<void> {\n\t\t\tlet isAborted = false;\n\t\t\tconst handleAbortMessage = (msg: MainToWorkerCommandMessage): void => {\n\t\t\t\tif (msg.id === id && msg.cmd === \"abort\") {\n\t\t\t\t\tisAborted = true;\n\t\t\t\t}\n\t\t\t};\n\t\t\tworkerPort.on(\"message\", handleAbortMessage);\n\t\t\tlet msg: WorkerToMainMessage<R>;\n\t\t\ttry {\n\t\t\t\tmsg = { id, result: await fn(...args) };\n\t\t\t} catch (error: unknown) {\n\t\t\t\tmsg = {\n\t\t\t\t\tid,\n\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t};\n\t\t\t}\n\t\t\tworkerPort.off(\"message\", handleAbortMessage);\n\n\t\t\tif (isAborted) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tworkerPort.postMessage(msg);\n\t\t\tAtomics.add(sharedBufferView, 0, 1);\n\t\t\tAtomics.notify(sharedBufferView, 0);\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises -- should not happen\n\t\tinner();\n\t});\n}\n\nfunction validateString(markup: string, filename: string, config: ConfigData): Promise<Report> {\n\tconst loader = new FileSystemConfigLoader({\n\t\textends: [\"html-validate:recommended\"],\n\t});\n\tconst htmlvalidate = new HtmlValidate(loader);\n\treturn htmlvalidate.validateString(markup, filename, config);\n}\n\nexport type ValidateStringFn = typeof validateString;\n\nrunAsWorker(validateString);\n"],"names":["msg"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,SAAS,YAAkE,EAAa
|
|
1
|
+
{"version":3,"file":"jest-worker.js","sources":["../../src/jest/worker/worker.ts"],"sourcesContent":["import { type MessagePort, parentPort, workerData } from \"node:worker_threads\";\nimport { type ConfigData } from \"../../config\";\nimport { FileSystemConfigLoader } from \"../../config/loaders/file-system\";\nimport { HtmlValidate } from \"../../htmlvalidate\";\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype AnyAsyncFn,\n\ttype MainToWorkerCommandMessage,\n\ttype MainToWorkerMessage,\n\ttype WorkerToMainMessage,\n} from \"./types\";\n\ninterface WorkerData {\n\tsharedBuffer: SharedArrayBuffer;\n\tworkerPort: MessagePort;\n}\n\n/* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- false positive, it is used in nested functions */\nfunction runAsWorker<R = unknown, T extends AnyAsyncFn<R> = AnyAsyncFn<R>>(fn: T): void {\n\tif (!workerData) {\n\t\treturn;\n\t}\n\n\tconst { workerPort, sharedBuffer } = workerData as WorkerData;\n\tconst sharedBufferView = new Int32Array(sharedBuffer, 0, 1);\n\n\t/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- better crash at runtime if not set */\n\tparentPort!.on(\"message\", ({ id, args }: MainToWorkerMessage<Parameters<T>>) => {\n\t\tasync function inner(): Promise<void> {\n\t\t\tlet isAborted = false;\n\t\t\tconst handleAbortMessage = (msg: MainToWorkerCommandMessage): void => {\n\t\t\t\tif (msg.id === id && msg.cmd === \"abort\") {\n\t\t\t\t\tisAborted = true;\n\t\t\t\t}\n\t\t\t};\n\t\t\tworkerPort.on(\"message\", handleAbortMessage);\n\t\t\tlet msg: WorkerToMainMessage<R>;\n\t\t\ttry {\n\t\t\t\tmsg = { id, result: await fn(...args) };\n\t\t\t} catch (error: unknown) {\n\t\t\t\tmsg = {\n\t\t\t\t\tid,\n\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t};\n\t\t\t}\n\t\t\tworkerPort.off(\"message\", handleAbortMessage);\n\n\t\t\tif (isAborted) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tworkerPort.postMessage(msg);\n\t\t\tAtomics.add(sharedBufferView, 0, 1);\n\t\t\tAtomics.notify(sharedBufferView, 0);\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises -- should not happen\n\t\tinner();\n\t});\n}\n\nfunction validateString(markup: string, filename: string, config: ConfigData): Promise<Report> {\n\tconst loader = new FileSystemConfigLoader({\n\t\textends: [\"html-validate:recommended\"],\n\t});\n\tconst htmlvalidate = new HtmlValidate(loader);\n\treturn htmlvalidate.validateString(markup, filename, config);\n}\n\nexport type ValidateStringFn = typeof validateString;\n\nrunAsWorker(validateString);\n"],"names":["msg"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,SAAS,YAAkE,EAAA,EAAa;AACvF,EAAA,IAAI,CAAC,UAAA,EAAY;AAChB,IAAA;AAAA;AAGD,EAAA,MAAM,EAAE,UAAA,EAAY,YAAA,EAAa,GAAI,UAAA;AACrC,EAAA,MAAM,gBAAA,GAAmB,IAAI,UAAA,CAAW,YAAA,EAAc,GAAG,CAAC,CAAA;AAG1D,EAAA,UAAA,CAAY,GAAG,SAAA,EAAW,CAAC,EAAE,EAAA,EAAI,MAAK,KAA0C;AAC/E,IAAA,eAAe,KAAA,GAAuB;AACrC,MAAA,IAAI,SAAA,GAAY,KAAA;AAChB,MAAA,MAAM,kBAAA,GAAqB,CAACA,IAAAA,KAA0C;AACrE,QAAA,IAAIA,IAAAA,CAAI,EAAA,KAAO,EAAA,IAAMA,IAAAA,CAAI,QAAQ,OAAA,EAAS;AACzC,UAAA,SAAA,GAAY,IAAA;AAAA;AACb,OACD;AACA,MAAA,UAAA,CAAW,EAAA,CAAG,WAAW,kBAAkB,CAAA;AAC3C,MAAA,IAAI,GAAA;AACJ,MAAA,IAAI;AACH,QAAA,GAAA,GAAM,EAAE,EAAA,EAAI,MAAA,EAAQ,MAAM,EAAA,CAAG,GAAG,IAAI,CAAA,EAAE;AAAA,eAC9B,KAAA,EAAgB;AACxB,QAAA,GAAA,GAAM;AAAA,UACL,EAAA;AAAA,UACA,OAAO,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,OAAA,GAAU,OAAO,KAAK;AAAA,SAC7D;AAAA;AAED,MAAA,UAAA,CAAW,GAAA,CAAI,WAAW,kBAAkB,CAAA;AAE5C,MAAA,IAAI,SAAA,EAAW;AACd,QAAA;AAAA;AAED,MAAA,UAAA,CAAW,YAAY,GAAG,CAAA;AAC1B,MAAA,OAAA,CAAQ,GAAA,CAAI,gBAAA,EAAkB,CAAA,EAAG,CAAC,CAAA;AAClC,MAAA,OAAA,CAAQ,MAAA,CAAO,kBAAkB,CAAC,CAAA;AAAA;AAGnC,IAAA,KAAA,EAAM;AAAA,GACN,CAAA;AACF;AAEA,SAAS,cAAA,CAAe,MAAA,EAAgB,QAAA,EAAkB,MAAA,EAAqC;AAC9F,EAAA,MAAM,MAAA,GAAS,IAAI,sBAAA,CAAuB;AAAA,IACzC,OAAA,EAAS,CAAC,2BAA2B;AAAA,GACrC,CAAA;AACD,EAAA,MAAM,YAAA,GAAe,IAAI,YAAA,CAAa,MAAM,CAAA;AAC5C,EAAA,OAAO,YAAA,CAAa,cAAA,CAAe,MAAA,EAAQ,QAAA,EAAU,MAAM,CAAA;AAC5D;AAIA,WAAA,CAAY,cAAc,CAAA"}
|
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,
|
|
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,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 +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,
|
|
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,KAClE,MAAO;AACN,MAAA,OAAO,EAAA,CAAG,IAAA,CAAK,IAAA,EAAM,MAAA,EAAQ,GAAG,IAAI,CAAA;AAAA;AACrC;AAED,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,GACzC,EAAG,EAAE,CAAA;AACN;;ACYA,MAAM,WAAA,GAAc,CAAA;AACpB,MAAM,WAAA,uBAAkB,GAAA,EAAmB;AAC3C,MAAM,YAAA,GAAe,IAAI,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-
{"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,
|
|
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,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,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AAA,EAAG;AACvB,MAAA,OAAO,MAAA,CAAO,KAAK,CAAC,QAAA,KAAa,2BAA2B,OAAA,EAAS,QAAA,EAAU,GAAG,IAAI,CAAC,CAAA;AAAA,KACxF,MAAO;AACN,MAAA,OAAO,0BAAA,CAA2B,OAAA,EAAS,MAAA,EAAQ,GAAG,IAAI,CAAA;AAAA;AAC3D;AAGD,EAAA,OAAO,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 { type Message } from \"../../message\";\nimport {\n\ttype DiffFunction,\n\ttype MatcherContext,\n\ttype MatcherExpect,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n} from \"../utils\";\nimport { type ValidateStringFn, createSyncFn, workerPath } from \"../worker\";\n\nfunction isMessage(arg: any): arg is Partial<Message> {\n\tif (!arg) {\n\t\treturn false;\n\t}\n\treturn Boolean(\n\t\targ.ruleId ??\n\t\t\targ.severity ??\n\t\t\targ.message ??\n\t\t\targ.offset ??\n\t\t\targ.line ??\n\t\t\targ.column ??\n\t\t\targ.size ??\n\t\t\targ.selector ??\n\t\t\targ.context,\n\t);\n}\n\nfunction isConfig(arg: any): arg is ConfigData {\n\tif (!arg) {\n\t\treturn false;\n\t}\n\treturn Boolean(\n\t\targ.root ?? arg.extends ?? arg.elements ?? arg.plugin ?? arg.transform ?? arg.rules,\n\t);\n}\n\nfunction isString(arg: any): arg is string {\n\treturn typeof arg === \"string\";\n}\n\nfunction getMarkup(src: unknown): string {\n\tif (typeof HTMLElement !== \"undefined\" && src instanceof HTMLElement) {\n\t\treturn (src as { outerHTML: string }).outerHTML;\n\t}\n\t/* istanbul ignore else: prototype only allows string or HTMLElement */\n\tif (typeof src === \"string\") {\n\t\treturn src;\n\t} else {\n\t\tthrow new Error(`Failed to get markup from \"${typeof src}\" argument`);\n\t}\n}\n\ntype Arg1 = Partial<Message> | ConfigData | string;\ntype Arg2 = ConfigData | string;\ntype Arg3 = string; /* eslint-disable-line sonarjs/redundant-type-aliases -- for consistency */\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\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});\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QAAQ,YAAY,CAAA;AAC5B;;ACzCgB,SAAA,UAAA,CAAW,UAAkB,KAAkC,EAAA;AAC9E,EAAI,IAAA,OAAO,UAAU,QAAU,EAAA;AAC9B,IAAM,MAAA,MAAA,GAAS,aAA+B,UAAU,CAAA;AACxD,IAAM,MAAA,MAAA,GAAS,MAAO,CAAA,KAAA,EAAO,QAAU,EAAA;AAAA,MACtC,KAAO,EAAA;AAAA,QACN,YAAc,EAAA;AAAA;AACf,KACA,CAAA;AACD,IAAA,OAAO,MAAO,CAAA,OAAA,CAAQ,GAAI,CAAA,CAAC,EAAO,KAAA;AACjC,MAAA,OAAO,EAAE,GAAG,EAAI,EAAA,QAAA,EAAU,QAAS,EAAA;AAAA,KACnC,CAAA;AAAA,GACK,MAAA;AACN,IAAA,OAAO,KAAM,CAAA,OAAA;AAAA;AAEf;;;;"}
|
|
1
|
+
{"version":3,"file":"matchers.js","sources":["../../src/jest/matchers/to-be-valid.ts","../../src/jest/matchers/to-be-invalid.ts","../../src/jest/matchers/to-htmlvalidate.ts","../../src/jest/matchers/to-have-error.ts","../../src/jest/matchers/to-have-errors.ts","../../src/jest/matchers/get-results.ts"],"sourcesContent":["import { type Report } from \"../../reporter\";\nimport { type MatcherResult, type MaybeAsyncCallback, diverge } from \"../utils\";\n\nfunction createMatcher(): MaybeAsyncCallback<Report, []> {\n\tfunction toBeValid(report: Report): MatcherResult {\n\t\tif (report.valid) {\n\t\t\treturn {\n\t\t\t\tpass: true,\n\t\t\t\tmessage: /* istanbul ignore next */ () => \"Result should not contain error\",\n\t\t\t};\n\t\t} else {\n\t\t\tconst firstError = report.results[0].messages[0];\n\t\t\treturn {\n\t\t\t\tpass: false,\n\t\t\t\tmessage: () => `Result should be valid but had error \"${firstError.message}\"`,\n\t\t\t};\n\t\t}\n\t}\n\treturn diverge(toBeValid);\n}\n\nexport { createMatcher as toBeValid };\n","import { type Report } from \"../../reporter\";\nimport { type MatcherResult, type MaybeAsyncCallback, diverge } from \"../utils\";\n\nfunction createMatcher(): MaybeAsyncCallback<Report, []> {\n\tfunction toBeInvalid(report: Report): MatcherResult {\n\t\tif (report.valid) {\n\t\t\treturn {\n\t\t\t\tpass: false,\n\t\t\t\tmessage: () => \"Result should be invalid but had no errors\",\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tpass: true,\n\t\t\t\tmessage: /* istanbul ignore next */ () => \"Result should not contain error\",\n\t\t\t};\n\t\t}\n\t}\n\treturn diverge(toBeInvalid);\n}\n\nexport { createMatcher as toBeInvalid };\n","import deepmerge from \"deepmerge\";\nimport { type ConfigData } from \"../../config\";\nimport { type Message } from \"../../message\";\nimport {\n\ttype DiffFunction,\n\ttype MatcherContext,\n\ttype MatcherExpect,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n} from \"../utils\";\nimport { type ValidateStringFn, createSyncFn, workerPath } from \"../worker\";\n\nfunction isMessage(arg: any): arg is Partial<Message> {\n\tif (!arg) {\n\t\treturn false;\n\t}\n\treturn Boolean(\n\t\targ.ruleId ??\n\t\t\targ.severity ??\n\t\t\targ.message ??\n\t\t\targ.offset ??\n\t\t\targ.line ??\n\t\t\targ.column ??\n\t\t\targ.size ??\n\t\t\targ.selector ??\n\t\t\targ.context,\n\t);\n}\n\nfunction isConfig(arg: any): arg is ConfigData {\n\tif (!arg) {\n\t\treturn false;\n\t}\n\treturn Boolean(\n\t\targ.root ?? arg.extends ?? arg.elements ?? arg.plugin ?? arg.transform ?? arg.rules,\n\t);\n}\n\nfunction isString(arg: any): arg is string {\n\treturn typeof arg === \"string\";\n}\n\nfunction getMarkup(src: unknown): string {\n\tif (typeof HTMLElement !== \"undefined\" && src instanceof HTMLElement) {\n\t\treturn (src as { outerHTML: string }).outerHTML;\n\t}\n\t/* istanbul ignore else: prototype only allows string or HTMLElement */\n\tif (typeof src === \"string\") {\n\t\treturn src;\n\t} else {\n\t\tthrow new Error(`Failed to get markup from \"${typeof src}\" argument`);\n\t}\n}\n\ntype Arg1 = Partial<Message> | ConfigData | string;\ntype Arg2 = ConfigData | string;\ntype Arg3 = string; /* eslint-disable-line sonarjs/redundant-type-aliases -- for consistency */\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\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,KACD,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;AACD;AAED,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,KACD,MAAO;AACN,MAAA,OAAO;AAAA,QACN,IAAA,EAAM,IAAA;AAAA,QACN,OAAA;AAAA;AAAA,UAAoC,MAAM;AAAA;AAAA,OAC3C;AAAA;AACD;AAED,EAAA,OAAO,QAAQ,WAAW,CAAA;AAC3B;;ACLA,SAAS,UAAU,GAAA,EAAmC;AACrD,EAAA,IAAI,CAAC,GAAA,EAAK;AACT,IAAA,OAAO,KAA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AK,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;AAEvC,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,KACnC,CAAA;AAAA,GACF,MAAO;AACN,IAAA,OAAO,KAAA,CAAM,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 ?? 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,
|
|
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 ?? 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,SAAA,EAAyC;AACvE,EAAA,OAAO,SAAA;AACR;;AC0BO,SAAS,+BAA+B,IAAA,EAAgB;AAC9D,EAAA,OAAO,CAAC,IAAA,KAA0B;AACjC,IAAA,IAAI,IAAA,CAAK,KAAK,CAAC,EAAA,KAAO,KAAK,YAAA,CAAa,EAAE,CAAC,CAAA,EAAG;AAC7C,MAAA,OAAO,IAAA;AAAA;AAER,IAAA,MAAM,QAAA,GAAW,YAAY,IAAA,CAAK,GAAA,CAAI,CAAC,EAAA,KAAO,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,CAAG,CAAC,CAAA;AACxD,IAAA,OAAO,YAAY,QAAQ,CAAA,wBAAA,CAAA;AAAA,GAC5B;AACD;AAKO,SAAS,8BAA8B,IAAA,EAA8C;AAC3F,EAAA,OAAO,CAAC,IAAA,KAA0B;AACjC,IAAA,MAAM,OAAA,GAAU,KAAK,MAAA,CAAO,CAAC,OAAO,IAAA,CAAK,YAAA,CAAa,EAAE,CAAC,CAAA;AACzD,IAAA,IAAI,OAAA,CAAQ,WAAW,CAAA,EAAG;AACzB,MAAA,OAAO,IAAA;AAAA;AAER,IAAA,MAAM,QAAA,GAAW,YAAY,OAAA,CAAQ,GAAA,CAAI,CAAC,EAAA,KAAO,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,CAAG,CAAC,CAAA;AAC3D,IAAA,OAAO,sCAAsC,QAAQ,CAAA,CAAA;AAAA,GACtD;AACD;AAKO,SAAS,2BACf,GAAA,EACA,aAAA,EACA,EAAE,YAAA,EAAa,GAAsC,EAAC,EACvB;AAC/B,EAAA,OAAO,CAAC,IAAA,KAA0B;AACjC,IAAA,MAAM,IAAA,GAAO,IAAA,CAAK,YAAA,CAAa,GAAG,CAAA;AAClC,IAAA,IAAI,IAAA,IAAQ,OAAO,IAAA,KAAS,QAAA,EAAU;AACrC,MAAA,OAAO,IAAA;AAAA;AAER,IAAA,MAAM,cAAc,IAAA,IAAQ,YAAA;AAC5B,IAAA,IAAI,eAAe,aAAA,CAAc,QAAA,CAAS,WAAA,CAAY,iBAAA,EAAmB,CAAA,EAAG;AAC3E,MAAA,OAAO,IAAA;AAAA;AAER,IAAA,MAAM,QAAA,GAAW,YAAY,aAAA,CAAc,GAAA,CAAI,CAAC,EAAA,KAAO,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,CAAG,CAAC,CAAA;AACjE,IAAA,OAAO,CAAA,CAAA,EAAI,GAAG,CAAA,oBAAA,EAAuB,QAAQ,CAAA,CAAA;AAAA,GAC9C;AACD;AAKO,SAAS,4BAEZ,IAAA,EAC4B;AAC/B,EAAA,OAAO,CAAC,IAAA,KAA0B;AACjC,IAAA,MAAM,KAAA,GAAQ,KAAK,IAAA,CAAK,CAAC,OAAO,IAAA,CAAK,OAAA,CAAQ,EAAE,CAAC,CAAA;AAChD,IAAA,IAAI,KAAA,EAAO;AACV,MAAA,OAAO,IAAA;AAAA;AAER,IAAA,MAAM,QAAA,GAAW,YAAY,IAAA,CAAK,GAAA,CAAI,CAAC,EAAA,KAAO,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,CAAG,CAAC,CAAA;AACxD,IAAA,OAAO,YAAY,QAAQ,CAAA,UAAA,CAAA;AAAA,GAC5B;AACD;AAKO,MAAM,cAAA,GAAiC;AAAA,EAC7C,2BAAA;AAAA,EACA,0BAAA;AAAA,EACA,0BAAA;AAAA,EACA;AACD;;;;"}
|
|
@@ -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":"
|
|
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":"AAaO,SAAS,WAAA,CAAY,MAAA,EAAkB,WAAA,GAAsB,IAAA,EAAc;AACjF,EAAA,QAAQ,OAAO,MAAA;AAAQ,IACtB,KAAK,CAAA;AACJ,MAAA,OAAO,EAAA;AAAA,IACR,KAAK,CAAA;AACJ,MAAA,OAAO,OAAO,CAAC,CAAA;AAAA,IAChB,KAAK,CAAA;AACJ,MAAA,OAAO,CAAA,EAAG,OAAO,CAAC,CAAC,IAAI,WAAW,CAAA,CAAA,EAAI,MAAA,CAAO,CAAC,CAAC,CAAA,CAAA;AAAA,IAChD;AACC,MAAA,OAAO,GAAG,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,EAAE,EAAE,IAAA,CAAK,IAAI,CAAC,CAAA,CAAA,EAAI,WAAW,CAAA,CAAA,EAAI,MAAA,CAAO,MAAM,EAAE,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,
|
|
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,MAAA,CAAO;AAAA,EACb,WAAWA,eAAA,EAAU;AAAA,EACrB,aAAaC,eAAA,EAAY;AAAA,EACzB,cAAA,EAAgBC,eAAA,CAAe,MAAA,EAAQ,MAAS,CAAA;AAAA,EAChD,WAAA,EAAaC,eAAA,CAAY,MAAA,EAAQ,MAAS,CAAA;AAAA,EAC1C,YAAA,EAAcC,aAAA,CAAa,MAAA,EAAQ,MAAS;AAC7C,CAAC,CAAA"}
|
|
@@ -130,6 +130,12 @@
|
|
|
130
130
|
"anyOf": [{ "type": "boolean" }, { "function": true }]
|
|
131
131
|
},
|
|
132
132
|
|
|
133
|
+
"templateRoot": {
|
|
134
|
+
"title": "Mark element as an element ignoring DOM ancestry, i.e. <template>.",
|
|
135
|
+
"description": "The <template> element can contain any elements.",
|
|
136
|
+
"type": "boolean"
|
|
137
|
+
},
|
|
138
|
+
|
|
133
139
|
"deprecatedAttributes": {
|
|
134
140
|
"title": "List of deprecated attributes",
|
|
135
141
|
"type": "array",
|
package/dist/types/browser.d.ts
CHANGED
|
@@ -1559,6 +1559,14 @@ export declare interface MetaData {
|
|
|
1559
1559
|
/** Mark element as a form-associated element */
|
|
1560
1560
|
formAssociated?: Partial<FormAssociated>;
|
|
1561
1561
|
labelable?: boolean | MetaLabelableCallback;
|
|
1562
|
+
/**
|
|
1563
|
+
* Set to `true` if this element should have no impact on DOM
|
|
1564
|
+
* ancestry. Default `false`.
|
|
1565
|
+
*
|
|
1566
|
+
* I.e., the `<template>` element (where allowed) can contain anything, as it
|
|
1567
|
+
* does not directly affect the DOM tree.
|
|
1568
|
+
*/
|
|
1569
|
+
templateRoot?: boolean;
|
|
1562
1570
|
/** @deprecated use {@link MetaAria.implicitRole} instead */
|
|
1563
1571
|
implicitRole?: MetaImplicitRoleCallback;
|
|
1564
1572
|
/** WAI-ARIA attributes */
|
|
@@ -1614,6 +1622,14 @@ export declare interface MetaElement extends Omit<MetaData, "deprecatedAttribute
|
|
|
1614
1622
|
tagName: string;
|
|
1615
1623
|
focusable: boolean | MetaFocusableCallback;
|
|
1616
1624
|
formAssociated?: FormAssociated;
|
|
1625
|
+
/**
|
|
1626
|
+
* Set to `true` if this element should have no impact on DOM
|
|
1627
|
+
* ancestry. Default `false`.
|
|
1628
|
+
*
|
|
1629
|
+
* I.e., the `<template>` element (where allowed) can contain anything. as it
|
|
1630
|
+
* does not directly affect the DOM tree.
|
|
1631
|
+
*/
|
|
1632
|
+
templateRoot: boolean;
|
|
1617
1633
|
/** @deprecated Use {@link MetaAria.implicitRole} instead */
|
|
1618
1634
|
implicitRole: MetaImplicitRoleCallback;
|
|
1619
1635
|
/** WAI-ARIA attributes */
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1799,6 +1799,14 @@ export declare interface MetaData {
|
|
|
1799
1799
|
/** Mark element as a form-associated element */
|
|
1800
1800
|
formAssociated?: Partial<FormAssociated>;
|
|
1801
1801
|
labelable?: boolean | MetaLabelableCallback;
|
|
1802
|
+
/**
|
|
1803
|
+
* Set to `true` if this element should have no impact on DOM
|
|
1804
|
+
* ancestry. Default `false`.
|
|
1805
|
+
*
|
|
1806
|
+
* I.e., the `<template>` element (where allowed) can contain anything, as it
|
|
1807
|
+
* does not directly affect the DOM tree.
|
|
1808
|
+
*/
|
|
1809
|
+
templateRoot?: boolean;
|
|
1802
1810
|
/** @deprecated use {@link MetaAria.implicitRole} instead */
|
|
1803
1811
|
implicitRole?: MetaImplicitRoleCallback;
|
|
1804
1812
|
/** WAI-ARIA attributes */
|
|
@@ -1854,6 +1862,14 @@ export declare interface MetaElement extends Omit<MetaData, "deprecatedAttribute
|
|
|
1854
1862
|
tagName: string;
|
|
1855
1863
|
focusable: boolean | MetaFocusableCallback;
|
|
1856
1864
|
formAssociated?: FormAssociated;
|
|
1865
|
+
/**
|
|
1866
|
+
* Set to `true` if this element should have no impact on DOM
|
|
1867
|
+
* ancestry. Default `false`.
|
|
1868
|
+
*
|
|
1869
|
+
* I.e., the `<template>` element (where allowed) can contain anything. as it
|
|
1870
|
+
* does not directly affect the DOM tree.
|
|
1871
|
+
*/
|
|
1872
|
+
templateRoot: boolean;
|
|
1857
1873
|
/** @deprecated Use {@link MetaAria.implicitRole} instead */
|
|
1858
1874
|
implicitRole: MetaImplicitRoleCallback;
|
|
1859
1875
|
/** WAI-ARIA attributes */
|
package/dist/types/vitest.d.ts
CHANGED
package/elements/html5.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const value:
|
|
1
|
+
declare const value: import("html-validate").MetaDataTable;
|
|
2
2
|
export default value;
|