Skip to content

Commit 20f6de7

Browse files
committed
fix: lint
1 parent e2e1d21 commit 20f6de7

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

src/commandLine.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,12 @@ function loadRcFile(rcPath: string): IRcFileConfig {
134134
}
135135
}
136136

137-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
138-
function validateRcConfig(config: any, rcPath: string): IRcFileConfig {
137+
function validateRcConfig(config: unknown, rcPath: string): IRcFileConfig {
139138
if (typeof config !== 'object' || config === null) throw new Error(`RC file ${rcPath} must contain a JSON object`);
140139

140+
// Type assertion after runtime check
141+
const configObject = config as Record<string, unknown>;
142+
141143
const validKeys = new Set([
142144
'engine',
143145
'sourcepath',
@@ -153,28 +155,33 @@ function validateRcConfig(config: any, rcPath: string): IRcFileConfig {
153155
]);
154156

155157
// Warn about unknown keys
156-
for (const key of Object.keys(config))
158+
for (const key of Object.keys(configObject))
157159
if (!validKeys.has(key)) console.warn(yellowLog(`Warning: Unknown property '${key}' in RC file ${rcPath}`));
158160

159161
// Validate individual properties
160-
if (config.engine !== undefined) config.engine = validateEngine(config.engine);
162+
if (configObject['engine'] !== undefined) configObject['engine'] = validateEngine(configObject['engine'] as string);
161163

162-
if (config.etag !== undefined) config.etag = validateTriState(config.etag, 'etag');
164+
if (configObject['etag'] !== undefined)
165+
configObject['etag'] = validateTriState(configObject['etag'] as string, 'etag');
163166

164-
if (config.gzip !== undefined) config.gzip = validateTriState(config.gzip, 'gzip');
167+
if (configObject['gzip'] !== undefined)
168+
configObject['gzip'] = validateTriState(configObject['gzip'] as string, 'gzip');
165169

166-
if (config.cachetime !== undefined && (typeof config.cachetime !== 'number' || Number.isNaN(config.cachetime)))
167-
throw new TypeError(`Invalid cachetime in RC file: ${config.cachetime}`);
170+
if (
171+
configObject['cachetime'] !== undefined &&
172+
(typeof configObject['cachetime'] !== 'number' || Number.isNaN(configObject['cachetime']))
173+
)
174+
throw new TypeError(`Invalid cachetime in RC file: ${configObject['cachetime']}`);
168175

169-
if (config.exclude !== undefined) {
170-
if (!Array.isArray(config.exclude)) throw new TypeError("'exclude' in RC file must be an array");
176+
if (configObject['exclude'] !== undefined) {
177+
if (!Array.isArray(configObject['exclude'])) throw new TypeError("'exclude' in RC file must be an array");
171178

172179
// Validate each exclude pattern is a string
173-
for (const pattern of config.exclude)
180+
for (const pattern of configObject['exclude'])
174181
if (typeof pattern !== 'string') throw new TypeError('All exclude patterns must be strings');
175182
}
176183

177-
return config;
184+
return configObject as IRcFileConfig;
178185
}
179186

180187
function parseArguments(): ICopyFilesArguments {

0 commit comments

Comments
 (0)