html-validate 10.9.0 → 10.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/cjs/cli.js +10 -10
  2. package/dist/cjs/cli.js.map +1 -1
  3. package/dist/cjs/core-browser.js +1 -1
  4. package/dist/cjs/core-browser.js.map +1 -1
  5. package/dist/cjs/core-nodejs.js +1 -1
  6. package/dist/cjs/core-nodejs.js.map +1 -1
  7. package/dist/cjs/core.js +179 -120
  8. package/dist/cjs/core.js.map +1 -1
  9. package/dist/cjs/elements.js +24 -16
  10. package/dist/cjs/elements.js.map +1 -1
  11. package/dist/cjs/html-validate.js +23 -15
  12. package/dist/cjs/html-validate.js.map +1 -1
  13. package/dist/cjs/matchers-jestonly.js +2 -2
  14. package/dist/cjs/matchers-jestonly.js.map +1 -1
  15. package/dist/cjs/tsdoc-metadata.json +1 -1
  16. package/dist/cjs/utils/natural-join.js +1 -1
  17. package/dist/cjs/utils/natural-join.js.map +1 -1
  18. package/dist/esm/cli.js +10 -10
  19. package/dist/esm/cli.js.map +1 -1
  20. package/dist/esm/core-browser.js +1 -1
  21. package/dist/esm/core-browser.js.map +1 -1
  22. package/dist/esm/core-nodejs.js +1 -1
  23. package/dist/esm/core-nodejs.js.map +1 -1
  24. package/dist/esm/core.js +179 -120
  25. package/dist/esm/core.js.map +1 -1
  26. package/dist/esm/elements.js +24 -16
  27. package/dist/esm/elements.js.map +1 -1
  28. package/dist/esm/html-validate.js +24 -16
  29. package/dist/esm/html-validate.js.map +1 -1
  30. package/dist/esm/matchers-jestonly.js +2 -2
  31. package/dist/esm/matchers-jestonly.js.map +1 -1
  32. package/dist/esm/utils/natural-join.js +1 -1
  33. package/dist/esm/utils/natural-join.js.map +1 -1
  34. package/dist/schema/elements.json +6 -0
  35. package/dist/tsdoc-metadata.json +1 -1
  36. package/dist/types/browser.d.ts +24 -9
  37. package/dist/types/index.d.ts +24 -9
  38. package/package.json +3 -3
@@ -3,7 +3,7 @@ import path from 'node:path';
3
3
  import kleur from 'kleur';
4
4
  import minimist from 'minimist';
5
5
  import { a2 as name, v as version, y as SchemaValidationError, O as isUserError, a3 as bugs } from './core.js';
6
- import { M as Mode, m as modeToFlag, C as CLI, h as haveImportMetaResolve, I as ImportResolveMissingError, l as lint, i as init, p as printConfig, d as dump, a as handleSchemaValidationError } from './cli.js';
6
+ import { M as Mode, m as modeToFlag, C as CLI, h as haveImportMetaResolve, I as ImportResolveMissingError, d as dump, p as printConfig, i as init, l as lint, a as handleSchemaValidationError } from './cli.js';
7
7
  import 'ajv';
8
8
  import './elements.js';
9
9
  import './meta-helper.js';
@@ -195,7 +195,7 @@ if (argv._.length === 0) {
195
195
  process.exit(1);
196
196
  }
197
197
  }
