mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 14:41:24 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -6,10 +6,14 @@ export function parseDurationMs(raw: string, opts?: DurationMsParseOptions): num
|
||||
const trimmed = String(raw ?? "")
|
||||
.trim()
|
||||
.toLowerCase();
|
||||
if (!trimmed) throw new Error("invalid duration (empty)");
|
||||
if (!trimmed) {
|
||||
throw new Error("invalid duration (empty)");
|
||||
}
|
||||
|
||||
const m = /^(\d+(?:\.\d+)?)(ms|s|m|h|d)?$/.exec(trimmed);
|
||||
if (!m) throw new Error(`invalid duration: ${raw}`);
|
||||
if (!m) {
|
||||
throw new Error(`invalid duration: ${raw}`);
|
||||
}
|
||||
|
||||
const value = Number(m[1]);
|
||||
if (!Number.isFinite(value) || value < 0) {
|
||||
@@ -28,6 +32,8 @@ export function parseDurationMs(raw: string, opts?: DurationMsParseOptions): num
|
||||
? 3_600_000
|
||||
: 86_400_000;
|
||||
const ms = Math.round(value * multiplier);
|
||||
if (!Number.isFinite(ms)) throw new Error(`invalid duration: ${raw}`);
|
||||
if (!Number.isFinite(ms)) {
|
||||
throw new Error(`invalid duration: ${raw}`);
|
||||
}
|
||||
return ms;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user