html-validate 8.20.1 → 8.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/cjs/browser.js +1 -1
  2. package/dist/cjs/cli.js.map +1 -1
  3. package/dist/cjs/core-nodejs.js.map +1 -1
  4. package/dist/cjs/core.js +1781 -1613
  5. package/dist/cjs/core.js.map +1 -1
  6. package/dist/cjs/elements.js +4 -6
  7. package/dist/cjs/elements.js.map +1 -1
  8. package/dist/cjs/html-validate.js +0 -1
  9. package/dist/cjs/html-validate.js.map +1 -1
  10. package/dist/cjs/index.js +1 -1
  11. package/dist/cjs/jest-diff.js.map +1 -1
  12. package/dist/cjs/jest.js +0 -1
  13. package/dist/cjs/jest.js.map +1 -1
  14. package/dist/cjs/matcher-utils.js.map +1 -1
  15. package/dist/cjs/matchers.js.map +1 -1
  16. package/dist/cjs/tsdoc-metadata.json +1 -1
  17. package/dist/cjs/vitest.js +0 -1
  18. package/dist/cjs/vitest.js.map +1 -1
  19. package/dist/es/browser.js +1 -2
  20. package/dist/es/browser.js.map +1 -1
  21. package/dist/es/cli.js.map +1 -1
  22. package/dist/es/core-browser.js +1 -1
  23. package/dist/es/core-nodejs.js +1 -1
  24. package/dist/es/core-nodejs.js.map +1 -1
  25. package/dist/es/core.js +1781 -1614
  26. package/dist/es/core.js.map +1 -1
  27. package/dist/es/elements.js +4 -6
  28. package/dist/es/elements.js.map +1 -1
  29. package/dist/es/html-validate.js +1 -2
  30. package/dist/es/html-validate.js.map +1 -1
  31. package/dist/es/index.js +1 -2
  32. package/dist/es/index.js.map +1 -1
  33. package/dist/es/jest-diff.js.map +1 -1
  34. package/dist/es/jest.js +0 -1
  35. package/dist/es/jest.js.map +1 -1
  36. package/dist/es/matcher-utils.js.map +1 -1
  37. package/dist/es/matchers-jestonly.js +1 -1
  38. package/dist/es/matchers.js.map +1 -1
  39. package/dist/es/vitest.js +0 -1
  40. package/dist/es/vitest.js.map +1 -1
  41. package/dist/tsdoc-metadata.json +1 -1
  42. package/dist/types/browser.d.ts +65 -18
  43. package/dist/types/index.d.ts +65 -18
  44. package/package.json +23 -27
