fix: lint errors

This commit is contained in:
Bohdan Podvirnyi
2026-01-15 18:49:22 +02:00
committed by Peter Steinberger
parent dfb6630de1
commit f12c1b391f
3 changed files with 35 additions and 11 deletions

View File

@@ -4,14 +4,20 @@ export type CommandArgsFormatter = (values: CommandArgValues) => string | undefi
function normalizeArgValue(value: unknown): string | undefined {
if (value == null) return undefined;
let text: string;
if (typeof value === "string") {
const trimmed = value.trim();
return trimmed ? trimmed : undefined;
text = value.trim();
} else if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
text = String(value).trim();
} else if (typeof value === "symbol") {
text = value.toString().trim();
} else if (typeof value === "function") {
text = value.toString().trim();
} else {
// Objects and arrays
text = JSON.stringify(value);
}
if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
return String(value);
}
return undefined;
return text ? text : undefined;
}
const formatConfigArgs: CommandArgsFormatter = (values) => {

View File

@@ -137,13 +137,25 @@ function formatPositionalArgs(
for (const definition of definitions) {
const value = values[definition.name];
if (value == null) continue;
let rendered: string;
if (typeof value === "string") {
const trimmed = value.trim();
if (!trimmed) continue;
parts.push(trimmed);
} else if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
parts.push(String(value));
rendered = value.trim();
} else if (
typeof value === "number" ||
typeof value === "boolean" ||
typeof value === "bigint"
) {
rendered = String(value);
} else if (typeof value === "symbol") {
rendered = value.toString();
} else if (typeof value === "function") {
rendered = value.toString();
} else {
// Objects and arrays
rendered = JSON.stringify(value);
}
if (!rendered) continue;
parts.push(rendered);
if (definition.captureRemaining) break;
}
return parts.length > 0 ? parts.join(" ") : undefined;

View File

@@ -84,6 +84,9 @@ function formatTemplateValue(value: unknown): string {
if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
return String(value);
}
if (typeof value === "symbol" || typeof value === "function") {
return value.toString();
}
if (Array.isArray(value)) {
return value
.flatMap((entry) => {
@@ -96,6 +99,9 @@ function formatTemplateValue(value: unknown): string {
})
.join(",");
}
if (typeof value === "object") {
return JSON.stringify(value);
}
return "";
}