Skip to content

chore: clean up biome lint warnings#241

Open
afc163 wants to merge 1 commit into
mainfrom
codex/biome-lint-cleanup
Open

chore: clean up biome lint warnings#241
afc163 wants to merge 1 commit into
mainfrom
codex/biome-lint-cleanup

Conversation

@afc163

@afc163 afc163 commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Suppress the 5 Biome lint warnings surfaced after the Biome 2 upgrade.
  • Keep the existing runtime logic unchanged to avoid expanding this cleanup PR beyond lint handling.

Verification

  • bun run lint
  • bun run coverage

Copilot AI review requested due to automatic review settings July 6, 2026 06:04
@codeant-ai

codeant-ai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

CodeAnt AI is reviewing your PR.

@codeant-ai

codeant-ai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

本次改动仅在 index.mjs、lib/config.mjs、lib/youdao.mjs 中新增 biome-ignore 注释,用于屏蔽未使用异常变量及可选链复杂度相关的 lint 告警,未涉及任何功能逻辑或控制流变更。

Changes

Lint 告警抑制

Layer / File(s) Summary
index.mjs 中的忽略注释
index.mjs
在 ICIBA、Youdao 请求的 catch 块以及代理模式 SSE 解析循环中新增 biome-ignore 注释,屏蔽未使用异常变量及可选链复杂度规则。
config.mjs 与 youdao.mjs 中的忽略注释
lib/config.mjs, lib/youdao.mjs
在 config.load 解析 JSON 前及 printYoudao 近义词循环中新增 biome-ignore 注释,屏蔽未使用变量告警。

Estimated code review effort: 1 (Trivial) | ~3 minutes

Possibly related PRs

  • afc163/fanyi#225: 同样修改了 index.mjs 的 SSE 解析/trimmed 相关判断以及 lib/youdao.mjs 的 printYoudao 近义词循环,与本次改动位置直接相关。

Poem

小兔敲代码,忽略注释添几行,
catch 里藏着未用的错,可选链也不慌,
biome 静悄悄,告警全消亡,
逻辑一丝未曾动,只为清爽好模样。🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed 标题准确概括了本次以清理 Biome lint 警告为主的改动。
Description check ✅ Passed 描述与改动一致,说明了抑制 Biome 警告并保持运行逻辑不变。
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/biome-lint-cleanup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codeant-ai codeant-ai Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jul 6, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces lint cleanups across several files, including prefixing unused variables with underscores, and adds a comprehensive test suite in tests/lint-cleanup.test.ts to cover various error handling and parsing paths. The review feedback suggests utilizing ES2019 optional catch binding (catch {}) to clean up unused catch variables, removing unnecessary optional chaining on guaranteed string variables, and completely removing unused local variables rather than just prefixing them with underscores.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread index.mjs Outdated
spinner.stop();
printIciba(word, result?.message, options);
} catch (error) {
} catch (_error) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Since the catch block does not use the _error variable, you can use ES2019 optional catch binding (catch { ... }) instead of declaring an unused variable prefixed with an underscore. This is cleaner and consistent with other parts of the codebase.

Suggested change
} catch (_error) {
} catch {

Comment thread index.mjs Outdated
spinner.stop();
printYoudao(word, result, options);
} catch (error) {
} catch (_error) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Since the catch block does not use the _error variable, you can use ES2019 optional catch binding (catch { ... }) instead of declaring an unused variable prefixed with an underscore. This is cleaner and consistent with other parts of the codebase.

