html-validate 9.1.2 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/browser.js +1 -0
- package/dist/cjs/browser.js.map +1 -1
- package/dist/cjs/cli.js +35 -4
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/core.js +791 -755
- package/dist/cjs/core.js.map +1 -1
- package/dist/cjs/html-validate.js +5 -1
- package/dist/cjs/html-validate.js.map +1 -1
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/browser.js +1 -1
- package/dist/es/cli.js +32 -5
- package/dist/es/cli.js.map +1 -1
- package/dist/es/core-browser.js +1 -1
- package/dist/es/core-nodejs.js +1 -1
- package/dist/es/core.js +789 -755
- package/dist/es/core.js.map +1 -1
- package/dist/es/html-validate.js +7 -3
- package/dist/es/html-validate.js.map +1 -1
- package/dist/es/index.js +2 -1
- package/dist/es/index.js.map +1 -1
- package/dist/es/matchers-jestonly.js +1 -1
- package/dist/es/matchers.js +1 -1
- package/dist/types/browser.d.ts +17 -23
- package/dist/types/index.d.ts +17 -23
- package/package.json +3 -3
package/dist/es/html-validate.js
CHANGED
|
@@ -2,8 +2,8 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import kleur from 'kleur';
|
|
4
4
|
import minimist from 'minimist';
|
|
5
|
-
import {
|
|
6
|
-
import { M as Mode, m as modeToFlag, l as lint, i as init, p as printConfig, d as dump,
|
|
5
|
+
import { Y as name, v as version, o as SchemaValidationError, q as isUserError, Z as bugs } from './core.js';
|
|
6
|
+
import { M as Mode, m as modeToFlag, h as haveImportMetaResolve, I as ImportResolveMissingError, l as lint, i as init, p as printConfig, d as dump, a as handleSchemaValidationError, C as CLI } from './cli.js';
|
|
7
7
|
import 'ajv';
|
|
8
8
|
import './elements.js';
|
|
9
9
|
import './meta-helper.js';
|
|
@@ -15,6 +15,7 @@ import 'semver';
|
|
|
15
15
|
import './core-nodejs.js';
|
|
16
16
|
import 'node:fs/promises';
|
|
17
17
|
import 'node:module';
|
|
18
|
+
import 'node:path/posix';
|
|
18
19
|
import 'glob';
|
|
19
20
|
import 'prompts';
|
|
20
21
|
|
|
@@ -225,6 +226,9 @@ async function run() {
|
|
|
225
226
|
process.exit(1);
|
|
226
227
|
}
|
|
227
228
|
try {
|
|
229
|
+
if (!haveImportMetaResolve()) {
|
|
230
|
+
throw new ImportResolveMissingError();
|
|
231
|
+
}
|
|
228
232
|
let success;
|
|
229
233
|
if (mode === Mode.LINT) {
|
|
230
234
|
success = await lint(htmlvalidate, process.stdout, files, {
|
|
@@ -243,7 +247,7 @@ async function run() {
|
|
|
243
247
|
} catch (err) {
|
|
244
248
|
if (err instanceof SchemaValidationError) {
|
|
245
249
|
handleSchemaValidationError(console, err);
|
|
246
|
-
} else if (err
|
|
250
|
+
} else if (isUserError(err)) {
|
|
247
251
|
handleUserError(err);
|
|
248
252
|
} else {
|
|
249
253
|
handleUnknownError(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, sonarjs/no-duplicate-string -- as expected from a cli app */\nimport fs from \"fs\";\nimport path from \"node:path\";\nimport kleur from \"kleur\";\nimport minimist from \"minimist\";\nimport { SchemaValidationError, UserError } from \"..\";\nimport { name, version, bugs as pkgBugs } from \"../generated/package\";\nimport { CLI } from \"./cli\";\nimport { handleSchemaValidationError } from \"./errors\";\nimport { Mode, modeToFlag } from \"./mode\";\nimport { lint } from \"./actions/lint\";\nimport { init } from \"./actions/init\";\nimport { printConfig } from \"./actions/print-config\";\nimport { dump } from \"./actions/dump\";\n\ninterface ParsedArgs {\n\tconfig?: string;\n\t\"dump-events\": boolean;\n\t\"dump-source\": boolean;\n\t\"dump-tokens\": boolean;\n\t\"dump-tree\": boolean;\n\text: string;\n\tformatter: string;\n\thelp: boolean;\n\tinit: boolean;\n\t\"max-warnings\"?: string;\n\tpreset?: string;\n\t\"print-config\": boolean;\n\trule?: string;\n\tstdin: boolean;\n\t\"stdin-filename\"?: string;\n\tversion: boolean;\n}\n\nfunction getMode(argv: Record<string, any>): Mode {\n\tif (argv.init) {\n\t\treturn Mode.INIT;\n\t}\n\n\tif (argv[\"dump-events\"]) {\n\t\treturn Mode.DUMP_EVENTS;\n\t}\n\n\tif (argv[\"dump-source\"]) {\n\t\treturn Mode.DUMP_SOURCE;\n\t}\n\n\tif (argv[\"dump-tokens\"]) {\n\t\treturn Mode.DUMP_TOKENS;\n\t}\n\n\tif (argv[\"dump-tree\"]) {\n\t\treturn Mode.DUMP_TREE;\n\t}\n\n\tif (argv[\"print-config\"]) {\n\t\treturn Mode.PRINT_CONFIG;\n\t}\n\n\treturn Mode.LINT;\n}\n\nfunction requiresFilename(mode: Mode): boolean {\n\tswitch (mode) {\n\t\tcase Mode.LINT:\n\t\t\treturn true;\n\t\tcase Mode.INIT:\n\t\t\treturn false;\n\t\tcase Mode.DUMP_EVENTS:\n\t\tcase Mode.DUMP_TOKENS:\n\t\tcase Mode.DUMP_TREE:\n\t\tcase Mode.DUMP_SOURCE:\n\t\tcase Mode.PRINT_CONFIG:\n\t\t\treturn true;\n\t}\n}\n\nfunction handleUserError(err: UserError): void {\n\tconst formatted = err.prettyFormat();\n\tif (formatted) {\n\t\tconsole.error(); /* blank line */\n\t\tconsole.error(formatted);\n\t\treturn;\n\t}\n\n\tconsole.error(kleur.red(\"Caught exception:\"));\n\tconsole.group();\n\t{\n\t\tconsole.error(err.prettyFormat() ?? err);\n\t}\n\tconsole.groupEnd();\n}\n\nfunction handleUnknownError(err: unknown): void {\n\tconsole.error(kleur.red(\"Caught exception:\"));\n\tconsole.group();\n\t{\n\t\tconsole.error(err);\n\t}\n\tconsole.groupEnd();\n\tconst bugUrl = `${pkgBugs}?issuable_template=Bug`;\n\tconsole.error(kleur.red(`This is a bug in ${name}-${version}.`));\n\tconsole.error(\n\t\tkleur.red(\n\t\t\t[\n\t\t\t\t`Please file a bug at ${bugUrl}`,\n\t\t\t\t`and include this message in full and if possible the content of the`,\n\t\t\t\t`file being parsed (or a reduced testcase).`,\n\t\t\t].join(\"\\n\"),\n\t\t),\n\t);\n}\n\nconst argv = minimist<ParsedArgs>(process.argv.slice(2), {\n\tstring: [\n\t\t\"c\",\n\t\t\"config\",\n\t\t\"ext\",\n\t\t\"f\",\n\t\t\"formatter\",\n\t\t\"max-warnings\",\n\t\t\"p\",\n\t\t\"preset\",\n\t\t\"rule\",\n\t\t\"stdin-filename\",\n\t],\n\tboolean: [\n\t\t\"init\",\n\t\t\"dump-events\",\n\t\t\"dump-source\",\n\t\t\"dump-tokens\",\n\t\t\"dump-tree\",\n\t\t\"h\",\n\t\t\"help\",\n\t\t\"print-config\",\n\t\t\"stdin\",\n\t\t\"version\",\n\t],\n\talias: {\n\t\tc: \"config\",\n\t\tf: \"formatter\",\n\t\tp: \"preset\",\n\t\th: \"help\",\n\t},\n\tdefault: {\n\t\text: \"html\",\n\t\tformatter: \"stylish\",\n\t},\n\tunknown: (opt: string) => {\n\t\tif (opt.startsWith(\"-\")) {\n\t\t\tprocess.stderr.write(`unknown option ${opt}\\n`);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\treturn true;\n\t},\n});\n\nfunction showUsage(): void {\n\tprocess.stdout.write(`${name}-${version}\nUsage: html-validate [OPTIONS] [FILENAME..] [DIR..]\n\nCommon options:\n --ext=STRING specify file extensions (commaseparated).\n -f, --formatter=FORMATTER specify the formatter to use.\n --max-warnings=INT number of warnings to trigger nonzero exit code\n -p, --preset=STRING configuration preset to use, use\n comma-separator for multiple presets. (default:\n \"recommended\")\n --rule=RULE:SEVERITY set additional rule, use comma separator for\n multiple.\n --stdin process markup from stdin.\n --stdin-filename=STRING specify filename to report when using stdin\n\nMiscellaneous:\n -c, --config=STRING use custom configuration file.\n --init initialize project with a new configuration\n --print-config output configuration for given file.\n -h, --help show help.\n --version show version.\n\nDebugging options:\n --dump-events output events during parsing.\n --dump-source output post-transformed source data.\n --dump-tokens output tokens from lexing stage.\n --dump-tree output nodes from the dom tree.\n\nFormatters:\n\nMultiple formatters can be specified with a comma-separated list,\ne.g. \"json,checkstyle\" to enable both.\n\nTo capture output to a file use \"formatter=/path/to/file\",\ne.g. \"checkstyle=dist/html-validate.xml\"\n`);\n}\n\nfunction showVersion(): void {\n\tprocess.stdout.write(`${name}-${version}\\n`);\n}\n\nif (argv.stdin) {\n\targv._.push(\"-\");\n}\n\nif (argv.version) {\n\tshowVersion();\n\tprocess.exit();\n}\n\nif (argv.help) {\n\tshowUsage();\n\tprocess.exit();\n}\n\nif (argv._.length === 0) {\n\tconst mode = getMode(argv);\n\tif (mode === Mode.LINT) {\n\t\tshowUsage();\n\t\tprocess.exit(0);\n\t} else if (requiresFilename(mode)) {\n\t\tconst flag = modeToFlag(mode);\n\t\tconsole.error(`\\`${flag}\\` requires a filename.`);\n\t\tprocess.exit(1);\n\t}\n}\n\n/* check that supplied config file exists before creating CLI */\nif (typeof argv.config !== \"undefined\") {\n\tconst checkPath = path.resolve(argv.config);\n\tif (!fs.existsSync(checkPath)) {\n\t\tconsole.log(`The file \"${String(argv.config)}\" was not found.`);\n\t\tconsole.log(`The location this file was checked for at was: \"${String(checkPath)}\"`);\n\t\tprocess.exit(1);\n\t}\n}\n\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\tlet success: boolean;\n\t\tif (mode === Mode.LINT) {\n\t\t\tsuccess = await lint(htmlvalidate, process.stdout, files, {\n\t\t\t\tformatter,\n\t\t\t\tmaxWarnings,\n\t\t\t\tstdinFilename: argv[\"stdin-filename\"] ?? false,\n\t\t\t});\n\t\t} else if (mode === Mode.INIT) {\n\t\t\tsuccess = await init(cli, process.stdout, { cwd: process.cwd() });\n\t\t} else if (mode === Mode.PRINT_CONFIG) {\n\t\t\tsuccess = await printConfig(htmlvalidate, process.stdout, files);\n\t\t} else {\n\t\t\tsuccess = await dump(htmlvalidate, process.stdout, files, mode);\n\t\t}\n\t\tprocess.exit(success ? 0 : 1);\n\t} catch (err) {\n\t\tif (err instanceof SchemaValidationError) {\n\t\t\thandleSchemaValidationError(console, err);\n\t\t} else if (err instanceof UserError) {\n\t\t\thandleUserError(err);\n\t\t} else {\n\t\t\thandleUnknownError(err);\n\t\t}\n\t\tprocess.exit(1);\n\t}\n}\n\nrun().catch((err: unknown) => {\n\tconsole.error(err);\n\tprocess.exit(1);\n});\n"],"names":["argv","pkgBugs"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkCA,SAAS,QAAQA,KAAiC,EAAA;AACjD,EAAA,IAAIA,MAAK,IAAM,EAAA;AACd,IAAA,OAAO,IAAK,CAAA,IAAA;AAAA;AAGb,EAAIA,IAAAA,KAAAA,CAAK,aAAa,CAAG,EAAA;AACxB,IAAA,OAAO,IAAK,CAAA,WAAA;AAAA;AAGb,EAAIA,IAAAA,KAAAA,CAAK,aAAa,CAAG,EAAA;AACxB,IAAA,OAAO,IAAK,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,GAAK,EAAA,OAAA,CAAQ,GAAI,EAAA,EAAG,CAAA;AAAA,KACjE,MAAA,IAAW,IAAS,KAAA,IAAA,CAAK,YAAc,EAAA;AACtC,MAAA,OAAA,GAAU,MAAM,WAAA,CAAY,YAAc,EAAA,OAAA,CAAQ,QAAQ,KAAK,CAAA;AAAA,KACzD,MAAA;AACN,MAAA,OAAA,GAAU,MAAM,IAAK,CAAA,YAAA,EAAc,OAAQ,CAAA,MAAA,EAAQ,OAAO,IAAI,CAAA;AAAA;AAE/D,IAAQ,OAAA,CAAA,IAAA,CAAK,OAAU,GAAA,CAAA,GAAI,CAAC,CAAA;AAAA,WACpB,GAAK,EAAA;AACb,IAAA,IAAI,eAAe,qBAAuB,EAAA;AACzC,MAAA,2BAAA,CAA4B,SAAS,GAAG,CAAA;AAAA,KACzC,MAAA,IAAW,eAAe,SAAW,EAAA;AACpC,MAAA,eAAA,CAAgB,GAAG,CAAA;AAAA,KACb,MAAA;AACN,MAAA,kBAAA,CAAmB,GAAG,CAAA;AAAA;AAEvB,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA;AAEhB;AAEA,GAAI,EAAA,CAAE,KAAM,CAAA,CAAC,GAAiB,KAAA;AAC7B,EAAA,OAAA,CAAQ,MAAM,GAAG,CAAA;AACjB,EAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AACf,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"html-validate.js","sources":["../../src/cli/html-validate.ts"],"sourcesContent":["/* eslint-disable no-console, n/no-process-exit, sonarjs/no-duplicate-string -- as expected from a cli app */\nimport fs from \"fs\";\nimport path from \"node:path\";\nimport kleur from \"kleur\";\nimport minimist from \"minimist\";\nimport { 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\t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A,CAAQ,MAAM,GAAG,CAAA;AACjB,EAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AACf,CAAC,CAAA"}
|
package/dist/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { F as FileSystemConfigLoader, c as cjsResolver, a as compatibilityCheck, e as esmResolver, n as nodejsResolver } from './core-nodejs.js';
|
|
2
|
-
export { A as Attribute, C as Config, a as ConfigError, b as ConfigLoader, D as DOMNode,
|
|
2
|
+
export { A as Attribute, C as Config, a as ConfigError, b as ConfigLoader, D as DOMNode, h as DOMTokenList, j as DOMTree, k as DynamicValue, J as EventHandler, l as HtmlElement, H as HtmlValidate, M as MetaCopyableProperty, r as MetaTable, n as NestedError, N as NodeClosed, m as NodeType, P as Parser, E as Reporter, R as ResolvedConfig, u as Rule, o as SchemaValidationError, S as Severity, f as StaticConfigLoader, x as TextClassification, t as TextContent, T as TextNode, U as UserError, V as Validator, W as WrappedError, w as ariaNaming, y as classifyNodeText, p as configPresets, c as defineConfig, F as definePlugin, g as formatterFactory, q as isUserError, z as keywordPatternMatcher, G as ruleExists, B as sliceLocation, s as staticResolver, v as version, I as walk } from './core.js';
|
|
3
3
|
export { C as CLI } from './cli.js';
|
|
4
4
|
export { d as defineMetadata, m as metadataHelper } from './meta-helper.js';
|
|
5
5
|
import 'node:path';
|
|
@@ -13,6 +13,7 @@ import '@sidvind/better-ajv-errors';
|
|
|
13
13
|
import './utils/natural-join.js';
|
|
14
14
|
import '@html-validate/stylish';
|
|
15
15
|
import 'semver';
|
|
16
|
+
import 'node:path/posix';
|
|
16
17
|
import 'fs';
|
|
17
18
|
import 'glob';
|
|
18
19
|
import 'prompts';
|
package/dist/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import kleur from 'kleur';
|
|
2
2
|
import { toMatchSnapshot, toMatchInlineSnapshot } from 'jest-snapshot';
|
|
3
|
-
import {
|
|
3
|
+
import { X as codeframe } from './core.js';
|
|
4
4
|
import { g as getResults } from './matchers.js';
|
|
5
5
|
import { d as diverge, i as isThenable } from './matcher-utils.js';
|
|
6
6
|
|
package/dist/es/matchers.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { d as diverge, c as createSyncFn, f as flattenMessages } from './matcher-utils.js';
|
|
2
|
-
import { d as deepmerge,
|
|
2
|
+
import { d as deepmerge, Q as workerPath } from './core.js';
|
|
3
3
|
|
|
4
4
|
function createMatcher$4() {
|
|
5
5
|
function toBeValid(report) {
|
package/dist/types/browser.d.ts
CHANGED
|
@@ -297,12 +297,7 @@ export declare interface ConfigData {
|
|
|
297
297
|
rules?: RuleConfig;
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
-
|
|
301
|
-
* @public
|
|
302
|
-
*/
|
|
303
|
-
export declare class ConfigError extends UserError {
|
|
304
|
-
constructor(message: string, nested?: Error);
|
|
305
|
-
}
|
|
300
|
+
/* Excluded from this release type: ConfigError */
|
|
306
301
|
|
|
307
302
|
/**
|
|
308
303
|
* Configuration loader interface.
|
|
@@ -1347,6 +1342,14 @@ export declare interface IncludeExcludeOptions {
|
|
|
1347
1342
|
exclude: string[] | null;
|
|
1348
1343
|
}
|
|
1349
1344
|
|
|
1345
|
+
/**
|
|
1346
|
+
* Returns `true` if the error is a `UserError`, i.e. it is an error thrown that
|
|
1347
|
+
* is caused by something the end user caused such as a misconfiguration.
|
|
1348
|
+
*
|
|
1349
|
+
* @public
|
|
1350
|
+
*/
|
|
1351
|
+
export declare function isUserError(error: unknown): error is UserErrorData;
|
|
1352
|
+
|
|
1350
1353
|
/* Excluded from this release type: keywordPatternMatcher */
|
|
1351
1354
|
|
|
1352
1355
|
/**
|
|
@@ -2328,20 +2331,7 @@ export declare type RuleSeverity = "off" | "warn" | "error" | 0 | 1 | 2;
|
|
|
2328
2331
|
|
|
2329
2332
|
export { SchemaObject }
|
|
2330
2333
|
|
|
2331
|
-
|
|
2332
|
-
* @public
|
|
2333
|
-
*/
|
|
2334
|
-
export declare class SchemaValidationError extends UserError {
|
|
2335
|
-
/** Configuration filename the error originates from */
|
|
2336
|
-
readonly filename: string | null;
|
|
2337
|
-
/** Configuration object the error originates from */
|
|
2338
|
-
readonly obj: unknown;
|
|
2339
|
-
/** JSON schema used when validating the configuration */
|
|
2340
|
-
readonly schema: SchemaObject;
|
|
2341
|
-
/** List of schema validation errors */
|
|
2342
|
-
readonly errors: ErrorObject[];
|
|
2343
|
-
constructor(filename: string | null, message: string, obj: unknown, schema: SchemaObject, errors: ErrorObject[]);
|
|
2344
|
-
}
|
|
2334
|
+
/* Excluded from this release type: SchemaValidationError */
|
|
2345
2335
|
|
|
2346
2336
|
/**
|
|
2347
2337
|
* @public
|
|
@@ -2781,13 +2771,17 @@ export declare interface TriggerEventMap {
|
|
|
2781
2771
|
|
|
2782
2772
|
/* Excluded from this release type: UnicodeBOMToken */
|
|
2783
2773
|
|
|
2774
|
+
/* Excluded from this release type: UserError */
|
|
2775
|
+
|
|
2784
2776
|
/**
|
|
2777
|
+
* Represents a `UserError`, i.e. an error thrown that is caused by something
|
|
2778
|
+
* the end user caused such as a misconfiguration.
|
|
2779
|
+
*
|
|
2785
2780
|
* @public
|
|
2786
2781
|
*/
|
|
2787
|
-
export declare
|
|
2788
|
-
constructor(message: string, nested?: Error);
|
|
2782
|
+
export declare interface UserErrorData extends Error {
|
|
2789
2783
|
/**
|
|
2790
|
-
*
|
|
2784
|
+
* Returns a pretty formatted description of the error, if possible.
|
|
2791
2785
|
*/
|
|
2792
2786
|
prettyFormat(): string | undefined;
|
|
2793
2787
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -395,12 +395,7 @@ export declare interface ConfigData {
|
|
|
395
395
|
rules?: RuleConfig;
|
|
396
396
|
}
|
|
397
397
|
|
|
398
|
-
|
|
399
|
-
* @public
|
|
400
|
-
*/
|
|
401
|
-
export declare class ConfigError extends UserError {
|
|
402
|
-
constructor(message: string, nested?: Error);
|
|
403
|
-
}
|
|
398
|
+
/* Excluded from this release type: ConfigError */
|
|
404
399
|
|
|
405
400
|
/**
|
|
406
401
|
* Configuration loader interface.
|
|
@@ -1587,6 +1582,14 @@ export declare interface InitResult {
|
|
|
1587
1582
|
filename: string;
|
|
1588
1583
|
}
|
|
1589
1584
|
|
|
1585
|
+
/**
|
|
1586
|
+
* Returns `true` if the error is a `UserError`, i.e. it is an error thrown that
|
|
1587
|
+
* is caused by something the end user caused such as a misconfiguration.
|
|
1588
|
+
*
|
|
1589
|
+
* @public
|
|
1590
|
+
*/
|
|
1591
|
+
export declare function isUserError(error: unknown): error is UserErrorData;
|
|
1592
|
+
|
|
1590
1593
|
/* Excluded from this release type: keywordPatternMatcher */
|
|
1591
1594
|
|
|
1592
1595
|
/**
|
|
@@ -2593,20 +2596,7 @@ export declare type RuleSeverity = "off" | "warn" | "error" | 0 | 1 | 2;
|
|
|
2593
2596
|
|
|
2594
2597
|
export { SchemaObject }
|
|
2595
2598
|
|
|
2596
|
-
|
|
2597
|
-
* @public
|
|
2598
|
-
*/
|
|
2599
|
-
export declare class SchemaValidationError extends UserError {
|
|
2600
|
-
/** Configuration filename the error originates from */
|
|
2601
|
-
readonly filename: string | null;
|
|
2602
|
-
/** Configuration object the error originates from */
|
|
2603
|
-
readonly obj: unknown;
|
|
2604
|
-
/** JSON schema used when validating the configuration */
|
|
2605
|
-
readonly schema: SchemaObject;
|
|
2606
|
-
/** List of schema validation errors */
|
|
2607
|
-
readonly errors: ErrorObject[];
|
|
2608
|
-
constructor(filename: string | null, message: string, obj: unknown, schema: SchemaObject, errors: ErrorObject[]);
|
|
2609
|
-
}
|
|
2599
|
+
/* Excluded from this release type: SchemaValidationError */
|
|
2610
2600
|
|
|
2611
2601
|
/**
|
|
2612
2602
|
* @public
|
|
@@ -3046,13 +3036,17 @@ export declare interface TriggerEventMap {
|
|
|
3046
3036
|
|
|
3047
3037
|
/* Excluded from this release type: UnicodeBOMToken */
|
|
3048
3038
|
|
|
3039
|
+
/* Excluded from this release type: UserError */
|
|
3040
|
+
|
|
3049
3041
|
/**
|
|
3042
|
+
* Represents a `UserError`, i.e. an error thrown that is caused by something
|
|
3043
|
+
* the end user caused such as a misconfiguration.
|
|
3044
|
+
*
|
|
3050
3045
|
* @public
|
|
3051
3046
|
*/
|
|
3052
|
-
export declare
|
|
3053
|
-
constructor(message: string, nested?: Error);
|
|
3047
|
+
export declare interface UserErrorData extends Error {
|
|
3054
3048
|
/**
|
|
3055
|
-
*
|
|
3049
|
+
* Returns a pretty formatted description of the error, if possible.
|
|
3056
3050
|
*/
|
|
3057
3051
|
prettyFormat(): string | undefined;
|
|
3058
3052
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-validate",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.2.0",
|
|
4
4
|
"description": "Offline html5 validator",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"html",
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"jest": "^27.1 || ^28.1.3 || ^29.0.3",
|
|
110
110
|
"jest-diff": "^27.1 || ^28.1.3 || ^29.0.3",
|
|
111
111
|
"jest-snapshot": "^27.1 || ^28.1.3 || ^29.0.3",
|
|
112
|
-
"vitest": "^0.34.0 || ^1.0.0 || ^2.0.0"
|
|
112
|
+
"vitest": "^0.34.0 || ^1.0.0 || ^2.0.0 || ^3.0.0"
|
|
113
113
|
},
|
|
114
114
|
"peerDependenciesMeta": {
|
|
115
115
|
"jest": {
|
|
@@ -126,6 +126,6 @@
|
|
|
126
126
|
}
|
|
127
127
|
},
|
|
128
128
|
"engines": {
|
|
129
|
-
"node": ">=
|
|
129
|
+
"node": "^18.19.0 || >= 20.6.0"
|
|
130
130
|
}
|
|
131
131
|
}
|