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,11 +17,17 @@ const EVENT_SCOPE_GUARDS: Record<string, string[]> = {
function hasEventScope(client: GatewayWsClient, event: string): boolean {
const required = EVENT_SCOPE_GUARDS[event];
if (!required) return true;
if (!required) {
return true;
}
const role = client.connect.role ?? "operator";
if (role !== "operator") return false;
if (role !== "operator") {
return false;
}
const scopes = Array.isArray(client.connect.scopes) ? client.connect.scopes : [];
if (scopes.includes(ADMIN_SCOPE)) return true;
if (scopes.includes(ADMIN_SCOPE)) {
return true;
}
return required.some((scope) => scopes.includes(scope));
}
@@ -56,9 +62,13 @@ export function createGatewayBroadcaster(params: { clients: Set<GatewayWsClient>
}
logWs("out", "event", logMeta);
for (const c of params.clients) {
if (!hasEventScope(c, event)) continue;
if (!hasEventScope(c, event)) {
continue;
}
const slow = c.socket.bufferedAmount > MAX_BUFFERED_BYTES;
if (slow && opts?.dropIfSlow) continue;
if (slow && opts?.dropIfSlow) {
continue;
}
if (slow) {
try {
c.socket.close(1008, "slow consumer");