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 { function normalizeArgValue(value: unknown): string | undefined {
if (value == null) return undefined; if (value == null) return undefined;
let text: string;
if (typeof value === "string") { if (typeof value === "string") {
const trimmed = value.trim(); text = value.trim();
return trimmed ? trimmed : undefined; } 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 text ? text : undefined;
return String(value);
}
return undefined;
} }
const formatConfigArgs: CommandArgsFormatter = (values) => { const formatConfigArgs: CommandArgsFormatter = (values) => {

View File

@ -137,13 +137,25 @@ function formatPositionalArgs(
for (const definition of definitions) { for (const definition of definitions) {
const value = values[definition.name]; const value = values[definition.name];
if (value == null) continue; if (value == null) continue;
let rendered: string;
if (typeof value === "string") { if (typeof value === "string") {
const trimmed = value.trim(); rendered = value.trim();
if (!trimmed) continue; } else if (
parts.push(trimmed); typeof value === "number" ||
} else if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") { typeof value === "boolean" ||
parts.push(String(value)); 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; if (definition.captureRemaining) break;
} }
return parts.length > 0 ? parts.join(" ") : undefined; 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") { if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
return String(value); return String(value);
} }
if (typeof value === "symbol" || typeof value === "function") {
return value.toString();
}
if (Array.isArray(value)) { if (Array.isArray(value)) {
return value return value
.flatMap((entry) => { .flatMap((entry) => {
@ -96,6 +99,9 @@ function formatTemplateValue(value: unknown): string {
}) })
.join(","); .join(",");
} }
if (typeof value === "object") {
return JSON.stringify(value);
}
return ""; return "";
} }