Skip to content

fix: import from @rc-component/util package root#621

Merged
zombieJ merged 1 commit into
masterfrom
fix/import-from-package-root
Jun 1, 2026
Merged

fix: import from @rc-component/util package root#621
zombieJ merged 1 commit into
masterfrom
fix/import-from-package-root

Conversation

@zombieJ
Copy link
Copy Markdown
Member

@zombieJ zombieJ commented Jun 1, 2026

Summary

npm run compile 失败,因为 father-plugin 注入的 no-restricted-imports lint 规则禁止从 @rc-component/*/lib/** 子路径导入,需要改为包根导入。

This PR replaces all 6 @rc-component/util/lib/* imports with named imports from the package root.

Affected files

  • src/Popup/index.tsx
  • src/UniqueProvider/index.tsx
  • src/hooks/useAlign.ts
  • src/hooks/useWatch.ts
  • src/hooks/useWinClick.ts
  • src/index.tsx

Notes

  • warning in useWinClick.ts switches from the always-fire named warning to the package root's default export (which is warningOnce). This is dev-only and dedup is preferable for a same-shadow-root sanity check that would otherwise spam on every effect re-run.

Test plan

  • npm run compile passes
  • npm test — 130 passed / 1 pre-existing skip

Summary by CodeRabbit

发版说明

  • 代码优化
    • 调整了内部依赖包的导入方式,优化模块结构

用户影响: 此版本无任何用户可见的功能变更,仅涉及内部代码结构调整。

Imports from `@rc-component/util/lib/*` are blocked by the
`no-restricted-imports` lint rule wired into `npm run compile`, causing
the build to fail. Switch all six call sites to the package root export.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

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: 440adf54-7511-4807-ad30-8a82bc196a91

📥 Commits

Reviewing files that changed from the base of the PR and between 614fd4b and bed663c.

📒 Files selected for processing (6)
  • src/Popup/index.tsx
  • src/UniqueProvider/index.tsx
  • src/hooks/useAlign.ts
  • src/hooks/useWatch.ts
  • src/hooks/useWinClick.ts
  • src/index.tsx

概览

此 PR 将 @rc-component/util 的导入方式从分散的深层子路径统一改为从包根直接导入。涉及主入口文件、两个组件及三个 Hook 工具函数的导入调整,无逻辑或导出接口变更。

改动

@rc-component/util 导入路径统一

Layer / File(s) 摘要
导入路径统一
src/index.tsx, src/Popup/index.tsx, src/UniqueProvider/index.tsx, src/hooks/useAlign.ts, src/hooks/useWatch.ts, src/hooks/useWinClick.ts
getDOMgetShadowRootisDOMuseEventuseLayoutEffectcomposeRef 等工具的导入从 @rc-component/util/lib/... 的深层路径改为从 @rc-component/util 根包进行具名导入。

预估审查工作量

🎯 1 (简单) | ⏱️ ~5 分钟

建议审查人

  • MadCcc

诗歌

🐰 导入路径整齐排,
深层改浅一步来,
包根直出更明快,
组件 Hook 齐步摆,
统一之美在其中。✨

🚥 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 The pull request title accurately summarizes the main change: consolidating imports from deep paths to the package root of @rc-component/util.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/import-from-package-root

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.

src/Popup/index.tsx

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

src/UniqueProvider/index.tsx

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

src/hooks/useAlign.ts

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

  • 3 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 simplifies and cleans up import statements across several files by replacing deep internal imports from @rc-component/util/lib/... with direct named imports from the root @rc-component/util package. There are no review comments, and I have no additional feedback to provide.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.28%. Comparing base (59b659d) to head (bed663c).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #621      +/-   ##
==========================================
+ Coverage   97.26%   97.28%   +0.01%     
==========================================
  Files          17       17              
  Lines         952      956       +4     
  Branches      274      274              
==========================================
+ Hits          926      930       +4     
  Misses         26       26              

☔ 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.

@zombieJ zombieJ merged commit c6c9e35 into master Jun 1, 2026
9 of 10 checks passed
@zombieJ zombieJ deleted the fix/import-from-package-root branch June 1, 2026 03:02
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