html-validate 10.14.0 → 10.15.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 +50 -4
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/core-browser.js +60 -11
- package/dist/cjs/core-browser.js.map +1 -1
- package/dist/cjs/core-nodejs.js +60 -11
- package/dist/cjs/core-nodejs.js.map +1 -1
- package/dist/cjs/core.js +306 -176
- package/dist/cjs/core.js.map +1 -1
- package/dist/cjs/html-validate.js +4 -1
- package/dist/cjs/html-validate.js.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/browser.js +1 -1
- package/dist/esm/cli.js +51 -5
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/core-browser.js +61 -12
- package/dist/esm/core-browser.js.map +1 -1
- package/dist/esm/core-nodejs.js +61 -12
- package/dist/esm/core-nodejs.js.map +1 -1
- package/dist/esm/core.js +306 -177
- package/dist/esm/core.js.map +1 -1
- package/dist/esm/html-validate.js +5 -2
- package/dist/esm/html-validate.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/matcher-utils.js +1 -1
- package/dist/esm/matchers.js +1 -1
- package/dist/types/browser.d.ts +15 -0
- package/dist/types/index.d.ts +15 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-browser.js","sources":["../../src/htmlvalidate.browser.ts","../../src/config/resolver/browser/import-function.ts","../../src/config/resolver/browser/esm-resolver.ts","../../src/utils/compatibility-check.browser.ts"],"sourcesContent":["import { type SchemaObject } from \"ajv\";\nimport { type ConfigData, type ResolvedConfig, ConfigLoader } from \"./config\";\nimport { StaticConfigLoader } from \"./config/loaders/static\";\nimport { type Source, normalizeSource } from \"./context\";\nimport { type SourceHooks } from \"./context/source\";\nimport { type EventDump, type TokenDump, Engine } from \"./engine\";\nimport { UserError } from \"./error\";\nimport { type Message } from \"./message\";\nimport { Parser } from \"./parser\";\nimport { type Report, Reporter } from \"./reporter\";\nimport { type RuleDocumentation } from \"./rule\";\nimport configurationSchema from \"./schema/config.json\";\nimport {\n\ttype TransformFS,\n\ttransformFilename,\n\ttransformFilenameSync,\n\ttransformSource,\n\ttransformSourceSync,\n} from \"./transform\";\nimport { isThenable } from \"./utils/is-thenable\";\n\nfunction isSourceHooks(value: string | SourceHooks | ConfigData | undefined): value is SourceHooks {\n\tif (!value || typeof value !== \"object\") {\n\t\treturn false;\n\t}\n\treturn [\"processAttribute\", \"processElement\"].some((key) => key in value);\n}\n\nfunction isConfigData(value: string | SourceHooks | ConfigData | undefined): value is ConfigData {\n\tif (!value || typeof value !== \"object\") {\n\t\treturn false;\n\t}\n\treturn ![\"processAttribute\", \"processElement\"].some((key) => key in value);\n}\n\n/**\n * Primary API for using HTML-validate.\n *\n * Provides high-level abstractions for common operations.\n *\n * @public\n */\nexport class HtmlValidate {\n\tprotected configLoader: ConfigLoader;\n\n\t/**\n\t * Create a new validator.\n\t *\n\t * @public\n\t * @param configLoader - Use a custom configuration loader.\n\t * @param config - If set it provides the global default configuration. By\n\t * default `Config.defaultConfig()` is used.\n\t */\n\tpublic constructor(config?: ConfigData);\n\tpublic constructor(configLoader: ConfigLoader);\n\tpublic constructor(arg?: ConfigLoader | ConfigData) {\n\t\tconst [loader, config] = arg instanceof ConfigLoader ? [arg, undefined] : [undefined, arg];\n\t\tthis.configLoader = loader ?? new StaticConfigLoader(config);\n\t}\n\n\t/**\n\t * Parse and validate HTML from string.\n\t *\n\t * @public\n\t * @param str - Text to parse.\n\t * @param filename - If set configuration is loaded for given filename.\n\t * @param hooks - Optional hooks (see [[Source]]) for definition.\n\t * @returns Report output.\n\t */\n\t/* eslint-disable @typescript-eslint/unified-signatures -- for easier readability */\n\tpublic validateString(str: string): Promise<Report>;\n\tpublic validateString(str: string, filename: string): Promise<Report>;\n\tpublic validateString(str: string, hooks: SourceHooks): Promise<Report>;\n\tpublic validateString(str: string, options: ConfigData): Promise<Report>;\n\tpublic validateString(str: string, filename: string, hooks: SourceHooks): Promise<Report>;\n\tpublic validateString(str: string, filename: string, options: ConfigData): Promise<Report>;\n\tpublic validateString(\n\t\tstr: string,\n\t\tfilename: string,\n\t\toptions: ConfigData,\n\t\thooks: SourceHooks,\n\t): Promise<Report>;\n\t/* eslint-enable @typescript-eslint/unified-signatures */\n\tpublic validateString(\n\t\tstr: string,\n\t\targ1?: string | SourceHooks | ConfigData,\n\t\targ2?: SourceHooks | ConfigData,\n\t\targ3?: SourceHooks,\n\t): Promise<Report> {\n\t\tconst filename = typeof arg1 === \"string\" ? arg1 : \"inline\";\n\t\tconst options = isConfigData(arg1) ? arg1 : isConfigData(arg2) ? arg2 : undefined; // eslint-disable-line sonarjs/no-nested-conditional -- easier to read than the alternative */\n\t\tconst hooks = isSourceHooks(arg1) ? arg1 : isSourceHooks(arg2) ? arg2 : arg3; // eslint-disable-line sonarjs/no-nested-conditional -- easier to read than the alternative */\n\t\tconst source = {\n\t\t\tdata: str,\n\t\t\tfilename,\n\t\t\tline: 1,\n\t\t\tcolumn: 1,\n\t\t\toffset: 0,\n\t\t\thooks,\n\t\t};\n\t\treturn this.validateSource(source, options);\n\t}\n\n\t/**\n\t * Parse and validate HTML from string.\n\t *\n\t * @public\n\t * @param str - Text to parse.\n\t * @param filename - If set configuration is loaded for given filename.\n\t * @param hooks - Optional hooks (see [[Source]]) for definition.\n\t * @returns Report output.\n\t */\n\t/* eslint-disable @typescript-eslint/unified-signatures -- for easier readability */\n\tpublic validateStringSync(str: string): Report;\n\tpublic validateStringSync(str: string, filename: string): Report;\n\tpublic validateStringSync(str: string, hooks: SourceHooks): Report;\n\tpublic validateStringSync(str: string, options: ConfigData): Report;\n\tpublic validateStringSync(str: string, filename: string, hooks: SourceHooks): Report;\n\tpublic validateStringSync(str: string, filename: string, options: ConfigData): Report;\n\tpublic validateStringSync(\n\t\tstr: string,\n\t\tfilename: string,\n\t\toptions: ConfigData,\n\t\thooks: SourceHooks,\n\t): Report;\n\t/* eslint-enable @typescript-eslint/unified-signatures */\n\tpublic validateStringSync(\n\t\tstr: string,\n\t\targ1?: string | SourceHooks | ConfigData,\n\t\targ2?: SourceHooks | ConfigData,\n\t\targ3?: SourceHooks,\n\t): Report {\n\t\tconst filename = typeof arg1 === \"string\" ? arg1 : \"inline\";\n\t\tconst options = isConfigData(arg1) ? arg1 : isConfigData(arg2) ? arg2 : undefined; // eslint-disable-line sonarjs/no-nested-conditional -- easier to read than the alternative */\n\t\tconst hooks = isSourceHooks(arg1) ? arg1 : isSourceHooks(arg2) ? arg2 : arg3; // eslint-disable-line sonarjs/no-nested-conditional -- easier to read than the alternative */\n\t\tconst source = {\n\t\t\tdata: str,\n\t\t\tfilename,\n\t\t\tline: 1,\n\t\t\tcolumn: 1,\n\t\t\toffset: 0,\n\t\t\thooks,\n\t\t};\n\t\treturn this.validateSourceSync(source, options);\n\t}\n\n\t/**\n\t * Parse and validate HTML from [[Source]].\n\t *\n\t * @public\n\t * @param input - Source to parse.\n\t * @returns Report output.\n\t */\n\tpublic async validateSource(input: Source, configOverride?: ConfigData): Promise<Report> {\n\t\tconst source = normalizeSource(input);\n\t\tconst config = await this.getConfigFor(source.filename, configOverride);\n\t\tconst resolvers = this.configLoader.getResolvers();\n\t\tconst transformedSource = await transformSource(resolvers, config, source);\n\t\tconst engine = new Engine(config, Parser);\n\t\treturn engine.lint(transformedSource);\n\t}\n\n\t/**\n\t * Parse and validate HTML from [[Source]].\n\t *\n\t * @public\n\t * @param input - Source to parse.\n\t * @returns Report output.\n\t */\n\tpublic validateSourceSync(input: Source, configOverride?: ConfigData): Report {\n\t\tconst source = normalizeSource(input);\n\t\tconst config = this.getConfigForSync(source.filename, configOverride);\n\t\tconst resolvers = this.configLoader.getResolvers();\n\t\tconst transformedSource = transformSourceSync(resolvers, config, source);\n\t\tconst engine = new Engine(config, Parser);\n\t\treturn engine.lint(transformedSource);\n\t}\n\n\t/**\n\t * Parse and validate HTML from file.\n\t *\n\t * @public\n\t * @param filename - Filename to read and parse.\n\t * @returns Report output.\n\t */\n\tpublic async validateFile(filename: string, fs: TransformFS): Promise<Report> {\n\t\tconst config = await this.getConfigFor(filename);\n\t\tconst resolvers = this.configLoader.getResolvers();\n\t\tconst source = await transformFilename(resolvers, config, filename, fs);\n\t\tconst engine = new Engine(config, Parser);\n\t\treturn engine.lint(source);\n\t}\n\n\t/**\n\t * Parse and validate HTML from file.\n\t *\n\t * @public\n\t * @param filename - Filename to read and parse.\n\t * @returns Report output.\n\t */\n\tpublic validateFileSync(filename: string, fs: TransformFS): Report {\n\t\tconst config = this.getConfigForSync(filename);\n\t\tconst resolvers = this.configLoader.getResolvers();\n\t\tconst source = transformFilenameSync(resolvers, config, filename, fs);\n\t\tconst engine = new Engine(config, Parser);\n\t\treturn engine.lint(source);\n\t}\n\n\t/**\n\t * Parse and validate HTML from multiple files. Result is merged together to a\n\t * single report.\n\t *\n\t * @param filenames - Filenames to read and parse.\n\t * @returns Report output.\n\t */\n\tpublic async validateMultipleFiles(filenames: string[], fs: TransformFS): Promise<Report> {\n\t\treturn Reporter.merge(filenames.map((filename) => this.validateFile(filename, fs)));\n\t}\n\n\t/**\n\t * Parse and validate HTML from multiple files. Result is merged together to a\n\t * single report.\n\t *\n\t * @param filenames - Filenames to read and parse.\n\t * @returns Report output.\n\t */\n\tpublic validateMultipleFilesSync(filenames: string[], fs: TransformFS): Report {\n\t\treturn Reporter.merge(filenames.map((filename) => this.validateFileSync(filename, fs)));\n\t}\n\n\t/**\n\t * Returns true if the given filename can be validated.\n\t *\n\t * A file is considered to be validatable if the extension is `.html` or if a\n\t * transformer matches the filename.\n\t *\n\t * This is mostly useful for tooling to determine whenever to validate the\n\t * file or not. CLI tools will run on all the given files anyway.\n\t */\n\tpublic async canValidate(filename: string): Promise<boolean> {\n\t\t/* .html is always supported */\n\t\tif (filename.toLowerCase().endsWith(\".html\")) {\n\t\t\treturn true;\n\t\t}\n\n\t\t/* test if there is a matching transformer */\n\t\tconst config = await this.getConfigFor(filename);\n\t\treturn config.canTransform(filename);\n\t}\n\n\t/**\n\t * Returns true if the given filename can be validated.\n\t *\n\t * A file is considered to be validatable if the extension is `.html` or if a\n\t * transformer matches the filename.\n\t *\n\t * This is mostly useful for tooling to determine whenever to validate the\n\t * file or not. CLI tools will run on all the given files anyway.\n\t */\n\tpublic canValidateSync(filename: string): boolean {\n\t\t/* .html is always supported */\n\t\tif (filename.toLowerCase().endsWith(\".html\")) {\n\t\t\treturn true;\n\t\t}\n\n\t\t/* test if there is a matching transformer */\n\t\tconst config = this.getConfigForSync(filename);\n\t\treturn config.canTransform(filename);\n\t}\n\n\t/**\n\t * Tokenize filename and output all tokens.\n\t *\n\t * Using CLI this is enabled with `--dump-tokens`. Mostly useful for\n\t * debugging.\n\t *\n\t * @internal\n\t * @param filename - Filename to tokenize.\n\t */\n\tpublic async dumpTokens(filename: string, fs: TransformFS): Promise<TokenDump[]> {\n\t\tconst config = await this.getConfigFor(filename);\n\t\tconst resolvers = this.configLoader.getResolvers();\n\t\tconst source = await transformFilename(resolvers, config, filename, fs);\n\t\tconst engine = new Engine(config, Parser);\n\t\treturn engine.dumpTokens(source);\n\t}\n\n\t/**\n\t * Parse filename and output all events.\n\t *\n\t * Using CLI this is enabled with `--dump-events`. Mostly useful for\n\t * debugging.\n\t *\n\t * @internal\n\t * @param filename - Filename to dump events from.\n\t */\n\tpublic async dumpEvents(filename: string, fs: TransformFS): Promise<EventDump[]> {\n\t\tconst config = await this.getConfigFor(filename);\n\t\tconst resolvers = this.configLoader.getResolvers();\n\t\tconst source = await transformFilename(resolvers, config, filename, fs);\n\t\tconst engine = new Engine(config, Parser);\n\t\treturn engine.dumpEvents(source);\n\t}\n\n\t/**\n\t * Parse filename and output DOM tree.\n\t *\n\t * Using CLI this is enabled with `--dump-tree`. Mostly useful for\n\t * debugging.\n\t *\n\t * @internal\n\t * @param filename - Filename to dump DOM tree from.\n\t */\n\tpublic async dumpTree(filename: string, fs: TransformFS): Promise<string[]> {\n\t\tconst config = await this.getConfigFor(filename);\n\t\tconst resolvers = this.configLoader.getResolvers();\n\t\tconst source = await transformFilename(resolvers, config, filename, fs);\n\t\tconst engine = new Engine(config, Parser);\n\t\treturn engine.dumpTree(source);\n\t}\n\n\t/**\n\t * Transform filename and output source data.\n\t *\n\t * Using CLI this is enabled with `--dump-source`. Mostly useful for\n\t * debugging.\n\t *\n\t * @internal\n\t * @param filename - Filename to dump source from.\n\t */\n\tpublic async dumpSource(filename: string, fs: TransformFS): Promise<string[]> {\n\t\tconst config = await this.getConfigFor(filename);\n\t\tconst resolvers = this.configLoader.getResolvers();\n\t\tconst sources = await transformFilename(resolvers, config, filename, fs);\n\t\treturn sources.reduce<string[]>((result: string[], source: Source) => {\n\t\t\tconst line = String(source.line);\n\t\t\tconst column = String(source.column);\n\t\t\tconst offset = String(source.offset);\n\t\t\tresult.push(`Source ${source.filename}@${line}:${column} (offset: ${offset})`);\n\t\t\tif (source.transformedBy) {\n\t\t\t\tresult.push(\"Transformed by:\");\n\t\t\t\tresult = result.concat(source.transformedBy.toReversed().map((name) => ` - ${name}`));\n\t\t\t}\n\t\t\tif (source.hooks && Object.keys(source.hooks).length > 0) {\n\t\t\t\tresult.push(\"Hooks\");\n\t\t\t\tfor (const [key, present] of Object.entries(source.hooks)) {\n\t\t\t\t\tif (present) {\n\t\t\t\t\t\tresult.push(` - ${key}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tresult.push(\"---\");\n\t\t\tresult = result.concat(source.data.split(\"\\n\"));\n\t\t\tresult.push(\"---\");\n\t\t\treturn result;\n\t\t}, []);\n\t}\n\n\t/**\n\t * Get effective configuration schema.\n\t */\n\tpublic getConfigurationSchema(): Promise<SchemaObject> {\n\t\treturn Promise.resolve(configurationSchema);\n\t}\n\n\t/**\n\t * Get effective metadata element schema.\n\t *\n\t * If a filename is given the configured plugins can extend the\n\t * schema. Filename must not be an existing file or a filetype normally\n\t * handled by html-validate but the path will be used when resolving\n\t * configuration. As a rule-of-thumb, set it to the elements json file.\n\t */\n\tpublic async getElementsSchema(filename?: string): Promise<SchemaObject> {\n\t\tconst config = await this.getConfigFor(filename ?? \"inline\");\n\t\tconst metaTable = config.getMetaTable();\n\t\treturn metaTable.getJSONSchema();\n\t}\n\n\t/**\n\t * Get effective metadata element schema.\n\t *\n\t * If a filename is given the configured plugins can extend the\n\t * schema. Filename must not be an existing file or a filetype normally\n\t * handled by html-validate but the path will be used when resolving\n\t * configuration. As a rule-of-thumb, set it to the elements json file.\n\t */\n\tpublic getElementsSchemaSync(filename?: string): SchemaObject {\n\t\tconst config = this.getConfigForSync(filename ?? \"inline\");\n\t\tconst metaTable = config.getMetaTable();\n\t\treturn metaTable.getJSONSchema();\n\t}\n\n\t/**\n\t * Get contextual documentation for the given rule. Configuration will be\n\t * resolved for given filename.\n\t *\n\t * @example\n\t *\n\t * ```js\n\t * const report = await htmlvalidate.validateFile(\"my-file.html\");\n\t * for (const result of report.results){\n\t * for (const message of result.messages){\n\t * const documentation = await htmlvalidate.getContextualDocumentation(message, result.filePath);\n\t * // do something with documentation\n\t * }\n\t * }\n\t * ```\n\t *\n\t * @public\n\t * @since 8.0.0\n\t * @param message - Message reported during validation\n\t * @param filename - Filename used to resolve configuration.\n\t * @returns Contextual documentation or `null` if the rule does not exist.\n\t */\n\tpublic getContextualDocumentation(\n\t\tmessage: Pick<Message, \"ruleId\" | \"context\">,\n\t\tfilename?: string,\n\t): Promise<RuleDocumentation | null>;\n\n\t/**\n\t * Get contextual documentation for the given rule using provided\n\t * configuration.\n\t *\n\t * @example\n\t *\n\t * ```js\n\t * const report = await htmlvalidate.validateFile(\"my-file.html\");\n\t * for (const result of report.results){\n\t * for (const message of result.messages){\n\t * const documentation = await htmlvalidate.getRuleDocumentation(message, result.filePath);\n\t * // do something with documentation\n\t * }\n\t * }\n\t * ```\n\t *\n\t * @public\n\t * @since 8.0.0\n\t * @param message - Message reported during validation\n\t * @param config - Configuration to use.\n\t * @returns Contextual documentation or `null` if the rule does not exist.\n\t */\n\tpublic getContextualDocumentation(\n\t\tmessage: Pick<Message, \"ruleId\" | \"context\">,\n\t\tconfig: ResolvedConfig | Promise<ResolvedConfig>,\n\t): Promise<RuleDocumentation | null>;\n\n\tpublic async getContextualDocumentation(\n\t\tmessage: Pick<Message, \"ruleId\" | \"context\">,\n\t\tfilenameOrConfig: ResolvedConfig | Promise<ResolvedConfig> | string = \"inline\",\n\t): Promise<RuleDocumentation | null> {\n\t\tconst config =\n\t\t\ttypeof filenameOrConfig === \"string\"\n\t\t\t\t? await this.getConfigFor(filenameOrConfig)\n\t\t\t\t: await filenameOrConfig;\n\t\tconst engine = new Engine(config, Parser);\n\t\treturn engine.getRuleDocumentation(message);\n\t}\n\n\t/**\n\t * Get contextual documentation for the given rule. Configuration will be\n\t * resolved for given filename.\n\t *\n\t * @example\n\t *\n\t * ```js\n\t * const report = htmlvalidate.validateFileSync(\"my-file.html\");\n\t * for (const result of report.results){\n\t * for (const message of result.messages){\n\t * const documentation = htmlvalidate.getRuleDocumentationSync(message, result.filePath);\n\t * // do something with documentation\n\t * }\n\t * }\n\t * ```\n\t *\n\t * @public\n\t * @since 8.0.0\n\t * @param message - Message reported during validation\n\t * @param filename - Filename used to resolve configuration.\n\t * @returns Contextual documentation or `null` if the rule does not exist.\n\t */\n\tpublic getContextualDocumentationSync(\n\t\tmessage: Pick<Message, \"ruleId\" | \"context\">,\n\t\tfilename?: string,\n\t): RuleDocumentation | null;\n\n\t/**\n\t * Get contextual documentation for the given rule using provided\n\t * configuration.\n\t *\n\t * @example\n\t *\n\t * ```js\n\t * const report = htmlvalidate.validateFileSync(\"my-file.html\");\n\t * for (const result of report.results){\n\t * for (const message of result.messages){\n\t * const documentation = htmlvalidate.getRuleDocumentationSync(message, result.filePath);\n\t * // do something with documentation\n\t * }\n\t * }\n\t * ```\n\t *\n\t * @public\n\t * @since 8.0.0\n\t * @param message - Message reported during validation\n\t * @param config - Configuration to use.\n\t * @returns Contextual documentation or `null` if the rule does not exist.\n\t */\n\tpublic getContextualDocumentationSync(\n\t\tmessage: Pick<Message, \"ruleId\" | \"context\">,\n\t\tconfig: ResolvedConfig,\n\t): RuleDocumentation | null;\n\n\tpublic getContextualDocumentationSync(\n\t\tmessage: Pick<Message, \"ruleId\" | \"context\">,\n\t\tfilenameOrConfig: ResolvedConfig | string = \"inline\",\n\t): RuleDocumentation | null {\n\t\tconst config =\n\t\t\ttypeof filenameOrConfig === \"string\"\n\t\t\t\t? this.getConfigForSync(filenameOrConfig)\n\t\t\t\t: filenameOrConfig;\n\t\tconst engine = new Engine(config, Parser);\n\t\treturn engine.getRuleDocumentation(message);\n\t}\n\n\t/**\n\t * Get contextual documentation for the given rule.\n\t *\n\t * Typical usage:\n\t *\n\t * ```js\n\t * const report = await htmlvalidate.validateFile(\"my-file.html\");\n\t * for (const result of report.results){\n\t * const config = await htmlvalidate.getConfigFor(result.filePath);\n\t * for (const message of result.messages){\n\t * const documentation = await htmlvalidate.getRuleDocumentation(message.ruleId, config, message.context);\n\t * // do something with documentation\n\t * }\n\t * }\n\t * ```\n\t *\n\t * @public\n\t * @deprecated Deprecated since 8.0.0, use [[getContextualDocumentation]] instead.\n\t * @param ruleId - Rule to get documentation for.\n\t * @param config - If set it provides more accurate description by using the\n\t * correct configuration for the file.\n\t * @param context - If set to `Message.context` some rules can provide\n\t * contextual details and suggestions.\n\t */\n\tpublic async getRuleDocumentation(\n\t\truleId: string,\n\t\tconfig: ResolvedConfig | Promise<ResolvedConfig> | null = null,\n\t\tcontext: unknown | null = null,\n\t): Promise<RuleDocumentation | null> {\n\t\tconst c = config ?? this.getConfigFor(\"inline\");\n\t\tconst engine = new Engine(await c, Parser);\n\t\treturn engine.getRuleDocumentation({ ruleId, context });\n\t}\n\n\t/**\n\t * Get contextual documentation for the given rule.\n\t *\n\t * Typical usage:\n\t *\n\t * ```js\n\t * const report = htmlvalidate.validateFileSync(\"my-file.html\");\n\t * for (const result of report.results){\n\t * const config = htmlvalidate.getConfigForSync(result.filePath);\n\t * for (const message of result.messages){\n\t * const documentation = htmlvalidate.getRuleDocumentationSync(message.ruleId, config, message.context);\n\t * // do something with documentation\n\t * }\n\t * }\n\t * ```\n\t *\n\t * @public\n\t * @deprecated Deprecated since 8.0.0, use [[getContextualDocumentationSync]] instead.\n\t * @param ruleId - Rule to get documentation for.\n\t * @param config - If set it provides more accurate description by using the\n\t * correct configuration for the file.\n\t * @param context - If set to `Message.context` some rules can provide\n\t * contextual details and suggestions.\n\t */\n\tpublic getRuleDocumentationSync(\n\t\truleId: string,\n\t\tconfig: ResolvedConfig | null = null,\n\t\tcontext: unknown | null = null,\n\t): RuleDocumentation | null {\n\t\tconst c = config ?? this.getConfigForSync(\"inline\");\n\t\tconst engine = new Engine(c, Parser);\n\t\treturn engine.getRuleDocumentation({ ruleId, context });\n\t}\n\n\t/**\n\t * Create a parser configured for given filename.\n\t *\n\t * @internal\n\t * @param source - Source to use.\n\t */\n\tpublic async getParserFor(source: Source): Promise<Parser> {\n\t\tconst config = await this.getConfigFor(source.filename);\n\t\treturn new Parser(config);\n\t}\n\n\t/**\n\t * Get configuration for given filename.\n\t *\n\t * See [[FileSystemConfigLoader]] for details.\n\t *\n\t * @public\n\t * @param filename - Filename to get configuration for.\n\t * @param configOverride - Configuration to apply last.\n\t */\n\tpublic getConfigFor(filename: string, configOverride?: ConfigData): Promise<ResolvedConfig> {\n\t\tconst config = this.configLoader.getConfigFor(filename, configOverride);\n\t\treturn Promise.resolve(config);\n\t}\n\n\t/**\n\t * Get configuration for given filename.\n\t *\n\t * See [[FileSystemConfigLoader]] for details.\n\t *\n\t * @public\n\t * @param filename - Filename to get configuration for.\n\t * @param configOverride - Configuration to apply last.\n\t */\n\tpublic getConfigForSync(filename: string, configOverride?: ConfigData): ResolvedConfig {\n\t\tconst config = this.configLoader.getConfigFor(filename, configOverride);\n\t\tif (isThenable(config)) {\n\t\t\tthrow new UserError(\"Cannot use asynchronous config loader with synchronous api\");\n\t\t}\n\t\treturn config;\n\t}\n\n\t/**\n\t * Get current configuration loader.\n\t *\n\t * @public\n\t * @since %version%\n\t * @returns Current configuration loader.\n\t */\n\t/* istanbul ignore next -- not testing setters/getters */\n\tpublic getConfigLoader(): ConfigLoader {\n\t\treturn this.configLoader;\n\t}\n\n\t/**\n\t * Set configuration loader.\n\t *\n\t * @public\n\t * @since %version%\n\t * @param loader - New configuration loader to use.\n\t */\n\t/* istanbul ignore next -- not testing setters/getters */\n\tpublic setConfigLoader(loader: ConfigLoader): void {\n\t\tthis.configLoader = loader;\n\t}\n\n\t/**\n\t * Flush configuration cache. Clears full cache unless a filename is given.\n\t *\n\t * See [[FileSystemConfigLoader]] for details.\n\t *\n\t * @public\n\t * @param filename - If set, only flush cache for given filename.\n\t */\n\tpublic flushConfigCache(filename?: string): void {\n\t\tthis.configLoader.flushCache(filename);\n\t}\n}\n","/* istanbul ignore file: this file is only for easier mocking */\n\n/**\n * Wrapper around import() so we can mock it in unittests.\n *\n * @internal\n */\nexport function importFunction(id: string): unknown {\n\treturn import(id);\n}\n","import { UserError } from \"../../../error\";\nimport { type MetaDataTable } from \"../../../meta\";\nimport { type Plugin } from \"../../../plugin\";\nimport { type Transformer } from \"../../../transform\";\nimport { type ConfigData } from \"../../config-data\";\nimport { type Resolver } from \"../resolver\";\nimport { importFunction } from \"./import-function\";\n\nexport async function internalImport<T = unknown>(id: string): Promise<T | null> {\n\tconst { default: defaultImport } = (await importFunction(id)) as { default?: T };\n\tif (!defaultImport) {\n\t\tthrow new UserError(`\"${id}\" does not have a default export`);\n\t}\n\treturn defaultImport;\n}\n\n/**\n * ESM resolver.\n *\n * @public\n * @since 9.0.0\n */\nexport type ESMResolver = Required<Resolver>;\n\n/**\n * Create a new resolver for using `import(..)`.\n *\n * @public\n * @since 9.0.0\n */\nexport function esmResolver(): ESMResolver {\n\treturn {\n\t\tname: \"esm-resolver\",\n\n\t\tresolveElements(id: string): Promise<MetaDataTable | null> {\n\t\t\treturn internalImport(id);\n\t\t},\n\n\t\tresolveConfig(id: string): Promise<ConfigData | null> {\n\t\t\treturn internalImport(id);\n\t\t},\n\n\t\tresolvePlugin(id: string): Promise<Plugin | null> {\n\t\t\treturn internalImport<Plugin>(id);\n\t\t},\n\n\t\tasync resolveTransformer(id: string): Promise<Transformer | null> {\n\t\t\treturn internalImport(id);\n\t\t},\n\t};\n}\n","import { version } from \"../generated/package-json\";\nimport { type CompatibilityOptions, compatibilityCheckImpl } from \"./compatibility-check\";\n\nconst defaults: CompatibilityOptions = {\n\tsilent: false,\n\tversion,\n\tlogger(text: string): void {\n\t\t/* eslint-disable-next-line no-console -- expected to log */\n\t\tconsole.error(text);\n\t},\n};\n\n/**\n * Tests if plugin is compatible with html-validate library. Unless the `silent`\n * option is used a warning is displayed on the console.\n *\n * @public\n * @since v5.0.0\n * @param name - Name of plugin\n * @param declared - What library versions the plugin support (e.g. declared peerDependencies)\n * @returns - `true` if version is compatible\n */\nexport function compatibilityCheck(\n\tname: string,\n\tdeclared: string,\n\toptions?: Partial<CompatibilityOptions>,\n): boolean {\n\treturn compatibilityCheckImpl(name, declared, {\n\t\t...defaults,\n\t\t...options,\n\t});\n}\n"],"names":["ConfigLoader","StaticConfigLoader","normalizeSource","transformSource","Engine","Parser","transformSourceSync","transformFilename","transformFilenameSync","Reporter","configurationSchema","isThenable","UserError","version","compatibilityCheckImpl"],"mappings":";;;;AAqBA,SAAS,cAAc,KAAA,EAA4E;AAClG,EAAA,IAAI,CAAC,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,EAAU;AACxC,IAAA,OAAO,KAAA;AAAA,EACR;AACA,EAAA,OAAO,CAAC,oBAAoB,gBAAgB,CAAA,CAAE,KAAK,CAAC,GAAA,KAAQ,OAAO,KAAK,CAAA;AACzE;AAEA,SAAS,aAAa,KAAA,EAA2E;AAChG,EAAA,IAAI,CAAC,KAAA,IAAS,OAAO,KAAA,KAAU,Q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IAAI,CAAA;AAAA,EACnB;AACD,CAAA;AAYO,SAAS,kBAAA,CACf,IAAA,EACA,QAAA,EACA,OAAA,EACU;AACV,EAAA,OAAOC,2BAAA,CAAuB,MAAM,QAAA,EAAU;AAAA,IAC7C,GAAG,QAAA;AAAA,IACH,GAAG;AAAA,GACH,CAAA;AACF;;;;;;"}
|
|
1
|
+
{"version":3,"file":"core-browser.js","sources":["../../src/htmlvalidate.browser.ts","../../src/config/resolver/browser/import-function.ts","../../src/config/resolver/browser/esm-resolver.ts","../../src/utils/compatibility-check.browser.ts"],"sourcesContent":["import { type SchemaObject } from \"ajv\";\nimport { type ConfigData, type ResolvedConfig, ConfigLoader } from \"./config\";\nimport { StaticConfigLoader } from \"./config/loaders/static\";\nimport { type Source, normalizeSource } from \"./context\";\nimport { type SourceHooks } from \"./context/source\";\nimport { type EventDump, type TokenDump, Engine } from \"./engine\";\nimport { UserError } from \"./error\";\nimport { type Message } from \"./message\";\nimport { Parser } from \"./parser\";\nimport { type PerformanceResult, PerformanceTracker } from \"./performance\";\nimport { type Report, Reporter } from \"./reporter\";\nimport { type RuleDocumentation } from \"./rule\";\nimport configurationSchema from \"./schema/config.json\";\nimport {\n\ttype TransformFS,\n\ttransformFilename,\n\ttransformFilenameSync,\n\ttransformSource,\n\ttransformSourceSync,\n} from \"./transform\";\nimport { isThenable } from \"./utils/is-thenable\";\n\nfunction isSourceHooks(value: string | SourceHooks | ConfigData | undefined): value is SourceHooks {\n\tif (!value || typeof value !== \"object\") {\n\t\treturn false;\n\t}\n\treturn [\"processAttribute\", \"processElement\"].some((key) => key in value);\n}\n\nfunction isConfigData(value: string | SourceHooks | ConfigData | undefined): value is ConfigData {\n\tif (!value || typeof value !== \"object\") {\n\t\treturn false;\n\t}\n\treturn ![\"processAttribute\", \"processElement\"].some((key) => key in value);\n}\n\n/**\n * Primary API for using HTML-validate.\n *\n * Provides high-level abstractions for common operations.\n *\n * @public\n */\nexport class HtmlValidate {\n\tprotected configLoader: ConfigLoader;\n\tprivate _performanceTracker: PerformanceTracker | null;\n\n\t/**\n\t * Create a new validator.\n\t *\n\t * @public\n\t * @param configLoader - Use a custom configuration loader.\n\t * @param config - If set it provides the global default configuration. By\n\t * default `Config.defaultConfig()` is used.\n\t */\n\tpublic constructor(config?: ConfigData);\n\tpublic constructor(configLoader: ConfigLoader);\n\tpublic constructor(arg?: ConfigLoader | ConfigData) {\n\t\tconst [loader, config] = arg instanceof ConfigLoader ? [arg, undefined] : [undefined, arg];\n\t\tthis.configLoader = loader ?? new StaticConfigLoader(config);\n\t\tthis._performanceTracker = null;\n\t}\n\n\t/**\n\t * Start recording performance data.\n\t *\n\t * When active, performance data is accumulated across all subsequent calls to\n\t * `validateString()`, `validateFile()` and similar methods until\n\t * {@link HtmlValidate.stopPerformance} is called.\n\t *\n\t * @internal\n\t */\n\tpublic startPerformance(): void {\n\t\tthis._performanceTracker = new PerformanceTracker();\n\t}\n\n\t/**\n\t * Stop recording performance data and return the result.\n\t *\n\t * @internal\n\t */\n\tpublic stopPerformance(): PerformanceResult {\n\t\tif (!this._performanceTracker) {\n\t\t\treturn { events: [], rules: [], configTime: 0, transformTime: 0, totalTime: 0 };\n\t\t}\n\t\tconst result = this._performanceTracker.getResult();\n\t\tthis._performanceTracker = null;\n\t\treturn result;\n\t}\n\n\t/**\n\t * Parse and validate HTML from string.\n\t *\n\t * @public\n\t * @param str - Text to parse.\n\t * @param filename - If set configuration is loaded for given filename.\n\t * @param hooks - Optional hooks (see [[Source]]) for definition.\n\t * @returns Report output.\n\t */\n\t/* eslint-disable @typescript-eslint/unified-signatures -- for easier readability */\n\tpublic validateString(str: string): Promise<Report>;\n\tpublic validateString(str: string, filename: string): Promise<Report>;\n\tpublic validateString(str: string, hooks: SourceHooks): Promise<Report>;\n\tpublic validateString(str: string, options: ConfigData): Promise<Report>;\n\tpublic validateString(str: string, filename: string, hooks: SourceHooks): Promise<Report>;\n\tpublic validateString(str: string, filename: string, options: ConfigData): Promise<Report>;\n\tpublic validateString(\n\t\tstr: string,\n\t\tfilename: string,\n\t\toptions: ConfigData,\n\t\thooks: SourceHooks,\n\t): Promise<Report>;\n\t/* eslint-enable @typescript-eslint/unified-signatures */\n\tpublic validateString(\n\t\tstr: string,\n\t\targ1?: string | SourceHooks | ConfigData,\n\t\targ2?: SourceHooks | ConfigData,\n\t\targ3?: SourceHooks,\n\t): Promise<Report> {\n\t\tconst filename = typeof arg1 === \"string\" ? arg1 : \"inline\";\n\t\tconst options = isConfigData(arg1) ? arg1 : isConfigData(arg2) ? arg2 : undefined; // eslint-disable-line sonarjs/no-nested-conditional -- easier to read than the alternative */\n\t\tconst hooks = isSourceHooks(arg1) ? arg1 : isSourceHooks(arg2) ? arg2 : arg3; // eslint-disable-line sonarjs/no-nested-conditional -- easier to read than the alternative */\n\t\tconst source = {\n\t\t\tdata: str,\n\t\t\tfilename,\n\t\t\tline: 1,\n\t\t\tcolumn: 1,\n\t\t\toffset: 0,\n\t\t\thooks,\n\t\t};\n\t\treturn this.validateSource(source, options);\n\t}\n\n\t/**\n\t * Parse and validate HTML from string.\n\t *\n\t * @public\n\t * @param str - Text to parse.\n\t * @param filename - If set configuration is loaded for given filename.\n\t * @param hooks - Optional hooks (see [[Source]]) for definition.\n\t * @returns Report output.\n\t */\n\t/* eslint-disable @typescript-eslint/unified-signatures -- for easier readability */\n\tpublic validateStringSync(str: string): Report;\n\tpublic validateStringSync(str: string, filename: string): Report;\n\tpublic validateStringSync(str: string, hooks: SourceHooks): Report;\n\tpublic validateStringSync(str: string, options: ConfigData): Report;\n\tpublic validateStringSync(str: string, filename: string, hooks: SourceHooks): Report;\n\tpublic validateStringSync(str: string, filename: string, options: ConfigData): Report;\n\tpublic validateStringSync(\n\t\tstr: string,\n\t\tfilename: string,\n\t\toptions: ConfigData,\n\t\thooks: SourceHooks,\n\t): Report;\n\t/* eslint-enable @typescript-eslint/unified-signatures */\n\tpublic validateStringSync(\n\t\tstr: string,\n\t\targ1?: string | SourceHooks | ConfigData,\n\t\targ2?: SourceHooks | ConfigData,\n\t\targ3?: SourceHooks,\n\t): Report {\n\t\tconst filename = typeof arg1 === \"string\" ? arg1 : \"inline\";\n\t\tconst options = isConfigData(arg1) ? arg1 : isConfigData(arg2) ? arg2 : undefined; // eslint-disable-line sonarjs/no-nested-conditional -- easier to read than the alternative */\n\t\tconst hooks = isSourceHooks(arg1) ? arg1 : isSourceHooks(arg2) ? arg2 : arg3; // eslint-disable-line sonarjs/no-nested-conditional -- easier to read than the alternative */\n\t\tconst source = {\n\t\t\tdata: str,\n\t\t\tfilename,\n\t\t\tline: 1,\n\t\t\tcolumn: 1,\n\t\t\toffset: 0,\n\t\t\thooks,\n\t\t};\n\t\treturn this.validateSourceSync(source, options);\n\t}\n\n\t/**\n\t * Parse and validate HTML from [[Source]].\n\t *\n\t * @public\n\t * @param input - Source to parse.\n\t * @returns Report output.\n\t */\n\tpublic async validateSource(input: Source, configOverride?: ConfigData): Promise<Report> {\n\t\tconst tracker = this._performanceTracker;\n\t\tconst source = normalizeSource(input);\n\t\tconst t0 = performance.now();\n\t\tconst config = await this.getConfigFor(source.filename, configOverride);\n\t\tconst resolvers = this.configLoader.getResolvers();\n\t\tconst t1 = performance.now();\n\t\ttracker?.trackConfig(t1 - t0);\n\t\tconst transformedSource = await transformSource(resolvers, config, source);\n\t\tconst t2 = performance.now();\n\t\ttracker?.trackTransform(t2 - t1);\n\t\tconst engine = new Engine(config, Parser, { tracker });\n\t\treturn engine.lint(transformedSource);\n\t}\n\n\t/**\n\t * Parse and validate HTML from [[Source]].\n\t *\n\t * @public\n\t * @param input - Source to parse.\n\t * @returns Report output.\n\t */\n\tpublic validateSourceSync(input: Source, configOverride?: ConfigData): Report {\n\t\tconst source = normalizeSource(input);\n\t\tconst t0 = performance.now();\n\t\tconst config = this.getConfigForSync(source.filename, configOverride);\n\t\tconst resolvers = this.configLoader.getResolvers();\n\t\tconst t1 = performance.now();\n\t\tthis._performanceTracker?.trackConfig(t1 - t0);\n\t\tconst transformedSource = transformSourceSync(resolvers, config, source);\n\t\tconst t2 = performance.now();\n\t\tthis._performanceTracker?.trackTransform(t2 - t1);\n\t\tconst engine = new Engine(config, Parser, { tracker: this._performanceTracker });\n\t\treturn engine.lint(transformedSource);\n\t}\n\n\t/**\n\t * Parse and validate HTML from file.\n\t *\n\t * @public\n\t * @param filename - Filename to read and parse.\n\t * @returns Report output.\n\t */\n\tpublic async validateFile(filename: string, fs: TransformFS): Promise<Report> {\n\t\tconst tracker = this._performanceTracker;\n\t\tconst t0 = performance.now();\n\t\tconst config = await this.getConfigFor(filename);\n\t\tconst resolvers = this.configLoader.getResolvers();\n\t\tconst t1 = performance.now();\n\t\ttracker?.trackConfig(t1 - t0);\n\t\tconst source = await transformFilename(resolvers, config, filename, fs);\n\t\tconst t2 = performance.now();\n\t\ttracker?.trackTransform(t2 - t1);\n\t\tconst engine = new Engine(config, Parser, { tracker });\n\t\treturn engine.lint(source);\n\t}\n\n\t/**\n\t * Parse and validate HTML from file.\n\t *\n\t * @public\n\t * @param filename - Filename to read and parse.\n\t * @returns Report output.\n\t */\n\tpublic validateFileSync(filename: string, fs: TransformFS): Report {\n\t\tconst t0 = performance.now();\n\t\tconst config = this.getConfigForSync(filename);\n\t\tconst resolvers = this.configLoader.getResolvers();\n\t\tconst t1 = performance.now();\n\t\tthis._performanceTracker?.trackConfig(t1 - t0);\n\t\tconst source = transformFilenameSync(resolvers, config, filename, fs);\n\t\tconst t2 = performance.now();\n\t\tthis._performanceTracker?.trackTransform(t2 - t1);\n\t\tconst engine = new Engine(config, Parser, { tracker: this._performanceTracker });\n\t\treturn engine.lint(source);\n\t}\n\n\t/**\n\t * Parse and validate HTML from multiple files. Result is merged together to a\n\t * single report.\n\t *\n\t * @param filenames - Filenames to read and parse.\n\t * @returns Report output.\n\t */\n\tpublic async validateMultipleFiles(filenames: string[], fs: TransformFS): Promise<Report> {\n\t\treturn Reporter.merge(filenames.map((filename) => this.validateFile(filename, fs)));\n\t}\n\n\t/**\n\t * Parse and validate HTML from multiple files. Result is merged together to a\n\t * single report.\n\t *\n\t * @param filenames - Filenames to read and parse.\n\t * @returns Report output.\n\t */\n\tpublic validateMultipleFilesSync(filenames: string[], fs: TransformFS): Report {\n\t\treturn Reporter.merge(filenames.map((filename) => this.validateFileSync(filename, fs)));\n\t}\n\n\t/**\n\t * Returns true if the given filename can be validated.\n\t *\n\t * A file is considered to be validatable if the extension is `.html` or if a\n\t * transformer matches the filename.\n\t *\n\t * This is mostly useful for tooling to determine whenever to validate the\n\t * file or not. CLI tools will run on all the given files anyway.\n\t */\n\tpublic async canValidate(filename: string): Promise<boolean> {\n\t\t/* .html is always supported */\n\t\tif (filename.toLowerCase().endsWith(\".html\")) {\n\t\t\treturn true;\n\t\t}\n\n\t\t/* test if there is a matching transformer */\n\t\tconst config = await this.getConfigFor(filename);\n\t\treturn config.canTransform(filename);\n\t}\n\n\t/**\n\t * Returns true if the given filename can be validated.\n\t *\n\t * A file is considered to be validatable if the extension is `.html` or if a\n\t * transformer matches the filename.\n\t *\n\t * This is mostly useful for tooling to determine whenever to validate the\n\t * file or not. CLI tools will run on all the given files anyway.\n\t */\n\tpublic canValidateSync(filename: string): boolean {\n\t\t/* .html is always supported */\n\t\tif (filename.toLowerCase().endsWith(\".html\")) {\n\t\t\treturn true;\n\t\t}\n\n\t\t/* test if there is a matching transformer */\n\t\tconst config = this.getConfigForSync(filename);\n\t\treturn config.canTransform(filename);\n\t}\n\n\t/**\n\t * Tokenize filename and output all tokens.\n\t *\n\t * Using CLI this is enabled with `--dump-tokens`. Mostly useful for\n\t * debugging.\n\t *\n\t * @internal\n\t * @param filename - Filename to tokenize.\n\t */\n\tpublic async dumpTokens(filename: string, fs: TransformFS): Promise<TokenDump[]> {\n\t\tconst config = await this.getConfigFor(filename);\n\t\tconst resolvers = this.configLoader.getResolvers();\n\t\tconst source = await transformFilename(resolvers, config, filename, fs);\n\t\tconst engine = new Engine(config, Parser, { tracker: null });\n\t\treturn engine.dumpTokens(source);\n\t}\n\n\t/**\n\t * Parse filename and output all events.\n\t *\n\t * Using CLI this is enabled with `--dump-events`. Mostly useful for\n\t * debugging.\n\t *\n\t * @internal\n\t * @param filename - Filename to dump events from.\n\t */\n\tpublic async dumpEvents(filename: string, fs: TransformFS): Promise<EventDump[]> {\n\t\tconst config = await this.getConfigFor(filename);\n\t\tconst resolvers = this.configLoader.getResolvers();\n\t\tconst source = await transformFilename(resolvers, config, filename, fs);\n\t\tconst engine = new Engine(config, Parser, { tracker: null });\n\t\treturn engine.dumpEvents(source);\n\t}\n\n\t/**\n\t * Parse filename and output DOM tree.\n\t *\n\t * Using CLI this is enabled with `--dump-tree`. Mostly useful for\n\t * debugging.\n\t *\n\t * @internal\n\t * @param filename - Filename to dump DOM tree from.\n\t */\n\tpublic async dumpTree(filename: string, fs: TransformFS): Promise<string[]> {\n\t\tconst config = await this.getConfigFor(filename);\n\t\tconst resolvers = this.configLoader.getResolvers();\n\t\tconst source = await transformFilename(resolvers, config, filename, fs);\n\t\tconst engine = new Engine(config, Parser, { tracker: null });\n\t\treturn engine.dumpTree(source);\n\t}\n\n\t/**\n\t * Transform filename and output source data.\n\t *\n\t * Using CLI this is enabled with `--dump-source`. Mostly useful for\n\t * debugging.\n\t *\n\t * @internal\n\t * @param filename - Filename to dump source from.\n\t */\n\tpublic async dumpSource(filename: string, fs: TransformFS): Promise<string[]> {\n\t\tconst config = await this.getConfigFor(filename);\n\t\tconst resolvers = this.configLoader.getResolvers();\n\t\tconst sources = await transformFilename(resolvers, config, filename, fs);\n\t\treturn sources.reduce<string[]>((result: string[], source: Source) => {\n\t\t\tconst line = String(source.line);\n\t\t\tconst column = String(source.column);\n\t\t\tconst offset = String(source.offset);\n\t\t\tresult.push(`Source ${source.filename}@${line}:${column} (offset: ${offset})`);\n\t\t\tif (source.transformedBy) {\n\t\t\t\tresult.push(\"Transformed by:\");\n\t\t\t\tresult = result.concat(source.transformedBy.toReversed().map((name) => ` - ${name}`));\n\t\t\t}\n\t\t\tif (source.hooks && Object.keys(source.hooks).length > 0) {\n\t\t\t\tresult.push(\"Hooks\");\n\t\t\t\tfor (const [key, present] of Object.entries(source.hooks)) {\n\t\t\t\t\tif (present) {\n\t\t\t\t\t\tresult.push(` - ${key}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tresult.push(\"---\");\n\t\t\tresult = result.concat(source.data.split(\"\\n\"));\n\t\t\tresult.push(\"---\");\n\t\t\treturn result;\n\t\t}, []);\n\t}\n\n\t/**\n\t * Get effective configuration schema.\n\t */\n\tpublic getConfigurationSchema(): Promise<SchemaObject> {\n\t\treturn Promise.resolve(configurationSchema);\n\t}\n\n\t/**\n\t * Get effective metadata element schema.\n\t *\n\t * If a filename is given the configured plugins can extend the\n\t * schema. Filename must not be an existing file or a filetype normally\n\t * handled by html-validate but the path will be used when resolving\n\t * configuration. As a rule-of-thumb, set it to the elements json file.\n\t */\n\tpublic async getElementsSchema(filename?: string): Promise<SchemaObject> {\n\t\tconst config = await this.getConfigFor(filename ?? \"inline\");\n\t\tconst metaTable = config.getMetaTable();\n\t\treturn metaTable.getJSONSchema();\n\t}\n\n\t/**\n\t * Get effective metadata element schema.\n\t *\n\t * If a filename is given the configured plugins can extend the\n\t * schema. Filename must not be an existing file or a filetype normally\n\t * handled by html-validate but the path will be used when resolving\n\t * configuration. As a rule-of-thumb, set it to the elements json file.\n\t */\n\tpublic getElementsSchemaSync(filename?: string): SchemaObject {\n\t\tconst config = this.getConfigForSync(filename ?? \"inline\");\n\t\tconst metaTable = config.getMetaTable();\n\t\treturn metaTable.getJSONSchema();\n\t}\n\n\t/**\n\t * Get contextual documentation for the given rule. Configuration will be\n\t * resolved for given filename.\n\t *\n\t * @example\n\t *\n\t * ```js\n\t * const report = await htmlvalidate.validateFile(\"my-file.html\");\n\t * for (const result of report.results){\n\t * for (const message of result.messages){\n\t * const documentation = await htmlvalidate.getContextualDocumentation(message, result.filePath);\n\t * // do something with documentation\n\t * }\n\t * }\n\t * ```\n\t *\n\t * @public\n\t * @since 8.0.0\n\t * @param message - Message reported during validation\n\t * @param filename - Filename used to resolve configuration.\n\t * @returns Contextual documentation or `null` if the rule does not exist.\n\t */\n\tpublic getContextualDocumentation(\n\t\tmessage: Pick<Message, \"ruleId\" | \"context\">,\n\t\tfilename?: string,\n\t): Promise<RuleDocumentation | null>;\n\n\t/**\n\t * Get contextual documentation for the given rule using provided\n\t * configuration.\n\t *\n\t * @example\n\t *\n\t * ```js\n\t * const report = await htmlvalidate.validateFile(\"my-file.html\");\n\t * for (const result of report.results){\n\t * for (const message of result.messages){\n\t * const documentation = await htmlvalidate.getRuleDocumentation(message, result.filePath);\n\t * // do something with documentation\n\t * }\n\t * }\n\t * ```\n\t *\n\t * @public\n\t * @since 8.0.0\n\t * @param message - Message reported during validation\n\t * @param config - Configuration to use.\n\t * @returns Contextual documentation or `null` if the rule does not exist.\n\t */\n\tpublic getContextualDocumentation(\n\t\tmessage: Pick<Message, \"ruleId\" | \"context\">,\n\t\tconfig: ResolvedConfig | Promise<ResolvedConfig>,\n\t): Promise<RuleDocumentation | null>;\n\n\tpublic async getContextualDocumentation(\n\t\tmessage: Pick<Message, \"ruleId\" | \"context\">,\n\t\tfilenameOrConfig: ResolvedConfig | Promise<ResolvedConfig> | string = \"inline\",\n\t): Promise<RuleDocumentation | null> {\n\t\tconst config =\n\t\t\ttypeof filenameOrConfig === \"string\"\n\t\t\t\t? await this.getConfigFor(filenameOrConfig)\n\t\t\t\t: await filenameOrConfig;\n\t\tconst engine = new Engine(config, Parser, { tracker: null });\n\t\treturn engine.getRuleDocumentation(message);\n\t}\n\n\t/**\n\t * Get contextual documentation for the given rule. Configuration will be\n\t * resolved for given filename.\n\t *\n\t * @example\n\t *\n\t * ```js\n\t * const report = htmlvalidate.validateFileSync(\"my-file.html\");\n\t * for (const result of report.results){\n\t * for (const message of result.messages){\n\t * const documentation = htmlvalidate.getRuleDocumentationSync(message, result.filePath);\n\t * // do something with documentation\n\t * }\n\t * }\n\t * ```\n\t *\n\t * @public\n\t * @since 8.0.0\n\t * @param message - Message reported during validation\n\t * @param filename - Filename used to resolve configuration.\n\t * @returns Contextual documentation or `null` if the rule does not exist.\n\t */\n\tpublic getContextualDocumentationSync(\n\t\tmessage: Pick<Message, \"ruleId\" | \"context\">,\n\t\tfilename?: string,\n\t): RuleDocumentation | null;\n\n\t/**\n\t * Get contextual documentation for the given rule using provided\n\t * configuration.\n\t *\n\t * @example\n\t *\n\t * ```js\n\t * const report = htmlvalidate.validateFileSync(\"my-file.html\");\n\t * for (const result of report.results){\n\t * for (const message of result.messages){\n\t * const documentation = htmlvalidate.getRuleDocumentationSync(message, result.filePath);\n\t * // do something with documentation\n\t * }\n\t * }\n\t * ```\n\t *\n\t * @public\n\t * @since 8.0.0\n\t * @param message - Message reported during validation\n\t * @param config - Configuration to use.\n\t * @returns Contextual documentation or `null` if the rule does not exist.\n\t */\n\tpublic getContextualDocumentationSync(\n\t\tmessage: Pick<Message, \"ruleId\" | \"context\">,\n\t\tconfig: ResolvedConfig,\n\t): RuleDocumentation | null;\n\n\tpublic getContextualDocumentationSync(\n\t\tmessage: Pick<Message, \"ruleId\" | \"context\">,\n\t\tfilenameOrConfig: ResolvedConfig | string = \"inline\",\n\t): RuleDocumentation | null {\n\t\tconst config =\n\t\t\ttypeof filenameOrConfig === \"string\"\n\t\t\t\t? this.getConfigForSync(filenameOrConfig)\n\t\t\t\t: filenameOrConfig;\n\t\tconst engine = new Engine(config, Parser, { tracker: null });\n\t\treturn engine.getRuleDocumentation(message);\n\t}\n\n\t/**\n\t * Get contextual documentation for the given rule.\n\t *\n\t * Typical usage:\n\t *\n\t * ```js\n\t * const report = await htmlvalidate.validateFile(\"my-file.html\");\n\t * for (const result of report.results){\n\t * const config = await htmlvalidate.getConfigFor(result.filePath);\n\t * for (const message of result.messages){\n\t * const documentation = await htmlvalidate.getRuleDocumentation(message.ruleId, config, message.context);\n\t * // do something with documentation\n\t * }\n\t * }\n\t * ```\n\t *\n\t * @public\n\t * @deprecated Deprecated since 8.0.0, use [[getContextualDocumentation]] instead.\n\t * @param ruleId - Rule to get documentation for.\n\t * @param config - If set it provides more accurate description by using the\n\t * correct configuration for the file.\n\t * @param context - If set to `Message.context` some rules can provide\n\t * contextual details and suggestions.\n\t */\n\tpublic async getRuleDocumentation(\n\t\truleId: string,\n\t\tconfig: ResolvedConfig | Promise<ResolvedConfig> | null = null,\n\t\tcontext: unknown | null = null,\n\t): Promise<RuleDocumentation | null> {\n\t\tconst c = config ?? this.getConfigFor(\"inline\");\n\t\tconst engine = new Engine(await c, Parser, { tracker: null });\n\t\treturn engine.getRuleDocumentation({ ruleId, context });\n\t}\n\n\t/**\n\t * Get contextual documentation for the given rule.\n\t *\n\t * Typical usage:\n\t *\n\t * ```js\n\t * const report = htmlvalidate.validateFileSync(\"my-file.html\");\n\t * for (const result of report.results){\n\t * const config = htmlvalidate.getConfigForSync(result.filePath);\n\t * for (const message of result.messages){\n\t * const documentation = htmlvalidate.getRuleDocumentationSync(message.ruleId, config, message.context);\n\t * // do something with documentation\n\t * }\n\t * }\n\t * ```\n\t *\n\t * @public\n\t * @deprecated Deprecated since 8.0.0, use [[getContextualDocumentationSync]] instead.\n\t * @param ruleId - Rule to get documentation for.\n\t * @param config - If set it provides more accurate description by using the\n\t * correct configuration for the file.\n\t * @param context - If set to `Message.context` some rules can provide\n\t * contextual details and suggestions.\n\t */\n\tpublic getRuleDocumentationSync(\n\t\truleId: string,\n\t\tconfig: ResolvedConfig | null = null,\n\t\tcontext: unknown | null = null,\n\t): RuleDocumentation | null {\n\t\tconst c = config ?? this.getConfigForSync(\"inline\");\n\t\tconst engine = new Engine(c, Parser, { tracker: null });\n\t\treturn engine.getRuleDocumentation({ ruleId, context });\n\t}\n\n\t/**\n\t * Create a parser configured for given filename.\n\t *\n\t * @internal\n\t * @param source - Source to use.\n\t */\n\tpublic async getParserFor(source: Source): Promise<Parser> {\n\t\tconst config = await this.getConfigFor(source.filename);\n\t\treturn new Parser(config);\n\t}\n\n\t/**\n\t * Get configuration for given filename.\n\t *\n\t * See [[FileSystemConfigLoader]] for details.\n\t *\n\t * @public\n\t * @param filename - Filename to get configuration for.\n\t * @param configOverride - Configuration to apply last.\n\t */\n\tpublic getConfigFor(filename: string, configOverride?: ConfigData): Promise<ResolvedConfig> {\n\t\tconst config = this.configLoader.getConfigFor(filename, configOverride);\n\t\treturn Promise.resolve(config);\n\t}\n\n\t/**\n\t * Get configuration for given filename.\n\t *\n\t * See [[FileSystemConfigLoader]] for details.\n\t *\n\t * @public\n\t * @param filename - Filename to get configuration for.\n\t * @param configOverride - Configuration to apply last.\n\t */\n\tpublic getConfigForSync(filename: string, configOverride?: ConfigData): ResolvedConfig {\n\t\tconst config = this.configLoader.getConfigFor(filename, configOverride);\n\t\tif (isThenable(config)) {\n\t\t\tthrow new UserError(\"Cannot use asynchronous config loader with synchronous api\");\n\t\t}\n\t\treturn config;\n\t}\n\n\t/**\n\t * Get current configuration loader.\n\t *\n\t * @public\n\t * @since %version%\n\t * @returns Current configuration loader.\n\t */\n\t/* istanbul ignore next -- not testing setters/getters */\n\tpublic getConfigLoader(): ConfigLoader {\n\t\treturn this.configLoader;\n\t}\n\n\t/**\n\t * Set configuration loader.\n\t *\n\t * @public\n\t * @since %version%\n\t * @param loader - New configuration loader to use.\n\t */\n\t/* istanbul ignore next -- not testing setters/getters */\n\tpublic setConfigLoader(loader: ConfigLoader): void {\n\t\tthis.configLoader = loader;\n\t}\n\n\t/**\n\t * Flush configuration cache. Clears full cache unless a filename is given.\n\t *\n\t * See [[FileSystemConfigLoader]] for details.\n\t *\n\t * @public\n\t * @param filename - If set, only flush cache for given filename.\n\t */\n\tpublic flushConfigCache(filename?: string): void {\n\t\tthis.configLoader.flushCache(filename);\n\t}\n}\n","/* istanbul ignore file: this file is only for easier mocking */\n\n/**\n * Wrapper around import() so we can mock it in unittests.\n *\n * @internal\n */\nexport function importFunction(id: string): unknown {\n\treturn import(id);\n}\n","import { UserError } from \"../../../error\";\nimport { type MetaDataTable } from \"../../../meta\";\nimport { type Plugin } from \"../../../plugin\";\nimport { type Transformer } from \"../../../transform\";\nimport { type ConfigData } from \"../../config-data\";\nimport { type Resolver } from \"../resolver\";\nimport { importFunction } from \"./import-function\";\n\nexport async function internalImport<T = unknown>(id: string): Promise<T | null> {\n\tconst { default: defaultImport } = (await importFunction(id)) as { default?: T };\n\tif (!defaultImport) {\n\t\tthrow new UserError(`\"${id}\" does not have a default export`);\n\t}\n\treturn defaultImport;\n}\n\n/**\n * ESM resolver.\n *\n * @public\n * @since 9.0.0\n */\nexport type ESMResolver = Required<Resolver>;\n\n/**\n * Create a new resolver for using `import(..)`.\n *\n * @public\n * @since 9.0.0\n */\nexport function esmResolver(): ESMResolver {\n\treturn {\n\t\tname: \"esm-resolver\",\n\n\t\tresolveElements(id: string): Promise<MetaDataTable | null> {\n\t\t\treturn internalImport(id);\n\t\t},\n\n\t\tresolveConfig(id: string): Promise<ConfigData | null> {\n\t\t\treturn internalImport(id);\n\t\t},\n\n\t\tresolvePlugin(id: string): Promise<Plugin | null> {\n\t\t\treturn internalImport<Plugin>(id);\n\t\t},\n\n\t\tasync resolveTransformer(id: string): Promise<Transformer | null> {\n\t\t\treturn internalImport(id);\n\t\t},\n\t};\n}\n","import { version } from \"../generated/package-json\";\nimport { type CompatibilityOptions, compatibilityCheckImpl } from \"./compatibility-check\";\n\nconst defaults: CompatibilityOptions = {\n\tsilent: false,\n\tversion,\n\tlogger(text: string): void {\n\t\t/* eslint-disable-next-line no-console -- expected to log */\n\t\tconsole.error(text);\n\t},\n};\n\n/**\n * Tests if plugin is compatible with html-validate library. Unless the `silent`\n * option is used a warning is displayed on the console.\n *\n * @public\n * @since v5.0.0\n * @param name - Name of plugin\n * @param declared - What library versions the plugin support (e.g. declared peerDependencies)\n * @returns - `true` if version is compatible\n */\nexport function compatibilityCheck(\n\tname: string,\n\tdeclared: string,\n\toptions?: Partial<CompatibilityOptions>,\n): boolean {\n\treturn compatibilityCheckImpl(name, declared, {\n\t\t...defaults,\n\t\t...options,\n\t});\n}\n"],"names":["ConfigLoader","StaticConfigLoader","PerformanceTracker","normalizeSource","transformSource","Engine","Parser","transformSourceSync","transformFilename","transformFilenameSync","Reporter","configurationSchema","isThenable","UserError","version","compatibilityCheckImpl"],"mappings":";;;;AAsBA,SAAS,cAAc,KAAA,EAA4E;AAClG,EAAA,IAAI,CAAC,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,EAAU;AACxC,IAAA,OAAO,KAAA;AAAA,EACR;AACA,EAAA,OAAO,CAAC,oBAAoB,gBAAgB,CAAA,CAAE,KAAK,CAAC,GAAA,KAAQ,OAAO,KAAK,CAAA;AACzE;AAEA,SAAS,aAAa,KAAA,EAA2E;AAChG,EAAA,IAAI,CAAC,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,EAAU;AACxC,IAAA,OAAO,KAAA;AAAA,EACR;AACA,EAAA,OAAO,CAAC,CAAC,kBAAA,EAAoB,gBAAgB,EAAE,IAAA,CAAK,CAAC,GAAA,KAAQ,GAAA,IAAO,KAAK,CAAA;AAC1E;AASO,MAAM,YAAA,CAAa;AAAA,EACf,YAAA;AAAA,EACF,mBAAA;AAAA,EAYD,YAAY,GAAA,EAAiC;AACnD,IAAA,MAAM,CAAC,MAAA,EAAQ,MAAM,CAAA,GAAI,GAAA,YAAeA,iBAAA,GAAe,CAAC,GAAA,EAAK,MAAS,CAAA,GAAI,CAAC,MAAA,EAAW,GAAG,CAAA;AACzF,IAAA,IAAA,CAAK,YAAA,GAAe,MAAA,IAAU,IAAIC,uBAAA,CAAmB,MAAM,CAAA;AAC3D,IAAA,IAAA,CAAK,mBAAA,GAAsB,IAAA;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWO,gBAAA,GAAyB;AAC/B,IAAA,IAAA,CAAK,mBAAA,GAAsB,IAAIC,uBAAA,EAAmB;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AAAA,IACzB;AAAA,GACD;AACD;;AC/CA,MAAM,QAAA,GAAiC;AAAA,EACtC,MAAA,EAAQ,KAAA;AAAA,WACRC,YAAA;AAAA,EACA,OAAO,IAAA,EAAoB;AAE1B,IAAA,OAAA,CAAQ,MAAM,IAAI,CAAA;AAAA,EACnB;AACD,CAAA;AAYO,SAAS,kBAAA,CACf,IAAA,EACA,QAAA,EACA,OAAA,EACU;AACV,EAAA,OAAOC,2BAAA,CAAuB,MAAM,QAAA,EAAU;AAAA,IAC7C,GAAG,QAAA;AAAA,IACH,GAAG;AAAA,GACH,CAAA;AACF;;;;;;"}
|
package/dist/cjs/core-nodejs.js
CHANGED
|
@@ -31,9 +31,36 @@ function isConfigData(value) {
|
|
|
31
31
|
}
|
|
32
32
|
class HtmlValidate {
|
|
33
33
|
configLoader;
|
|
34
|
+
_performanceTracker;
|
|
34
35
|
constructor(arg) {
|
|
35
36
|
const [loader, config] = arg instanceof core.ConfigLoader ? [arg, void 0] : [void 0, arg];
|
|
36
37
|
this.configLoader = loader ?? new core.StaticConfigLoader(config);
|
|
38
|
+
this._performanceTracker = null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Start recording performance data.
|
|
42
|
+
*
|
|
43
|
+
* When active, performance data is accumulated across all subsequent calls to
|
|
44
|
+
* `validateString()`, `validateFile()` and similar methods until
|
|
45
|
+
* {@link HtmlValidate.stopPerformance} is called.
|
|
46
|
+
*
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
startPerformance() {
|
|
50
|
+
this._performanceTracker = new core.PerformanceTracker();
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Stop recording performance data and return the result.
|
|
54
|
+
*
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
stopPerformance() {
|
|
58
|
+
if (!this._performanceTracker) {
|
|
59
|
+
return { events: [], rules: [], configTime: 0, transformTime: 0, totalTime: 0 };
|
|
60
|
+
}
|
|
61
|
+
const result = this._performanceTracker.getResult();
|
|
62
|
+
this._performanceTracker = null;
|
|
63
|
+
return result;
|
|
37
64
|
}
|
|
38
65
|
/* eslint-enable @typescript-eslint/unified-signatures */
|
|
39
66
|
validateString(str, arg1, arg2, arg3) {
|
|
@@ -73,11 +100,17 @@ class HtmlValidate {
|
|
|
73
100
|
* @returns Report output.
|
|
74
101
|
*/
|
|
75
102
|
async validateSource(input, configOverride) {
|
|
103
|
+
const tracker = this._performanceTracker;
|
|
76
104
|
const source = core.normalizeSource(input);
|
|
105
|
+
const t0 = performance.now();
|
|
77
106
|
const config = await this.getConfigFor(source.filename, configOverride);
|
|
78
107
|
const resolvers = this.configLoader.getResolvers();
|
|
108
|
+
const t1 = performance.now();
|
|
109
|
+
tracker?.trackConfig(t1 - t0);
|
|
79
110
|
const transformedSource = await core.transformSource(resolvers, config, source);
|
|
80
|
-
const
|
|
111
|
+
const t2 = performance.now();
|
|
112
|
+
tracker?.trackTransform(t2 - t1);
|
|
113
|
+
const engine = new core.Engine(config, core.Parser, { tracker });
|
|
81
114
|
return engine.lint(transformedSource);
|
|
82
115
|
}
|
|
83
116
|
/**
|
|
@@ -89,10 +122,15 @@ class HtmlValidate {
|
|
|
89
122
|
*/
|
|
90
123
|
validateSourceSync(input, configOverride) {
|
|
91
124
|
const source = core.normalizeSource(input);
|
|
125
|
+
const t0 = performance.now();
|
|
92
126
|
const config = this.getConfigForSync(source.filename, configOverride);
|
|
93
127
|
const resolvers = this.configLoader.getResolvers();
|
|
128
|
+
const t1 = performance.now();
|
|
129
|
+
this._performanceTracker?.trackConfig(t1 - t0);
|
|
94
130
|
const transformedSource = core.transformSourceSync(resolvers, config, source);
|
|
95
|
-
const
|
|
131
|
+
const t2 = performance.now();
|
|
132
|
+
this._performanceTracker?.trackTransform(t2 - t1);
|
|
133
|
+
const engine = new core.Engine(config, core.Parser, { tracker: this._performanceTracker });
|
|
96
134
|
return engine.lint(transformedSource);
|
|
97
135
|
}
|
|
98
136
|
/**
|
|
@@ -103,10 +141,16 @@ class HtmlValidate {
|
|
|
103
141
|
* @returns Report output.
|
|
104
142
|
*/
|
|
105
143
|
async validateFile(filename, fs2 = defaultFS) {
|
|
144
|
+
const tracker = this._performanceTracker;
|
|
145
|
+
const t0 = performance.now();
|
|
106
146
|
const config = await this.getConfigFor(filename);
|
|
107
147
|
const resolvers = this.configLoader.getResolvers();
|
|
148
|
+
const t1 = performance.now();
|
|
149
|
+
tracker?.trackConfig(t1 - t0);
|
|
108
150
|
const source = await core.transformFilename(resolvers, config, filename, fs2);
|
|
109
|
-
const
|
|
151
|
+
const t2 = performance.now();
|
|
152
|
+
tracker?.trackTransform(t2 - t1);
|
|
153
|
+
const engine = new core.Engine(config, core.Parser, { tracker });
|
|
110
154
|
return engine.lint(source);
|
|
111
155
|
}
|
|
112
156
|
/**
|
|
@@ -117,10 +161,15 @@ class HtmlValidate {
|
|
|
117
161
|
* @returns Report output.
|
|
118
162
|
*/
|
|
119
163
|
validateFileSync(filename, fs2 = defaultFS) {
|
|
164
|
+
const t0 = performance.now();
|
|
120
165
|
const config = this.getConfigForSync(filename);
|
|
121
166
|
const resolvers = this.configLoader.getResolvers();
|
|
167
|
+
const t1 = performance.now();
|
|
168
|
+
this._performanceTracker?.trackConfig(t1 - t0);
|
|
122
169
|
const source = core.transformFilenameSync(resolvers, config, filename, fs2);
|
|
123
|
-
const
|
|
170
|
+
const t2 = performance.now();
|
|
171
|
+
this._performanceTracker?.trackTransform(t2 - t1);
|
|
172
|
+
const engine = new core.Engine(config, core.Parser, { tracker: this._performanceTracker });
|
|
124
173
|
return engine.lint(source);
|
|
125
174
|
}
|
|
126
175
|
/**
|
|
@@ -188,7 +237,7 @@ class HtmlValidate {
|
|
|
188
237
|
const config = await this.getConfigFor(filename);
|
|
189
238
|
const resolvers = this.configLoader.getResolvers();
|
|
190
239
|
const source = await core.transformFilename(resolvers, config, filename, fs2);
|
|
191
|
-
const engine = new core.Engine(config, core.Parser);
|
|
240
|
+
const engine = new core.Engine(config, core.Parser, { tracker: null });
|
|
192
241
|
return engine.dumpTokens(source);
|
|
193
242
|
}
|
|
194
243
|
/**
|
|
@@ -204,7 +253,7 @@ class HtmlValidate {
|
|
|
204
253
|
const config = await this.getConfigFor(filename);
|
|
205
254
|
const resolvers = this.configLoader.getResolvers();
|
|
206
255
|
const source = await core.transformFilename(resolvers, config, filename, fs2);
|
|
207
|
-
const engine = new core.Engine(config, core.Parser);
|
|
256
|
+
const engine = new core.Engine(config, core.Parser, { tracker: null });
|
|
208
257
|
return engine.dumpEvents(source);
|
|
209
258
|
}
|
|
210
259
|
/**
|
|
@@ -220,7 +269,7 @@ class HtmlValidate {
|
|
|
220
269
|
const config = await this.getConfigFor(filename);
|
|
221
270
|
const resolvers = this.configLoader.getResolvers();
|
|
222
271
|
const source = await core.transformFilename(resolvers, config, filename, fs2);
|
|
223
|
-
const engine = new core.Engine(config, core.Parser);
|
|
272
|
+
const engine = new core.Engine(config, core.Parser, { tracker: null });
|
|
224
273
|
return engine.dumpTree(source);
|
|
225
274
|
}
|
|
226
275
|
/**
|
|
@@ -293,12 +342,12 @@ class HtmlValidate {
|
|
|
293
342
|
}
|
|
294
343
|
async getContextualDocumentation(message, filenameOrConfig = "inline") {
|
|
295
344
|
const config = typeof filenameOrConfig === "string" ? await this.getConfigFor(filenameOrConfig) : await filenameOrConfig;
|
|
296
|
-
const engine = new core.Engine(config, core.Parser);
|
|
345
|
+
const engine = new core.Engine(config, core.Parser, { tracker: null });
|
|
297
346
|
return engine.getRuleDocumentation(message);
|
|
298
347
|
}
|
|
299
348
|
getContextualDocumentationSync(message, filenameOrConfig = "inline") {
|
|
300
349
|
const config = typeof filenameOrConfig === "string" ? this.getConfigForSync(filenameOrConfig) : filenameOrConfig;
|
|
301
|
-
const engine = new core.Engine(config, core.Parser);
|
|
350
|
+
const engine = new core.Engine(config, core.Parser, { tracker: null });
|
|
302
351
|
return engine.getRuleDocumentation(message);
|
|
303
352
|
}
|
|
304
353
|
/**
|
|
@@ -327,7 +376,7 @@ class HtmlValidate {
|
|
|
327
376
|
*/
|
|
328
377
|
async getRuleDocumentation(ruleId, config = null, context = null) {
|
|
329
378
|
const c = config ?? this.getConfigFor("inline");
|
|
330
|
-
const engine = new core.Engine(await c, core.Parser);
|
|
379
|
+
const engine = new core.Engine(await c, core.Parser, { tracker: null });
|
|
331
380
|
return engine.getRuleDocumentation({ ruleId, context });
|
|
332
381
|
}
|
|
333
382
|
/**
|
|
@@ -356,7 +405,7 @@ class HtmlValidate {
|
|
|
356
405
|
*/
|
|
357
406
|
getRuleDocumentationSync(ruleId, config = null, context = null) {
|
|
358
407
|
const c = config ?? this.getConfigForSync("inline");
|
|
359
|
-
const engine = new core.Engine(c, core.Parser);
|
|
408
|
+
const engine = new core.Engine(c, core.Parser, { tracker: null });
|
|
360
409
|
return engine.getRuleDocumentation({ ruleId, context });
|
|
361
410
|
}
|
|
362
411
|
/**
|