Skip to content

fix: update import paths to resolve no-restricted-imports ESLint errors#866

Merged
zombieJ merged 4 commits into
react-component:masterfrom
EmilyyyLiu:fix/ci-compile
May 28, 2026
Merged

fix: update import paths to resolve no-restricted-imports ESLint errors#866
zombieJ merged 4 commits into
react-component:masterfrom
EmilyyyLiu:fix/ci-compile

Conversation

@EmilyyyLiu
Copy link
Copy Markdown
Contributor

@EmilyyyLiu EmilyyyLiu commented May 28, 2026

Summary

  • Change lib imports to use package root imports where available
  • Add eslint-disable comments for internal hooks not exported from root

Test plan

  • Run npm run compile locally to verify build passes

关联 pr:#864

Summary by CodeRabbit

  • Chores

    • 统一并简化了若干内部模块的导入方式,提升代码一致性与维护性
    • 更新了内部依赖版本以使用更高版本的工具包
    • 未修改任何对外接口、导出或运行时语义,用户端无功能或行为变化
  • Tests

    • 调整了测试文件的导入以匹配新的内部导入方式,测试逻辑保持不变

Review Change Stack

Copy link
Copy Markdown

@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 refactors imports from @rc-component/util to use named imports directly from the package instead of deep paths, while adding /* eslint-disable no-restricted-imports */ comments for remaining deep imports. The reviewer recommends replacing the blanket file-wide ESLint disable comments with targeted // eslint-disable-next-line comments to prevent accidentally bypassing the rule for future imports, and suggests combining duplicate import statements from @rc-component/util.

Comment thread src/Menu.tsx Outdated
Comment thread src/MenuItem.tsx Outdated
Comment thread src/SubMenu/PopupTrigger.tsx Outdated
Comment thread src/context/MenuContext.tsx Outdated
Comment thread src/hooks/useAccessibility.ts Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.72%. Comparing base (038c4b3) to head (47bc332).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #866   +/-   ##
=======================================
  Coverage   99.72%   99.72%           
=======================================
  Files          26       26           
  Lines         729      729           
  Branches      201      201           
=======================================
  Hits          727      727           
  Misses          2        2           

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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

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: 18537bb1-bec6-4877-bf4b-a24efbe22d9a

📥 Commits

Reviewing files that changed from the base of the PR and between cf65009 and 47bc332.

📒 Files selected for processing (12)
  • package.json
  • src/Menu.tsx
  • src/MenuItem.tsx
  • src/SubMenu/PopupTrigger.tsx
  • src/context/MenuContext.tsx
  • src/hooks/useAccessibility.ts
  • tests/Focus.spec.tsx
  • tests/Keyboard.spec.tsx
  • tests/Menu.spec.tsx
  • tests/MenuItem.spec.tsx
  • tests/Responsive.spec.tsx
  • tests/SubMenu.spec.tsx
✅ Files skipped from review due to trivial changes (6)
  • package.json
  • tests/Responsive.spec.tsx
  • src/context/MenuContext.tsx
  • tests/SubMenu.spec.tsx
  • src/SubMenu/PopupTrigger.tsx
  • src/Menu.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/MenuItem.tsx

Walkthrough

该 PR 将多个文件的深层 @rc-component/util/lib/* 导入统一改为从 @rc-component/util 包入口的命名导入;未改动运行时代码或导出签名,且更新了 @rc-component/util 版本号。

Changes

Import Path Standardization to @rc-component/util Entry Point

Layer / File(s) Summary
UI component imports
src/Menu.tsx, src/MenuItem.tsx, src/MenuItemGroup.tsx, src/SubMenu/index.tsx, src/SubMenu/PopupTrigger.tsx
warning, omit, raf, useId, isEqual, useControlledState 等从 @rc-component/util/lib/* 的深层导入切换为从 @rc-component/util 的命名导入;实现和导出不变。
Context and hooks imports
src/context/MenuContext.tsx, src/hooks/useAccessibility.ts, src/hooks/useKeyRecords.ts
useMemoisEqualKeyCodegetFocusNodeListrafwarning 等导入改为从包入口按需导入;实现与导出接口未变。
Utility module imports
src/utils/commonUtil.ts, src/utils/warnUtil.ts
toArraywarning 的导入来源由深层路径迁移至 @rc-component/util 包入口,未更改导出接口或行为。
Test imports update
tests/* (Focus.spec.tsx, Keyboard.spec.tsx, Menu.spec.tsx, MenuItem.spec.tsx, Responsive.spec.tsx, SubMenu.spec.tsx)
将测试用例中对 KeyCodespyElementPrototypesresetWarned 等的导入改为从包入口命名导入;测试逻辑与断言不变。
Dependency update
package.json
将依赖 @rc-component/util^1.3.0 更新为 ^1.11.1

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • react-component/menu#756: 同类将深层 @rc-component/* 导入迁移到包入口的改动,影响相同组件和工具函数。

Suggested reviewers

  • zombieJ

Poem

兔子来巡视代码园,
把深巷导入带回前门,
ESLint 静声不再唠叨,
引用整齐如新春剪纸,
小兔跳跃,笑意盈盈。

🚥 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标题准确概括了主要变更内容:更新导入路径以解决ESLint的no-restricted-imports错误,这正是该PR涉及所有文件的核心目的。
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.

src/Menu.tsx

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

src/MenuItem.tsx

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

src/SubMenu/PopupTrigger.tsx

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

  • 8 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.

@zombieJ zombieJ merged commit e5b4a53 into react-component:master May 28, 2026
7 of 8 checks passed
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