Skip to content

Conversation

@li-jia-nan
Copy link
Member

@li-jia-nan li-jia-nan commented Nov 26, 2025

Summary by CodeRabbit

  • 重构
    • 包名与版本迁移为 @rc-component/virtual-list;内部依赖与实现已统一,外部 API 无变化。
  • 杂项
    • 更新依赖与测试相关引用,调整 .gitignore,恢复部分测试模拟目录的版本控制规则。
  • 文档
    • README 同步为新包名,更新安装/导入示例与演示链接,并做少量格式调整。

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Nov 26, 2025

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

Project Deployment Preview Comments Updated (UTC)
virtual-list Error Error Dec 1, 2025 2:53am

@coderabbitai
Copy link

coderabbitai bot commented Nov 26, 2025

Walkthrough

本次提交统一迁移依赖与导入:将 classnames 替换为 clsx,rc-util 与 rc-resize-observer 的内部路径迁移到 @rc-component/*,更新 package.json 与 .gitignore(添加 pnpm-lock.yaml 并取消忽略部分 tests mock 路径)。无运行时行为改动。

Changes

Cohort / File(s) 变更摘要
配置与元信息
\.gitignore, package.json
添加 pnpm-lock.yaml.gitignore;通过否定模式重新包含 tests/__mocks__/rc-util/libtests/__mocks__/@rc-component/util/libpackage.json 改名 rc-virtual-list@rc-component/virtual-list、版本更新并替换依赖(移除 classnamesrc-resize-observerrc-util,新增 clsx@rc-component/resize-observer@rc-component/util@types/node)。
类名工具替换(classnames → clsx)
examples/animate.tsx, src/Filler.tsx, src/List.tsx, src/ScrollBar.tsx
将 classnames 导入与调用替换为 clsx(部分以 { clsx } 形式);所有 className 组合点等价替换,伴随少量格式调整,行为不变。
工具导入迁移(rc-util → @rc-component/util
src/hooks/useFrameWheel.ts, src/hooks/useMobileTouchMove.ts, src/hooks/useScrollDrag.ts, src/hooks/useScrollTo.tsx, src/List.tsx, src/ScrollBar.tsx, examples/animate.tsx
将 raf、useLayoutEffect、useEvent、warning 等工具的导入路径由 rc-util 子路径迁移到 @rc-component/util 相应位置;仅导入源路径变化,无逻辑更改。
ResizeObserver 包迁移
src/Filler.tsx, tests/scroll.test.js, tests/scrollWidth.test.tsx
将 rc-resize-observer 的导入替换为 @rc-component/resize-observer(包括 utils 子路径)。
示例与文档更新
examples/animate.tsx, README.md
README 与示例中包名与导入路径由 rc-virtual-list/rc-... 更新为 @rc-component/virtual-list / @rc-component/*,并做了小幅格式化调整。
测试文件小改动
tests/scroll.test.js, tests/scrollWidth.test.tsx
更新测试中工具导入到 @rc-component/* 对应实现;在一个测试 helper 上添加了 TypeScript 参数注解(仅类型标注);少量格式/空白调整。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • 变更为跨多文件的一致性依赖与导入迁移,重复性高但涉及目录子路径需核对。
  • 重点检查:package.json 发布入口/exports、目标包中子路径是否存在且导出签名一致、被取消忽略的 tests mock 路径是否影响测试。

Poem

🐰 我在代码沟里轻轻跳,换了包名也换了帽,
clsx 闪亮代旧草,路径迁徙踏新刨,
锁文件入列排好号,测试假人回家笑,
兔子拍拍小尾巴,版本上线路不焦。

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR标题"refactor: drop rc-virtual-list and classnames"准确反映了主要变更内容:将包名从rc-virtual-list重构为@rc-component/virtual-list,同时用clsx替换classnames依赖。
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch clsx-update

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.

@gemini-code-assist
Copy link

Summary of Changes

Hello @li-jia-nan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on modernizing the project's dependency stack by migrating from classnames to clsx and from rc-util to @rc-component/util. This change involves a comprehensive update of import paths and class name concatenation logic throughout the codebase, ensuring consistency and leveraging more efficient utility packages. Supporting build configuration changes have also been made to accommodate these new dependencies.

Highlights

  • Dependency Migration: Replaced the classnames package with clsx and rc-util with @rc-component/util to streamline utility imports and potentially reduce bundle size.
  • Codebase Refactoring: Updated import statements and refactored class name generation logic across multiple components and hooks to utilize the new clsx and @rc-component/util packages.
  • Build System Updates: Modified package.json to reflect the new dependencies and updated .gitignore to include pnpm-lock.yaml and a new mock path for @rc-component/util.
  • Type Definitions: Added @types/node to the development dependencies in package.json.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov
Copy link

codecov bot commented Nov 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.48%. Comparing base (4c51c46) to head (e00a912).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #351      +/-   ##
==========================================
- Coverage   97.86%   97.48%   -0.38%     
==========================================
  Files          19       19              
  Lines         796      796              
  Branches      189      193       +4     
==========================================
- Hits          779      776       -3     
- Misses         17       20       +3     

☔ View full report in Codecov by Sentry.
📢 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.

Copy link

@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 primarily focuses on updating dependencies, most notably replacing the classnames library with clsx and migrating from rc-util to the scoped package @rc-component/util. These changes are applied consistently across the codebase, including source files, examples, and tests. The update to clsx is a good improvement for performance and bundle size. Additionally, the PR includes minor stylistic enhancements and code cleanup, such as standardizing arrow function syntax and removing trailing whitespace. The changes are well-implemented and I have no further recommendations.

Copy link

@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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4c51c46 and ab8980d.

📒 Files selected for processing (12)
  • .gitignore (1 hunks)
  • examples/animate.tsx (5 hunks)
  • package.json (2 hunks)
  • src/Filler.tsx (2 hunks)
  • src/List.tsx (2 hunks)
  • src/ScrollBar.tsx (5 hunks)
  • src/hooks/useFrameWheel.ts (1 hunks)
  • src/hooks/useMobileTouchMove.ts (1 hunks)
  • src/hooks/useScrollDrag.ts (1 hunks)
  • src/hooks/useScrollTo.tsx (1 hunks)
  • tests/scroll.test.js (3 hunks)
  • tests/scrollWidth.test.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Socket Security: Pull Request Alerts
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (13)
tests/scrollWidth.test.tsx (1)

4-4: 测试 domHook 迁移到 @rc-component/util 的兼容性需要确认

这里将 spyElementPrototypes 的来源从 rc-util/lib/test/domHook 切到了 @rc-component/util/lib/test/domHook,逻辑本身不变,但需要确保:

  1. 新包中导出的 spyElementPrototypes API 与旧版完全一致(签名、行为、mock 恢复方式相同)。
  2. package.json 和 Jest 的 moduleNameMapper / 手动 mock 目录已经同步更新到 @rc-component/util,否则单测在 CI 环境可能会找不到模块或拿不到 mock。

整体修改看起来是机械替换,没有功能层面的风险,只要上面两点在实际环境中验证通过即可。

src/hooks/useFrameWheel.ts (1)

1-1: raf 源切换后请确认 API 完全兼容

useFrameWheel 中使用了:

  • raf.cancel(id)
  • raf(() => { ... })
  • raf(() => { ... }, 2)(带第二个参数)

rc-util/lib/raf 切到 @rc-component/util/lib/raf 后,请确认新实现对上述用法完全兼容(尤其是多帧延迟和 cancel 的语义),并在本仓库跑一遍单测 / typecheck,避免运行时动画节流行为出现微妙差异。

src/hooks/useMobileTouchMove.ts (1)

1-1: useLayoutEffect 迁移到 @rc-component/util 后需验证 SSR 行为

这里从 rc-util/lib/hooks/useLayoutEffect 切到 @rc-component/util/lib/hooks/useLayoutEffect,只要新实现仍旧是在 SSR 环境降级为 useEffect、在浏览器使用 useLayoutEffect,行为就与之前一致。

建议:

  • 确认 @rc-component/util 的这个 hook 实现与原来保持兼容;
  • 在 SSR 场景下跑一次渲染(或现有 e2e/单测)确保没有再出现 useLayoutEffect 警告。
src/hooks/useScrollDrag.ts (1)

1-1: useScrollDrag 使用的 raf 也依赖完整的 cancel 能力

本文件同样将 rafrc-util/lib/raf 切到 @rc-component/util/lib/raf,并在拖拽平滑滚动逻辑中依赖:

  • raf(() => { ... }) 循环驱动滚动;
  • raf.cancel(id) 及时终止滚动。

为了避免拖拽滚动残留、无法停止等问题,请在升级后确认:

  • @rc-component/util/lib/raf 的默认导出与旧实现签名一致;
  • 滚动相关单测(特别是 “mouse down drag” 那一组)在本地和 CI 均通过。
tests/scroll.test.js (3)

5-5: resetWarned 迁移到 @rc-component/util 时注意全局 warning 状态一致性

这里将 resetWarned 的来源从 rc-util/lib/warning 切到 @rc-component/util/lib/warningscroll 测试依赖它来清空全局告警缓存,验证 “exceed should not warning”。

请确认:

  1. 新包中的 resetWarned 行为与旧版完全一致(清空的是同一个 warning 池,而不是互不相干的实例)。
  2. 其他生产代码中使用的 warning 也已经统一切换到 @rc-component/util/lib/warning,否则会出现测试清的是 A 实例、运行时写的是 B 实例的问题。

如果已经在整个仓库统一迁移到 @rc-component/util,当前改动是合理的。


770-770: 仅为空行调整,无功能影响

该处只是插入/调整空行,对测试逻辑和行为没有影响,可以保持当前改动或按团队格式化规则处理。


808-808: 同上:格式化空行调整

这里同样只是空行变化,不影响逻辑与断言,可忽略。

.gitignore (1)

10-12: 忽略 pnpm lockfile,并保留新 util 的 mocks 目录是合理的

  • 增加 pnpm-lock.yaml 忽略,符合多包管理工具共存的惯例,不影响 npm/yarn 用户。
  • 通过 !tests/__mocks__/@rc-component/util/lib 把新 util 的 mock 目录从忽略列表中排除,保证 Jest 手动 mock 能被提交和使用,与现有的 rc-util mocks 规则保持一致。

这部分配置与本次依赖迁移方向一致,没有额外风险。

src/Filler.tsx (1)

3-3: I'll verify the concerns raised in the review comment about the clsx import statement. Let me start by examining the codebase.
<function_calls>

#!/bin/bash

First, let's check the current state of src/Filler.tsx

if [ -f "src/Filler.tsx" ]; then
echo "=== src/Filler.tsx (first 100 lines) ===" && head -100 src/Filler.tsx
else
echo "File not found, searching for Filler.tsx"
fd "Filler.tsx" --type f
fi


</function_calls>

I need to explore the repository structure and verify the clsx import issue. Let me search for the relevant files:
<function_calls>

#!/bin/bash

Search for Filler.tsx and package.json

echo "=== Finding Filler.tsx ==="
fd "Filler.tsx" --type f 2>/dev/null || find . -name "Filler.tsx" 2>/dev/null | head -5

echo ""
echo "=== Finding package.json ==="
fd "package.json" --type f 2>/dev/null | head -5


</function_calls>

Let me check what files exist in the repository:
<function_calls>

#!/bin/bash

List repository structure

echo "=== Repository root files ==="
ls -la | head -20

echo ""
echo "=== Repository structure (first level) ==="
git ls-files | head -30


</function_calls>

Let me search for all TypeScript/TSX files and the clsx package information:
<function_calls>

#!/bin/bash

Search for any Filler files and package info

echo "=== Searching for Filler-related files ==="
find . -name "Filler" -o -name "package.json" 2>/dev/null | grep -v node_modules | head -20

echo ""
echo "=== Searching for clsx imports ==="
rg "import.*clsx" --type ts --type tsx -n 2>/dev/null | head -20


</function_calls>

Let me use web_search to verify the clsx library's export pattern, as this is a critical factual question about how a popular library works:
<function_calls>

clsx library javascript default export named export how to import

</function_calls>

I'll also search for the clsx package documentation:
<function_calls>

clsx npm package export pattern import syntax

</function_calls>

src/hooks/useScrollTo.tsx (1)

3-7: import 迁移到新工具包,逻辑保持不变

这里只是将 rafuseLayoutEffectwarning 的来源切换到新的工具包,实现和调用方式与之前一致,看起来不会引入行为变化。建议在本地或 CI 跑一遍现有测试,确认新包的实现与旧版 rc-util 完全兼容。

package.json (1)

49-49: 新增依赖与源码改动一致,建议确认工具链与版本兼容

  • 新增的 @types/node@rc-component/utilclsxrc-resize-observer 与源码中的 import 使用是一一对应的,整体依赖面收紧到了新工具包和 clsx,看起来合理。
  • 由于这些依赖(特别是 @types/node@rc-component/util)版本都比较新,建议在目标 Node 版本下重新安装依赖并跑一轮 lint/测试,确认编译、类型检查和运行时都没有异常。

Also applies to: 70-72

src/List.tsx (1)

1-5: clsx 与 @rc-component/util 替换保持原有行为

  • clsx 通过命名导入使用,并在 mergedClassName 中组合 prefixCls、RTL 修饰类和外部 className,语义与原先的 classnames 实现等价。
  • useEventuseLayoutEffect 从新的工具包导入,仅替换来源,调用时机和依赖项都未改变,对 List 行为不构成影响。

整体来看这几处改动是“无逻辑变更”的依赖迁移,代码风格也与 rc 生态的其它仓库保持一致。建议在迁移完成后跑一轮组件测试/示例页面,确保滚动、虚拟化和滚动事件回调在新工具包下工作正常。

Also applies to: 149-149

examples/animate.tsx (1)

6-8: 示例中改用 clsx 与新 useLayoutEffect,不影响原有动效逻辑

  • MyItemclassName={clsx('item', className)} 与原先的 classnames('item', className) 行为一致,依然在基础类名上叠加外部传入的 className
  • useLayoutEffect 改为从新工具包导入,仅是来源迁移,卸载时触发 onAppear 的逻辑不变。
  • onAppearActive 参数加括号以及 filter/findIndex 回调的小改动都只是语法风格调整,不改变筛选、插入逻辑。

建议在本地跑一下 examples/animate 示例页面,确认列表插入/删除时的过渡动画和数量统计仍然按预期工作。

Also applies to: 77-90, 143-143, 158-165

@afc163
Copy link
Member

afc163 commented Nov 26, 2025

标题不对,得改下。

@li-jia-nan li-jia-nan changed the title feat: clsx update refactor: drop rc-virtual-list and classnames Nov 26, 2025
@li-jia-nan
Copy link
Member Author

标题不对,得改下。

改好了

Co-authored-by: afc163 <afc163@gmail.com>
@afc163
Copy link
Member

afc163 commented Nov 26, 2025

README 里也翻一下,顺便把 badges 修复了

@socket-security
Copy link

socket-security bot commented Nov 26, 2025

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report

@li-jia-nan
Copy link
Member Author

README 里也翻一下,顺便把 badges 修复了

好了

@li-jia-nan li-jia-nan requested a review from afc163 November 26, 2025 12:46
@afc163 afc163 merged commit 37f4320 into master Dec 1, 2025
10 of 12 checks passed
@afc163 afc163 deleted the clsx-update branch December 1, 2025 04:07
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.

4 participants