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

@@ -36,7 +36,9 @@ export const normalizeAllowFromWithStore = (params: {
export const firstDefined = <T>(...values: Array<T | undefined>) => {
for (const value of values) {
if (typeof value !== "undefined") return value;
if (typeof value !== "undefined") {
return value;
}
}
return undefined;
};
@@ -47,11 +49,19 @@ export const isSenderAllowed = (params: {
senderUsername?: string;
}) => {
const { allow, senderId, senderUsername } = params;
if (!allow.hasEntries) return true;
if (allow.hasWildcard) return true;
if (senderId && allow.entries.includes(senderId)) return true;
if (!allow.hasEntries) {
return true;
}
if (allow.hasWildcard) {
return true;
}
if (senderId && allow.entries.includes(senderId)) {
return true;
}
const username = senderUsername?.toLowerCase();
if (!username) return false;
if (!username) {
return false;
}
return allow.entriesLower.some((entry) => entry === username || entry === `@${username}`);
};
@@ -64,12 +74,16 @@ export const resolveSenderAllowMatch = (params: {
if (allow.hasWildcard) {
return { allowed: true, matchKey: "*", matchSource: "wildcard" };
}
if (!allow.hasEntries) return { allowed: false };
if (!allow.hasEntries) {
return { allowed: false };
}
if (senderId && allow.entries.includes(senderId)) {
return { allowed: true, matchKey: senderId, matchSource: "id" };
}
const username = senderUsername?.toLowerCase();
if (!username) return { allowed: false };
if (!username) {
return { allowed: false };
}
const entry = allow.entriesLower.find(
(candidate) => candidate === username || candidate === `@${username}`,
);