@herb-tools/config 0.8.10 → 0.9.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/README.md +1 -1
- package/dist/{src/config-schema.js → config-schema.js} +9 -0
- package/dist/config-schema.js.map +1 -0
- package/dist/{src/config.js → config.js} +73 -83
- package/dist/config.js.map +1 -0
- package/dist/herb-config.cjs +87 -87
- package/dist/herb-config.cjs.map +1 -1
- package/dist/herb-config.esm.js +88 -88
- package/dist/herb-config.esm.js.map +1 -1
- package/dist/index.js.map +1 -0
- package/dist/{src/merge.js → merge.js} +1 -1
- package/dist/merge.js.map +1 -0
- package/dist/types/config-schema.d.ts +19 -0
- package/dist/types/config.d.ts +16 -6
- package/dist/{src/vscode.js → vscode.js} +1 -1
- package/dist/vscode.js.map +1 -0
- package/package.json +2 -2
- package/src/config-schema.ts +11 -0
- package/src/config-template.yml +7 -1
- package/src/config.ts +90 -87
- package/src/merge.ts +1 -1
- package/src/vscode.ts +1 -1
- package/dist/package.json +0 -49
- package/dist/src/config-schema.js.map +0 -1
- package/dist/src/config.js.map +0 -1
- package/dist/src/index.js.map +0 -1
- package/dist/src/merge.js.map +0 -1
- package/dist/src/vscode.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/types/src/config-schema.d.ts +0 -102
- package/dist/types/src/config.d.ts +0 -365
- package/dist/types/src/index.d.ts +0 -5
- package/dist/types/src/merge.d.ts +0 -11
- package/dist/types/src/vscode.d.ts +0 -13
- /package/dist/{src/index.js → index.js} +0 -0
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const SeveritySchema: z.ZodEnum<{
|
|
3
|
-
error: "error";
|
|
4
|
-
warning: "warning";
|
|
5
|
-
info: "info";
|
|
6
|
-
hint: "hint";
|
|
7
|
-
}>;
|
|
8
|
-
export declare const FilesConfigSchema: z.ZodOptional<z.ZodObject<{
|
|
9
|
-
include: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
10
|
-
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
11
|
-
}, z.core.$strict>>;
|
|
12
|
-
export declare const RuleConfigSchema: z.ZodOptional<z.ZodObject<{
|
|
13
|
-
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
14
|
-
severity: z.ZodOptional<z.ZodEnum<{
|
|
15
|
-
error: "error";
|
|
16
|
-
warning: "warning";
|
|
17
|
-
info: "info";
|
|
18
|
-
hint: "hint";
|
|
19
|
-
}>>;
|
|
20
|
-
include: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
21
|
-
only: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
22
|
-
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
23
|
-
}, z.core.$strip>>;
|
|
24
|
-
export declare const LinterConfigSchema: z.ZodOptional<z.ZodObject<{
|
|
25
|
-
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
26
|
-
failLevel: z.ZodOptional<z.ZodEnum<{
|
|
27
|
-
error: "error";
|
|
28
|
-
warning: "warning";
|
|
29
|
-
info: "info";
|
|
30
|
-
hint: "hint";
|
|
31
|
-
}>>;
|
|
32
|
-
include: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
33
|
-
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
34
|
-
rules: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
35
|
-
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
36
|
-
severity: z.ZodOptional<z.ZodEnum<{
|
|
37
|
-
error: "error";
|
|
38
|
-
warning: "warning";
|
|
39
|
-
info: "info";
|
|
40
|
-
hint: "hint";
|
|
41
|
-
}>>;
|
|
42
|
-
include: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
43
|
-
only: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
44
|
-
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
45
|
-
}, z.core.$strip>>>;
|
|
46
|
-
}, z.core.$strict>>;
|
|
47
|
-
export declare const FormatterConfigSchema: z.ZodOptional<z.ZodObject<{
|
|
48
|
-
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
49
|
-
include: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
50
|
-
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
51
|
-
indentWidth: z.ZodOptional<z.ZodNumber>;
|
|
52
|
-
maxLineLength: z.ZodOptional<z.ZodNumber>;
|
|
53
|
-
rewriter: z.ZodOptional<z.ZodObject<{
|
|
54
|
-
pre: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
55
|
-
post: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
56
|
-
}, z.core.$strict>>;
|
|
57
|
-
}, z.core.$strict>>;
|
|
58
|
-
export declare const HerbConfigSchema: z.ZodObject<{
|
|
59
|
-
version: z.ZodString;
|
|
60
|
-
files: z.ZodOptional<z.ZodObject<{
|
|
61
|
-
include: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
62
|
-
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
63
|
-
}, z.core.$strict>>;
|
|
64
|
-
linter: z.ZodOptional<z.ZodObject<{
|
|
65
|
-
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
66
|
-
failLevel: z.ZodOptional<z.ZodEnum<{
|
|
67
|
-
error: "error";
|
|
68
|
-
warning: "warning";
|
|
69
|
-
info: "info";
|
|
70
|
-
hint: "hint";
|
|
71
|
-
}>>;
|
|
72
|
-
include: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
73
|
-
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
74
|
-
rules: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
75
|
-
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
76
|
-
severity: z.ZodOptional<z.ZodEnum<{
|
|
77
|
-
error: "error";
|
|
78
|
-
warning: "warning";
|
|
79
|
-
info: "info";
|
|
80
|
-
hint: "hint";
|
|
81
|
-
}>>;
|
|
82
|
-
include: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
83
|
-
only: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
84
|
-
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
85
|
-
}, z.core.$strip>>>;
|
|
86
|
-
}, z.core.$strict>>;
|
|
87
|
-
formatter: z.ZodOptional<z.ZodObject<{
|
|
88
|
-
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
89
|
-
include: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
90
|
-
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
91
|
-
indentWidth: z.ZodOptional<z.ZodNumber>;
|
|
92
|
-
maxLineLength: z.ZodOptional<z.ZodNumber>;
|
|
93
|
-
rewriter: z.ZodOptional<z.ZodObject<{
|
|
94
|
-
pre: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
95
|
-
post: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
96
|
-
}, z.core.$strict>>;
|
|
97
|
-
}, z.core.$strict>>;
|
|
98
|
-
}, z.core.$strict>;
|
|
99
|
-
export type HerbConfigSchemaType = z.infer<typeof HerbConfigSchema>;
|
|
100
|
-
export type RuleConfigSchemaType = z.infer<typeof RuleConfigSchema>;
|
|
101
|
-
export type FilesConfigSchemaType = z.infer<typeof FilesConfigSchema>;
|
|
102
|
-
export type SeveritySchemaType = z.infer<typeof SeveritySchema>;
|
|
@@ -1,365 +0,0 @@
|
|
|
1
|
-
import { DiagnosticSeverity } from "@herb-tools/core";
|
|
2
|
-
export interface ConfigValidationError {
|
|
3
|
-
message: string;
|
|
4
|
-
path: (string | number | symbol)[];
|
|
5
|
-
code: string;
|
|
6
|
-
line?: number;
|
|
7
|
-
column?: number;
|
|
8
|
-
severity?: 'error' | 'warning';
|
|
9
|
-
}
|
|
10
|
-
export type FilesConfig = {
|
|
11
|
-
include?: string[];
|
|
12
|
-
exclude?: string[];
|
|
13
|
-
};
|
|
14
|
-
export type RuleConfig = {
|
|
15
|
-
enabled?: boolean;
|
|
16
|
-
severity?: DiagnosticSeverity;
|
|
17
|
-
autoCorrect?: boolean;
|
|
18
|
-
include?: string[];
|
|
19
|
-
only?: string[];
|
|
20
|
-
exclude?: string[];
|
|
21
|
-
};
|
|
22
|
-
export type LinterConfig = {
|
|
23
|
-
enabled?: boolean;
|
|
24
|
-
failLevel?: DiagnosticSeverity;
|
|
25
|
-
include?: string[];
|
|
26
|
-
exclude?: string[];
|
|
27
|
-
rules?: Record<string, RuleConfig>;
|
|
28
|
-
};
|
|
29
|
-
export type FormatterConfig = {
|
|
30
|
-
enabled?: boolean;
|
|
31
|
-
include?: string[];
|
|
32
|
-
exclude?: string[];
|
|
33
|
-
indentWidth?: number;
|
|
34
|
-
maxLineLength?: number;
|
|
35
|
-
rewriter?: {
|
|
36
|
-
pre?: string[];
|
|
37
|
-
post?: string[];
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
export type HerbConfigOptions = {
|
|
41
|
-
files?: FilesConfig;
|
|
42
|
-
linter?: LinterConfig;
|
|
43
|
-
formatter?: FormatterConfig;
|
|
44
|
-
};
|
|
45
|
-
export type HerbConfig = HerbConfigOptions & {
|
|
46
|
-
version: string;
|
|
47
|
-
};
|
|
48
|
-
export type LoadOptions = {
|
|
49
|
-
silent?: boolean;
|
|
50
|
-
version?: string;
|
|
51
|
-
createIfMissing?: boolean;
|
|
52
|
-
exitOnError?: boolean;
|
|
53
|
-
};
|
|
54
|
-
export type FromObjectOptions = {
|
|
55
|
-
projectPath?: string;
|
|
56
|
-
version?: string;
|
|
57
|
-
};
|
|
58
|
-
export declare class Config {
|
|
59
|
-
static configPath: string;
|
|
60
|
-
private static PROJECT_INDICATORS;
|
|
61
|
-
readonly path: string;
|
|
62
|
-
config: HerbConfig;
|
|
63
|
-
constructor(projectPath: string, config: HerbConfig);
|
|
64
|
-
get projectPath(): string;
|
|
65
|
-
get version(): string;
|
|
66
|
-
get options(): HerbConfigOptions;
|
|
67
|
-
get linter(): LinterConfig | undefined;
|
|
68
|
-
get formatter(): FormatterConfig | undefined;
|
|
69
|
-
toJSON(): string;
|
|
70
|
-
/**
|
|
71
|
-
* Check if the linter is enabled.
|
|
72
|
-
* @returns true if linter is enabled (default), false if explicitly disabled
|
|
73
|
-
*/
|
|
74
|
-
get isLinterEnabled(): boolean;
|
|
75
|
-
/**
|
|
76
|
-
* Check if the formatter is enabled.
|
|
77
|
-
* @returns true if formatter is explicitly enabled, false otherwise (default)
|
|
78
|
-
*/
|
|
79
|
-
get isFormatterEnabled(): boolean;
|
|
80
|
-
/**
|
|
81
|
-
* Check if a specific rule is disabled.
|
|
82
|
-
* @param ruleName - The name of the rule to check
|
|
83
|
-
* @returns true if the rule is explicitly disabled, false otherwise
|
|
84
|
-
*/
|
|
85
|
-
isRuleDisabled(ruleName: string): boolean;
|
|
86
|
-
/**
|
|
87
|
-
* Check if a specific rule is enabled.
|
|
88
|
-
* @param ruleName - The name of the rule to check
|
|
89
|
-
* @returns true if the rule is enabled, false otherwise
|
|
90
|
-
*/
|
|
91
|
-
isRuleEnabled(ruleName: string): boolean;
|
|
92
|
-
/**
|
|
93
|
-
* Get the files configuration for a specific tool.
|
|
94
|
-
* Tool-specific file config takes precedence over top-level config.
|
|
95
|
-
* Include patterns are additive (defaults are already merged in this.config).
|
|
96
|
-
* @param tool - The tool to get files config for ('linter' or 'formatter')
|
|
97
|
-
* @returns The merged files configuration
|
|
98
|
-
*/
|
|
99
|
-
getFilesConfigForTool(tool: 'linter' | 'formatter'): FilesConfig;
|
|
100
|
-
/**
|
|
101
|
-
* Get the files configuration for the linter.
|
|
102
|
-
* Linter-specific file config takes precedence over top-level config.
|
|
103
|
-
* @returns The merged files configuration for linter
|
|
104
|
-
*/
|
|
105
|
-
get filesConfigForLinter(): FilesConfig;
|
|
106
|
-
/**
|
|
107
|
-
* Get the files configuration for the formatter.
|
|
108
|
-
* Formatter-specific file config takes precedence over top-level config.
|
|
109
|
-
* @returns The merged files configuration for formatter
|
|
110
|
-
*/
|
|
111
|
-
get filesConfigForFormatter(): FilesConfig;
|
|
112
|
-
/**
|
|
113
|
-
* Find files for a specific tool based on its configuration.
|
|
114
|
-
* Uses include patterns from config, applies exclude patterns.
|
|
115
|
-
* @param tool - The tool to find files for ('linter' or 'formatter')
|
|
116
|
-
* @param cwd - The directory to search from (defaults to project path)
|
|
117
|
-
* @returns Promise resolving to array of absolute file paths
|
|
118
|
-
*/
|
|
119
|
-
findFilesForTool(tool: 'linter' | 'formatter', cwd?: string): Promise<string[]>;
|
|
120
|
-
/**
|
|
121
|
-
* Find files for the linter based on linter configuration.
|
|
122
|
-
* @param cwd - The directory to search from (defaults to project path)
|
|
123
|
-
* @returns Promise resolving to array of absolute file paths
|
|
124
|
-
*/
|
|
125
|
-
findFilesForLinter(cwd?: string): Promise<string[]>;
|
|
126
|
-
/**
|
|
127
|
-
* Find files for the formatter based on formatter configuration.
|
|
128
|
-
* @param cwd - The directory to search from (defaults to project path)
|
|
129
|
-
* @returns Promise resolving to array of absolute file paths
|
|
130
|
-
*/
|
|
131
|
-
findFilesForFormatter(cwd?: string): Promise<string[]>;
|
|
132
|
-
/**
|
|
133
|
-
* Check if a file path is excluded by glob patterns.
|
|
134
|
-
* @param filePath - The file path to check
|
|
135
|
-
* @param excludePatterns - Array of glob patterns to check against
|
|
136
|
-
* @returns true if the path matches any exclude pattern
|
|
137
|
-
*/
|
|
138
|
-
private isPathExcluded;
|
|
139
|
-
/**
|
|
140
|
-
* Check if a file path matches any of the include patterns.
|
|
141
|
-
* @param filePath - The file path to check
|
|
142
|
-
* @param includePatterns - Array of glob patterns to check against
|
|
143
|
-
* @returns true if the path matches any include pattern, or true if no patterns specified
|
|
144
|
-
*/
|
|
145
|
-
private isPathIncluded;
|
|
146
|
-
/**
|
|
147
|
-
* Check if a tool (linter or formatter) is enabled for a specific file path.
|
|
148
|
-
* Respects both the tool's enabled state and its exclude patterns.
|
|
149
|
-
* @param filePath - The file path to check
|
|
150
|
-
* @param tool - The tool to check ('linter' or 'formatter')
|
|
151
|
-
* @returns true if the tool is enabled for this path
|
|
152
|
-
*/
|
|
153
|
-
isEnabledForPath(filePath: string, tool: 'linter' | 'formatter'): boolean;
|
|
154
|
-
/**
|
|
155
|
-
* Check if the linter is enabled for a specific file path.
|
|
156
|
-
* Respects both linter.enabled and linter.exclude patterns.
|
|
157
|
-
* @param filePath - The file path to check
|
|
158
|
-
* @returns true if the linter is enabled for this path
|
|
159
|
-
*/
|
|
160
|
-
isLinterEnabledForPath(filePath: string): boolean;
|
|
161
|
-
/**
|
|
162
|
-
* Check if the formatter is enabled for a specific file path.
|
|
163
|
-
* Respects both formatter.enabled and formatter.exclude patterns.
|
|
164
|
-
* @param filePath - The file path to check
|
|
165
|
-
* @returns true if the formatter is enabled for this path
|
|
166
|
-
*/
|
|
167
|
-
isFormatterEnabledForPath(filePath: string): boolean;
|
|
168
|
-
/**
|
|
169
|
-
* Check if a specific rule is enabled for a specific file path.
|
|
170
|
-
* Respects linter.enabled, linter.exclude, rule.enabled, rule.include, rule.only, and rule.exclude patterns.
|
|
171
|
-
*
|
|
172
|
-
* Pattern precedence:
|
|
173
|
-
* - If rule.only is specified: Only files matching 'only' patterns (ignores all 'include' patterns)
|
|
174
|
-
* - If rule.only is NOT specified: Files matching 'include' patterns (if specified, additive)
|
|
175
|
-
* - rule.exclude is always applied regardless of 'only' or 'include'
|
|
176
|
-
*
|
|
177
|
-
* @param ruleName - The name of the rule to check
|
|
178
|
-
* @param filePath - The file path to check
|
|
179
|
-
* @returns true if the rule is enabled for this path
|
|
180
|
-
*/
|
|
181
|
-
isRuleEnabledForPath(ruleName: string, filePath: string): boolean;
|
|
182
|
-
/**
|
|
183
|
-
* Apply configured severity overrides to a lint offense.
|
|
184
|
-
* Returns the configured severity if set, otherwise returns the original severity.
|
|
185
|
-
*/
|
|
186
|
-
getConfiguredSeverity(ruleName: string, defaultSeverity: DiagnosticSeverity): DiagnosticSeverity;
|
|
187
|
-
/**
|
|
188
|
-
* Apply severity overrides from config to an array of offenses.
|
|
189
|
-
* Each offense must have a `rule` and `severity` property.
|
|
190
|
-
*/
|
|
191
|
-
applySeverityOverrides<T extends {
|
|
192
|
-
rule: string;
|
|
193
|
-
severity: DiagnosticSeverity;
|
|
194
|
-
}>(offenses: T[]): T[];
|
|
195
|
-
static configPathFromProjectPath(projectPath: string): string;
|
|
196
|
-
/**
|
|
197
|
-
* Get the default file patterns that Herb recognizes.
|
|
198
|
-
* These are the default extensions/patterns used when no custom patterns are specified.
|
|
199
|
-
* @returns Array of glob patterns for HTML+ERB files
|
|
200
|
-
*/
|
|
201
|
-
static getDefaultFilePatterns(): string[];
|
|
202
|
-
/**
|
|
203
|
-
* Check if a .herb.yml config file exists at the given path.
|
|
204
|
-
*
|
|
205
|
-
* @param pathOrFile - Path to directory or explicit config file path
|
|
206
|
-
* @returns True if .herb.yml exists at the location, false otherwise
|
|
207
|
-
*/
|
|
208
|
-
static exists(pathOrFile: string): boolean;
|
|
209
|
-
/**
|
|
210
|
-
* Find the project root by walking up from a given path.
|
|
211
|
-
* Looks for .herb.yml first, then falls back to project indicators
|
|
212
|
-
* (.git, Gemfile, package.json, etc.)
|
|
213
|
-
*
|
|
214
|
-
* @param startPath - File or directory path to start searching from
|
|
215
|
-
* @returns The project root directory path
|
|
216
|
-
*/
|
|
217
|
-
static findProjectRoot(startPath: string): Promise<string>;
|
|
218
|
-
/**
|
|
219
|
-
* Synchronous version of findProjectRoot for use in CLIs.
|
|
220
|
-
*
|
|
221
|
-
* @param startPath - File or directory path to start searching from
|
|
222
|
-
* @returns The project root directory path
|
|
223
|
-
*/
|
|
224
|
-
static findProjectRootSync(startPath: string): string;
|
|
225
|
-
/**
|
|
226
|
-
* Read raw YAML content from a config file.
|
|
227
|
-
* Handles both explicit .herb.yml paths and directory paths.
|
|
228
|
-
*
|
|
229
|
-
* @param pathOrFile - Path to .herb.yml file or directory containing it
|
|
230
|
-
* @returns string - The raw YAML content
|
|
231
|
-
*/
|
|
232
|
-
static readRawYaml(pathOrFile: string): string;
|
|
233
|
-
/**
|
|
234
|
-
* Load Herb configuration from a file or directory
|
|
235
|
-
*
|
|
236
|
-
* This is the main entry point for loading configuration. It:
|
|
237
|
-
* 1. Discovers the config file by walking up the directory tree
|
|
238
|
-
* 2. Reads and validates the config
|
|
239
|
-
* 3. Merges with defaults for a fully resolved config
|
|
240
|
-
* 4. Auto-creates default config if createIfMissing option is true
|
|
241
|
-
* 5. Prints informative messages to console
|
|
242
|
-
*
|
|
243
|
-
* @param pathOrFile - File path, directory path, or any path to start search from
|
|
244
|
-
* @param options - Loading options
|
|
245
|
-
* @returns Promise<Config> - Fully resolved config instance
|
|
246
|
-
*/
|
|
247
|
-
static load(pathOrFile: string, options?: LoadOptions): Promise<Config>;
|
|
248
|
-
/**
|
|
249
|
-
* Load config for editor/language server use (silent mode, no file creation).
|
|
250
|
-
* This is a convenience method for the common pattern used in editors.
|
|
251
|
-
*
|
|
252
|
-
* @param pathOrFile - Directory path or explicit .herb.yml file path
|
|
253
|
-
* @param version - Optional version string (defaults to package version)
|
|
254
|
-
* @returns Config instance or throws on errors
|
|
255
|
-
*/
|
|
256
|
-
static loadForEditor(pathOrFile: string, version?: string): Promise<Config>;
|
|
257
|
-
/**
|
|
258
|
-
* Load config for CLI use (may create file, show errors).
|
|
259
|
-
* This is a convenience method for the common pattern used in CLI tools.
|
|
260
|
-
*
|
|
261
|
-
* @param pathOrFile - Directory path or explicit .herb.yml file path
|
|
262
|
-
* @param version - Optional version string (defaults to package version)
|
|
263
|
-
* @param createIfMissing - Whether to create config if missing (default: false)
|
|
264
|
-
* @returns Config instance or throws on errors
|
|
265
|
-
*/
|
|
266
|
-
static loadForCLI(pathOrFile: string, version?: string, createIfMissing?: boolean): Promise<Config>;
|
|
267
|
-
/**
|
|
268
|
-
* Mutate an existing config file by reading it, validating, merging with a mutation, and writing back.
|
|
269
|
-
* This preserves the user's YAML file structure and only writes what's explicitly configured.
|
|
270
|
-
*
|
|
271
|
-
* @param configPath - Path to the .herb.yml file
|
|
272
|
-
* @param mutation - Partial config to merge (e.g., { linter: { rules: { "rule-name": { enabled: false } } } })
|
|
273
|
-
* @returns Promise<void>
|
|
274
|
-
*
|
|
275
|
-
* @example
|
|
276
|
-
* // Disable a rule in .herb.yml
|
|
277
|
-
* await Config.mutateConfigFile('/path/to/.herb.yml', {
|
|
278
|
-
* linter: {
|
|
279
|
-
* rules: {
|
|
280
|
-
* 'html-img-require-alt': { enabled: false }
|
|
281
|
-
* }
|
|
282
|
-
* }
|
|
283
|
-
* })
|
|
284
|
-
*/
|
|
285
|
-
static mutateConfigFile(configPath: string, mutation: Partial<HerbConfigOptions>): Promise<void>;
|
|
286
|
-
/**
|
|
287
|
-
* Apply mutation to YAML content and return the mutated string (synchronous)
|
|
288
|
-
* Useful for code actions and other scenarios where you need the mutated content
|
|
289
|
-
* without writing to disk.
|
|
290
|
-
*
|
|
291
|
-
* @param yamlContent - The original YAML content (with comments)
|
|
292
|
-
* @param mutation - The mutation to apply
|
|
293
|
-
* @returns The mutated YAML content (with comments preserved)
|
|
294
|
-
*/
|
|
295
|
-
static applyMutationToYamlString(yamlContent: string, mutation: Partial<HerbConfigOptions>): string;
|
|
296
|
-
/**
|
|
297
|
-
* Create a new config file content with a mutation applied
|
|
298
|
-
* Uses the default template with comments and applies the mutation
|
|
299
|
-
*
|
|
300
|
-
* @param mutation - The mutation to apply to the default config
|
|
301
|
-
* @param version - The version to use (defaults to package version)
|
|
302
|
-
* @returns The config file content as a YAML string
|
|
303
|
-
*/
|
|
304
|
-
static createConfigYamlString(mutation: Partial<HerbConfigOptions>, version?: string): string;
|
|
305
|
-
/**
|
|
306
|
-
* Apply mutation to a YAML document while preserving comments
|
|
307
|
-
* Works recursively to handle nested objects
|
|
308
|
-
*/
|
|
309
|
-
private static applyMutationToDocument;
|
|
310
|
-
/**
|
|
311
|
-
* Add spacing between top-level keys and nested rule keys in YAML
|
|
312
|
-
*/
|
|
313
|
-
private static addYamlSpacing;
|
|
314
|
-
/**
|
|
315
|
-
* Create a Config instance from a partial config object
|
|
316
|
-
*
|
|
317
|
-
* Useful for testing and programmatic config creation.
|
|
318
|
-
* Deep merges the partial config with defaults.
|
|
319
|
-
*
|
|
320
|
-
* @param partial - Partial config object
|
|
321
|
-
* @param options - Options including projectPath and version
|
|
322
|
-
* @returns Config instance with fully resolved config
|
|
323
|
-
*/
|
|
324
|
-
static fromObject(partial: Partial<HerbConfigOptions>, options?: FromObjectOptions): Config;
|
|
325
|
-
/**
|
|
326
|
-
* Find config file by walking up directory tree
|
|
327
|
-
*
|
|
328
|
-
* @param startPath - Path to start searching from (file or directory)
|
|
329
|
-
* @returns Object with configPath (if found) and projectRoot
|
|
330
|
-
*/
|
|
331
|
-
private static findConfigFile;
|
|
332
|
-
/**
|
|
333
|
-
* Check if a directory is a project root
|
|
334
|
-
*/
|
|
335
|
-
private static isProjectRoot;
|
|
336
|
-
/**
|
|
337
|
-
* Load config from explicit path (from --config-file argument)
|
|
338
|
-
*/
|
|
339
|
-
private static loadFromExplicitPath;
|
|
340
|
-
/**
|
|
341
|
-
* Load config from discovered path
|
|
342
|
-
*/
|
|
343
|
-
private static loadFromPath;
|
|
344
|
-
/**
|
|
345
|
-
* Create default config at project root
|
|
346
|
-
*/
|
|
347
|
-
private static createDefaultConfig;
|
|
348
|
-
/**
|
|
349
|
-
* Validate config text without loading or exiting process
|
|
350
|
-
* Used by language servers to show diagnostics
|
|
351
|
-
* Returns empty array if valid, array of errors/warnings if invalid
|
|
352
|
-
*/
|
|
353
|
-
static validateConfigText(text: string, options?: {
|
|
354
|
-
version?: string;
|
|
355
|
-
projectPath?: string;
|
|
356
|
-
}): Promise<ConfigValidationError[]>;
|
|
357
|
-
/**
|
|
358
|
-
* Read, parse, and validate config file
|
|
359
|
-
*/
|
|
360
|
-
private static readAndValidateConfig;
|
|
361
|
-
/**
|
|
362
|
-
* Get default configuration object
|
|
363
|
-
*/
|
|
364
|
-
private static getDefaultConfig;
|
|
365
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { Config } from "./config.js";
|
|
2
|
-
export { HerbConfigSchema } from "./config-schema.js";
|
|
3
|
-
export { addHerbExtensionRecommendation, getExtensionsJsonRelativePath } from "./vscode.js";
|
|
4
|
-
export type { HerbConfig, HerbConfigOptions, LinterConfig, FormatterConfig, RuleConfig, FilesConfig, LoadOptions, FromObjectOptions, ConfigValidationError } from "./config.js";
|
|
5
|
-
export type { VSCodeExtensionsJson } from "./vscode.js";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
type DeepPartial<T> = T extends object ? {
|
|
2
|
-
[P in keyof T]?: DeepPartial<T[P]>;
|
|
3
|
-
} : T;
|
|
4
|
-
/**
|
|
5
|
-
* Deep merge two objects
|
|
6
|
-
* @param target - The base object (defaults)
|
|
7
|
-
* @param source - The object to merge in (user config)
|
|
8
|
-
* @returns Merged object
|
|
9
|
-
*/
|
|
10
|
-
export declare function deepMerge<T extends Record<string, any>>(target: T, source: DeepPartial<T>): T;
|
|
11
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface VSCodeExtensionsJson {
|
|
2
|
-
recommendations?: string[];
|
|
3
|
-
unwantedRecommendations?: string[];
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Adds the Herb VSCode extension to the recommended extensions list
|
|
7
|
-
* Returns true if the extension was added, false if it was already present
|
|
8
|
-
*/
|
|
9
|
-
export declare function addHerbExtensionRecommendation(projectPath: string): boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Gets the relative path to the extensions.json file from the project root
|
|
12
|
-
*/
|
|
13
|
-
export declare function getExtensionsJsonRelativePath(): string;
|
|
File without changes
|