@markuplint/file-resolver 4.9.17 → 4.9.18
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/CHANGELOG.md +3 -3
- package/lib/config-provider.d.ts +37 -0
- package/lib/config-provider.js +37 -0
- package/lib/resolve-files.d.ts +8 -0
- package/lib/resolve-files.js +8 -0
- package/lib/resolve-parser.d.ts +11 -0
- package/lib/resolve-parser.js +11 -0
- package/lib/resolve-pretenders.d.ts +7 -0
- package/lib/resolve-pretenders.js +7 -0
- package/lib/resolve-rules.d.ts +12 -0
- package/lib/resolve-rules.js +12 -0
- package/lib/resolve-specs.d.ts +3 -3
- package/lib/resolve-specs.js +3 -3
- package/lib/types.d.ts +11 -0
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [4.9.
|
|
6
|
+
## [4.9.18](https://github.com/markuplint/markuplint/compare/@markuplint/file-resolver@4.9.17...@markuplint/file-resolver@4.9.18) (2026-02-10)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @markuplint/file-resolver
|
|
9
9
|
|
|
10
|
+
## [4.9.17](https://github.com/markuplint/markuplint/compare/@markuplint/file-resolver@4.9.16...@markuplint/file-resolver@4.9.17) (2025-11-05)
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
**Note:** Version bump only for package @markuplint/file-resolver
|
|
13
13
|
|
|
14
14
|
## [4.9.16](https://github.com/markuplint/markuplint/compare/@markuplint/file-resolver@4.9.15...@markuplint/file-resolver@4.9.16) (2025-08-24)
|
|
15
15
|
|
package/lib/config-provider.d.ts
CHANGED
|
@@ -2,14 +2,51 @@ import type { MLFile } from './ml-file/index.js';
|
|
|
2
2
|
import type { ConfigSet } from './types.js';
|
|
3
3
|
import type { OptimizedConfig } from '@markuplint/ml-config';
|
|
4
4
|
import type { Nullable } from '@markuplint/shared';
|
|
5
|
+
/**
|
|
6
|
+
* Manages loading, caching, and resolving markuplint configuration files.
|
|
7
|
+
*
|
|
8
|
+
* Handles `extends` chains, plugins, presets, overrides, and circular reference detection.
|
|
9
|
+
* Configuration files are searched via cosmiconfig and cached by file path.
|
|
10
|
+
*/
|
|
5
11
|
export declare class ConfigProvider {
|
|
6
12
|
#private;
|
|
13
|
+
/**
|
|
14
|
+
* Recursively loads a configuration and all its `extends` dependencies.
|
|
15
|
+
*
|
|
16
|
+
* @param key - The config file path or module name to load
|
|
17
|
+
* @param cache - Whether to use cached results
|
|
18
|
+
* @param referrer - The file path of the config that referenced this key
|
|
19
|
+
* @param depth - Current recursion depth (for circular reference detection)
|
|
20
|
+
* @returns A set of loaded config keys and any errors encountered
|
|
21
|
+
*/
|
|
7
22
|
recursiveLoad(key: string, cache: boolean, referrer: string, depth?: number): Promise<{
|
|
8
23
|
stack: Set<string>;
|
|
9
24
|
errs: Error[];
|
|
10
25
|
}>;
|
|
26
|
+
/**
|
|
27
|
+
* Resolves the full configuration for a target file by merging all named configs,
|
|
28
|
+
* resolving plugins, and applying file-specific overrides.
|
|
29
|
+
*
|
|
30
|
+
* @param targetFile - The file being linted
|
|
31
|
+
* @param names - Config file paths or module names to merge
|
|
32
|
+
* @param cache - Whether to use cached results
|
|
33
|
+
* @returns The fully resolved configuration set including plugins and errors
|
|
34
|
+
*/
|
|
11
35
|
resolve(targetFile: Readonly<MLFile>, names: readonly Nullable<string>[], cache?: boolean): Promise<ConfigSet>;
|
|
36
|
+
/**
|
|
37
|
+
* Searches for a markuplint configuration file starting from the target file's directory.
|
|
38
|
+
*
|
|
39
|
+
* @param targetFile - The file whose directory to search from
|
|
40
|
+
* @returns The file path of the found config, or `null` if none was found
|
|
41
|
+
*/
|
|
12
42
|
search(targetFile: Readonly<MLFile>): Promise<string | null>;
|
|
43
|
+
/**
|
|
44
|
+
* Stores a pre-built configuration in the provider's internal store.
|
|
45
|
+
*
|
|
46
|
+
* @param config - The optimized configuration to store
|
|
47
|
+
* @param key - An optional key to store the config under; auto-generated if omitted
|
|
48
|
+
* @returns The key under which the config was stored
|
|
49
|
+
*/
|
|
13
50
|
set(config: OptimizedConfig, key?: string): string;
|
|
14
51
|
private _load;
|
|
15
52
|
private _mergeConfigs;
|
package/lib/config-provider.js
CHANGED
|
@@ -22,6 +22,12 @@ import { cacheClear, resolvePlugins } from './resolve-plugins.js';
|
|
|
22
22
|
import { fileExists, uuid } from './utils.js';
|
|
23
23
|
const cpLog = log.extend('config-provider');
|
|
24
24
|
const KEY_SEPARATOR = '__ML_CONFIG_MERGE__';
|
|
25
|
+
/**
|
|
26
|
+
* Manages loading, caching, and resolving markuplint configuration files.
|
|
27
|
+
*
|
|
28
|
+
* Handles `extends` chains, plugins, presets, overrides, and circular reference detection.
|
|
29
|
+
* Configuration files are searched via cosmiconfig and cached by file path.
|
|
30
|
+
*/
|
|
25
31
|
export class ConfigProvider {
|
|
26
32
|
constructor() {
|
|
27
33
|
_ConfigProvider_cache.set(this, new Map());
|
|
@@ -29,6 +35,15 @@ export class ConfigProvider {
|
|
|
29
35
|
_ConfigProvider_recursiveLoadKeyAndDepth.set(this, new Map());
|
|
30
36
|
_ConfigProvider_store.set(this, new Map());
|
|
31
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Recursively loads a configuration and all its `extends` dependencies.
|
|
40
|
+
*
|
|
41
|
+
* @param key - The config file path or module name to load
|
|
42
|
+
* @param cache - Whether to use cached results
|
|
43
|
+
* @param referrer - The file path of the config that referenced this key
|
|
44
|
+
* @param depth - Current recursion depth (for circular reference detection)
|
|
45
|
+
* @returns A set of loaded config keys and any errors encountered
|
|
46
|
+
*/
|
|
32
47
|
async recursiveLoad(key, cache, referrer, depth = 1) {
|
|
33
48
|
const stack = new Set();
|
|
34
49
|
const errs = [];
|
|
@@ -67,6 +82,15 @@ export class ConfigProvider {
|
|
|
67
82
|
stack.add(key);
|
|
68
83
|
return { stack, errs };
|
|
69
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Resolves the full configuration for a target file by merging all named configs,
|
|
87
|
+
* resolving plugins, and applying file-specific overrides.
|
|
88
|
+
*
|
|
89
|
+
* @param targetFile - The file being linted
|
|
90
|
+
* @param names - Config file paths or module names to merge
|
|
91
|
+
* @param cache - Whether to use cached results
|
|
92
|
+
* @returns The fully resolved configuration set including plugins and errors
|
|
93
|
+
*/
|
|
70
94
|
async resolve(targetFile, names, cache = true) {
|
|
71
95
|
if (!cache) {
|
|
72
96
|
__classPrivateFieldGet(this, _ConfigProvider_store, "f").clear();
|
|
@@ -136,6 +160,12 @@ export class ConfigProvider {
|
|
|
136
160
|
__classPrivateFieldGet(this, _ConfigProvider_cache, "f").set(key, result);
|
|
137
161
|
return result;
|
|
138
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Searches for a markuplint configuration file starting from the target file's directory.
|
|
165
|
+
*
|
|
166
|
+
* @param targetFile - The file whose directory to search from
|
|
167
|
+
* @returns The file path of the found config, or `null` if none was found
|
|
168
|
+
*/
|
|
139
169
|
async search(targetFile) {
|
|
140
170
|
const isExists = await targetFile.dirExists();
|
|
141
171
|
cpLog('search: %s', targetFile.path);
|
|
@@ -154,6 +184,13 @@ export class ConfigProvider {
|
|
|
154
184
|
cpLog('Store key: %s', filePath);
|
|
155
185
|
return filePath;
|
|
156
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* Stores a pre-built configuration in the provider's internal store.
|
|
189
|
+
*
|
|
190
|
+
* @param config - The optimized configuration to store
|
|
191
|
+
* @param key - An optional key to store the config under; auto-generated if omitted
|
|
192
|
+
* @returns The key under which the config was stored
|
|
193
|
+
*/
|
|
157
194
|
set(config, key) {
|
|
158
195
|
key = key ?? uuid();
|
|
159
196
|
__classPrivateFieldGet(this, _ConfigProvider_store, "f").set(key, config);
|
package/lib/resolve-files.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import type { MLFile } from './ml-file/index.js';
|
|
2
2
|
import type { Target } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Resolves a list of targets (file globs or inline source code objects) into
|
|
5
|
+
* an array of {@link MLFile} instances.
|
|
6
|
+
*
|
|
7
|
+
* @param targetList - An array of file path globs or inline source code targets
|
|
8
|
+
* @param ignoreGlob - An optional glob pattern for files to exclude
|
|
9
|
+
* @returns An array of resolved MLFile instances
|
|
10
|
+
*/
|
|
3
11
|
export declare function resolveFiles(targetList: readonly Readonly<Target>[], ignoreGlob?: string): Promise<MLFile[]>;
|
package/lib/resolve-files.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { getAnonymousFile, getFiles } from './ml-file/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves a list of targets (file globs or inline source code objects) into
|
|
4
|
+
* an array of {@link MLFile} instances.
|
|
5
|
+
*
|
|
6
|
+
* @param targetList - An array of file path globs or inline source code targets
|
|
7
|
+
* @param ignoreGlob - An optional glob pattern for files to exclude
|
|
8
|
+
* @returns An array of resolved MLFile instances
|
|
9
|
+
*/
|
|
2
10
|
export async function resolveFiles(targetList, ignoreGlob) {
|
|
3
11
|
const res = [];
|
|
4
12
|
for (const target of targetList) {
|
package/lib/resolve-parser.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import type { MLFile } from './ml-file/index.js';
|
|
2
2
|
import type { MLMarkupLanguageParser, MLParser, ParserOptions } from '@markuplint/ml-ast';
|
|
3
3
|
import type { ParserConfig } from '@markuplint/ml-config';
|
|
4
|
+
/**
|
|
5
|
+
* Resolves the appropriate parser for a given file based on the parser configuration.
|
|
6
|
+
*
|
|
7
|
+
* Matches the file's basename against patterns in the parser config to find
|
|
8
|
+
* the correct parser module. Falls back to the HTML parser if no pattern matches.
|
|
9
|
+
*
|
|
10
|
+
* @param file - The file to find a parser for
|
|
11
|
+
* @param parserConfig - A mapping of file extension patterns to parser module names
|
|
12
|
+
* @param parserOptions - Parser options to pass through
|
|
13
|
+
* @returns The resolved parser, its module name, parser options, and whether a pattern matched
|
|
14
|
+
*/
|
|
4
15
|
export declare function resolveParser(file: Readonly<MLFile>, parserConfig?: ParserConfig, parserOptions?: ParserOptions): Promise<{
|
|
5
16
|
parserModName: string;
|
|
6
17
|
parser: MLParser | MLMarkupLanguageParser;
|
package/lib/resolve-parser.js
CHANGED
|
@@ -2,6 +2,17 @@ import path from 'node:path';
|
|
|
2
2
|
import { generalImport } from './general-import.js';
|
|
3
3
|
import { toRegexp } from './utils.js';
|
|
4
4
|
const parsers = new Map();
|
|
5
|
+
/**
|
|
6
|
+
* Resolves the appropriate parser for a given file based on the parser configuration.
|
|
7
|
+
*
|
|
8
|
+
* Matches the file's basename against patterns in the parser config to find
|
|
9
|
+
* the correct parser module. Falls back to the HTML parser if no pattern matches.
|
|
10
|
+
*
|
|
11
|
+
* @param file - The file to find a parser for
|
|
12
|
+
* @param parserConfig - A mapping of file extension patterns to parser module names
|
|
13
|
+
* @param parserOptions - Parser options to pass through
|
|
14
|
+
* @returns The resolved parser, its module name, parser options, and whether a pattern matched
|
|
15
|
+
*/
|
|
5
16
|
export async function resolveParser(file, parserConfig, parserOptions) {
|
|
6
17
|
parserConfig = {
|
|
7
18
|
...parserConfig,
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { OptimizedConfig, Pretender } from '@markuplint/ml-config';
|
|
2
2
|
type PretendersConfig = OptimizedConfig['pretenders'];
|
|
3
|
+
/**
|
|
4
|
+
* Resolves pretender definitions from files, imported modules, and inline data
|
|
5
|
+
* in the configuration.
|
|
6
|
+
*
|
|
7
|
+
* @param config - The pretenders configuration section from the optimized config
|
|
8
|
+
* @returns An array of all resolved pretender definitions
|
|
9
|
+
*/
|
|
3
10
|
export declare function resolvePretenders(config: PretendersConfig): Promise<Pretender[]>;
|
|
4
11
|
export {};
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { generalImport } from './general-import.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves pretender definitions from files, imported modules, and inline data
|
|
4
|
+
* in the configuration.
|
|
5
|
+
*
|
|
6
|
+
* @param config - The pretenders configuration section from the optimized config
|
|
7
|
+
* @returns An array of all resolved pretender definitions
|
|
8
|
+
*/
|
|
2
9
|
export async function resolvePretenders(config) {
|
|
3
10
|
if (!config) {
|
|
4
11
|
return [];
|
package/lib/resolve-rules.d.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import type { AnyMLRule, Ruleset, Plugin } from '@markuplint/ml-core';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves all rules from preset rules, plugins, and auto-loaded rules into
|
|
4
|
+
* a flat array of {@link MLRule} instances.
|
|
5
|
+
*
|
|
6
|
+
* @param plugins - The resolved plugins that may provide custom rules
|
|
7
|
+
* @param ruleset - The current ruleset (used for auto-loading)
|
|
8
|
+
* @param importPreset - Whether to import the built-in preset rules from `@markuplint/rules`
|
|
9
|
+
* @param autoLoad - Whether to auto-load rules referenced in the ruleset
|
|
10
|
+
* @returns An array of all resolved MLRule instances
|
|
11
|
+
*
|
|
12
|
+
* @deprecated The `autoLoad` parameter is deprecated
|
|
13
|
+
*/
|
|
2
14
|
export declare function resolveRules(plugins: readonly Plugin[], ruleset: Ruleset, importPreset: boolean,
|
|
3
15
|
/**
|
|
4
16
|
* @deprecated
|
package/lib/resolve-rules.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { MLRule } from '@markuplint/ml-core';
|
|
2
2
|
import { autoLoadRules } from './auto-load-rules.js';
|
|
3
3
|
let cachedPresetRules = null;
|
|
4
|
+
/**
|
|
5
|
+
* Resolves all rules from preset rules, plugins, and auto-loaded rules into
|
|
6
|
+
* a flat array of {@link MLRule} instances.
|
|
7
|
+
*
|
|
8
|
+
* @param plugins - The resolved plugins that may provide custom rules
|
|
9
|
+
* @param ruleset - The current ruleset (used for auto-loading)
|
|
10
|
+
* @param importPreset - Whether to import the built-in preset rules from `@markuplint/rules`
|
|
11
|
+
* @param autoLoad - Whether to auto-load rules referenced in the ruleset
|
|
12
|
+
* @returns An array of all resolved MLRule instances
|
|
13
|
+
*
|
|
14
|
+
* @deprecated The `autoLoad` parameter is deprecated
|
|
15
|
+
*/
|
|
4
16
|
export async function resolveRules(plugins, ruleset, importPreset,
|
|
5
17
|
/**
|
|
6
18
|
* @deprecated
|
package/lib/resolve-specs.d.ts
CHANGED
|
@@ -26,9 +26,9 @@ import type { ExtendedSpec, MLMLSpec } from '@markuplint/ml-spec';
|
|
|
26
26
|
* }
|
|
27
27
|
* ```
|
|
28
28
|
*
|
|
29
|
-
* @param filePath The
|
|
30
|
-
* @param specConfig The `
|
|
31
|
-
* @returns
|
|
29
|
+
* @param filePath - The path of the file being linted, used for pattern matching
|
|
30
|
+
* @param specConfig - The `specs` property from the config, mapping file patterns to spec module names
|
|
31
|
+
* @returns An object containing the base HTML spec and any matched extended specs as a schemas tuple
|
|
32
32
|
*/
|
|
33
33
|
export declare function resolveSpecs(filePath: string, specConfig?: SpecConfig): Promise<{
|
|
34
34
|
schemas: readonly [MLMLSpec, ...ExtendedSpec[]];
|
package/lib/resolve-specs.js
CHANGED
|
@@ -28,9 +28,9 @@ const caches = new Map();
|
|
|
28
28
|
* }
|
|
29
29
|
* ```
|
|
30
30
|
*
|
|
31
|
-
* @param filePath The
|
|
32
|
-
* @param specConfig The `
|
|
33
|
-
* @returns
|
|
31
|
+
* @param filePath - The path of the file being linted, used for pattern matching
|
|
32
|
+
* @param specConfig - The `specs` property from the config, mapping file patterns to spec module names
|
|
33
|
+
* @returns An object containing the base HTML spec and any matched extended specs as a schemas tuple
|
|
34
34
|
*/
|
|
35
35
|
export async function resolveSpecs(filePath, specConfig) {
|
|
36
36
|
const htmlSpec = await importSpecs('@markuplint/html-spec');
|
package/lib/types.d.ts
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import type { OptimizedConfig } from '@markuplint/ml-config';
|
|
2
2
|
import type { Plugin } from '@markuplint/ml-core';
|
|
3
|
+
/**
|
|
4
|
+
* A fully resolved configuration set including merged config, plugins, source file paths,
|
|
5
|
+
* and any errors encountered during resolution.
|
|
6
|
+
*/
|
|
3
7
|
export interface ConfigSet {
|
|
8
|
+
/** The merged and optimized configuration */
|
|
4
9
|
readonly config: OptimizedConfig;
|
|
10
|
+
/** The resolved plugins */
|
|
5
11
|
readonly plugins: readonly Plugin[];
|
|
12
|
+
/** The set of config file paths that contributed to this configuration */
|
|
6
13
|
readonly files: ReadonlySet<string>;
|
|
14
|
+
/** Errors encountered during config loading or resolution */
|
|
7
15
|
readonly errs: readonly Readonly<Error>[];
|
|
8
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* A lint target: either a file path/glob string, or an inline source code object.
|
|
19
|
+
*/
|
|
9
20
|
export type Target = string | {
|
|
10
21
|
/**
|
|
11
22
|
* Target source code of evaluation
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/file-resolver",
|
|
3
|
-
"version": "4.9.
|
|
3
|
+
"version": "4.9.18",
|
|
4
4
|
"description": "The file resolver of markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -27,21 +27,21 @@
|
|
|
27
27
|
"@types/node": "24.5.1"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@markuplint/html-parser": "4.6.
|
|
31
|
-
"@markuplint/ml-ast": "4.4.
|
|
32
|
-
"@markuplint/ml-config": "4.8.
|
|
33
|
-
"@markuplint/ml-core": "4.13.
|
|
34
|
-
"@markuplint/ml-spec": "4.10.
|
|
35
|
-
"@markuplint/parser-utils": "4.8.
|
|
36
|
-
"@markuplint/selector": "4.7.
|
|
37
|
-
"@markuplint/shared": "4.4.
|
|
30
|
+
"@markuplint/html-parser": "4.6.23",
|
|
31
|
+
"@markuplint/ml-ast": "4.4.11",
|
|
32
|
+
"@markuplint/ml-config": "4.8.15",
|
|
33
|
+
"@markuplint/ml-core": "4.13.3",
|
|
34
|
+
"@markuplint/ml-spec": "4.10.2",
|
|
35
|
+
"@markuplint/parser-utils": "4.8.11",
|
|
36
|
+
"@markuplint/selector": "4.7.8",
|
|
37
|
+
"@markuplint/shared": "4.4.13",
|
|
38
38
|
"cosmiconfig": "9.0.0",
|
|
39
39
|
"debug": "4.4.3",
|
|
40
|
-
"glob": "
|
|
40
|
+
"glob": "13.0.1",
|
|
41
41
|
"ignore": "7.0.5",
|
|
42
42
|
"import-meta-resolve": "4.2.0",
|
|
43
43
|
"jsonc": "2.0.0",
|
|
44
|
-
"minimatch": "10.
|
|
44
|
+
"minimatch": "10.1.2"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "193ee7c1262bbed95424e38efdf1a8e56ff049f4"
|
|
47
47
|
}
|