Skip to content

🧹 fix: remove any and eslint-disable in LayoutEditor.test.tsx#290

Closed
is0692vs wants to merge 2 commits into
mainfrom
fix-layout-editor-test-types-17370837818716439583
Closed

🧹 fix: remove any and eslint-disable in LayoutEditor.test.tsx#290
is0692vs wants to merge 2 commits into
mainfrom
fix-layout-editor-test-types-17370837818716439583

Conversation

@is0692vs
Copy link
Copy Markdown
Contributor

@is0692vs is0692vs commented May 22, 2026

🎯 What: Removed instances of (window as any) casting and their corresponding // eslint-disable-next-line @typescript-eslint/no-explicit-any suppressions in src/components/__tests__/LayoutEditor.test.tsx. A new interface DndWindowMock was created to model the global test variables triggerDragEnd and mockIsOverId injected for testing @dnd-kit/core interactions.

💡 Why: Relying on any bypasses TypeScript's type checking, reducing code safety and readability. Defining a custom interface explicitly documents what properties are being mocked on the global window object during tests, improving maintainability and avoiding linter suppressions.

Verification:

  • Ran npm run test confirming that LayoutEditor.test.tsx and all other tests pass successfully.
  • Ran npm run lint confirming there are no remaining @typescript-eslint/no-explicit-any errors in the test file.

Result: Cleaned up test mocks, strictly typing global dependencies and reducing tech debt in the test suite without altering component behavior.


PR created automatically by Jules for task 17370837818716439583 started by @is0692vs

Greptile Summary

テストファイル内の (window as any) キャストと対応する eslint-disable コメントをすべて削除し、@dnd-kit/core テスト用のグローバルモック変数を型付けする DndWindowMock インターフェースを導入したリファクタリングです。コンポーネントの動作変更はありません。

  • DndWindowMock extends Window インターフェースを追加し、triggerDragEndmockIsOverId を明示的に型付け。
  • 全 10 箇所の (window as any)(window as unknown as DndWindowMock) に置き換え、9 個の eslint-disable コメントを削除。

Confidence Score: 4/5

テストファイルのみを変更するリファクタリングであり、プロダクションコードへの影響はありません。

DndWindowMock の省略可能フィールドを null チェックなしで呼び出している箇所が複数あり、strict: true 設定下の TypeScript コンパイラでは型エラーとして検出されます。Vitest は型チェックをスキップするためテスト自体は通りますが、tsc --noEmit を CI で実行している場合や IDE の型チェックで問題が顕在化する可能性があります。

src/components/tests/LayoutEditor.test.tsx — triggerDragEnd の省略可能型と呼び出し箇所の整合性を確認してください。

Important Files Changed

Filename Overview
src/components/tests/LayoutEditor.test.tsx (window as any) と eslint-disable コメントをすべて DndWindowMock インターフェース経由のキャストに置き換え。省略可能フィールド(?)を null チェックなしで呼び出す箇所があり、strict モードでは型エラーになる可能性あり。

Sequence Diagram

sequenceDiagram
    participant Test as テストケース
    participant Window as window (DndWindowMock)
    participant DndCtx as DndContext (モック)
    participant LayoutEditor as LayoutEditor

    Test->>LayoutEditor: render()
    Test->>DndCtx: fireEvent.click(dnd-context)
    DndCtx->>Window: "triggerDragEnd = onDragEnd"
    Test->>Window: "triggerDragEnd({active, over})"
    Window->>LayoutEditor: "onDragEnd({active, over})"
    LayoutEditor->>Test: mockOnLayoutChange が呼ばれる
Loading
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
src/components/__tests__/LayoutEditor.test.tsx:9-10
`triggerDragEnd``undefined` のまま呼び出される可能性がある

`DndWindowMock``triggerDragEnd``mockIsOverId` は省略可能(`?`)な型として定義されているため、TypeScript の型は `((event: unknown) => void) | undefined` になります。`tsconfig.json``"strict": true``strictNullChecks` 含む)が有効になっているため、`const triggerDragEnd = (window as unknown as DndWindowMock).triggerDragEnd` の後に null チェックなしで `triggerDragEnd({...})` を呼び出すコードは、TypeScript コンパイラ(`tsc --noEmit`)では型エラーになります。Vitest は esbuild でトランスパイルするため型チェックをスキップしてテスト自体は通りますが、エディタや CI の型チェックステップでは問題が検出されます。`?` を外して `| undefined` を明示するか、呼び出し箇所に非 null アサーション演算子(`!`)を追加することで解消できます。

