-
Notifications
You must be signed in to change notification settings - Fork 108
chore: migrate to @rc-component namespace and update #294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: migrate to @rc-component namespace and update #294
Conversation
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Walkthrough将包名与导入路径从 Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User as 用户
participant Checkbox as Checkbox 组件
participant Hook as useControlledState (Hook)
User->>Checkbox: 交互(点击/键盘)
Checkbox->>Hook: 读取当前值(props.checked 或 defaultChecked)
Hook-->>Checkbox: 返回 [rawValue, setRawValue]
Checkbox->>Checkbox: 调用 setRawValue 或基于 props 决定不更新内部状态
Checkbox->>User: 触发 onChange 事件(通知外部)
note right of Hook #E6F4EA: 新增/替换的 hook:useControlledState
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal). Please share your feedback with us on this Discord post. 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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @EmilyyyLiu, 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!
此拉取请求旨在将 rc-checkbox
组件及其相关依赖迁移到 @rc-component
命名空间下,以实现项目内包管理和依赖的一致性。这包括更新包名、调整导入路径以及替换内部使用的 React Hook,从而确保组件与新的生态系统标准对齐,并为未来的维护和开发奠定基础。
Highlights
- 包名和引用迁移: 将所有包名和内部引用从
rc-checkbox
迁移到@rc-component/checkbox
命名空间,以实现统一管理。 - 依赖更新: 将
rc-util
依赖更新为@rc-component/util
,并替换了useMergedState
为useControlledState
。 - 项目配置更新: 更新了
package.json
中的版本号、主页链接、构建脚本和依赖项,并调整了tsconfig.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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
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 issue 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
-
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. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
本次 PR 主要将 rc-checkbox
迁移到了 @rc-component
命名空间下,并更新了相关依赖和 API 调用。整体来看,修改内容清晰,符合迁移目标。但是,我在 package.json
中发现一个严重问题,可能会导致项目构建失败,并已在代码评论中提出修复建议。请务必修正。
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
README.md (1)
1-1
: README 仍大量指向 rc-checkbox,需同步到新作用域包已迁移到
@rc-component/checkbox
,README 标题、徽章与链接应统一,否则会误导使用者。建议:
- 标题改为
# @rc-component/checkbox
(Line 1)。- NPM 徽章与链接更新到 scoped 包(Lines 14–16、26–27、35)。
- bundlephobia 链接与徽章也应改为 scoped 包(Lines 28–29)。
- Nodei 图片改为
@rc-component/checkbox
(Line 35)。注意:带作用域的 URL 需做 URL 编码(如
%40rc-component%2Fcheckbox
)。需要的话我可以提 PR 批量替换。Also applies to: 14-16, 26-29, 35-36
🧹 Nitpick comments (1)
docs/demo/simple.tsx (1)
37-37
: 示例文案仍显示 rc-checkbox,建议同步到新包名避免混淆页面可见文本建议统一为
@rc-component/checkbox
或更通用的 “Checkbox”。可按需修改(示例):
- controlled checked rc-checkbox + controlled checked @rc-component/checkbox ... - defaultChecked rc-checkbox + defaultChecked @rc-component/checkbox ... - defaultChecked rc-checkbox with name + defaultChecked @rc-component/checkbox with name ... - rc-checkbox with key events + @rc-component/checkbox with key eventsAlso applies to: 55-55, 72-72, 100-101
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
README.md
(1 hunks)docs/demo/focus.tsx
(1 hunks)docs/demo/simple.tsx
(1 hunks)docs/index.md
(1 hunks)package.json
(3 hunks)src/index.tsx
(2 hunks)tests/index.test.tsx
(1 hunks)tsconfig.json
(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). (1)
- GitHub Check: Socket Security: Pull Request Alerts
🔇 Additional comments (6)
tests/index.test.tsx (1)
1-1
: KeyCode 路径迁移对齐 @rc-component/util,LGTM与源码依赖一致,测试可继续覆盖键盘事件分支,无需额外改动。
docs/index.md (1)
3-3
: 文档导入与安装命令已对齐新包名,LGTMAlso applies to: 11-11, 14-14, 17-17, 23-23
docs/demo/simple.tsx (1)
2-2
: 示例导入与类型对齐新包名,LGTMAlso applies to: 6-6
tsconfig.json (1)
14-15
: paths 映射已切换到 @rc-component/checkbox,LGTM与文档/测试用法一致,开发时能直连源码入口。
src/index.tsx (1)
1-1
: useMergedState → useControlledState 行为一致性请做一次回归确认改为
useControlledState(defaultChecked, checked)
后,受控/非受控分支仍由('checked' in props)
判定,表面逻辑无变。但不同 hook 的边界行为(如 defaultChecked 仅首轮生效、受控时 set 是否为 no-op)可能与旧实现略有差异。建议重点回归:
- 受控模式:传入
checked
时点击不应改变内部状态(已有测试覆盖)。- 非受控模式:
defaultChecked
仅初始化一次;后续点击能切换。- disabled 时不触发状态与回调。
若需要,我可以补一组针对受控/非受控边界的额外测试用例。Also applies to: 47-47
docs/demo/focus.tsx (1)
1-2
: 示例导入与类型对齐新包名,LGTM
"name": "@rc-component/checkbox", | ||
"version": "1.0.0", | ||
"description": "checkbox ui component for react", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
首次发布 scoped 包建议显式声明为 public
NPM 对作用域包默认私有。为避免首发失败或误发私有,建议添加 publishConfig.access: public
。
可在根级添加:
"publishConfig": {
"access": "public"
}
需要我顺手补上并校验发布流程脚本吗?
🤖 Prompt for AI Agents
In package.json around lines 2 to 4, this scoped package lacks an explicit
publishConfig and NPM defaults scoped packages to private; add a root-level
"publishConfig": { "access": "public" } entry to ensure the first publish is
public, and verify any publish scripts or CI use the package.json root so the
new field is picked up.
```js | ||
import checkbox from 'rc-checkbox'; | ||
import checkbox from '@rc-component/checkbox'; | ||
|
||
export default () => <checkbox />; | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
README 用法示例中的组件名大小写错误,当前会被当作原生标签渲染
应使用大写组件名并与默认导出同名,避免 <checkbox />
被识别为自定义元素而非 React 组件。
建议改成:
-import checkbox from '@rc-component/checkbox';
+import Checkbox from '@rc-component/checkbox';
-export default () => <checkbox />;
+export default () => <Checkbox />;
🤖 Prompt for AI Agents
In README.md around lines 39 to 43 the example imports and uses a lowercase
component name causing React to treat it as a native DOM tag; change the import
to a PascalCase name that matches the default export and use that PascalCase in
JSX (e.g., import Checkbox from '...'; export default () => <Checkbox />) so the
element is recognized as a React component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (2)
package.json (2)
2-3
: 首次发布 scoped 包建议显式设置为 public为避免
npm publish
默认发布为私有,请在根级添加publishConfig.access: public
。{ "name": "@rc-component/checkbox", "version": "1.0.0", + "publishConfig": { + "access": "public" + }, "description": "checkbox ui component for react",
56-56
: 已修复版本号尾随空格问题,赞!
🧹 Nitpick comments (3)
package.json (3)
11-13
: 统一使用 https 链接
bugs.url
仍为http
,建议改为https
以保持一致与安全。"homepage": "https://react-component.github.io/checkbox", "bugs": { - "url": "http://github.com/react-component/checkbox/issues" + "url": "https://github.com/react-component/checkbox/issues" },
37-38
: 去除对 bun 的工具依赖脚本中使用
bunx
会增加贡献门槛,直接调用本地tsc
更稳妥。- "test": "jest", - "tsc": "bunx tsc --noEmit" + "test": "jest", + "tsc": "tsc --noEmit"
53-54
: 建议声明 Node 运行时版本依赖(如 husky 9、现代 eslint/dumi/father)通常要求 Node ≥18。建议在
engines
中约束,避免 CI/本地版本漂移。"devDependencies": { "@rc-component/father-plugin": "^2.1.3", "@rc-component/np": "^1.0.0", @@ "typescript": "^5.2.2" }, + "engines": { + "node": ">=18" + },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
package.json
(3 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). (1)
- GitHub Check: Socket Security: Pull Request Alerts
🔇 Additional comments (3)
package.json (3)
32-32
: 确认 gh-pages 部署命令与 dumi 2/father v4 的兼容性
father doc deploy -d dist
在 dumi 2 场景下是否仍为推荐方式?如有问题可改用dumi deploy
。
35-35
: 发布流检查:rc-np 与 scoped 包请确认
rc-np
会传递--access public
(或依赖上方publishConfig
)并配置 2FA/跳过发布阶段的 tag 推送策略。
49-50
: 确认:依赖替换已落地(未发现 rc-util/useMergedState;useControlledState 来自 @rc-component/util)证据:src/index.tsx —
import useControlledState from '@rc-component/util/lib/hooks/useControlledState'
(使用处第47行);package.json —@rc-component/util: "^1.3.0"
(第49行)。未检出rc-util
或useMergedState
。
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #294 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 30 30
Branches 5 5
=========================================
Hits 30 30 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
依赖rc-util修改为 @rc-component/util
替换 useMergedState 为 useControlledState
Summary by CodeRabbit
新功能
文档
重构
测试
事务