Skip to content

Conversation

@yoyo837
Copy link
Contributor

@yoyo837 yoyo837 commented Nov 24, 2025

Summary by CodeRabbit

  • Chores
    • 将类名合并工具替换为 clsx,示例、组件和测试中的类名拼接已统一。
    • 更新若干内部运行时与样式工具引用(从 rc-util 切换到 @rc-component/util),不影响公共 API 或组件行为。
    • 移除与旧类名类型相关的开发依赖并微调代码风格与测试格式。

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

@coderabbitai
Copy link

coderabbitai bot commented Nov 24, 2025

📝 Walkthrough

Walkthrough

本次 PR 将项目中对 rc-utilclassnames 的引用迁移为 @rc-component/utilclsx,并在 package.json 中更新相应依赖;仅调整导入路径与若干格式/分号,未改动公共 API 或核心逻辑(≤50 字)。

Changes

Cohort / File(s) 变更摘要
包管理配置
package.json
替换/更新依赖:移除 rc-utilclassnames(及 @types/classnames),新增 @rc-component/utilclsx
导入迁移:核心工具
src/StyleContext.tsx, src/theme/Theme.ts, src/linters/utils.ts, src/util/cacheMapUtil.ts, src/util/index.ts
rc-util 下的工具(如 isEqualuseMemowarningcanUseDomremoveCSSupdateCSS 等)导入源改为 @rc-component/util(仅路径调整,无逻辑变更)
导入迁移:hooks
src/hooks/useCSSVarRegister.ts, src/hooks/useCacheToken.tsx, src/hooks/useEffectCleanupRegister.ts, src/hooks/useStyleRegister.tsx
hooks 内对 dynamicCSSupdateCSSwarning 等的导入路径统一改为 @rc-component/util,并更新相关注释;功能与签名未变
类名拼接替换
docs/examples/components/Button.tsx, docs/examples/components/Spin.tsx, docs/examples/diff-salt.tsx, docs/examples/layer.tsx, tests/**/*.spec.tsx
classnames / classNames 替换为 clsx,调用处改为 clsx(...),使用语义等价,行为不变
测试与 mocks
tests/server.spec.tsx, tests/linter.spec.tsx, tests/css-variables.spec.tsx, tests/index.spec.tsx
更新测试中对工具的导入与 mock 路径(rc-util/...@rc-component/util/...);若干格式/分号微调,逻辑不变

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 分钟

需要额外注意的点:

  • 确认 package.json 中新增 @rc-component/utilclsx 版本与项目兼容,且移除的包已无残留引用。
  • 检查 tests 中的 mock 路径是否全部指向新位置(如 canUseDomresetWarned 等)。
  • 确认 classnamesclsx 的替换未引入边界差异(传入对象、数组或非字符串值的情况)。

Poem

🐰 旧径换新路,跳过一片草,
导入换了名,功能依然好。
小兔在代码间轻轻绕,
依赖更新,测试笑,
一跳两跳,新枝俏。 🌿

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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的主要变更:将rc-util替换为@rc-component/util,将classnames替换为clsx,与提供的变更内容完全对应。
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a3bdf12 and aa12dd5.

📒 Files selected for processing (7)
  • docs/examples/components/Button.tsx (2 hunks)
  • docs/examples/components/Spin.tsx (2 hunks)
  • docs/examples/diff-salt.tsx (2 hunks)
  • docs/examples/layer.tsx (2 hunks)
  • tests/css-variables.spec.tsx (5 hunks)
  • tests/index.spec.tsx (12 hunks)
  • tests/server.spec.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • docs/examples/diff-salt.tsx
  • docs/examples/components/Spin.tsx
  • tests/index.spec.tsx
  • tests/server.spec.tsx
  • tests/css-variables.spec.tsx
🔇 Additional comments (2)
docs/examples/components/Button.tsx (1)

3-3: 迁移正确,类名组合逻辑保持一致。

clsx 的导入和使用都正确:

  • 命名导入语法正确
  • 多参数使用场景(包括 hashId、cssVarKey 等)与 classNames 行为一致,都会正确过滤 falsy 值

该 Button 组件是示例代码,建议测试确保样式应用正常。

Also applies to: 163-163

docs/examples/layer.tsx (1)

2-2: 迁移验证完成,无需进一步修改。

