Skip to content
17 changes: 12 additions & 5 deletions src/lib/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,12 +630,19 @@ export async function fetchActivity(
const pages = [1, 2, 3];
const allEvents: GitHubEvent[] = [];

for (const page of pages) {
const promises = pages.map((page) =>
restGet<GitHubEvent[]>(
`/users/${encodeURIComponent(username)}/events/public?per_page=100&page=${page}`,
token
)
);

// Suppress unhandled promise rejections for subsequent pages if we break early or throw
promises.forEach((p) => p.catch((e) => console.error("Suppressed event fetch error:", e)));
Comment on lines +640 to +641
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

forEach コールバックから値を返しているため、リンターエラーが発生しています。

p.catch() は Promise を返しますが、forEach はコールバックの戻り値を無視します。Biome がこれを疑わしいパターンとしてフラグしています。void 演算子を使用して意図を明確にするか、for-of ループに変更することで解決できます。

♻️ 修正案

オプション 1: void 演算子を使用

-  promises.forEach((p) => p.catch((e) => console.error("Suppressed event fetch error:", e)));
+  promises.forEach((p) => void p.catch((e) => console.error("Suppressed event fetch error:", e)));

オプション 2: for-of ループを使用

-  promises.forEach((p) => p.catch((e) => console.error("Suppressed event fetch error:", e)));
+  for (const p of promises) {
+    p.catch((e) => console.error("Suppressed event fetch error:", e));
+  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Suppress unhandled promise rejections for subsequent pages if we break early or throw
promises.forEach((p) => p.catch((e) => console.error("Suppressed event fetch error:", e)));
// Suppress unhandled promise rejections for subsequent pages if we break early or throw
promises.forEach((p) => void p.catch((e) => console.error("Suppressed event fetch error:", e)));
🧰 Tools
🪛 Biome (2.4.6)

[error] 641-641: This callback passed to forEach() iterable method should not return a value.

(lint/suspicious/useIterableCallbackReturn)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lib/github.ts` around lines 640 - 641, The linter flags the
promises.forEach callback because p.catch(...) returns a Promise which forEach
ignores; fix by explicitly signaling intent or iterating properly: either prefix
the callback call with the void operator (change the callback passed to
promises.forEach in the code that currently references promises.forEach((p) =>
p.catch(...)) to use void p.catch(...)) or replace the forEach with an explicit
for-of loop over the promises array and call p.catch(...) inside it; update the
occurrence that uses promises.forEach in this file (the suppressed event fetch
error line) accordingly.


for (const p of promises) {
try {
const events = await restGet<GitHubEvent[]>(
`/users/${encodeURIComponent(username)}/events/public?per_page=100&page=${page}`,
token
);
const events = await p;
allEvents.push(...events);
if (events.length < 100) break;
} catch (error) {
Expand Down
Loading