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

@@ -21,7 +21,9 @@ export function registerSlackChannelEvents(params: { ctx: SlackMonitorContext })
"channel_created",
async ({ event, body }: SlackEventMiddlewareArgs<"channel_created">) => {
try {
if (ctx.shouldDropMismatchedSlackEvent(body)) return;
if (ctx.shouldDropMismatchedSlackEvent(body)) {
return;
}
const payload = event as SlackChannelCreatedEvent;
const channelId = payload.channel?.id;
@@ -54,7 +56,9 @@ export function registerSlackChannelEvents(params: { ctx: SlackMonitorContext })
"channel_rename",
async ({ event, body }: SlackEventMiddlewareArgs<"channel_rename">) => {
try {
if (ctx.shouldDropMismatchedSlackEvent(body)) return;
if (ctx.shouldDropMismatchedSlackEvent(body)) {
return;
}
const payload = event as SlackChannelRenamedEvent;
const channelId = payload.channel?.id;
@@ -87,12 +91,16 @@ export function registerSlackChannelEvents(params: { ctx: SlackMonitorContext })
"channel_id_changed",
async ({ event, body }: SlackEventMiddlewareArgs<"channel_id_changed">) => {
try {
if (ctx.shouldDropMismatchedSlackEvent(body)) return;
if (ctx.shouldDropMismatchedSlackEvent(body)) {
return;
}
const payload = event as SlackChannelIdChangedEvent;
const oldChannelId = payload.old_channel_id;
const newChannelId = payload.new_channel_id;
if (!oldChannelId || !newChannelId) return;
if (!oldChannelId || !newChannelId) {
return;
}
const channelInfo = await ctx.resolveChannelName(newChannelId);
const label = resolveSlackChannelLabel({

View File

@@ -14,7 +14,9 @@ export function registerSlackMemberEvents(params: { ctx: SlackMonitorContext })
"member_joined_channel",
async ({ event, body }: SlackEventMiddlewareArgs<"member_joined_channel">) => {
try {
if (ctx.shouldDropMismatchedSlackEvent(body)) return;
if (ctx.shouldDropMismatchedSlackEvent(body)) {
return;
}
const payload = event as SlackMemberChannelEvent;
const channelId = payload.channel;
const channelInfo = channelId ? await ctx.resolveChannelName(channelId) : {};
@@ -52,7 +54,9 @@ export function registerSlackMemberEvents(params: { ctx: SlackMonitorContext })
"member_left_channel",
async ({ event, body }: SlackEventMiddlewareArgs<"member_left_channel">) => {
try {
if (ctx.shouldDropMismatchedSlackEvent(body)) return;
if (ctx.shouldDropMismatchedSlackEvent(body)) {
return;
}
const payload = event as SlackMemberChannelEvent;
const channelId = payload.channel;
const channelInfo = channelId ? await ctx.resolveChannelName(channelId) : {};

View File

@@ -21,7 +21,9 @@ export function registerSlackMessageEvents(params: {
ctx.app.event("message", async ({ event, body }: SlackEventMiddlewareArgs<"message">) => {
try {
if (ctx.shouldDropMismatchedSlackEvent(body)) return;
if (ctx.shouldDropMismatchedSlackEvent(body)) {
return;
}
const message = event as SlackMessageEvent;
if (message.subtype === "message_changed") {
@@ -119,7 +121,9 @@ export function registerSlackMessageEvents(params: {
ctx.app.event("app_mention", async ({ event, body }: SlackEventMiddlewareArgs<"app_mention">) => {
try {
if (ctx.shouldDropMismatchedSlackEvent(body)) return;
if (ctx.shouldDropMismatchedSlackEvent(body)) {
return;
}
const mention = event as SlackAppMentionEvent;
await handleSlackMessage(mention as unknown as SlackMessageEvent, {

View File

@@ -12,7 +12,9 @@ export function registerSlackPinEvents(params: { ctx: SlackMonitorContext }) {
ctx.app.event("pin_added", async ({ event, body }: SlackEventMiddlewareArgs<"pin_added">) => {
try {
if (ctx.shouldDropMismatchedSlackEvent(body)) return;
if (ctx.shouldDropMismatchedSlackEvent(body)) {
return;
}
const payload = event as SlackPinEvent;
const channelId = payload.channel_id;
@@ -49,7 +51,9 @@ export function registerSlackPinEvents(params: { ctx: SlackMonitorContext }) {
ctx.app.event("pin_removed", async ({ event, body }: SlackEventMiddlewareArgs<"pin_removed">) => {
try {
if (ctx.shouldDropMismatchedSlackEvent(body)) return;
if (ctx.shouldDropMismatchedSlackEvent(body)) {
return;
}
const payload = event as SlackPinEvent;
const channelId = payload.channel_id;

View File

@@ -13,7 +13,9 @@ export function registerSlackReactionEvents(params: { ctx: SlackMonitorContext }
const handleReactionEvent = async (event: SlackReactionEvent, action: string) => {
try {
const item = event.item;
if (!item || item.type !== "message") return;
if (!item || item.type !== "message") {
return;
}
const channelInfo = item.channel ? await ctx.resolveChannelName(item.channel) : {};
const channelType = channelInfo?.type;
@@ -54,7 +56,9 @@ export function registerSlackReactionEvents(params: { ctx: SlackMonitorContext }
ctx.app.event(
"reaction_added",
async ({ event, body }: SlackEventMiddlewareArgs<"reaction_added">) => {
if (ctx.shouldDropMismatchedSlackEvent(body)) return;
if (ctx.shouldDropMismatchedSlackEvent(body)) {
return;
}
await handleReactionEvent(event as SlackReactionEvent, "added");
},
);
@@ -62,7 +66,9 @@ export function registerSlackReactionEvents(params: { ctx: SlackMonitorContext }
ctx.app.event(
"reaction_removed",
async ({ event, body }: SlackEventMiddlewareArgs<"reaction_removed">) => {
if (ctx.shouldDropMismatchedSlackEvent(body)) return;
if (ctx.shouldDropMismatchedSlackEvent(body)) {
return;
}
await handleReactionEvent(event as SlackReactionEvent, "removed");
},
);