已验证:

  • clsx 导入语法正确(import { clsx } from 'clsx'
  • 代码库中 clsx 使用一致(7 个文件均采用相同导入方式)
  • 无残留的 classnames 导入,迁移完整
  • 使用方式 clsx(className, 'layer-div') 完全兼容

示例功能正常。


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 @yoyo837, 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 primarily focuses on a dependency migration, transitioning from the rc-util package to its new scoped counterpart, @rc-component/util. This change involves updating the project's package.json and modifying all import statements throughout the codebase that reference utilities from the old package. The goal is to align with updated package naming conventions and maintain consistency within the component ecosystem.

Highlights

  • Dependency Migration: The project's dependency on rc-util has been updated to the new scoped package @rc-component/util.
  • Codebase Refactoring: All import statements and relevant code references across the project have been updated to reflect the new @rc-component/util package.
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 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.63%. Comparing base (37b7a7b) to head (aa12dd5).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #237      +/-   ##
==========================================
- Coverage   94.63%   94.63%   -0.01%     
==========================================
  Files          32       32              
  Lines        2815     2813       -2     
  Branches      445      445              
==========================================
- Hits         2664     2662       -2     
  Misses        151      151              

☔ 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 correctly migrates the dependency from rc-util to @rc-component/util. The changes primarily involve updating import statements across the codebase and modifying package.json. Additionally, several files have received minor formatting improvements, such as consistent spacing and line breaks, which enhance code readability. The changes are straightforward and well-executed. By the way, there seems to be a small typo in the pull request title ('componet' instead of 'component').

@socket-security
Copy link

socket-security bot commented Nov 24, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedclsx@​2.1.11001009680100
Added@​rc-component/​util@​1.4.010010010093100

View full report

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 37b7a7b and cfe68f1.

📒 Files selected for processing (12)
  • package.json (1 hunks)
  • src/StyleContext.tsx (1 hunks)
  • src/hooks/useCSSVarRegister.ts (2 hunks)
  • src/hooks/useCacheToken.tsx (3 hunks)
  • src/hooks/useEffectCleanupRegister.ts (1 hunks)
  • src/hooks/useStyleRegister.tsx (2 hunks)
  • src/linters/utils.ts (1 hunks)
  • src/theme/Theme.ts (1 hunks)
  • src/util/cacheMapUtil.ts (1 hunks)
  • src/util/index.ts (1 hunks)
  • tests/linter.spec.tsx (17 hunks)
  • tests/server.spec.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/server.spec.tsx (3)
src/hooks/useStyleRegister.tsx (1)
  • useStyleRegister (373-518)
src/extractStyle.ts (1)
  • extractStyle (32-111)
src/StyleContext.tsx (1)
  • StyleProvider (100-139)
⏰ 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: preview
🔇 Additional comments (19)
src/theme/Theme.ts (1)

1-1: 导入路径更新正确

导入路径已成功从 rc-util 迁移到 @rc-component/util,与 PR 的整体目标一致。

src/StyleContext.tsx (1)

1-2: 导入路径迁移正确

useMemoisEqual 的导入路径已正确更新至 @rc-component/util

src/hooks/useCacheToken.tsx (3)

2-2: 导入路径更新正确

updateCSS 的导入路径已正确迁移至 @rc-component/util


99-99: 格式改进

添加分号提高了代码风格的一致性。


255-255: 注释已同步更新

注释已正确更新以反映新的依赖包名称。

src/util/cacheMapUtil.ts (1)

1-1: 导入路径更新正确

canUseDom 的导入路径已成功迁移至 @rc-component/util

src/linters/utils.ts (1)

1-1: 导入路径更新正确

warning 工具函数的导入路径已正确更新至 @rc-component/util

src/hooks/useEffectCleanupRegister.ts (1)

1-3: 导入路径更新正确

warning 的导入路径已正确迁移至 @rc-component/util,导入顺序的调整也符合规范。

src/util/index.ts (1)

2-5: 导入路径迁移完成

所有 DOM 工具函数(canUseDomremoveCSSupdateCSS)的导入路径已正确更新至 @rc-component/util。导入顺序的调整也保持了良好的代码组织。

package.json (1)

48-48: 确认依赖包版本和安全性,API 兼容性需手动验证

已验证 @rc-component/util 的最新版本为 1.4.0,并且无已知的安全漏洞。

但是,从 rc-util 迁移至 @rc-component/util 时,建议:

  • 虽然两个包提供相同的 API 文档示例,但未找到官方迁移指南或 breaking changes 说明
  • 需要手动验证代码中所有对旧包的导入是否已正确更新为新包
  • 在合并前运行完整的测试套件确保功能完整性
tests/server.spec.tsx (3)

39-43: LGTM!mock 路径更新正确

Mock 模块路径已正确从 rc-util/lib/Dom/canUseDom 更新为 @rc-component/util/lib/Dom/canUseDom,与依赖迁移保持一致。


93-95: 代码格式调整

useStyleRegister 调用的格式调整为多行,提高了可读性。


450-464: extractStyle 参数格式优化

参数对象格式调整为多行展开,使代码更易读。

src/hooks/useCSSVarRegister.ts (1)

104-104: 注释更新保持一致

注释已同步更新为 @rc-component/util,与新的导入路径保持一致。

src/hooks/useStyleRegister.tsx (2)

2-2: dynamicCSS 工具导入路径迁移

removeCSSupdateCSS 的导入路径已正确从 rc-util 更新为 @rc-component/util


537-537: 注释同步更新

注释已更新为 @rc-component/util,保持代码文档的准确性。

tests/linter.spec.tsx (3)

1-1: warning 工具导入路径更新

resetWarned 的导入路径已正确从 rc-util/lib/warning 迁移至 @rc-component/util/lib/warning


35-35: mock 实现简化

console.error 的 mock 实现改用更简洁的箭头函数形式,功能等效。


71-73: 测试代码格式统一优化

多处 useCacheToken 调用的参数对象格式调整为多行展开,提高了测试代码的可读性和一致性。

Also applies to: 95-95, 102-107, 118-123, 141-143, 166-168, 197-199, 224-226, 241-243, 262-264, 295-297, 323-325, 355-357, 391-393, 421-423, 453-455

@yoyo837 yoyo837 changed the title chore: move rc-util to @rc-componet/util chore: move rc-util to @rc-componet/util and move classnames to clsx Nov 24, 2025
@afc163 afc163 merged commit 3445fe5 into ant-design:master Nov 24, 2025
8 checks passed
@yoyo837 yoyo837 deleted the move-util branch November 24, 2025 08:58
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.

2 participants