refactor: lint cleanups and helpers

This commit is contained in:
Peter Steinberger
2025-12-23 00:28:40 +00:00
parent f5837dff9c
commit 918cbdcf03
39 changed files with 679 additions and 338 deletions

View File

@@ -77,7 +77,7 @@ describe("trigger handling", () => {
makeCfg(home),
);
const text = Array.isArray(res) ? res[0]?.text : res?.text;
expect(text?.startsWith("⚙️ Restarting" ?? "")).toBe(true);
expect(text?.startsWith("⚙️ Restarting")).toBe(true);
expect(runEmbeddedPiAgent).not.toHaveBeenCalled();
});
});

View File

@@ -25,7 +25,7 @@ export type TemplateContext = MsgContext & {
export function applyTemplate(str: string | undefined, ctx: TemplateContext) {
if (!str) return "";
return str.replace(/{{\s*(\w+)\s*}}/g, (_, key) => {
const value = (ctx as Record<string, unknown>)[key];
return value == null ? "" : String(value);
const value = ctx[key as keyof TemplateContext];
return value ?? "";
});
}