mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 01:14:33 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -17,7 +17,9 @@ export function parseFrontmatter(content: string): ParsedSkillFrontmatter {
|
||||
}
|
||||
|
||||
function normalizeStringList(input: unknown): string[] {
|
||||
if (!input) return [];
|
||||
if (!input) {
|
||||
return [];
|
||||
}
|
||||
if (Array.isArray(input)) {
|
||||
return input.map((value) => String(value).trim()).filter(Boolean);
|
||||
}
|
||||
@@ -31,7 +33,9 @@ function normalizeStringList(input: unknown): string[] {
|
||||
}
|
||||
|
||||
function parseInstallSpec(input: unknown): SkillInstallSpec | undefined {
|
||||
if (!input || typeof input !== "object") return undefined;
|
||||
if (!input || typeof input !== "object") {
|
||||
return undefined;
|
||||
}
|
||||
const raw = input as Record<string, unknown>;
|
||||
const kindRaw =
|
||||
typeof raw.kind === "string" ? raw.kind : typeof raw.type === "string" ? raw.type : "";
|
||||
@@ -44,20 +48,44 @@ function parseInstallSpec(input: unknown): SkillInstallSpec | undefined {
|
||||
kind: kind,
|
||||
};
|
||||
|
||||
if (typeof raw.id === "string") spec.id = raw.id;
|
||||
if (typeof raw.label === "string") spec.label = raw.label;
|
||||
if (typeof raw.id === "string") {
|
||||
spec.id = raw.id;
|
||||
}
|
||||
if (typeof raw.label === "string") {
|
||||
spec.label = raw.label;
|
||||
}
|
||||
const bins = normalizeStringList(raw.bins);
|
||||
if (bins.length > 0) spec.bins = bins;
|
||||
if (bins.length > 0) {
|
||||
spec.bins = bins;
|
||||
}
|
||||
const osList = normalizeStringList(raw.os);
|
||||
if (osList.length > 0) spec.os = osList;
|
||||
if (typeof raw.formula === "string") spec.formula = raw.formula;
|
||||
if (typeof raw.package === "string") spec.package = raw.package;
|
||||
if (typeof raw.module === "string") spec.module = raw.module;
|
||||
if (typeof raw.url === "string") spec.url = raw.url;
|
||||
if (typeof raw.archive === "string") spec.archive = raw.archive;
|
||||
if (typeof raw.extract === "boolean") spec.extract = raw.extract;
|
||||
if (typeof raw.stripComponents === "number") spec.stripComponents = raw.stripComponents;
|
||||
if (typeof raw.targetDir === "string") spec.targetDir = raw.targetDir;
|
||||
if (osList.length > 0) {
|
||||
spec.os = osList;
|
||||
}
|
||||
if (typeof raw.formula === "string") {
|
||||
spec.formula = raw.formula;
|
||||
}
|
||||
if (typeof raw.package === "string") {
|
||||
spec.package = raw.package;
|
||||
}
|
||||
if (typeof raw.module === "string") {
|
||||
spec.module = raw.module;
|
||||
}
|
||||
if (typeof raw.url === "string") {
|
||||
spec.url = raw.url;
|
||||
}
|
||||
if (typeof raw.archive === "string") {
|
||||
spec.archive = raw.archive;
|
||||
}
|
||||
if (typeof raw.extract === "boolean") {
|
||||
spec.extract = raw.extract;
|
||||
}
|
||||
if (typeof raw.stripComponents === "number") {
|
||||
spec.stripComponents = raw.stripComponents;
|
||||
}
|
||||
if (typeof raw.targetDir === "string") {
|
||||
spec.targetDir = raw.targetDir;
|
||||
}
|
||||
|
||||
return spec;
|
||||
}
|
||||
@@ -76,10 +104,14 @@ export function resolveOpenClawMetadata(
|
||||
frontmatter: ParsedSkillFrontmatter,
|
||||
): OpenClawSkillMetadata | undefined {
|
||||
const raw = getFrontmatterValue(frontmatter, "metadata");
|
||||
if (!raw) return undefined;
|
||||
if (!raw) {
|
||||
return undefined;
|
||||
}
|
||||
try {
|
||||
const parsed = JSON5.parse(raw);
|
||||
if (!parsed || typeof parsed !== "object") return undefined;
|
||||
if (!parsed || typeof parsed !== "object") {
|
||||
return undefined;
|
||||
}
|
||||
const metadataRawCandidates = [MANIFEST_KEY, ...LEGACY_MANIFEST_KEYS];
|
||||
let metadataRaw: unknown;
|
||||
for (const key of metadataRawCandidates) {
|
||||
@@ -89,7 +121,9 @@ export function resolveOpenClawMetadata(
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!metadataRaw || typeof metadataRaw !== "object") return undefined;
|
||||
if (!metadataRaw || typeof metadataRaw !== "object") {
|
||||
return undefined;
|
||||
}
|
||||
const metadataObj = metadataRaw as Record<string, unknown>;
|
||||
const requiresRaw =
|
||||
typeof metadataObj.requires === "object" && metadataObj.requires !== null
|
||||
|
||||
Reference in New Issue
Block a user