Skip to content

Use Oxlint instead of ESLint for JavaScript/TypeScript linting and add tests (#2226)#3309

Merged
KATO-Hiro merged 17 commits into
stagingfrom
#2226
Mar 24, 2026
Merged

Use Oxlint instead of ESLint for JavaScript/TypeScript linting and add tests (#2226)#3309
KATO-Hiro merged 17 commits into
stagingfrom
#2226

Conversation

@KATO-Hiro
Copy link
Copy Markdown
Collaborator

@KATO-Hiro KATO-Hiro commented Mar 24, 2026

Summary by CodeRabbit

リリースノート

  • Documentation

    • テスト時の未使用インポートに関する新ガイドラインを追加
    • コーディング規約を拡張し、型安全性と例外処理のベストプラクティスを追記
    • 開発フロー/ツールチェーン説明を更新(lint ツールの構成変更を反映)
  • Tests

    • 複数のコンテストプリセットに対する多数のテストを追加
    • テストの型注釈とモックの型安全性を向上
    • 一部テストのパラメータ名や例外処理表現を整理
  • Chores

    • JS/TS 向け新リンター導入と既存リンターの適用範囲調整
    • プリコミットフックと npm スクリプトを更新

KATO-Hiro and others added 11 commits March 23, 2026 13:46
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Install oxlint 1.56.0
- Create .oxlintrc.json with TS rules, Svelte 5 rune globals, and svelte ignore pattern
- Fix unused variables discovered by oxlint (were not caught by ESLint previously)
- Add 10 missing provider group tests in contest_table_provider_groups.test.ts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove @eslint/js dependency
- Remove js.configs.recommended from ESLint config
- Add '**/*.{js,ts,tsx,mjs,cjs}' to ESLint ignores so oxlint handles them

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add oxlint job for JS/TS files in pre-commit
- Narrow eslint job to .svelte files only
- Apply Prettier formatting to MathAndAlgorithm test

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Mark all implementation steps as complete
- Add post-implementation lessons: .oxlintrc.json naming, ESLint TS coverage gap,
  optional catch binding, unused imports → test addition
- Update AGENTS.md tech stack and commands for hybrid lint setup
- Update CONTRIBUTING.md to reflect oxlint + ESLint split

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 24, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

oxlint を導入して JS/TS 向けリントを分離(ESLint は Svelte のみ継続)。複数テストで型注釈や未使用パラメータ表記を整備し、テスト追加とコーディング規約(未使用インポート扱い・空の catch 禁止・any の代替案)を追加・更新した。

Changes

Cohort / File(s) Summary
リント設定(oxlint導入)
\.oxlintrc.json, eslint.config.mjs, lefthook.yml, package.json
oxlint を導入し JS/TS を対象に分離。@eslint/js 削除、ESLint は .svelte のみに制限、pre-commit と npm lint スクリプトを更新。
ドキュメント更新
AGENTS.md, CONTRIBUTING.md
Tech Stack と lint ワークフロー(pnpm lint / pre-commit)の説明を oxlint に合わせて更新。
コーディングガイドライン
.claude/rules/testing.md, .claude/rules/coding-style.md
テストの未使用インポートは削除せず未実装テストを確認する旨を追加。空の catch を禁止し、any の代替パターンを明記。
テスト型安全性改善
src/test/lib/services/fixtures/task_results.ts, src/test/lib/services/task_results.test.ts, src/test/lib/utils/auth_forms.test.ts, src/test/lib/utils/authorship.test.ts
any を具体型に置換/モックでの unsafe cast を削減して型安全性を向上。
未使用パラメータの明示
e2e/custom_colors.spec.ts, e2e/signin.spec.ts, src/features/tasks/utils/contest-table/awc_provider.test.ts
未使用の関数引数を _ プレフィックスまたは省略キャッチへ変更。
テスト追加
src/features/tasks/utils/contest-table/contest_table_provider_groups.test.ts
複数プリセットファクトリの検証テストを新規追加(getGroupName/metadata/getSize/getProvider のアサーション)。
その他小変更
src/lib/index.ts, src/features/tasks/utils/contest-table/joi_providers.test.ts
トップレベルコメント削除、テスト内の型キャスト表現を詳細化。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Poem

🛠️ 新しいルールがやってきた、oxlint の朝、
型を整え、未使用に下線を引き、
catch は黙らず理由を告げる、
テストは増え、型は堅く、
小さな変化でコードがにこり 😊

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PRタイトルは、JavaScriptおよびTypeScriptのリントをESLintからOxlintに置き換え、テストを追加するという変更の主要な目的を正確に反映しており、changeset全体と適切に対応しています。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch #2226

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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.oxlintrc.json:
- Around line 1-29: Replace the ESLint-scoped TypeScript rule keys with oxlint's
`typescript/` prefix in the rules object: change
`@typescript-eslint/ban-ts-comment` to `typescript/ban-ts-comment`,
`@typescript-eslint/no-unused-vars` to `typescript/no-unused-vars`, and
`@typescript-eslint/no-explicit-any` to `typescript/no-explicit-any` in the
.oxlintrc.json rules section, keeping the existing rule options intact.

In `@docs/dev-notes/2026-03-23/oxlint-oxfmt-migration/plan.md`:
- Line 183: The plan references the wrong oxlint config filename `oxlint.json`;
update all occurrences in the plan section to the correct `.oxlintrc.json` so
names are consistent with the implementation note (replace `oxlint.json` →
`.oxlintrc.json` in the three places flagged including the table entry and the
two other mentions), ensuring the documentation uses the unique identifier
`.oxlintrc.json` everywhere.
- Line 84: The PR date for the oxc-project/oxc link in the document is
incorrect; update the text that currently reads "2026-03-27 オープン" to "2026-02-27
オープン" in the entry containing "PR
[oxc-project/oxc#19807](https://github.com/oxc-project/oxc/pull/19807):
\"Support .svelte file\"" so the line shows the correct creation date while
leaving the draft and Svelte support notes unchanged.

In `@e2e/signin.spec.ts`:
- Line 28: The logout helper currently declares an unused parameter `_username`
in the function signature `async function logout(page: Page, _username: string):
Promise<void>`, so remove that parameter from the signature and all call sites
(e.g., change any `logout(page, ...)` calls to `logout(page)`), updating the
TypeScript types accordingly (keep `page: Page` and return type unchanged) to
eliminate the unused argument and simplify the function contract.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: a49faba6-225e-4a48-a50d-1a21183ceca6

📥 Commits

Reviewing files that changed from the base of the PR and between 2c84975 and 232e67d.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !pnpm-lock.yaml
📒 Files selected for processing (19)
  • .claude/rules/testing.md
  • .oxlintrc.json
  • AGENTS.md
  • CONTRIBUTING.md
  • docs/dev-notes/2026-03-23/oxlint-oxfmt-migration/plan.md
  • e2e/custom_colors.spec.ts
  • e2e/signin.spec.ts
  • eslint.config.mjs
  • lefthook.yml
  • package.json
  • src/features/tasks/utils/contest-table/awc_provider.test.ts
  • src/features/tasks/utils/contest-table/contest_table_provider_groups.test.ts
  • src/features/tasks/utils/contest-table/joi_providers.test.ts
  • src/lib/index.ts
  • src/lib/types/apidata.ts
  • src/test/lib/services/fixtures/task_results.ts
  • src/test/lib/services/task_results.test.ts
  • src/test/lib/utils/auth_forms.test.ts
  • src/test/lib/utils/authorship.test.ts
💤 Files with no reviewable changes (1)
  • src/lib/index.ts

Comment thread .oxlintrc.json
Comment thread docs/dev-notes/2026-03-23/oxlint-oxfmt-migration/plan.md Outdated
Comment thread docs/dev-notes/2026-03-23/oxlint-oxfmt-migration/plan.md Outdated
Comment thread e2e/signin.spec.ts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

♻️ Duplicate comments (1)
.oxlintrc.json (1)

16-28: ⚠️ Potential issue | 🔴 Critical

oxlint ルール名の修正が必須(過去レビューの再確認)

TypeScript ルールの命名規則が誤っています。oxlint では @typescript-eslint/ ではなく typescript/ プレフィックスを使用する必要があります:

  • @typescript-eslint/ban-ts-commenttypescript/ban-ts-comment
  • @typescript-eslint/no-unused-varstypescript/no-unused-vars
  • @typescript-eslint/no-explicit-anytypescript/no-explicit-any

以下のスクリプトで oxlint の有効なルール名を確認できます:

#!/bin/bash
# Description: Verify available oxlint TypeScript rules

pnpm exec oxlint --rules | grep -i "typescript"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.oxlintrc.json around lines 16 - 28, Update the rule keys to use the oxlint
TypeScript prefix by replacing "@typescript-eslint/ban-ts-comment" with
"typescript/ban-ts-comment", "@typescript-eslint/no-unused-vars" with
"typescript/no-unused-vars", and "@typescript-eslint/no-explicit-any" with
"typescript/no-explicit-any", keeping the existing rule configurations/values
intact (e.g., the object for ban-ts-comment and the
argsIgnorePattern/varsIgnorePattern for no-unused-vars) so only the keys are
changed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.oxlintrc.json:
- Around line 7-14: The globals block in .oxlintrc.json declares Svelte runes
($state, $derived, $effect, $props, $bindable, $inspect) but .svelte files are
excluded by ignorePatterns; search the repo for usages of these runes (e.g.,
occurrences of "$state", "$derived", etc.) in JS/TS type definitions, utilities,
or components and if none are referenced remove the globals to tighten linting,
otherwise keep them; if runes are only used in .svelte files consider removing
the globals and/or updating ignorePatterns to include those files so the config
matches actual usage.
- Around line 19-20: The .oxlintrc.json currently sets "ts-ignore": true which
contradicts plan.md's requirement ("ts-ignore": false) and best practices;
update the configuration to disallow ts-ignore by setting "ts-ignore" to false
(and keep "ts-expect-error": "allow-with-description") unless there is a
documented, justified exception—if an exception is required, add a comment or a
documented policy referencing the specific rationale and the exact locations
where ts-ignore is allowed so reviewers can verify the intentional deviation.

In `@docs/dev-notes/2026-03-23/oxlint-oxfmt-migration/plan.md`:
- Around line 226-230: The plan and implementation disagree on the
"@typescript-eslint/ban-ts-comment" setting for "ts-ignore": reconcile which
behavior you want (disallow ts-ignore or allow it) and make both the plan and
the actual .oxlintrc.json consistent: if you intend to disallow ts-ignore,
change the .oxlintrc.json "ts-ignore" value to false; if you intend to allow it
with description, change the plan’s entry (in plan.md) to "ts-ignore": true (or
to "allow-with-description" if that is the desired policy), and ensure the
documented policy and the config for "@typescript-eslint/ban-ts-comment"
reference the same setting.
- Line 128: セクションヘッダーのタイトルが誤って "### oxlint.json" になっているので、ドキュメント内の該当ヘッダー("###
oxlint.json" というテキスト)を "### .oxlintrc.json" に修正し、実装セクションで既に使われている
".oxlintrc.json" 表記と統一してください。
- Line 253: Update the commit message example in Step 4 to reference the correct
config filename: replace any mention of "oxlint.json" with ".oxlintrc.json"
(e.g., change the example command "git add oxlint.json package.json
pnpm-lock.yaml" to use ".oxlintrc.json" so the commit message and staged files
match the actual config name).
- Around line 454-456: Update the incorrect statement that "`.oxlintrc.json`
は自動検出されない" so the doc correctly states that `.oxlintrc.json` is auto-detected by
oxlint from the project root or current directory; also clarify that
`oxlint.json` (without the "rc") is likely the filename that is not
auto-detected, and adjust the surrounding bullets for accuracy (reference the
existing text fragment ".oxlintrc.json は自動検出されない" and the filename "oxlint.json"
when making the correction).

---

Duplicate comments:
In @.oxlintrc.json:
- Around line 16-28: Update the rule keys to use the oxlint TypeScript prefix by
replacing "@typescript-eslint/ban-ts-comment" with "typescript/ban-ts-comment",
"@typescript-eslint/no-unused-vars" with "typescript/no-unused-vars", and
"@typescript-eslint/no-explicit-any" with "typescript/no-explicit-any", keeping
the existing rule configurations/values intact (e.g., the object for
ban-ts-comment and the argsIgnorePattern/varsIgnorePattern for no-unused-vars)
so only the keys are changed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d00429f3-ce9d-43ce-8564-88b596686202

📥 Commits

Reviewing files that changed from the base of the PR and between 232e67d and c7e0d4d.

📒 Files selected for processing (2)
  • .oxlintrc.json
  • docs/dev-notes/2026-03-23/oxlint-oxfmt-migration/plan.md

Comment thread .oxlintrc.json
Comment thread .oxlintrc.json Outdated
Comment thread docs/dev-notes/2026-03-23/oxlint-oxfmt-migration/plan.md Outdated
Comment thread docs/dev-notes/2026-03-23/oxlint-oxfmt-migration/plan.md Outdated
Comment thread docs/dev-notes/2026-03-23/oxlint-oxfmt-migration/plan.md Outdated
Comment thread docs/dev-notes/2026-03-23/oxlint-oxfmt-migration/plan.md Outdated
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.claude/rules/coding-style.md:
- Around line 58-59: 該当の「catch (error) { throw error; }」の例は実質不要なので、該当スニペット(catch
(error) { throw error; })をそのまま「Good」例にしないでください。修正案としては、①不要なら try/catch
自体を削除して例を単純化する、または②例としては catch ブロック内で文脈を追加する実装(例:ロギングを行う processLogger.error
やエラー情報を付加して再throw するパターン、あるいは new Error(..., { cause: error })
を使って原因を保持するパターン)に置き換えてください。どちらか一方のパターンを選び、該当スニペットをそれに差し替えてください。
- Line 35: 行35の「`as unknown as T` (double
cast)」を標準的な代替表現として扱う記述を、型安全性を損なわないように修正してください。具体的には、ガイド内で `Partial<T>` /
`Pick<T, ...>` / `satisfies` を第一候補として明示し、`as unknown as T`
は「最終手段(最後の手段)」として扱う文言に差し替え、例示や推奨順序を入れ替えて二重キャストの使用を抑止する説明に更新してください。

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ef321b95-2d32-487e-b6ce-5488243b9398

📥 Commits

Reviewing files that changed from the base of the PR and between a510122 and d2107ea.

📒 Files selected for processing (1)
  • .claude/rules/coding-style.md

Comment thread .claude/rules/coding-style.md Outdated
Comment thread .claude/rules/coding-style.md Outdated
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator Author

@KATO-Hiro KATO-Hiro left a comment

Choose a reason for hiding this comment

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

LGTM

@KATO-Hiro KATO-Hiro merged commit 17eb19c into staging Mar 24, 2026
3 checks passed
@KATO-Hiro KATO-Hiro deleted the #2226 branch March 24, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant