mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 05:41:24 +00:00
chore: Enable more lint rules, disable some that trigger a lot. Will clean up later.
This commit is contained in:
@@ -71,7 +71,7 @@ export function normalizeCronJobInput(
|
||||
const next: UnknownRecord = { ...base };
|
||||
|
||||
if ("agentId" in base) {
|
||||
const agentId = (base as UnknownRecord).agentId;
|
||||
const agentId = base.agentId;
|
||||
if (agentId === null) {
|
||||
next.agentId = null;
|
||||
} else if (typeof agentId === "string") {
|
||||
@@ -82,7 +82,7 @@ export function normalizeCronJobInput(
|
||||
}
|
||||
|
||||
if ("enabled" in base) {
|
||||
const enabled = (base as UnknownRecord).enabled;
|
||||
const enabled = base.enabled;
|
||||
if (typeof enabled === "boolean") {
|
||||
next.enabled = enabled;
|
||||
} else if (typeof enabled === "string") {
|
||||
|
||||
@@ -82,5 +82,5 @@ export async function readCronRunLogEntries(
|
||||
// ignore invalid lines
|
||||
}
|
||||
}
|
||||
return parsed.reverse();
|
||||
return parsed.toReversed();
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ export function createJob(state: CronServiceState, input: CronJobCreate): CronJo
|
||||
agentId: normalizeOptionalAgentId(input.agentId),
|
||||
name: normalizeRequiredName(input.name),
|
||||
description: normalizeOptionalText(input.description),
|
||||
enabled: input.enabled !== false,
|
||||
enabled: input.enabled,
|
||||
deleteAfterRun: input.deleteAfterRun,
|
||||
createdAtMs: now,
|
||||
updatedAtMs: now,
|
||||
|
||||
@@ -45,7 +45,7 @@ export async function status(state: CronServiceState) {
|
||||
enabled: state.deps.cronEnabled,
|
||||
storePath: state.deps.storePath,
|
||||
jobs: state.store?.jobs.length ?? 0,
|
||||
nextWakeAtMs: state.deps.cronEnabled === true ? (nextWakeAtMs(state) ?? null) : null,
|
||||
nextWakeAtMs: state.deps.cronEnabled ? (nextWakeAtMs(state) ?? null) : null,
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -55,7 +55,7 @@ export async function list(state: CronServiceState, opts?: { includeDisabled?: b
|
||||
await ensureLoaded(state);
|
||||
const includeDisabled = opts?.includeDisabled === true;
|
||||
const jobs = (state.store?.jobs ?? []).filter((j) => includeDisabled || j.enabled);
|
||||
return jobs.sort((a, b) => (a.state.nextRunAtMs ?? 0) - (b.state.nextRunAtMs ?? 0));
|
||||
return jobs.toSorted((a, b) => (a.state.nextRunAtMs ?? 0) - (b.state.nextRunAtMs ?? 0));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ export function resolveCronStorePath(storePath?: string) {
|
||||
export async function loadCronStore(storePath: string): Promise<CronStoreFile> {
|
||||
try {
|
||||
const raw = await fs.promises.readFile(storePath, "utf-8");
|
||||
const parsed = JSON5.parse(raw) as Partial<CronStoreFile> | null;
|
||||
const parsed = JSON5.parse(raw);
|
||||
const jobs = Array.isArray(parsed?.jobs) ? (parsed?.jobs as never[]) : [];
|
||||
return {
|
||||
version: 1,
|
||||
|
||||
Reference in New Issue
Block a user