@@ -1 +1 @@
1
- {"version":3,"file":"core-nodejs.js","sources":["../../src/utils/require-uncached.ts","../../src/config/resolver/nodejs/determine-root-dir.ts","../../src/config/resolver/nodejs/expand-relative-path.ts","../../src/config/resolver/nodejs/cjs-resolver.ts","../../src/config/loaders/file-system.ts","../../src/utils/compatibility-check.nodejs.ts"],"sourcesContent":["/**\n * Similar to `require(..)` but removes the cached copy first.\n */\nexport function requireUncached(require: NodeJS.Require, moduleId: string): unknown {\n\tconst filename = require.resolve(moduleId);\n\n\t/* remove references from the parent module to prevent memory leak */\n\tconst m = require.cache[filename];\n\tif (m?.parent) {\n\t\tconst { parent } = m;\n\t\tfor (let i = parent.children.length - 1; i >= 0; i--) {\n\t\t\tif (parent.children[i].id === filename) {\n\t\t\t\tparent.children.splice(i, 1);\n\t\t\t}\n\t\t}\n\t}\n\n\t/* remove old module from cache */\n\t/* eslint-disable-next-line @typescript-eslint/no-dynamic-delete -- needed to perform its function */\n\tdelete require.cache[filename];\n\n\t/* eslint-disable-next-line import/no-dynamic-require, security/detect-non-literal-require -- as expected but should be moved to upcoming resolver class */\n\treturn require(filename);\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\n\nlet cachedRootDir: string | null = null;\n\ninterface FSLike {\n\texistsSync(path: string): boolean;\n}\n\n/**\n * @internal\n */\nexport function determineRootDirImpl(intial: string, fs: FSLike): string {\n\t/* try to locate package.json */\n\tlet current = intial;\n\n\t// eslint-disable-next-line no-constant-condition -- break outs when filesystem is traversed\n\twhile (true) {\n\t\tconst search = path.join(current, \"package.json\");\n\t\tif (fs.existsSync(search)) {\n\t\t\treturn current;\n\t\t}\n\n\t\t/* get the parent directory */\n\t\tconst child = current;\n\t\tcurrent = path.dirname(current);\n\n\t\t/* stop if this is the root directory */\n\t\tif (current === child) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t/* default to working directory if no package.json is found */\n\treturn intial;\n}\n\n/**\n * Try to determine root directory based on the location of the closest\n * `package.json`. Fallbacks on `process.cwd()` if no package.json was found.\n *\n * @internal\n */\n/* istanbul ignore next: cached version of determineRootDirImpl, no need to test */\nexport function determineRootDir(): string {\n\tif (cachedRootDir === null) {\n\t\tcachedRootDir = determineRootDirImpl(process.cwd(), fs);\n\t}\n\treturn cachedRootDir;\n}\n","import path from \"node:path\";\n\n/**\n * @internal\n */\nexport function expandRelativePath<T>(value: string | T, { cwd }: { cwd: string }): string | T {\n\tif (typeof value === \"string\" && value.startsWith(\".\")) {\n\t\treturn path.normalize(path.join(cwd, value));\n\t} else {\n\t\treturn value;\n\t}\n}\n","import path from \"node:path\";\nimport { type MetaDataTable } from \"../../../meta\";\nimport { type Plugin } from \"../../../plugin\";\nimport { legacyRequire } from \"../../../resolve\";\nimport { type Transformer } from \"../../../transform\";\nimport { requireUncached } from \"../../../utils\";\nimport { type ConfigData } from \"../../config-data\";\nimport { ConfigError } from \"../../error\";\nimport { type Resolver, type ResolverOptions } from \"../resolver\";\nimport { determineRootDir } from \"./determine-root-dir\";\nimport { expandRelativePath } from \"./expand-relative-path\";\n\n/**\n * @internal\n */\nexport interface RequireError extends Error {\n\tcode: string;\n}\n\nfunction isRequireError(error: unknown): error is RequireError {\n\treturn Boolean(error && typeof error === \"object\" && \"code\" in error);\n}\n\nfunction isTransformer(value: Transformer | Plugin): value is Transformer {\n\treturn typeof value === \"function\";\n}\n\n/**\n * CommonJS resolver.\n *\n * @public\n * @since 8.8.0\n */\nexport type CommonJSResolver = Required<Resolver>;\n\n/**\n * CommonJS resolver.\n *\n * @public\n * @deprecated Deprecated alias for [[CommonJSResolver]].\n * @since 8.0.0\n */\nexport type NodeJSResolver = Required<Resolver>;\n\n/**\n * Create a new resolver for NodeJS packages using `require(..)`.\n *\n * If the module name contains `<rootDir>` (e.g. `<rootDir/foo`) it will be\n * expanded relative to the root directory either explicitly set by the\n * `rootDir` parameter or determined automatically by the closest `package.json`\n * file (starting at the current working directory).\n *\n * @public\n * @since 8.8.0\n */\nexport function cjsResolver(options: { rootDir?: string } = {}): CommonJSResolver {\n\tconst rootDir = options.rootDir ?? determineRootDir();\n\n\tfunction internalRequire<T = unknown>(id: string, { cache }: ResolverOptions): T | null {\n\t\tconst moduleName = id.replace(\"<rootDir>\", rootDir);\n\t\ttry {\n\t\t\t/* istanbul ignore else: the tests only runs the cached versions to get\n\t\t\t * unmodified access to `require`, the implementation of `requireUncached`\n\t\t\t * is assumed to be tested elsewhere */\n\t\t\tif (cache) {\n\t\t\t\treturn legacyRequire(moduleName) as T;\n\t\t\t} else {\n\t\t\t\treturn requireUncached(legacyRequire, moduleName) as T;\n\t\t\t}\n\t\t} catch (err: unknown) {\n\t\t\tif (isRequireError(err) && err.code === \"MODULE_NOT_FOUND\") {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\treturn {\n\t\tname: \"nodejs-resolver\",\n\n\t\tresolveElements(id: string, options: ResolverOptions): MetaDataTable | null {\n\t\t\treturn internalRequire(id, options);\n\t\t},\n\n\t\tresolveConfig(id: string, options: ResolverOptions): ConfigData | null {\n\t\t\tconst configData = internalRequire<ConfigData>(id, options);\n\t\t\tif (!configData) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t/* expand any relative paths */\n\t\t\tconst cwd = path.dirname(id);\n\t\t\tconst expand = <T>(value: string | T): string | T => expandRelativePath(value, { cwd });\n\n\t\t\tif (Array.isArray(configData.elements)) {\n\t\t\t\tconfigData.elements = configData.elements.map(expand);\n\t\t\t}\n\n\t\t\tif (Array.isArray(configData.extends)) {\n\t\t\t\tconfigData.extends = configData.extends.map(expand);\n\t\t\t}\n\n\t\t\tif (Array.isArray(configData.plugins)) {\n\t\t\t\tconfigData.plugins = configData.plugins.map(expand);\n\t\t\t}\n\n\t\t\treturn configData;\n\t\t},\n\n\t\tresolvePlugin(id: string, options: ResolverOptions): Plugin | null {\n\t\t\treturn internalRequire<Plugin>(id, options);\n\t\t},\n\n\t\tresolveTransformer(id: string, options: ResolverOptions): Transformer | null {\n\t\t\tconst mod = internalRequire<Transformer | Plugin>(id, options);\n\t\t\tif (!mod) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tif (isTransformer(mod)) {\n\t\t\t\treturn mod;\n\t\t\t}\n\n\t\t\t/* this is not a proper transformer, is it a plugin exposing a transformer? */\n\t\t\tif (mod.transformer) {\n\t\t\t\tthrow new ConfigError(\n\t\t\t\t\t`Module \"${id}\" is not a valid transformer. This looks like a plugin, did you forget to load the plugin first?`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthrow new ConfigError(`Module \"${id}\" is not a valid transformer.`);\n\t\t},\n\t};\n}\n\n/**\n * Create a new resolver for NodeJS packages using `require(..)`.\n *\n * If the module name contains `<rootDir>` (e.g. `<rootDir/foo`) it will be\n * expanded relative to the root directory either explicitly set by the\n * `rootDir` parameter or determined automatically by the closest `package.json`\n * file (starting at the current working directory).\n *\n * @public\n * @deprecated Deprecated alias for [[commonjsResolver]].\n * @since 8.0.0\n */\n/* istanbul ignore next -- deprecated alias */\nexport function nodejsResolver(options: { rootDir?: string } = {}): NodeJSResolver {\n\treturn cjsResolver(options);\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { Config } from \"../config\";\nimport { type ConfigData } from \"../config-data\";\nimport { ConfigLoader } from \"../config-loader\";\nimport { type ResolvedConfig } from \"../resolved-config\";\nimport { type Resolver } from \"../resolver\";\nimport { type FSLike, cjsResolver } from \"../resolver/nodejs\";\n\n/**\n * Options for [[FileSystemConfigLoader]].\n *\n * @public\n */\nexport interface FileSystemConfigLoaderOptions {\n\t/** An implementation of `fs` as needed by [[FileSystemConfigLoader]] */\n\tfs: FSLike;\n}\n\n/**\n * @internal\n */\nfunction findConfigurationFiles(fs: FSLike, directory: string): string[] {\n\treturn [\"json\", \"cjs\", \"js\"]\n\t\t.map((extension) => path.join(directory, `.htmlvalidate.${extension}`))\n\t\t.filter((filePath) => fs.existsSync(filePath));\n}\n\nconst defaultResolvers: Resolver[] = [cjsResolver()];\n\ntype ConstructorParametersDefault = [ConfigData?, Partial<FileSystemConfigLoaderOptions>?];\ntype ConstructorParametersResolver = [\n\tResolver[],\n\tConfigData?,\n\tPartial<FileSystemConfigLoaderOptions>?,\n];\ntype ConstructorParameters = ConstructorParametersDefault | ConstructorParametersResolver;\n\nfunction hasResolver(value: ConstructorParameters): value is ConstructorParametersResolver {\n\treturn Array.isArray(value[0]);\n}\n\n/**\n * Loads configuration by traversing filesystem.\n *\n * Configuration is read from three sources and in the following order:\n *\n * 1. Global configuration passed to constructor.\n * 2. Configuration files found when traversing the directory structure.\n * 3. Override passed to this function.\n *\n * The following configuration filenames are searched:\n *\n * - `.htmlvalidate.json`\n * - `.htmlvalidate.js`\n * - `.htmlvalidate.cjs`\n *\n * Global configuration is used when no configuration file is found. The\n * result is always merged with override if present.\n *\n * The `root` property set to `true` affects the configuration as following:\n *\n * 1. If set in override the override is returned as-is.\n * 2. If set in the global config the override is merged into global and\n * returned. No configuration files are searched.\n * 3. Setting `root` in configuration file only stops directory traversal.\n *\n * @public\n */\nexport class FileSystemConfigLoader extends ConfigLoader {\n\tprotected cache: Map<string, Config | null>;\n\tprivate fs: FSLike;\n\n\t/**\n\t * Create a filesystem configuration loader with default resolvers.\n\t *\n\t * @param fs - `fs` implementation,\n\t * @param config - Global configuration.\n\t * @param configFactory - Optional configuration factory.\n\t */\n\tpublic constructor(config?: ConfigData, options?: Partial<FileSystemConfigLoaderOptions>);\n\n\t/**\n\t * Create a filesystem configuration loader with custom resolvers.\n\t *\n\t * @param fs - `fs` implementation,\n\t * @param resolvers - Resolvers to use.\n\t * @param config - Global configuration.\n\t * @param configFactory - Optional configuration factory.\n\t */\n\tpublic constructor(\n\t\tresolvers: Resolver[],\n\t\tconfig?: ConfigData,\n\t\toptions?: Partial<FileSystemConfigLoaderOptions>,\n\t);\n\n\tpublic constructor(...args: ConstructorParameters) {\n\t\tif (hasResolver(args)) {\n\t\t\t/* istanbul ignore next */\n\t\t\tconst [resolvers, config, options = {}] = args;\n\t\t\tsuper(resolvers, config);\n\t\t\tthis.fs = /* istanbul ignore next */ options.fs ?? fs;\n\t\t} else {\n\t\t\t/* istanbul ignore next */\n\t\t\tconst [config, options = {}] = args;\n\t\t\tsuper(defaultResolvers, config);\n\t\t\tthis.fs = /* istanbul ignore next */ options.fs ?? fs;\n\t\t}\n\t\tthis.cache = new Map();\n\t}\n\n\t/**\n\t * Get configuration for given filename.\n\t *\n\t * @param filename - Filename to get configuration for.\n\t * @param configOverride - Configuration to merge final result with.\n\t */\n\tpublic override getConfigFor(filename: string, configOverride?: ConfigData): ResolvedConfig {\n\t\t/* special case when the overridden configuration is marked as root, should\n\t\t * not try to load any more configuration files */\n\t\tconst override = this.loadFromObject(configOverride ?? {});\n\t\tif (override.isRootFound()) {\n\t\t\toverride.init();\n\t\t\treturn override.resolve();\n\t\t}\n\n\t\t/* special case when the global configuration is marked as root, should not\n\t\t * try to load and more configuration files */\n\t\tif (this.globalConfig.isRootFound()) {\n\t\t\tconst merged = this.globalConfig.merge(this.resolvers, override);\n\t\t\tmerged.init();\n\t\t\treturn merged.resolve();\n\t\t}\n\n\t\tconst config = this.fromFilename(filename);\n\t\tconst merged = config\n\t\t\t? config.merge(this.resolvers, override)\n\t\t\t: this.globalConfig.merge(this.resolvers, override);\n\t\tmerged.init();\n\t\treturn merged.resolve();\n\t}\n\n\t/**\n\t * Flush configuration cache.\n\t *\n\t * @param filename - If given only the cache for that file is flushed.\n\t */\n\tpublic override flushCache(filename?: string): void {\n\t\tif (filename) {\n\t\t\tthis.cache.delete(filename);\n\t\t} else {\n\t\t\tthis.cache.clear();\n\t\t}\n\t}\n\n\t/**\n\t * Load raw configuration from directory traversal.\n\t *\n\t * This configuration is not merged with global configuration and may return\n\t * `null` if no configuration files are found.\n\t */\n\tpublic fromFilename(filename: string): Config | null {\n\t\tif (filename === \"inline\") {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst cache = this.cache.get(filename);\n\t\tif (cache) {\n\t\t\treturn cache;\n\t\t}\n\n\t\tlet found = false;\n\t\tlet current = path.resolve(path.dirname(filename));\n\t\tlet config = this.empty();\n\n\t\t// eslint-disable-next-line no-constant-condition -- it will break out when filesystem is traversed\n\t\twhile (true) {\n\t\t\t/* search configuration files in current directory */\n\t\t\tfor (const configFile of findConfigurationFiles(this.fs, current)) {\n\t\t\t\tconst local = this.loadFromFile(configFile);\n\t\t\t\tfound = true;\n\t\t\t\tconfig = local.merge(this.resolvers, config);\n\t\t\t}\n\n\t\t\t/* stop if a configuration with \"root\" is set to true */\n\t\t\tif (config.isRootFound()) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t/* get the parent directory */\n\t\t\tconst child = current;\n\t\t\tcurrent = path.dirname(current);\n\n\t\t\t/* stop if this is the root directory */\n\t\t\tif (current === child) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t/* no config was found by loader, return null and let caller decide what to do */\n\t\tif (!found) {\n\t\t\tthis.cache.set(filename, null);\n\t\t\treturn null;\n\t\t}\n\n\t\tthis.cache.set(filename, config);\n\t\treturn config;\n\t}\n\n\t/**\n\t * @internal For testing only\n\t */\n\tpublic _getInternalCache(): Map<string, Config | null> {\n\t\treturn this.cache;\n\t}\n\n\tprotected defaultConfig(): Config {\n\t\treturn Config.defaultConfig();\n\t}\n}\n","import kleur from \"kleur\";\nimport { version } from \"../generated/package\";\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(kleur.red(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":["fs","options","merged"],"mappings":";;;;;;AAGgB,SAAA,eAAA,CAAgB,SAAyB,QAA2B,EAAA;AACnF,EAAM,MAAA,QAAA,GAAW,OAAQ,CAAA,OAAA,CAAQ,QAAQ,CAAA,CAAA;AAGzC,EAAM,MAAA,CAAA,GAAI,OAAQ,CAAA,KAAA,CAAM,QAAQ,CAAA,CAAA;AAChC,EAAA,IAAI,uBAAG,MAAQ,EAAA;AACd,IAAM,MAAA,EAAE,QAAW,GAAA,CAAA,CAAA;AACnB,IAAA,KAAA,IAAS,IAAI,MAAO,CAAA,QAAA,CAAS,SAAS,CAAG,EAAA,CAAA,IAAK,GAAG,CAAK,EAAA,EAAA;AACrD,MAAA,IAAI,MAAO,CAAA,QAAA,CAAS,CAAC,CAAA,CAAE,OAAO,QAAU,EAAA;AACvC,QAAO,MAAA,CAAA,QAAA,CAAS,MAAO,CAAA,CAAA,EAAG,CAAC,CAAA,CAAA;AAAA,OAC5B;AAAA,KACD;AAAA,GACD;AAIA,EAAO,OAAA,OAAA,CAAQ,MAAM,QAAQ,CAAA,CAAA;AAG7B,EAAA,OAAO,QAAQ,QAAQ,CAAA,CAAA;AACxB;;;;ACpBA,IAAI,aAA+B,GAAA,IAAA,CAAA;AASnB,SAAA,oBAAA,CAAqB,QAAgBA,GAAoB,EAAA;AAExE,EAAA,IAAI,OAAU,GAAA,MAAA,CAAA;AAGd,EAAA,OAAO,IAAM,EAAA;AACZ,IAAA,MAAM,MAAS,GAAA,IAAA,CAAK,IAAK,CAAA,OAAA,EAAS,cAAc,CAAA,CAAA;AAChD,IAAIA,IAAAA,GAAAA,CAAG,UAAW,CAAA,MAAM,CAAG,EAAA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AAA,GACb;AAAA,EAEU,aAAwB,GAAA;AACjC,IAAA,OAAO,OAAO,aAAc,EAAA,CAAA;AAAA,GAC7B;AACD;;ACvNA,MAAM,QAAiC,GAAA;AAAA,EACtC,MAAQ,EAAA,KAAA;AAAA,EACR,OAAA;AAAA,EACA,OAAO,IAAoB,EAAA;AAE1B,IAAA,OAAA,CAAQ,KAAM,CAAA,KAAA,CAAM,GAAI,CAAA,IAAI,CAAC,CAAA,CAAA;AAAA,GAC9B;AACD,CAAA,CAAA;AAYgB,SAAA,kBAAA,CACf,IACA,EAAA,QAAA,EACA,OACU,EAAA;AACV,EAAO,OAAA,sBAAA,CAAuB,MAAM,QAAU,EAAA;AAAA,IAC7C,GAAG,QAAA;AAAA,IACH,GAAG,OAAA;AAAA,GACH,CAAA,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"core-nodejs.js","sources":["../../src/utils/require-uncached.ts","../../src/config/resolver/nodejs/determine-root-dir.ts","../../src/config/resolver/nodejs/expand-relative-path.ts","../../src/config/resolver/nodejs/cjs-resolver.ts","../../src/config/loaders/file-system.ts","../../src/utils/compatibility-check.nodejs.ts"],"sourcesContent":["/**\n * Similar to `require(..)` but removes the cached copy first.\n */\nexport function requireUncached(require: NodeJS.Require, moduleId: string): unknown {\n\tconst filename = require.resolve(moduleId);\n\n\t/* remove references from the parent module to prevent memory leak */\n\tconst m = require.cache[filename];\n\tif (m?.parent) {\n\t\tconst { parent } = m;\n\t\tfor (let i = parent.children.length - 1; i >= 0; i--) {\n\t\t\tif (parent.children[i].id === filename) {\n\t\t\t\tparent.children.splice(i, 1);\n\t\t\t}\n\t\t}\n\t}\n\n\t/* remove old module from cache */\n\t/* eslint-disable-next-line @typescript-eslint/no-dynamic-delete -- needed to perform its function */\n\tdelete require.cache[filename];\n\n\t/* eslint-disable-next-line import/no-dynamic-require, security/detect-non-literal-require -- as expected but should be moved to upcoming resolver class */\n\treturn require(filename);\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\n\nlet cachedRootDir: string | null = null;\n\ninterface FSLike {\n\texistsSync(path: string): boolean;\n}\n\n/**\n * @internal\n */\nexport function determineRootDirImpl(intial: string, fs: FSLike): string {\n\t/* try to locate package.json */\n\tlet current = intial;\n\n\t// eslint-disable-next-line no-constant-condition, @typescript-eslint/no-unnecessary-condition -- break outs when filesystem is traversed\n\twhile (true) {\n\t\tconst search = path.join(current, \"package.json\");\n\t\tif (fs.existsSync(search)) {\n\t\t\treturn current;\n\t\t}\n\n\t\t/* get the parent directory */\n\t\tconst child = current;\n\t\tcurrent = path.dirname(current);\n\n\t\t/* stop if this is the root directory */\n\t\tif (current === child) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t/* default to working directory if no package.json is found */\n\treturn intial;\n}\n\n/**\n * Try to determine root directory based on the location of the closest\n * `package.json`. Fallbacks on `process.cwd()` if no package.json was found.\n *\n * @internal\n */\n/* istanbul ignore next: cached version of determineRootDirImpl, no need to test */\nexport function determineRootDir(): string {\n\tif (cachedRootDir === null) {\n\t\tcachedRootDir = determineRootDirImpl(process.cwd(), fs);\n\t}\n\treturn cachedRootDir;\n}\n","import path from \"node:path\";\n\n/**\n * @internal\n */\nexport function expandRelativePath<T>(value: string | T, { cwd }: { cwd: string }): string | T {\n\tif (typeof value === \"string\" && value.startsWith(\".\")) {\n\t\treturn path.normalize(path.join(cwd, value));\n\t} else {\n\t\treturn value;\n\t}\n}\n","import path from \"node:path\";\nimport { type MetaDataTable } from \"../../../meta\";\nimport { type Plugin } from \"../../../plugin\";\nimport { legacyRequire } from \"../../../resolve\";\nimport { type Transformer } from \"../../../transform\";\nimport { requireUncached } from \"../../../utils\";\nimport { type ConfigData } from \"../../config-data\";\nimport { ConfigError } from \"../../error\";\nimport { type Resolver, type ResolverOptions } from \"../resolver\";\nimport { determineRootDir } from \"./determine-root-dir\";\nimport { expandRelativePath } from \"./expand-relative-path\";\n\n/**\n * @internal\n */\nexport interface RequireError extends Error {\n\tcode: string;\n}\n\nfunction isRequireError(error: unknown): error is RequireError {\n\treturn Boolean(error && typeof error === \"object\" && \"code\" in error);\n}\n\nfunction isTransformer(value: Transformer | Plugin): value is Transformer {\n\treturn typeof value === \"function\";\n}\n\n/**\n * CommonJS resolver.\n *\n * @public\n * @since 8.8.0\n */\nexport type CommonJSResolver = Required<Resolver>;\n\n/**\n * CommonJS resolver.\n *\n * @public\n * @deprecated Deprecated alias for [[CommonJSResolver]].\n * @since 8.0.0\n */\nexport type NodeJSResolver = Required<Resolver>;\n\n/**\n * Create a new resolver for NodeJS packages using `require(..)`.\n *\n * If the module name contains `<rootDir>` (e.g. `<rootDir/foo`) it will be\n * expanded relative to the root directory either explicitly set by the\n * `rootDir` parameter or determined automatically by the closest `package.json`\n * file (starting at the current working directory).\n *\n * @public\n * @since 8.8.0\n */\nexport function cjsResolver(options: { rootDir?: string } = {}): CommonJSResolver {\n\tconst rootDir = options.rootDir ?? determineRootDir();\n\n\tfunction internalRequire<T = unknown>(id: string, { cache }: ResolverOptions): T | null {\n\t\tconst moduleName = id.replace(\"<rootDir>\", rootDir);\n\t\ttry {\n\t\t\t/* istanbul ignore else: the tests only runs the cached versions to get\n\t\t\t * unmodified access to `require`, the implementation of `requireUncached`\n\t\t\t * is assumed to be tested elsewhere */\n\t\t\tif (cache) {\n\t\t\t\treturn legacyRequire(moduleName) as T;\n\t\t\t} else {\n\t\t\t\treturn requireUncached(legacyRequire, moduleName) as T;\n\t\t\t}\n\t\t} catch (err: unknown) {\n\t\t\tif (isRequireError(err) && err.code === \"MODULE_NOT_FOUND\") {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\treturn {\n\t\tname: \"nodejs-resolver\",\n\n\t\tresolveElements(id: string, options: ResolverOptions): MetaDataTable | null {\n\t\t\treturn internalRequire(id, options);\n\t\t},\n\n\t\tresolveConfig(id: string, options: ResolverOptions): ConfigData | null {\n\t\t\tconst configData = internalRequire<ConfigData>(id, options);\n\t\t\tif (!configData) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t/* expand any relative paths */\n\t\t\tconst cwd = path.dirname(id);\n\t\t\tconst expand = <T>(value: string | T): string | T => expandRelativePath(value, { cwd });\n\n\t\t\tif (Array.isArray(configData.elements)) {\n\t\t\t\tconfigData.elements = configData.elements.map(expand);\n\t\t\t}\n\n\t\t\tif (Array.isArray(configData.extends)) {\n\t\t\t\tconfigData.extends = configData.extends.map(expand);\n\t\t\t}\n\n\t\t\tif (Array.isArray(configData.plugins)) {\n\t\t\t\tconfigData.plugins = configData.plugins.map(expand);\n\t\t\t}\n\n\t\t\treturn configData;\n\t\t},\n\n\t\tresolvePlugin(id: string, options: ResolverOptions): Plugin | null {\n\t\t\treturn internalRequire<Plugin>(id, options);\n\t\t},\n\n\t\tresolveTransformer(id: string, options: ResolverOptions): Transformer | null {\n\t\t\tconst mod = internalRequire<Transformer | Plugin>(id, options);\n\t\t\tif (!mod) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tif (isTransformer(mod)) {\n\t\t\t\treturn mod;\n\t\t\t}\n\n\t\t\t/* this is not a proper transformer, is it a plugin exposing a transformer? */\n\t\t\tif (mod.transformer) {\n\t\t\t\tthrow new ConfigError(\n\t\t\t\t\t`Module \"${id}\" is not a valid transformer. This looks like a plugin, did you forget to load the plugin first?`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthrow new ConfigError(`Module \"${id}\" is not a valid transformer.`);\n\t\t},\n\t};\n}\n\n/**\n * Create a new resolver for NodeJS packages using `require(..)`.\n *\n * If the module name contains `<rootDir>` (e.g. `<rootDir/foo`) it will be\n * expanded relative to the root directory either explicitly set by the\n * `rootDir` parameter or determined automatically by the closest `package.json`\n * file (starting at the current working directory).\n *\n * @public\n * @deprecated Deprecated alias for [[commonjsResolver]].\n * @since 8.0.0\n */\n/* istanbul ignore next -- deprecated alias */\nexport function nodejsResolver(options: { rootDir?: string } = {}): NodeJSResolver {\n\treturn cjsResolver(options);\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { Config } from \"../config\";\nimport { type ConfigData } from \"../config-data\";\nimport { ConfigLoader } from \"../config-loader\";\nimport { type ResolvedConfig } from \"../resolved-config\";\nimport { type Resolver } from \"../resolver\";\nimport { type FSLike, cjsResolver } from \"../resolver/nodejs\";\n\n/**\n * Options for [[FileSystemConfigLoader]].\n *\n * @public\n */\nexport interface FileSystemConfigLoaderOptions {\n\t/** An implementation of `fs` as needed by [[FileSystemConfigLoader]] */\n\tfs: FSLike;\n}\n\n/**\n * @internal\n */\nfunction findConfigurationFiles(fs: FSLike, directory: string): string[] {\n\treturn [\"json\", \"cjs\", \"js\"]\n\t\t.map((extension) => path.join(directory, `.htmlvalidate.${extension}`))\n\t\t.filter((filePath) => fs.existsSync(filePath));\n}\n\nconst defaultResolvers: Resolver[] = [cjsResolver()];\n\ntype ConstructorParametersDefault = [ConfigData?, Partial<FileSystemConfigLoaderOptions>?];\ntype ConstructorParametersResolver = [\n\tResolver[],\n\tConfigData?,\n\tPartial<FileSystemConfigLoaderOptions>?,\n];\ntype ConstructorParameters = ConstructorParametersDefault | ConstructorParametersResolver;\n\nfunction hasResolver(value: ConstructorParameters): value is ConstructorParametersResolver {\n\treturn Array.isArray(value[0]);\n}\n\n/**\n * Loads configuration by traversing filesystem.\n *\n * Configuration is read from three sources and in the following order:\n *\n * 1. Global configuration passed to constructor.\n * 2. Configuration files found when traversing the directory structure.\n * 3. Override passed to this function.\n *\n * The following configuration filenames are searched:\n *\n * - `.htmlvalidate.json`\n * - `.htmlvalidate.js`\n * - `.htmlvalidate.cjs`\n *\n * Global configuration is used when no configuration file is found. The\n * result is always merged with override if present.\n *\n * The `root` property set to `true` affects the configuration as following:\n *\n * 1. If set in override the override is returned as-is.\n * 2. If set in the global config the override is merged into global and\n * returned. No configuration files are searched.\n * 3. Setting `root` in configuration file only stops directory traversal.\n *\n * @public\n */\nexport class FileSystemConfigLoader extends ConfigLoader {\n\tprotected cache: Map<string, Config | null>;\n\tprivate fs: FSLike;\n\n\t/**\n\t * Create a filesystem configuration loader with default resolvers.\n\t *\n\t * @param fs - `fs` implementation,\n\t * @param config - Global configuration.\n\t * @param configFactory - Optional configuration factory.\n\t */\n\tpublic constructor(config?: ConfigData, options?: Partial<FileSystemConfigLoaderOptions>);\n\n\t/**\n\t * Create a filesystem configuration loader with custom resolvers.\n\t *\n\t * @param fs - `fs` implementation,\n\t * @param resolvers - Resolvers to use.\n\t * @param config - Global configuration.\n\t * @param configFactory - Optional configuration factory.\n\t */\n\tpublic constructor(\n\t\tresolvers: Resolver[],\n\t\tconfig?: ConfigData,\n\t\toptions?: Partial<FileSystemConfigLoaderOptions>,\n\t);\n\n\tpublic constructor(...args: ConstructorParameters) {\n\t\tif (hasResolver(args)) {\n\t\t\t/* istanbul ignore next */\n\t\t\tconst [resolvers, config, options = {}] = args;\n\t\t\tsuper(resolvers, config);\n\t\t\tthis.fs = /* istanbul ignore next */ options.fs ?? fs;\n\t\t} else {\n\t\t\t/* istanbul ignore next */\n\t\t\tconst [config, options = {}] = args;\n\t\t\tsuper(defaultResolvers, config);\n\t\t\tthis.fs = /* istanbul ignore next */ options.fs ?? fs;\n\t\t}\n\t\tthis.cache = new Map();\n\t}\n\n\t/**\n\t * Get configuration for given filename.\n\t *\n\t * @param filename - Filename to get configuration for.\n\t * @param configOverride - Configuration to merge final result with.\n\t */\n\tpublic override getConfigFor(filename: string, configOverride?: ConfigData): ResolvedConfig {\n\t\t/* special case when the overridden configuration is marked as root, should\n\t\t * not try to load any more configuration files */\n\t\tconst override = this.loadFromObject(configOverride ?? {});\n\t\tif (override.isRootFound()) {\n\t\t\toverride.init();\n\t\t\treturn override.resolve();\n\t\t}\n\n\t\t/* special case when the global configuration is marked as root, should not\n\t\t * try to load and more configuration files */\n\t\tif (this.globalConfig.isRootFound()) {\n\t\t\tconst merged = this.globalConfig.merge(this.resolvers, override);\n\t\t\tmerged.init();\n\t\t\treturn merged.resolve();\n\t\t}\n\n\t\tconst config = this.fromFilename(filename);\n\t\tconst merged = config\n\t\t\t? config.merge(this.resolvers, override)\n\t\t\t: this.globalConfig.merge(this.resolvers, override);\n\t\tmerged.init();\n\t\treturn merged.resolve();\n\t}\n\n\t/**\n\t * Flush configuration cache.\n\t *\n\t * @param filename - If given only the cache for that file is flushed.\n\t */\n\tpublic override flushCache(filename?: string): void {\n\t\tif (filename) {\n\t\t\tthis.cache.delete(filename);\n\t\t} else {\n\t\t\tthis.cache.clear();\n\t\t}\n\t}\n\n\t/**\n\t * Load raw configuration from directory traversal.\n\t *\n\t * This configuration is not merged with global configuration and may return\n\t * `null` if no configuration files are found.\n\t */\n\tpublic fromFilename(filename: string): Config | null {\n\t\tif (filename === \"inline\") {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst cache = this.cache.get(filename);\n\t\tif (cache) {\n\t\t\treturn cache;\n\t\t}\n\n\t\tlet found = false;\n\t\tlet current = path.resolve(path.dirname(filename));\n\t\tlet config = this.empty();\n\n\t\t// eslint-disable-next-line no-constant-condition, @typescript-eslint/no-unnecessary-condition -- it will break out when filesystem is traversed\n\t\twhile (true) {\n\t\t\t/* search configuration files in current directory */\n\t\t\tfor (const configFile of findConfigurationFiles(this.fs, current)) {\n\t\t\t\tconst local = this.loadFromFile(configFile);\n\t\t\t\tfound = true;\n\t\t\t\tconfig = local.merge(this.resolvers, config);\n\t\t\t}\n\n\t\t\t/* stop if a configuration with \"root\" is set to true */\n\t\t\tif (config.isRootFound()) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t/* get the parent directory */\n\t\t\tconst child = current;\n\t\t\tcurrent = path.dirname(current);\n\n\t\t\t/* stop if this is the root directory */\n\t\t\tif (current === child) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t/* no config was found by loader, return null and let caller decide what to do */\n\t\tif (!found) {\n\t\t\tthis.cache.set(filename, null);\n\t\t\treturn null;\n\t\t}\n\n\t\tthis.cache.set(filename, config);\n\t\treturn config;\n\t}\n\n\t/**\n\t * @internal For testing only\n\t */\n\tpublic _getInternalCache(): Map<string, Config | null> {\n\t\treturn this.cache;\n\t}\n\n\tprotected defaultConfig(): Config {\n\t\treturn Config.defaultConfig();\n\t}\n}\n","import kleur from \"kleur\";\nimport { version } from \"../generated/package\";\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(kleur.red(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":["fs","options","merged"],"mappings":";;;;;;AAGgB,SAAA,eAAA,CAAgB,SAAyB,QAA2B,EAAA;AACnF,EAAM,MAAA,QAAA,GAAW,OAAQ,CAAA,OAAA,CAAQ,QAAQ,CAAA,CAAA;AAGzC,EAAM,MAAA,CAAA,GAAI,OAAQ,CAAA,KAAA,CAAM,QAAQ,CAAA,CAAA;AAChC,EAAA,IAAI,uBAAG,MAAQ,EAAA;AACd,IAAM,MAAA,EAAE,QAAW,GAAA,CAAA,CAAA;AACnB,IAAA,KAAA,IAAS,IAAI,MAAO,CAAA,QAAA,CAAS,SAAS,CAAG,EAAA,CAAA,IAAK,GAAG,CAAK,EAAA,EAAA;AACrD,MAAA,IAAI,MAAO,CAAA,QAAA,CAAS,CAAC,CAAA,CAAE,OAAO,QAAU,EAAA;AACvC,QAAO,MAAA,CAAA,QAAA,CAAS,MAAO,CAAA,CAAA,EAAG,CAAC,CAAA,CAAA;AAAA,OAC5B;AAAA,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