Reviews (1): Last reviewed commit: "🧹 fix: remove any and eslint-disable in..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

This commit improves the code health of the test file by defining a strong type 'DndWindowMock' for the global 'window' variables used to mock '@dnd-kit/core' dragging interactions. This removes all instances of '(window as any)' casting and the corresponding 'eslint-disable-next-line @typescript-eslint/no-explicit-any' lines, improving type safety.

Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
github-user-summary Ignored Ignored May 22, 2026 7:13am

@qodo-code-review
Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

Warning

Rate limit exceeded

@is0692vs has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 42 minutes and 13 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ba220479-1925-4952-8649-caaadfe9a251

📥 Commits

Reviewing files that changed from the base of the PR and between 4020bb3 and 5158e4a.

📒 Files selected for processing (1)
  • src/components/__tests__/LayoutEditor.test.tsx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-layout-editor-test-types-17370837818716439583

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment on lines +9 to +10
triggerDragEnd?: (event: unknown) => void;
mockIsOverId?: string;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 triggerDragEndundefined のまま呼び出される可能性がある

DndWindowMocktriggerDragEndmockIsOverId は省略可能(?)な型として定義されているため、TypeScript の型は ((event: unknown) => void) | undefined になります。tsconfig.json"strict": truestrictNullChecks 含む)が有効になっているため、const triggerDragEnd = (window as unknown as DndWindowMock).triggerDragEnd の後に null チェックなしで triggerDragEnd({...}) を呼び出すコードは、TypeScript コンパイラ(tsc --noEmit)では型エラーになります。Vitest は esbuild でトランスパイルするため型チェックをスキップしてテスト自体は通りますが、エディタや CI の型チェックステップでは問題が検出されます。? を外して | undefined を明示するか、呼び出し箇所に非 null アサーション演算子(!)を追加することで解消できます。

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/components/__tests__/LayoutEditor.test.tsx
Line: 9-10

Comment:
`triggerDragEnd``undefined` のまま呼び出される可能性がある

`DndWindowMock``triggerDragEnd``mockIsOverId` は省略可能(`?`)な型として定義されているため、TypeScript の型は `((event: unknown) => void) | undefined` になります。`tsconfig.json``"strict": true``strictNullChecks` 含む)が有効になっているため、`const triggerDragEnd = (window as unknown as DndWindowMock).triggerDragEnd` の後に null チェックなしで `triggerDragEnd({...})` を呼び出すコードは、TypeScript コンパイラ(`tsc --noEmit`)では型エラーになります。Vitest は esbuild でトランスパイルするため型チェックをスキップしてテスト自体は通りますが、エディタや CI の型チェックステップでは問題が検出されます。`?` を外して `| undefined` を明示するか、呼び出し箇所に非 null アサーション演算子(`!`)を追加することで解消できます。

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Copy Markdown

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

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 improves type safety in the LayoutEditor.test.tsx file by introducing a DndWindowMock interface to handle window-level mock variables used for drag-and-drop testing. It replaces various any casts and removes corresponding ESLint disable comments, leading to cleaner and more maintainable test code. I have no feedback to provide.

This commit improves the code health of the test file by defining a strong type 'DndWindowMock' for the global 'window' variables used to mock '@dnd-kit/core' dragging interactions. This removes all instances of '(window as any)' casting and the corresponding 'eslint-disable-next-line @typescript-eslint/no-explicit-any' lines, improving type safety. It also fixes TypeScript errors caused by possibly undefined mock functions.

Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
@is0692vs
Copy link
Copy Markdown
Contributor Author

Superseded by #299, which keeps the same LayoutEditor test cleanup scope with passing checks and no active review threads. Closing this duplicate to keep the open PR queue actionable.

@is0692vs is0692vs closed this May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant