chore: Enable "curly" rule to avoid single-statement if confusion/errors.

This commit is contained in:
cpojer
2026-01-31 16:19:20 +09:00
parent 009b16fab8
commit 5ceff756e1
1266 changed files with 27871 additions and 9393 deletions

View File

@@ -20,20 +20,30 @@ export const DEFAULT_HEARTBEAT_ACK_MAX_CHARS = 300;
* decide what to do. This function is only for when the file exists but has no content.
*/
export function isHeartbeatContentEffectivelyEmpty(content: string | undefined | null): boolean {
if (content === undefined || content === null) return false;
if (typeof content !== "string") return false;
if (content === undefined || content === null) {
return false;
}
if (typeof content !== "string") {
return false;
}
const lines = content.split("\n");
for (const line of lines) {
const trimmed = line.trim();
// Skip empty lines
if (!trimmed) continue;
if (!trimmed) {
continue;
}
// Skip markdown header lines (# followed by space or EOL, ## etc)
// This intentionally does NOT skip lines like "#TODO" or "#hashtag" which might be content
// (Those aren't valid markdown headers - ATX headers require space after #)
if (/^#+(\s|$)/.test(trimmed)) continue;
if (/^#+(\s|$)/.test(trimmed)) {
continue;
}
// Skip empty markdown list items like "- [ ]" or "* [ ]" or just "- "
if (/^[-*+]\s*(\[[\sXx]?\]\s*)?$/.test(trimmed)) continue;
if (/^[-*+]\s*(\[[\sXx]?\]\s*)?$/.test(trimmed)) {
continue;
}
// Found a non-empty, non-comment line - there's actionable content
return false;
}
@@ -50,10 +60,14 @@ export type StripHeartbeatMode = "heartbeat" | "message";
function stripTokenAtEdges(raw: string): { text: string; didStrip: boolean } {
let text = raw.trim();
if (!text) return { text: "", didStrip: false };
if (!text) {
return { text: "", didStrip: false };
}
const token = HEARTBEAT_TOKEN;
if (!text.includes(token)) return { text, didStrip: false };
if (!text.includes(token)) {
return { text, didStrip: false };
}
let didStrip = false;
let changed = true;
@@ -83,9 +97,13 @@ export function stripHeartbeatToken(
raw?: string,
opts: { mode?: StripHeartbeatMode; maxAckChars?: number } = {},
) {
if (!raw) return { shouldSkip: true, text: "", didStrip: false };
if (!raw) {
return { shouldSkip: true, text: "", didStrip: false };
}
const trimmed = raw.trim();
if (!trimmed) return { shouldSkip: true, text: "", didStrip: false };
if (!trimmed) {
return { shouldSkip: true, text: "", didStrip: false };
}
const mode: StripHeartbeatMode = opts.mode ?? "message";
const maxAckCharsRaw = opts.maxAckChars;