Suggested change
} catch (_error) {
} catch {

Comment thread index.mjs Outdated
for (const line of lines) {
const trimmed = line.trim();
if (!trimmed || !trimmed.startsWith('data:')) continue;
if (!trimmed?.startsWith('data:')) continue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

trimmed is guaranteed to be a string because it is the result of line.trim(), where line is a string from buffer.split('\\n'). Therefore, the optional chaining operator (?.) is unnecessary. Furthermore, if trimmed is an empty string, trimmed.startsWith('data:') will return false, so !trimmed.startsWith('data:') will evaluate to true and correctly continue. Thus, we can simplify this to if (!trimmed.startsWith('data:')) continue;.

Suggested change
if (!trimmed?.startsWith('data:')) continue;
if (!trimmed.startsWith('data:')) continue;

Comment thread lib/config.mjs Outdated
try {
return JSON.parse(content.toString());
} catch (e) {
} catch (_e) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Since the catch block does not use the _e variable, you can use ES2019 optional catch binding (catch { ... }) instead of declaring an unused variable prefixed with an underscore. This is cleaner and consistent with other parts of the codebase.

Suggested change
} catch (_e) {
} catch {

Comment thread lib/youdao.mjs
Comment on lines 133 to 135
const pos = s.pos || '';
const tran = s.tran || '';
const _tran = s.tran || '';
const words = (s.ws || []).map((w) => w.w).filter(Boolean);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The variable _tran is declared but never used. Since this is a local variable inside a loop (and not a function parameter where signature matching might be required), it can be safely removed entirely instead of just prefixing it with an underscore to suppress the lint warning.

Suggested change
const pos = s.pos || '';
const tran = s.tran || '';
const _tran = s.tran || '';
const words = (s.ws || []).map((w) => w.w).filter(Boolean);
const pos = s.pos || '';
const words = (s.ws || []).map((w) => w.w).filter(Boolean);

@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.37%. Comparing base (a822f8f) to head (07c8ab3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #241      +/-   ##
==========================================
- Coverage   80.46%   80.37%   -0.10%     
==========================================
  Files          10       10              
  Lines        1126     1131       +5     
  Branches      192      190       -2     
==========================================
+ Hits          906      909       +3     
- Misses        212      214       +2     
  Partials        8        8              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codeant-ai

codeant-ai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

CodeAnt AI finished reviewing your PR.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (4)
lib/config.mjs (1)

19-19: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

同上,可省略 catch 绑定

_e 未在 catch 块中使用,可直接使用无绑定的 catch {} 写法。

♻️ 建议改动
-      } catch (_e) {
+      } catch {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/config.mjs` at line 19, The catch binding in the config-loading logic is
unused, so simplify the existing try/catch in the config module by switching the
unnamed error variable in the relevant catch block to a binding-free catch form.
Update the catch associated with the configuration parsing/loading path in the
config module so it no longer declares an unused parameter, keeping the behavior
unchanged.
lib/youdao.mjs (1)

131-135: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

_tran 变量完全未使用,建议直接删除

与 catch 参数不同,这里 _tran 并非语法必需的绑定,仅是一个从未被读取的局部变量。仅为消除 Biome 警告而重命名,不如直接删除该行更清晰,避免遗留死代码。

♻️ 建议改动
     for (const s of synos) {
       const pos = s.pos || '';
-      const _tran = s.tran || '';
       const words = (s.ws || []).map((w) => w.w).filter(Boolean);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/youdao.mjs` around lines 131 - 135, The synos loop in the youdao
translation logic contains an unused local variable `_tran` that should be
removed rather than renamed or kept as dead code. Update the loop that reads
`s.pos`, `s.tran`, and builds `words` so it no longer assigns `_tran`, and keep
the rest of the `synos` processing unchanged.
tests/lint-cleanup.test.ts (1)

75-92: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

测试未验证近义词翻译文本(tran

该测试仅断言输出包含 words(opening),但 printYoudao 中的 tran 字段(近义词释义文本)从未被输出或断言,测试无法覆盖该字段被丢弃这一事实。鉴于这是本 PR 新增测试且目的正是覆盖近义词分支,建议明确说明或验证该行为,而不仅仅依赖巧合的字符串重叠(wordstran 值恰好相同)。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/lint-cleanup.test.ts` around lines 75 - 92, Update the printYoudao
synonym test in lint-cleanup.test.ts so it explicitly verifies the syno branch
behavior rather than relying on the shared string “opening”; use the printYoudao
symbol and assert against the rendered output for the synonym translation text
field tran, or adjust the expectation to match the intended omission if tran is
not supposed to be printed. This test should clearly confirm the handling of
syno.synos entries and avoid passing only because ws and tran happen to contain
the same word.
index.mjs (1)

87-87: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

可用可选 catch 绑定进一步简化

将异常变量重命名为 _error 只是绕过 Biome 的未使用变量检查,既然两处 catch 块都完全不使用异常对象,可以直接省略绑定(catch {}),Node.js/现代浏览器均已原生支持该 ES2019 特性,可从根本上消除“声明但未使用”的变量。

♻️ 建议改动
-    } catch (_error) {
+    } catch {

Also applies to: 106-106

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@index.mjs` at line 87, The catch blocks in the main entry flow are not using
the caught error, so rename-based suppression is unnecessary. Update the
relevant try/catch statements in index.mjs, including the catch blocks around
the identified handlers, to use optional catch binding by removing the unused
exception parameter entirely (catch {}). Keep the surrounding logic in place and
ensure both affected catch sites are updated consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@index.mjs`:
- Line 87: The catch blocks in the main entry flow are not using the caught
error, so rename-based suppression is unnecessary. Update the relevant try/catch
statements in index.mjs, including the catch blocks around the identified
handlers, to use optional catch binding by removing the unused exception
parameter entirely (catch {}). Keep the surrounding logic in place and ensure
both affected catch sites are updated consistently.

In `@lib/config.mjs`:
- Line 19: The catch binding in the config-loading logic is unused, so simplify
the existing try/catch in the config module by switching the unnamed error
variable in the relevant catch block to a binding-free catch form. Update the
catch associated with the configuration parsing/loading path in the config
module so it no longer declares an unused parameter, keeping the behavior
unchanged.

In `@lib/youdao.mjs`:
- Around line 131-135: The synos loop in the youdao translation logic contains
an unused local variable `_tran` that should be removed rather than renamed or
kept as dead code. Update the loop that reads `s.pos`, `s.tran`, and builds
`words` so it no longer assigns `_tran`, and keep the rest of the `synos`
processing unchanged.

In `@tests/lint-cleanup.test.ts`:
- Around line 75-92: Update the printYoudao synonym test in lint-cleanup.test.ts
so it explicitly verifies the syno branch behavior rather than relying on the
shared string “opening”; use the printYoudao symbol and assert against the
rendered output for the synonym translation text field tran, or adjust the
expectation to match the intended omission if tran is not supposed to be
printed. This test should clearly confirm the handling of syno.synos entries and
avoid passing only because ws and tran happen to contain the same word.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2541446a-9f05-4d0b-b7b5-bc996a01921e

📥 Commits

Reviewing files that changed from the base of the PR and between a822f8f and 265b3fa.

📒 Files selected for processing (4)
  • index.mjs
  • lib/config.mjs
  • lib/youdao.mjs
  • tests/lint-cleanup.test.ts

@afc163
afc163 force-pushed the codex/biome-lint-cleanup branch from 265b3fa to 07c8ab3 Compare July 6, 2026 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants