Skip to content

Avoid rc package deep imports#638

Open
QDyanbing wants to merge 1 commit into
react-component:masterfrom
QDyanbing:avoid-deep-imports
Open

Avoid rc package deep imports#638
QDyanbing wants to merge 1 commit into
react-component:masterfrom
QDyanbing:avoid-deep-imports

Conversation

@QDyanbing
Copy link
Copy Markdown

@QDyanbing QDyanbing commented May 25, 2026

背景

antd 侧需要移除对 rc 包 lib / es 内部路径的依赖,统一改为通过 rc 包根入口使用公开 API。

关联:ant-design/ant-design#58115

调整

  • 升级 @rc-component/select~1.7.1@rc-component/tree~1.3.2
  • @rc-component/select@rc-component/tree 的内部路径导入改为包根入口导入
  • 对不再公开的内部类型改为基于公开类型在包内推导
  • 适配 @rc-component/select 新版本展示节点结构,更新相关测试断言和 snapshot

验证

  • npm run compile
  • npm run lint(仅保留现有 react-hooks warning)
  • npm test -- --runInBand

Summary by CodeRabbit

发布说明

  • Chores

    • 升级依赖版本(@rc-component/select、@rc-component/tree、@rc-component/util 等)
    • 标准化模块导入路径,统一采用包入口方式
  • Bug Fixes

    • 修复级联选择器内容显示的 DOM 选择器问题

Review Change Stack

@vercel
Copy link
Copy Markdown

vercel Bot commented May 25, 2026

@QDyanbing is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 07aeefa8-53b0-4ad5-b8ce-3c6e0e40f127

📥 Commits

Reviewing files that changed from the base of the PR and between 2613505 and eecbffc.

⛔ Files ignored due to path filters (1)
  • tests/__snapshots__/search.spec.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (16)
  • examples/adjust-overflow.tsx
  • package.json
  • src/Cascader.tsx
  • src/OptionList/Column.tsx
  • src/OptionList/List.tsx
  • src/OptionList/index.tsx
  • src/OptionList/useKeyboard.ts
  • src/hooks/useEntities.ts
  • src/hooks/useSearchConfig.ts
  • src/hooks/useSelect.ts
  • src/hooks/useValues.ts
  • src/utils/warningPropsUtil.ts
  • tests/fieldNames.spec.tsx
  • tests/index.spec.tsx
  • tests/keyboard.spec.tsx
  • tests/search.spec.tsx

Walkthrough

This pull request migrates internal component library imports from deep /lib/* paths to package root exports across the cascader codebase. Dependency versions are updated to support these changes, Cascader's public placement prop type is refined, and test selectors are adjusted to match updated DOM class names.

Changes

Import Path Migration and Type Refinement

Layer / File(s) Summary
Dependency version updates
package.json
@rc-component/select, @rc-component/tree, @rc-component/util dependencies and @rc-component/father-plugin devDependency versions are upgraded to access newly exported public APIs.
Cascader component type refinement
src/Cascader.tsx
Cascader imports migrate from /lib/* paths to package entry points. The public placement prop type is updated to use BaseSelectPropsWithoutPrivate['placement']. Type inference for valueCells in the display value callback is refined.
OptionList and keyboard hook imports
src/OptionList/List.tsx, src/OptionList/index.tsx, src/OptionList/Column.tsx, src/OptionList/useKeyboard.ts
Imports for useMemo and pickAttrs migrate to package root exports. New RefOptionListProps type is exported from List.tsx. Local import references in index.tsx and useKeyboard.ts are updated accordingly.
Hooks utility import migration
src/hooks/useEntities.ts, src/hooks/useSearchConfig.ts, src/hooks/useSelect.ts, src/hooks/useValues.ts
Imports of convertDataToEntities, conductCheck, and warning migrate from /lib/* paths to package entry points. DataEntity type in useEntities is now derived from convertDataToEntities return type instead of direct import.
Utility and example import migration
src/utils/warningPropsUtil.ts, examples/adjust-overflow.tsx
warning and BuildInPlacements imports migrate from /lib/* internal paths to package root exports.
Test suite updates
tests/index.spec.tsx, tests/keyboard.spec.tsx, tests/search.spec.tsx, tests/fieldNames.spec.tsx
Test file imports for KeyCode and resetWarned are updated to use package root exports. DOM selectors are changed from .rc-cascader-content-value to .rc-cascader-content in multiple test assertions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • afc163
  • zombieJ

Poem

🐰 Hoppy imports, cleaner paths so bright,
From lib's deep nooks to entry points of light,
Types refined, and selectors aligned,
A cascading refactor, organized and kind! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR标题准确总结了主要变更内容:避免深层导入rc包的内部lib路径,改用包的公共入口点。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

examples/adjust-overflow.tsx

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

src/Cascader.tsx

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

src/OptionList/Column.tsx

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

  • 12 others

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

@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 updates several dependencies and refactors imports to use main package entry points instead of internal file paths. It also refines TypeScript type definitions and updates test selectors to match class name changes in the rendered output. Feedback was provided regarding a type cast in src/Cascader.tsx, suggesting the use of NonNullable to ensure compatibility with TypeScript's strict mode when accessing optional properties.

Comment thread src/Cascader.tsx
Comment on lines +381 to +383
const { valueCells } = info.values[0] as BaseSelectProps['displayValues'][number] & {
valueCells: SingleValueType;
};
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.

medium

由于 BaseSelectProps 中的 displayValues 是可选属性,直接通过 [number] 访问其元素类型在严格模式下会报错。建议使用 NonNullable 来确保类型推导的准确性。

Suggested change
const { valueCells } = info.values[0] as BaseSelectProps['displayValues'][number] & {
valueCells: SingleValueType;
};
const { valueCells } = info.values[0] as NonNullable<BaseSelectProps['displayValues']>[number] & {
valueCells: SingleValueType;
};

@socket-security
Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: npm webpack is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: ?npm/dumi@2.4.28npm/father@4.6.20npm/webpack@5.107.1

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/webpack@5.107.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

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