198
- if (typeof argv.config !== "undefined") {
198
+ if (argv.config !== void 0) {
199
199
  const checkPath = path.resolve(argv.config);
200
200
  if (!fs.existsSync(checkPath)) {
201
201
  console.error(`The file "${argv.config}" was not found.`);
@@ -211,9 +211,9 @@ async function run() {
211
211
  });
212
212
  const mode = getMode(argv);
213
213
  const formatter = await cli.getFormatter(argv.formatter);
214
- const maxWarnings = parseInt(argv["max-warnings"] ?? "-1", 10);
214
+ const maxWarnings = Number.parseInt(argv["max-warnings"] ?? "-1", 10);
215
215
  const htmlvalidate = await cli.getValidator();
216
- if (isNaN(maxWarnings)) {
216
+ if (Number.isNaN(maxWarnings)) {
217
217
  console.error(`Invalid value "${String(argv["max-warnings"])}" given to --max-warnings`);
218
218
  process.exit(1);
219
219
  }
@@ -230,18 +230,26 @@ async function run() {
230
230
  throw new ImportResolveMissingError();
231
231
  }
232
232
  let success;
233
- if (mode === Mode.LINT) {
234
- success = await lint(htmlvalidate, process.stdout, files, {
235
- formatter,
236
- maxWarnings,
237
- stdinFilename: argv["stdin-filename"] ?? false
238
- });
239
- } else if (mode === Mode.INIT) {
240
- success = await init(cli, process.stdout, { cwd: process.cwd() });
241
- } else if (mode === Mode.PRINT_CONFIG) {
242
- success = await printConfig(htmlvalidate, process.stdout, files);
243
- } else {
244
- success = await dump(htmlvalidate, process.stdout, files, mode);
233
+ switch (mode) {
234
+ case Mode.LINT: {
235
+ success = await lint(htmlvalidate, process.stdout, files, {
236
+ formatter,
237
+ maxWarnings,
238
+ stdinFilename: argv["stdin-filename"] ?? false
239
+ });
240
+ break;
241
+ }
242
+ case Mode.INIT: {
243
+ success = await init(cli, process.stdout, { cwd: process.cwd() });
244
+ break;
245
+ }
246
+ case Mode.PRINT_CONFIG: {
247
+ success = await printConfig(htmlvalidate, process.stdout, files);
248
+ break;
249
+ }
250
+ default: {
251
+ success = await dump(htmlvalidate, process.stdout, files, mode);
252
+ }
245
253
  }
246
254
  process.exit(success ? 0 : 1);
247
255
  } catch (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"html-validate.js","sources":["../../src/cli/html-validate.ts"],"sourcesContent":["/* eslint-disable no-console, n/no-process-exit -- as expected from a cli app */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport kleur from \"kleur\";\nimport minimist from \"minimist\";\nimport { type UserErrorData, SchemaValidationError, isUserError } from \"..\";\nimport { bugs as pkgBugs, name, version } from \"../generated/package\";\nimport { dump } from \"./actions/dump\";\nimport { init } from \"./actions/init\";\nimport { lint } from \"./actions/lint\";\nimport { printConfig } from \"./actions/print-config\";\nimport { CLI } from \"./cli\";\nimport { ImportResolveMissingError, handleSchemaValidationError } from \"./errors\";\nimport { haveImportMetaResolve } from \"./have-import-meta-resolve\";\nimport { Mode, modeToFlag } from \"./mode\";\n\ninterface ParsedArgs {\n\tconfig?: string;\n\t\"dump-events\": boolean;\n\t\"dump-source\": boolean;\n\t\"dump-tokens\": boolean;\n\t\"dump-tree\": boolean;\n\text: string;\n\tformatter: string;\n\thelp: boolean;\n\tinit: boolean;\n\t\"max-warnings\"?: string;\n\tpreset?: string;\n\t\"print-config\": boolean;\n\trule?: string;\n\tstdin: boolean;\n\t\"stdin-filename\"?: string;\n\tversion: boolean;\n}\n\nfunction getMode(argv: Record<string, any>): Mode {\n\tif (argv[\"init\"]) {\n\t\treturn Mode.INIT;\n\t}\n\n\tif (argv[\"dump-events\"]) {\n\t\treturn Mode.DUMP_EVENTS;\n\t}\n\n\tif (argv[\"dump-source\"]) {\n\t\treturn Mode.DUMP_SOURCE;\n\t}\n\n\tif (argv[\"dump-tokens\"]) {\n\t\treturn Mode.DUMP_TOKENS;\n\t}\n\n\tif (argv[\"dump-tree\"]) {\n\t\treturn Mode.DUMP_TREE;\n\t}\n\n\tif (argv[\"print-config\"]) {\n\t\treturn Mode.PRINT_CONFIG;\n\t}\n\n\treturn Mode.LINT;\n}\n\nfunction requiresFilename(mode: Mode): boolean {\n\tswitch (mode) {\n\t\tcase Mode.LINT:\n\t\t\treturn true;\n\t\tcase Mode.INIT:\n\t\t\treturn false;\n\t\tcase Mode.DUMP_EVENTS:\n\t\tcase Mode.DUMP_TOKENS:\n\t\tcase Mode.DUMP_TREE:\n\t\tcase Mode.DUMP_SOURCE:\n\t\tcase Mode.PRINT_CONFIG:\n\t\t\treturn true;\n\t}\n}\n\nfunction handleUserError(err: UserErrorData): void {\n\tconst formatted = err.prettyFormat();\n\tif (formatted) {\n\t\tconsole.error(); /* blank line */\n\t\tconsole.error(formatted);\n\t\treturn;\n\t}\n\n\tconsole.error(kleur.red(\"Caught exception:\"));\n\tconsole.group();\n\t{\n\t\tconsole.error(err.prettyFormat() ?? err);\n\t}\n\tconsole.groupEnd();\n}\n\nfunction handleUnknownError(err: unknown): void {\n\tconsole.error(kleur.red(\"Caught exception:\"));\n\tconsole.group();\n\t{\n\t\tconsole.error(err);\n\t}\n\tconsole.groupEnd();\n\tconst bugUrl = `${pkgBugs}?issuable_template=Bug`;\n\tconsole.error(kleur.red(`This is a bug in ${name}-${version}.`));\n\tconsole.error(\n\t\tkleur.red(\n\t\t\t[\n\t\t\t\t`Please file a bug at ${bugUrl}`,\n\t\t\t\t`and include this message in full and if possible the content of the`,\n\t\t\t\t`file being parsed (or a reduced testcase).`,\n\t\t\t].join(\"\\n\"),\n\t\t),\n\t);\n}\n\nconst argv = minimist<ParsedArgs>(process.argv.slice(2), {\n\tstring: [\n\t\t\"c\",\n\t\t\"config\",\n\t\t\"ext\",\n\t\t\"f\",\n\t\t\"formatter\",\n\t\t\"max-warnings\",\n\t\t\"p\",\n\t\t\"preset\",\n\t\t\"rule\",\n\t\t\"stdin-filename\",\n\t],\n\tboolean: [\n\t\t\"init\",\n\t\t\"dump-events\",\n\t\t\"dump-source\",\n\t\t\"dump-tokens\",\n\t\t\"dump-tree\",\n\t\t\"h\",\n\t\t\"help\",\n\t\t\"print-config\",\n\t\t\"stdin\",\n\t\t\"version\",\n\t],\n\talias: {\n\t\tc: \"config\",\n\t\tf: \"formatter\",\n\t\tp: \"preset\",\n\t\th: \"help\",\n\t},\n\tdefault: {\n\t\text: \"html\",\n\t\tformatter: \"stylish\",\n\t},\n\tunknown: (opt: string) => {\n\t\tif (opt.startsWith(\"-\")) {\n\t\t\tprocess.stderr.write(`unknown option ${opt}\\n`);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\treturn true;\n\t},\n});\n\nfunction showUsage(): void {\n\tprocess.stdout.write(`${name}-${version}\nUsage: html-validate [OPTIONS] [FILENAME..] [DIR..]\n\nCommon options:\n --ext=STRING specify file extensions (commaseparated).\n -f, --formatter=FORMATTER specify the formatter to use.\n --max-warnings=INT number of warnings to trigger nonzero exit code\n -p, --preset=STRING configuration preset to use, use\n comma-separator for multiple presets. (default:\n \"recommended\")\n --rule=RULE:SEVERITY set additional rule, use comma separator for\n multiple.\n --stdin process markup from stdin.\n --stdin-filename=STRING specify filename to report when using stdin\n\nMiscellaneous:\n -c, --config=STRING use custom configuration file.\n --init initialize project with a new configuration\n --print-config output configuration for given file.\n -h, --help show help.\n --version show version.\n\nDebugging options:\n --dump-events output events during parsing.\n --dump-source output post-transformed source data.\n --dump-tokens output tokens from lexing stage.\n --dump-tree output nodes from the dom tree.\n\nFormatters:\n\nMultiple formatters can be specified with a comma-separated list,\ne.g. \"json,checkstyle\" to enable both.\n\nTo capture output to a file use \"formatter=/path/to/file\",\ne.g. \"checkstyle=dist/html-validate.xml\"\n`);\n}\n\nfunction showVersion(): void {\n\tprocess.stdout.write(`${name}-${version}\\n`);\n}\n\nif (argv.stdin) {\n\targv._.push(\"-\");\n}\n\nif (argv.version) {\n\tshowVersion();\n\tprocess.exit();\n}\n\nif (argv.help) {\n\tshowUsage();\n\tprocess.exit();\n}\n\nif (argv._.length === 0) {\n\tconst mode = getMode(argv);\n\tif (mode === Mode.LINT) {\n\t\tshowUsage();\n\t\tprocess.exit(0);\n\t} else if (requiresFilename(mode)) {\n\t\tconst flag = modeToFlag(mode);\n\t\tconsole.error(`\\`${flag}\\` requires a filename.`);\n\t\tprocess.exit(1);\n\t}\n}\n\n/* check that supplied config file exists before creating CLI */\nif (typeof argv.config !== \"undefined\") {\n\tconst checkPath = path.resolve(argv.config);\n\tif (!fs.existsSync(checkPath)) {\n\t\tconsole.error(`The file \"${argv.config}\" was not found.`);\n\t\tconsole.error(`The location this file was checked for at was: \"${checkPath}\"`);\n\t\tprocess.exit(1);\n\t}\n}\n\n/* eslint-disable-next-line complexity -- for now */\nasync function run(): Promise<void> {\n\tconst cli = new CLI({\n\t\tconfigFile: argv.config,\n\t\tpreset: argv.preset,\n\t\trules: argv.rule,\n\t});\n\tconst mode = getMode(argv);\n\tconst formatter = await cli.getFormatter(argv.formatter);\n\tconst maxWarnings = 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.error(`Invalid value \"${String(argv[\"max-warnings\"])}\" given to --max-warnings`);\n\t\tprocess.exit(1);\n\t}\n\n\t/* parse extensions (used when expanding directories) */\n\tconst extensions = argv.ext.split(\",\").map((cur: string) => {\n\t\treturn cur.startsWith(\".\") ? cur.slice(1) : cur;\n\t});\n\n\tconst files = await cli.expandFiles(argv._, { extensions });\n\tif (files.length === 0 && mode !== Mode.INIT) {\n\t\tconsole.error(\"No files matching patterns\", argv._);\n\t\tprocess.exit(1);\n\t}\n\n\ttry {\n\t\t/* istanbul ignore next -- not tested with unittests */\n\t\tif (!haveImportMetaResolve()) {\n\t\t\tthrow new ImportResolveMissingError();\n\t\t}\n\n\t\tlet success: boolean;\n\t\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,KAAAA,CAAK,MAAM,CAAA,EAAG;AACjB,IAAA,OAAO,IAAA,CAAK,IAAA;AAAA,EACb;AAEA,EAAA,IAAIA,KAAAA,CAAK,aAAa,CAAA,EAAG;AACxB,IAAA,OAAO,IAAA,CAAK,WAAA;AAAA,EACb;AAEA,EAAA,IAAIA,KAAAA,CAAK,aAAa,CAAA,EAAG;AACxB,IAAA,OAAO,IAAA,CAAK,WAA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AAA,KAAS,IAAA,CAAK,IAAA,EAAM;AAC9B,MAAA,OAAA,GAAU,MAAM,IAAA,CAAK,GAAA,EAAK,OAAA,CAAQ,MAAA,EAAQ,EAAE,GAAA,EAAK,OAAA,CAAQ,GAAA,EAAI,EAAG,CAAA;AAAA,IACjE,CAAA,MAAA,IAAW,IAAA,KAAS,IAAA,CAAK,YAAA,EAAc;AACtC,MAAA,OAAA,GAAU,MAAM,WAAA,CAAY,YAAA,EAAc,OAAA,CAAQ,QAAQ,KAAK,CAAA;AAAA,IAChE,CAAA,MAAO;AACN,MAAA,OAAA,GAAU,MAAM,IAAA,CAAK,YAAA,EAAc,OAAA,CAAQ,MAAA,EAAQ,OAAO,IAAI,CAAA;AAAA,IAC/D;AACA,IAAA,OAAA,CAAQ,IAAA,CAAK,OAAA,GAAU,CAAA,GAAI,CAAC,CAAA;AAAA,EAC7B,SAAS,GAAA,EAAK;AACb,IAAA,IAAI,eAAe,qBAAA,EAAuB;AACzC,MAAA,2BAAA,CAA4B,SAAS,GAAG,CAAA;AAAA,IACzC,CAAA,MAAA,IAAW,WAAA,CAAY,GAAG,CAAA,EAAG;AAC5B,MAAA,eAAA,CAAgB,GAAG,CAAA;AAAA,IACpB,CAAA,MAAO;AACN,MAAA,kBAAA,CAAmB,GAAG,CAAA;AAAA,IACvB;AACA,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EACf;AACD;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"}
1
+ {"version":3,"file":"html-validate.js","sources":["../../src/cli/html-validate.ts"],"sourcesContent":["/* eslint-disable no-console, n/no-process-exit -- as expected from a cli app */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport kleur from \"kleur\";\nimport minimist from \"minimist\";\nimport { type UserErrorData, SchemaValidationError, isUserError } from \"..\";\nimport { bugs as pkgBugs, name, version } from \"../generated/package\";\nimport { dump } from \"./actions/dump\";\nimport { init } from \"./actions/init\";\nimport { lint } from \"./actions/lint\";\nimport { printConfig } from \"./actions/print-config\";\nimport { CLI } from \"./cli\";\nimport { ImportResolveMissingError, handleSchemaValidationError } from \"./errors\";\nimport { haveImportMetaResolve } from \"./have-import-meta-resolve\";\nimport { Mode, modeToFlag } from \"./mode\";\n\ninterface ParsedArgs {\n\tconfig?: string;\n\t\"dump-events\": boolean;\n\t\"dump-source\": boolean;\n\t\"dump-tokens\": boolean;\n\t\"dump-tree\": boolean;\n\text: string;\n\tformatter: string;\n\thelp: boolean;\n\tinit: boolean;\n\t\"max-warnings\"?: string;\n\tpreset?: string;\n\t\"print-config\": boolean;\n\trule?: string;\n\tstdin: boolean;\n\t\"stdin-filename\"?: string;\n\tversion: boolean;\n}\n\nfunction getMode(argv: Record<string, any>): Mode {\n\tif (argv[\"init\"]) {\n\t\treturn Mode.INIT;\n\t}\n\n\tif (argv[\"dump-events\"]) {\n\t\treturn Mode.DUMP_EVENTS;\n\t}\n\n\tif (argv[\"dump-source\"]) {\n\t\treturn Mode.DUMP_SOURCE;\n\t}\n\n\tif (argv[\"dump-tokens\"]) {\n\t\treturn Mode.DUMP_TOKENS;\n\t}\n\n\tif (argv[\"dump-tree\"]) {\n\t\treturn Mode.DUMP_TREE;\n\t}\n\n\tif (argv[\"print-config\"]) {\n\t\treturn Mode.PRINT_CONFIG;\n\t}\n\n\treturn Mode.LINT;\n}\n\nfunction requiresFilename(mode: Mode): boolean {\n\tswitch (mode) {\n\t\tcase Mode.LINT:\n\t\t\treturn true;\n\t\tcase Mode.INIT:\n\t\t\treturn false;\n\t\tcase Mode.DUMP_EVENTS:\n\t\tcase Mode.DUMP_TOKENS:\n\t\tcase Mode.DUMP_TREE:\n\t\tcase Mode.DUMP_SOURCE:\n\t\tcase Mode.PRINT_CONFIG:\n\t\t\treturn true;\n\t}\n}\n\nfunction handleUserError(err: UserErrorData): void {\n\tconst formatted = err.prettyFormat();\n\tif (formatted) {\n\t\tconsole.error(); /* blank line */\n\t\tconsole.error(formatted);\n\t\treturn;\n\t}\n\n\tconsole.error(kleur.red(\"Caught exception:\"));\n\tconsole.group();\n\t{\n\t\tconsole.error(err.prettyFormat() ?? err);\n\t}\n\tconsole.groupEnd();\n}\n\nfunction handleUnknownError(err: unknown): void {\n\tconsole.error(kleur.red(\"Caught exception:\"));\n\tconsole.group();\n\t{\n\t\tconsole.error(err);\n\t}\n\tconsole.groupEnd();\n\tconst bugUrl = `${pkgBugs}?issuable_template=Bug`;\n\tconsole.error(kleur.red(`This is a bug in ${name}-${version}.`));\n\tconsole.error(\n\t\tkleur.red(\n\t\t\t[\n\t\t\t\t`Please file a bug at ${bugUrl}`,\n\t\t\t\t`and include this message in full and if possible the content of the`,\n\t\t\t\t`file being parsed (or a reduced testcase).`,\n\t\t\t].join(\"\\n\"),\n\t\t),\n\t);\n}\n\nconst argv = minimist<ParsedArgs>(process.argv.slice(2), {\n\tstring: [\n\t\t\"c\",\n\t\t\"config\",\n\t\t\"ext\",\n\t\t\"f\",\n\t\t\"formatter\",\n\t\t\"max-warnings\",\n\t\t\"p\",\n\t\t\"preset\",\n\t\t\"rule\",\n\t\t\"stdin-filename\",\n\t],\n\tboolean: [\n\t\t\"init\",\n\t\t\"dump-events\",\n\t\t\"dump-source\",\n\t\t\"dump-tokens\",\n\t\t\"dump-tree\",\n\t\t\"h\",\n\t\t\"help\",\n\t\t\"print-config\",\n\t\t\"stdin\",\n\t\t\"version\",\n\t],\n\talias: {\n\t\tc: \"config\",\n\t\tf: \"formatter\",\n\t\tp: \"preset\",\n\t\th: \"help\",\n\t},\n\tdefault: {\n\t\text: \"html\",\n\t\tformatter: \"stylish\",\n\t},\n\tunknown: (opt: string) => {\n\t\tif (opt.startsWith(\"-\")) {\n\t\t\tprocess.stderr.write(`unknown option ${opt}\\n`);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\treturn true;\n\t},\n});\n\nfunction showUsage(): void {\n\tprocess.stdout.write(`${name}-${version}\nUsage: html-validate [OPTIONS] [FILENAME..] [DIR..]\n\nCommon options:\n --ext=STRING specify file extensions (commaseparated).\n -f, --formatter=FORMATTER specify the formatter to use.\n --max-warnings=INT number of warnings to trigger nonzero exit code\n -p, --preset=STRING configuration preset to use, use\n comma-separator for multiple presets. (default:\n \"recommended\")\n --rule=RULE:SEVERITY set additional rule, use comma separator for\n multiple.\n --stdin process markup from stdin.\n --stdin-filename=STRING specify filename to report when using stdin\n\nMiscellaneous:\n -c, --config=STRING use custom configuration file.\n --init initialize project with a new configuration\n --print-config output configuration for given file.\n -h, --help show help.\n --version show version.\n\nDebugging options:\n --dump-events output events during parsing.\n --dump-source output post-transformed source data.\n --dump-tokens output tokens from lexing stage.\n --dump-tree output nodes from the dom tree.\n\nFormatters:\n\nMultiple formatters can be specified with a comma-separated list,\ne.g. \"json,checkstyle\" to enable both.\n\nTo capture output to a file use \"formatter=/path/to/file\",\ne.g. \"checkstyle=dist/html-validate.xml\"\n`);\n}\n\nfunction showVersion(): void {\n\tprocess.stdout.write(`${name}-${version}\\n`);\n}\n\nif (argv.stdin) {\n\targv._.push(\"-\");\n}\n\nif (argv.version) {\n\tshowVersion();\n\tprocess.exit();\n}\n\nif (argv.help) {\n\tshowUsage();\n\tprocess.exit();\n}\n\nif (argv._.length === 0) {\n\tconst mode = getMode(argv);\n\tif (mode === Mode.LINT) {\n\t\tshowUsage();\n\t\tprocess.exit(0);\n\t} else if (requiresFilename(mode)) {\n\t\tconst flag = modeToFlag(mode);\n\t\tconsole.error(`\\`${flag}\\` requires a filename.`);\n\t\tprocess.exit(1);\n\t}\n}\n\n/* check that supplied config file exists before creating CLI */\nif (argv.config !== undefined) {\n\tconst checkPath = path.resolve(argv.config);\n\tif (!fs.existsSync(checkPath)) {\n\t\tconsole.error(`The file \"${argv.config}\" was not found.`);\n\t\tconsole.error(`The location this file was checked for at was: \"${checkPath}\"`);\n\t\tprocess.exit(1);\n\t}\n}\n\n/* eslint-disable-next-line complexity -- for now */\nasync function run(): Promise<void> {\n\tconst cli = new CLI({\n\t\tconfigFile: argv.config,\n\t\tpreset: argv.preset,\n\t\trules: argv.rule,\n\t});\n\tconst mode = getMode(argv);\n\tconst formatter = await cli.getFormatter(argv.formatter);\n\tconst maxWarnings = Number.parseInt(argv[\"max-warnings\"] ?? \"-1\", 10);\n\tconst htmlvalidate = await cli.getValidator();\n\n\t/* sanity check: ensure maxWarnings has a valid value */\n\tif (Number.isNaN(maxWarnings)) {\n\t\tconsole.error(`Invalid value \"${String(argv[\"max-warnings\"])}\" given to --max-warnings`);\n\t\tprocess.exit(1);\n\t}\n\n\t/* parse extensions (used when expanding directories) */\n\tconst extensions = argv.ext.split(\",\").map((cur: string) => {\n\t\treturn cur.startsWith(\".\") ? cur.slice(1) : cur;\n\t});\n\n\tconst files = await cli.expandFiles(argv._, { extensions });\n\tif (files.length === 0 && mode !== Mode.INIT) {\n\t\tconsole.error(\"No files matching patterns\", argv._);\n\t\tprocess.exit(1);\n\t}\n\n\ttry {\n\t\t/* istanbul ignore next -- not tested with unittests */\n\t\tif (!haveImportMetaResolve()) {\n\t\t\tthrow new ImportResolveMissingError();\n\t\t}\n\n\t\tlet success: boolean;\n\t\tswitch (mode) {\n\t\t\tcase Mode.LINT: {\n\t\t\t\tsuccess = await lint(htmlvalidate, process.stdout, files, {\n\t\t\t\t\tformatter,\n\t\t\t\t\tmaxWarnings,\n\t\t\t\t\tstdinFilename: argv[\"stdin-filename\"] ?? false,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase Mode.INIT: {\n\t\t\t\tsuccess = await init(cli, process.stdout, { cwd: process.cwd() });\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase Mode.PRINT_CONFIG: {\n\t\t\t\tsuccess = await printConfig(htmlvalidate, process.stdout, files);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tsuccess = await dump(htmlvalidate, process.stdout, files, mode);\n\t\t\t}\n\t\t}\n\t\tprocess.exit(success ? 0 : 1);\n\t} catch (err) {\n\t\tif (err instanceof SchemaValidationError) {\n\t\t\thandleSchemaValidationError(console, err);\n\t\t} else if (isUserError(err)) {\n\t\t\thandleUserError(err);\n\t\t} else {\n\t\t\thandleUnknownError(err);\n\t\t}\n\t\tprocess.exit(1);\n\t}\n}\n\nrun().catch((err: unknown) => {\n\tconsole.error(err);\n\tprocess.exit(1);\n});\n"],"names":["argv","pkgBugs"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmCA,SAAS,QAAQA,KAAAA,EAAiC;AACjD,EAAA,IAAIA,KAAAA,CAAK,MAAM,CAAA,EAAG;AACjB,IAAA,OAAO,IAAA,CAAK,IAAA;AAAA,EACb;AAEA,EAAA,IAAIA,KAAAA,CAAK,aAAa,CAAA,EAAG;AACxB,IAAA,OAAO,IAAA,CAAK,WAAA;AAAA,EACb;AAEA,EAAA,IAAIA,KAAAA,CAAK,aAAa,CAAA,EAAG;AACxB,IAAA,OAAO,IAAA,CAAK,WAAA;AAAA,EACb;AAEA,EAAA,IAAIA,KAAAA,CAAK,aAAa,CAAA,EAAG;AACxB,IAAA,OAAO,IAAA,CAAK,WAAA;AAAA,EACb;AAEA,EAAA,IAAIA,KAAAA,CAAK,WAAW,CAAA,EAAG;AACtB,IAAA,OAAO,IAAA,CAAK,SAAA;AAAA,EACb;AAEA,EAAA,IAAIA,KAAAA,CAAK,cAAc,CAAA,EAAG;AACzB,IAAA,OAAO,IAAA,CAAK,YAAA;AAAA,EACb;AAEA,EAAA,OAAO,IAAA,CAAK,IAAA;AACb;AAEA,SAAS,iBAAiB,IAAA,EAAqB;AAC9C,EAAA,QAAQ,IAAA;AAAM,IACb,KAAK,IAAA,CAAK,IAAA;AACT,MAAA,OAAO,IAAA;AAAA,IACR,KAAK,IAAA,CAAK,IAAA;AACT,MAAA,OAAO,KAAA;AAAA,IACR,KAAK,IAAA,CAAK,WAA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AAA,EAC7B,SAAS,GAAA,EAAK;AACb,IAAA,IAAI,eAAe,qBAAA,EAAuB;AACzC,MAAA,2BAAA,CAA4B,SAAS,GAAG,CAAA;AAAA,IACzC,CAAA,MAAA,IAAW,WAAA,CAAY,GAAG,CAAA,EAAG;AAC5B,MAAA,eAAA,CAAgB,GAAG,CAAA;AAAA,IACpB,CAAA,MAAO;AACN,MAAA,kBAAA,CAAmB,GAAG,CAAA;AAAA,IACvB;AACA,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EACf;AACD;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"}
@@ -15,7 +15,7 @@ function createMatcher$1() {
15
15
  const results = getResults(filename, actual);
16
16
  const enabled = kleur.enabled;
17
17
  kleur.enabled = false;
18
- const snapshot = codeframe(results, options$1).replace(/\s+$/gm, "");
18
+ const snapshot = codeframe(results, options$1).replaceAll(/\s+$/gm, "");
19
19
  kleur.enabled = enabled;
20
20
  return toMatchSnapshot.call(this, snapshot, ...rest);
21
21
  }
@@ -32,7 +32,7 @@ function toMatchInlineCodeframeImpl(context, actual, ...rest) {
32
32
  const results = getResults(filename, actual);
33
33
  const enabled = kleur.enabled;
34
34
  kleur.enabled = false;
35
- const snapshot = codeframe(results, options).replace(/\s+$/gm, "");
35
+ const snapshot = codeframe(results, options).replaceAll(/\s+$/gm, "");
36
36
  kleur.enabled = enabled;
37
37
  return toMatchInlineSnapshot.call(context, snapshot, ...rest);
38
38
  }
@@ -1 +1 @@
1
- {"version":3,"file":"matchers-jestonly.js","sources":["../../src/jest/matchers/to-match-codeframe.ts","../../src/jest/matchers/to-match-inline-codeframe.ts"],"sourcesContent":["import { toMatchSnapshot } from \"jest-snapshot\";\nimport kleur from \"kleur\";\nimport { type CodeframeOptions, codeframe } from \"../../formatters/codeframe\";\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype MatcherContext,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n} from \"../utils\";\nimport { getResults } from \"./get-results\";\n\nconst options: CodeframeOptions = {\n\tshowLink: false,\n\tshowSummary: false,\n\tshowSelector: true,\n};\n\nfunction createMatcher(): MaybeAsyncCallback<Report | string, [Array<string | object>]> {\n\tfunction toMatchCodeframe(\n\t\tthis: MatcherContext,\n\t\tactual: Report | string,\n\t\t...rest: Array<string | object>\n\t): MatcherResult {\n\t\t/* istanbul ignore next: cant figure out when this would be unset */\n\t\tconst filename = this.testPath ?? \"inline\";\n\t\tconst results = getResults(filename, actual);\n\t\tconst enabled = kleur.enabled;\n\t\tkleur.enabled = false;\n\t\tconst snapshot = codeframe(results, options).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 { toMatchInlineSnapshot } from \"jest-snapshot\";\nimport kleur from \"kleur\";\nimport { type CodeframeOptions, codeframe } from \"../../formatters/codeframe\";\nimport { type Report } from \"../../reporter\";\nimport { type MatcherContext, type MatcherResult, isThenable } from \"../utils\";\nimport { getResults } from \"./get-results\";\n\nconst options: CodeframeOptions = {\n\tshowLink: false,\n\tshowSummary: false,\n\tshowSelector: true,\n};\n\nfunction toMatchInlineCodeframeImpl(\n\tcontext: MatcherContext,\n\tactual: Report | string,\n\t...rest: Array<string | object>\n): MatcherResult {\n\t/* istanbul ignore next: cant figure out when this would be unset */\n\tconst filename = context.testPath ?? \"inline\";\n\tconst results = getResults(filename, actual);\n\tconst enabled = kleur.enabled;\n\tkleur.enabled = false;\n\tconst snapshot = codeframe(results, options).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,CAAA;AAC3C,IAAA,MAAM,UAAU,KAAA,CAAM,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O,KAAK,CAAC,QAAA,KAAa,2BAA2B,OAAA,EAAS,QAAA,EAAU,GAAG,IAAI,CAAC,CAAA;AAAA,IACxF,CAAA,MAAO;AACN,MAAA,OAAO,0BAAA,CAA2B,OAAA,EAAS,MAAA,EAAQ,GAAG,IAAI,CAAA;AAAA,IAC3D;AAAA,EACD;AAEA,EAAA,OAAO,sBAAA;AACR;;;;"}
1
+ {"version":3,"file":"matchers-jestonly.js","sources":["../../src/jest/matchers/to-match-codeframe.ts","../../src/jest/matchers/to-match-inline-codeframe.ts"],"sourcesContent":["import { toMatchSnapshot } from \"jest-snapshot\";\nimport kleur from \"kleur\";\nimport { type CodeframeOptions, codeframe } from \"../../formatters/codeframe\";\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype MatcherContext,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n} from \"../utils\";\nimport { getResults } from \"./get-results\";\n\nconst options: CodeframeOptions = {\n\tshowLink: false,\n\tshowSummary: false,\n\tshowSelector: true,\n};\n\nfunction createMatcher(): MaybeAsyncCallback<Report | string, [Array<string | object>]> {\n\tfunction toMatchCodeframe(\n\t\tthis: MatcherContext,\n\t\tactual: Report | string,\n\t\t...rest: Array<string | object>\n\t): MatcherResult {\n\t\t/* istanbul ignore next: cant figure out when this would be unset */\n\t\tconst filename = this.testPath ?? \"inline\";\n\t\tconst results = getResults(filename, actual);\n\t\tconst enabled = kleur.enabled;\n\t\tkleur.enabled = false;\n\t\tconst snapshot = codeframe(results, options).replaceAll(/\\s+$/gm, \"\");\n\t\tkleur.enabled = enabled;\n\n\t\t/* eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call --\n\t\t * the implementation works but the declarations doesn't allow it */\n\t\treturn (toMatchSnapshot as any).call(this, snapshot, ...rest);\n\t}\n\treturn diverge(toMatchCodeframe);\n}\n\nexport { createMatcher as toMatchCodeframe };\n","import { toMatchInlineSnapshot } from \"jest-snapshot\";\nimport kleur from \"kleur\";\nimport { type CodeframeOptions, codeframe } from \"../../formatters/codeframe\";\nimport { type Report } from \"../../reporter\";\nimport { type MatcherContext, type MatcherResult, isThenable } from \"../utils\";\nimport { getResults } from \"./get-results\";\n\nconst options: CodeframeOptions = {\n\tshowLink: false,\n\tshowSummary: false,\n\tshowSelector: true,\n};\n\nfunction toMatchInlineCodeframeImpl(\n\tcontext: MatcherContext,\n\tactual: Report | string,\n\t...rest: Array<string | object>\n): MatcherResult {\n\t/* istanbul ignore next: cant figure out when this would be unset */\n\tconst filename = context.testPath ?? \"inline\";\n\tconst results = getResults(filename, actual);\n\tconst enabled = kleur.enabled;\n\tkleur.enabled = false;\n\tconst snapshot = codeframe(results, options).replaceAll(/\\s+$/gm, \"\");\n\tkleur.enabled = enabled;\n\n\t/* eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call --\n\t * the implementation works but the declarations doesn't allow it */\n\treturn (toMatchInlineSnapshot as any).call(context, snapshot, ...rest);\n}\n\ntype ToMatchInlineCodeframeMatcher = (\n\tthis: MatcherContext,\n\tactual: Report | Promise<Report> | string,\n\t...rest: Array<string | object>\n) => MatcherResult | Promise<MatcherResult>;\n\nfunction createMatcher(): ToMatchInlineCodeframeMatcher {\n\tfunction toMatchInlineCodeframe(\n\t\tthis: MatcherContext,\n\t\tactual: Report | Promise<Report> | string,\n\t\t...rest: Array<string | object>\n\t): MatcherResult | Promise<MatcherResult> {\n\t\tconst context = {\n\t\t\t...this,\n\n\t\t\t/* Capture the original stack frames as they are needed by \"jest-snapshot\"\n\t\t\t * to determine where to write the inline snapshots. When resolving the\n\t\t\t * promise the original stack frames are lost and the snapshot will be\n\t\t\t * written in this files instaed. */\n\t\t\terror: new Error(),\n\t\t};\n\n\t\tif (isThenable(actual)) {\n\t\t\treturn actual.then((resolved) => toMatchInlineCodeframeImpl(context, resolved, ...rest));\n\t\t} else {\n\t\t\treturn toMatchInlineCodeframeImpl(context, actual, ...rest);\n\t\t}\n\t}\n\n\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CAAW,UAAU,EAAE,CAAA;AACpE,EAAA,KAAA,CAAM,OAAA,GAAU,OAAA;AAIhB,EAAA,OAAQ,qBAAA,CAA8B,IAAA,CAAK,OAAA,EAAS,QAAA,EAAU,GAAG,IAAI,CAAA;AACtE;AAQA,SAAS,aAAA,GAA+C;AACvD,EAAA,SAAS,sBAAA,CAER,WACG,IAAA,EACsC;AACzC,IAAA,MAAM,OAAA,GAAU;AAAA,MACf,GAAG,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMH,KAAA,EAAO,IAAI,KAAA;AAAM,KAClB;AAEA,IAAA,IAAI,UAAA,CAAW,MAAM,CAAA,EAAG;AACvB,MAAA,OAAO,MAAA,CAAO,KAAK,CAAC,QAAA,KAAa,2BAA2B,OAAA,EAAS,QAAA,EAAU,GAAG,IAAI,CAAC,CAAA;AAAA,IACxF,CAAA,MAAO;AACN,MAAA,OAAO,0BAAA,CAA2B,OAAA,EAAS,MAAA,EAAQ,GAAG,IAAI,CAAA;AAAA,IAC3D;AAAA,EACD;AAEA,EAAA,OAAO,sBAAA;AACR;;;;"}
@@ -7,7 +7,7 @@ function naturalJoin(values, conjunction = "or") {
7
7
  case 2:
8
8
  return `${values[0]} ${conjunction} ${values[1]}`;
9
9
  default:
10
- return `${values.slice(0, -1).join(", ")} ${conjunction} ${values.slice(-1)[0]}`;
10
+ return `${values.slice(0, -1).join(", ")} ${conjunction} ${values.at(-1)}`;
11
11
  }
12
12
  }
13
13
 
@@ -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":"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;;;;"}
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\t/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- we\n\t\t\t * know length will be greater than two so there must be an element */\n\t\t\treturn `${values.slice(0, -1).join(\", \")} ${conjunction} ${values.at(-1)!}`;\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;AAGC,MAAA,OAAO,CAAA,EAAG,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC,IAAI,WAAW,CAAA,CAAA,EAAI,MAAA,CAAO,EAAA,CAAG,EAAE,CAAE,CAAA,CAAA;AAAA;AAE5E;;;;"}
@@ -130,6 +130,12 @@
130
130
  "anyOf": [{ "type": "boolean" }, { "function": true }]
131
131
  },
132
132
 
133
+ "submitButton": {
134
+ "title": "Mark this element as a submit button",
135
+ "description": "This element can be used to submit forms.",
136
+ "anyOf": [{ "type": "boolean" }, { "function": true }]
137
+ },
138
+
133
139
  "templateRoot": {
134
140
  "title": "Mark element as an element ignoring DOM ancestry, i.e. <template>.",
135
141
  "description": "The <template> element can contain any elements.",
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.57.2"
8
+ "packageVersion": "7.57.6"
9
9
  }
10
10
  ]
11
11
  }
@@ -41,7 +41,7 @@ export declare class Attribute {
41
41
  * transformation (e.g. vuejs `:id` generating the `id` attribute) this
42
42
  * parameter should be set to the attribute name of the source attribute (`:id`).
43
43
  */
44
- constructor(key: string, value: string | DynamicValue | null, keyLocation: Location_2, valueLocation: Location_2 | null, originalAttribute?: string);
44
+ constructor(key: string, value: string | DynamicValue | null | undefined, keyLocation: Location_2, valueLocation: Location_2 | null, originalAttribute?: string);
45
45
  /**
46
46
  * Flag set to true if the attribute value is static.
47
47
  */
@@ -561,7 +561,7 @@ export declare class DOMNode {
561
561
  * Returns a DOMNode representing the last direct child node or `null` if the
562
562
  * node has no children.
563
563
  */
564
- get lastChild(): DOMNode;
564
+ get lastChild(): DOMNode | null;
565
565
  /* Excluded from this release type: removeChild */
566
566
  /* Excluded from this release type: blockRule */
567
567
  /* Excluded from this release type: blockRules */
@@ -1574,6 +1574,8 @@ export declare interface MetaData {
1574
1574
  /** Mark element as a form-associated element */
1575
1575
  formAssociated?: Partial<FormAssociated>;
1576
1576
  labelable?: boolean | MetaLabelableCallback;
1577
+ /** Mark element as a submit button (i.e. it will submit the form it belongs to) */
1578
+ submitButton?: boolean | MetaSubmitButtonCallback;
1577
1579
  /**
1578
1580
  * Set to `true` if this element should have no impact on DOM
1579
1581
  * ancestry. Default `false`.
@@ -1701,7 +1703,18 @@ export declare type MetaLabelableCallback = (node: HtmlElementLike) => boolean;
1701
1703
  *
1702
1704
  * @public
1703
1705
  */
1704
- export declare type MetaLookupableProperty = "metadata" | "flow" | "sectioning" | "heading" | "phrasing" | "embedded" | "interactive" | "deprecated" | "foreign" | "void" | "transparent" | "scriptSupporting" | "focusable" | "form" | "formAssociated" | "labelable";
1706
+ export declare type MetaLookupableProperty = "metadata" | "flow" | "sectioning" | "heading" | "phrasing" | "embedded" | "interactive" | "deprecated" | "foreign" | "void" | "transparent" | "scriptSupporting" | "focusable" | "form" | "formAssociated" | "labelable" | "submitButton";
1707
+
1708
+ /**
1709
+ * Callback for the `submitButton` property of `MetaData`. It takes a node and
1710
+ * returns whenever the element is a submit button or not.
1711
+ *
1712
+ * @public
1713
+ * @since 10.10.0
1714
+ * @param node - The node to determine if it is a submit button.
1715
+ * @returns `true` if the node is a submit button.
1716
+ */
1717
+ export declare type MetaSubmitButtonCallback = (node: HtmlElementLike) => boolean;
1705
1718
 
1706
1719
  /**
1707
1720
  * @public
@@ -2076,11 +2089,12 @@ export { Report_2 as Report }
2076
2089
  * @public
2077
2090
  */
2078
2091
  export declare class Reporter {
2079
- protected result: Record<string, DeferredMessage[]>;
2080
- constructor();
2092
+ /* Excluded from this release type: result */
2093
+ /* Excluded from this release type: __constructor */
2081
2094
  /**
2082
2095
  * Merge two or more reports into a single one.
2083
2096
  *
2097
+ * @public
2084
2098
  * @param reports- Reports to merge.
2085
2099
  * @returns A merged report.
2086
2100
  */
@@ -2088,14 +2102,15 @@ export declare class Reporter {
2088
2102
  /**
2089
2103
  * Merge two or more reports into a single one.
2090
2104
  *
2105
+ * @public
2091
2106
  * @param reports- Reports to merge.
2092
2107
  * @returns A promise resolved with the merged report.
2093
2108
  */
2094
2109
  static merge(reports: Promise<Report_2[]> | Array<Promise<Report_2>>): Promise<Report_2>;
2095
- add<ContextType, OptionsType>(rule: Rule<ContextType, OptionsType>, message: string, severity: number, node: DOMNode | null, location: Location_2, context: ContextType): void;
2096
- addManual(filename: string, message: DeferredMessage): void;
2097
- save(sources?: Source[]): Report_2;
2098
- protected isValid(): boolean;
2110
+ /* Excluded from this release type: add */
2111
+ /* Excluded from this release type: addManual */
2112
+ /* Excluded from this release type: save */
2113
+ /* Excluded from this release type: isValid */
2099
2114
  }
2100
2115
 
2101
2116
  /**
@@ -41,7 +41,7 @@ export declare class Attribute {
41
41
  * transformation (e.g. vuejs `:id` generating the `id` attribute) this
42
42
  * parameter should be set to the attribute name of the source attribute (`:id`).
43
43
  */
44
- constructor(key: string, value: string | DynamicValue | null, keyLocation: Location_2, valueLocation: Location_2 | null, originalAttribute?: string);
44
+ constructor(key: string, value: string | DynamicValue | null | undefined, keyLocation: Location_2, valueLocation: Location_2 | null, originalAttribute?: string);
45
45
  /**
46
46
  * Flag set to true if the attribute value is static.
47
47
  */
@@ -659,7 +659,7 @@ export declare class DOMNode {
659
659
  * Returns a DOMNode representing the last direct child node or `null` if the
660
660
  * node has no children.
661
661
  */
662
- get lastChild(): DOMNode;
662
+ get lastChild(): DOMNode | null;
663
663
  /* Excluded from this release type: removeChild */
664
664
  /* Excluded from this release type: blockRule */
665
665
  /* Excluded from this release type: blockRules */
@@ -1814,6 +1814,8 @@ export declare interface MetaData {
1814
1814
  /** Mark element as a form-associated element */
1815
1815
  formAssociated?: Partial<FormAssociated>;
1816
1816
  labelable?: boolean | MetaLabelableCallback;
1817
+ /** Mark element as a submit button (i.e. it will submit the form it belongs to) */
1818
+ submitButton?: boolean | MetaSubmitButtonCallback;
1817
1819
  /**
1818
1820
  * Set to `true` if this element should have no impact on DOM
1819
1821
  * ancestry. Default `false`.
@@ -1941,7 +1943,18 @@ export declare type MetaLabelableCallback = (node: HtmlElementLike) => boolean;
1941
1943
  *
1942
1944
  * @public
1943
1945
  */
1944
- export declare type MetaLookupableProperty = "metadata" | "flow" | "sectioning" | "heading" | "phrasing" | "embedded" | "interactive" | "deprecated" | "foreign" | "void" | "transparent" | "scriptSupporting" | "focusable" | "form" | "formAssociated" | "labelable";
1946
+ export declare type MetaLookupableProperty = "metadata" | "flow" | "sectioning" | "heading" | "phrasing" | "embedded" | "interactive" | "deprecated" | "foreign" | "void" | "transparent" | "scriptSupporting" | "focusable" | "form" | "formAssociated" | "labelable" | "submitButton";
1947
+
1948
+ /**
1949
+ * Callback for the `submitButton` property of `MetaData`. It takes a node and
1950
+ * returns whenever the element is a submit button or not.
1951
+ *
1952
+ * @public
1953
+ * @since 10.10.0
1954
+ * @param node - The node to determine if it is a submit button.
1955
+ * @returns `true` if the node is a submit button.
1956
+ */
1957
+ export declare type MetaSubmitButtonCallback = (node: HtmlElementLike) => boolean;
1945
1958
 
1946
1959
  /**
1947
1960
  * @public
@@ -2341,11 +2354,12 @@ export { Report_2 as Report }
2341
2354
  * @public
2342
2355
  */
2343
2356
  export declare class Reporter {
2344
- protected result: Record<string, DeferredMessage[]>;
2345
- constructor();
2357
+ /* Excluded from this release type: result */
2358
+ /* Excluded from this release type: __constructor */
2346
2359
  /**
2347
2360
  * Merge two or more reports into a single one.
2348
2361
  *
2362
+ * @public
2349
2363
  * @param reports- Reports to merge.
2350
2364
  * @returns A merged report.
2351
2365
  */
@@ -2353,14 +2367,15 @@ export declare class Reporter {
2353
2367
  /**
2354
2368
  * Merge two or more reports into a single one.
2355
2369
  *
2370
+ * @public
2356
2371
  * @param reports- Reports to merge.
2357
2372
  * @returns A promise resolved with the merged report.
2358
2373
  */
2359
2374
  static merge(reports: Promise<Report_2[]> | Array<Promise<Report_2>>): Promise<Report_2>;
2360
- add<ContextType, OptionsType>(rule: Rule<ContextType, OptionsType>, message: string, severity: number, node: DOMNode | null, location: Location_2, context: ContextType): void;
2361
- addManual(filename: string, message: DeferredMessage): void;
2362
- save(sources?: Source[]): Report_2;
2363
- protected isValid(): boolean;
2375
+ /* Excluded from this release type: add */
2376
+ /* Excluded from this release type: addManual */
2377
+ /* Excluded from this release type: save */
2378
+ /* Excluded from this release type: isValid */
2364
2379
  }
2365
2380
 
2366
2381
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "html-validate",
3
- "version": "10.9.0",
3
+ "version": "10.10.0",
4
4
  "description": "Offline HTML5 validator and linter",
5
5
  "keywords": [
6
6
  "html",
@@ -89,7 +89,7 @@
89
89
  "dist"
90
90
  ],
91
91
  "dependencies": {
92
- "@html-validate/stylish": "^4.1.0",
92
+ "@html-validate/stylish": "^5.0.0",
93
93
  "@sidvind/better-ajv-errors": "4.0.1",
94
94
  "ajv": "^8.0.0",
95
95
  "glob": "^13.0.0",
@@ -119,6 +119,6 @@
119
119
  }
120
120
  },
121
121
  "engines": {
122
- "node": "^20.19.0 || >= 22.12.0"
122
+ "node": "^20.19.0 || >= 22.16.0"
123
123
  }
124
124
  }