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

@@ -17,7 +17,9 @@ function looksLikeUuid(value: string): boolean {
return true;
}
const compact = value.replace(/-/g, "");
if (!/^[0-9a-f]+$/i.test(compact)) return false;
if (!/^[0-9a-f]+$/i.test(compact)) {
return false;
}
return /[a-f]/i.test(compact);
}
@@ -69,14 +71,20 @@ export function resolveSignalPeerId(sender: SignalSender): string {
function parseSignalAllowEntry(entry: string): SignalAllowEntry | null {
const trimmed = entry.trim();
if (!trimmed) return null;
if (trimmed === "*") return { kind: "any" };
if (!trimmed) {
return null;
}
if (trimmed === "*") {
return { kind: "any" };
}
const stripped = stripSignalPrefix(trimmed);
const lower = stripped.toLowerCase();
if (lower.startsWith("uuid:")) {
const raw = stripped.slice("uuid:".length).trim();
if (!raw) return null;
if (!raw) {
return null;
}
return { kind: "uuid", raw };
}
@@ -88,11 +96,15 @@ function parseSignalAllowEntry(entry: string): SignalAllowEntry | null {
}
export function isSignalSenderAllowed(sender: SignalSender, allowFrom: string[]): boolean {
if (allowFrom.length === 0) return false;
if (allowFrom.length === 0) {
return false;
}
const parsed = allowFrom
.map(parseSignalAllowEntry)
.filter((entry): entry is SignalAllowEntry => entry !== null);
if (parsed.some((entry) => entry.kind === "any")) return true;
if (parsed.some((entry) => entry.kind === "any")) {
return true;
}
return parsed.some((entry) => {
if (entry.kind === "phone" && sender.kind === "phone") {
return entry.e164 === sender.e164;
@@ -110,8 +122,14 @@ export function isSignalGroupAllowed(params: {
sender: SignalSender;
}): boolean {
const { groupPolicy, allowFrom, sender } = params;
if (groupPolicy === "disabled") return false;
if (groupPolicy === "open") return true;
if (allowFrom.length === 0) return false;
if (groupPolicy === "disabled") {
return false;
}
if (groupPolicy === "open") {
return true;
}
if (allowFrom.length === 0) {
return false;
}
return isSignalSenderAllowed(sender, allowFrom);
}