chore(cron): simplify enabled checks for lint

This commit is contained in:
Gustavo Madeira Santana
2026-02-15 10:19:50 -05:00
parent fa4c282f9e
commit 88caa4b50c
3 changed files with 14 additions and 21 deletions

View File

@@ -55,7 +55,7 @@ export function findJobOrThrow(state: CronServiceState, id: string) {
}
export function computeJobNextRunAtMs(job: CronJob, nowMs: number): number | undefined {
if (job.enabled === false) {
if (!job.enabled) {
return undefined;
}
if (job.schedule.kind === "every") {
@@ -102,7 +102,7 @@ function normalizeJobTickState(params: { state: CronServiceState; job: CronJob;
changed = true;
}
if (job.enabled === false) {
if (!job.enabled) {
if (job.state.nextRunAtMs !== undefined) {
job.state.nextRunAtMs = undefined;
changed = true;
@@ -220,9 +220,7 @@ export function recomputeNextRunsForMaintenance(state: CronServiceState): boolea
export function nextWakeAtMs(state: CronServiceState) {
const jobs = state.store?.jobs ?? [];
const enabled = jobs.filter(
(j) => j.enabled !== false && typeof j.state.nextRunAtMs === "number",
);
const enabled = jobs.filter((j) => j.enabled && typeof j.state.nextRunAtMs === "number");
if (enabled.length === 0) {
return undefined;
}
@@ -482,11 +480,7 @@ export function isJobDue(job: CronJob, nowMs: number, opts: { forced: boolean })
if (opts.forced) {
return true;
}
return (
job.enabled !== false &&
typeof job.state.nextRunAtMs === "number" &&
nowMs >= job.state.nextRunAtMs
);
return job.enabled && typeof job.state.nextRunAtMs === "number" && nowMs >= job.state.nextRunAtMs;
}
export function resolveJobPayloadTextForMain(job: CronJob): string | undefined {