Skip to content

Avoid rc package deep imports#1071

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

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

Conversation

@QDyanbing
Copy link
Copy Markdown

@QDyanbing QDyanbing commented May 21, 2026

背景

antd 侧限制继续使用 rc 包的 lib / es 深路径导入,需要将 slider 中依赖的 rc 包内部路径统一改为包根入口。

调整内容

  • 升级 @rc-component/father-plugin,使用插件统一拦截 rc 包 lib / es 深路径导入。
  • 升级 @rc-component/util,改为从 @rc-component/util 根入口导入 KeyCodewarningraf、hooks 与测试工具。
  • 合并同来源的重复 import,保持导入更清晰。
  • 补充测试环境依赖,配合当前 React 18 测试环境。

验证

  • npm run lint
  • npm run tsc
  • npm test -- --runInBand
  • npm run compile

Summary by CodeRabbit

发布说明

  • Chores
    • 升级依赖版本,包括 React、TypeScript ESLint 及相关工具库,以获得最新功能和安全更新
    • 整理代码导入语句,统一模块引入方式
    • 更新 ESLint 配置规则

Review Change Stack

@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 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
Contributor

coderabbitai Bot commented May 21, 2026

Walkthrough

本 PR 升级了 @rc-component/util 依赖版本,并系统性地调整了整个仓库的导入语句,将深层子路径导入统一为包入口导入,同时更新了 React 16 至 18 以及相关开发工具。

Changes

导入路径整合与依赖升级

Layer / File(s) Summary
依赖版本和 ESLint 配置更新
package.json, .eslintrc.js
@rc-component/util 升级至 ^1.11.1,React 与 React DOM 升级至 ^18.0.0,新增/更新 TypeScript ESLint 工具至 ^5.62.0,并在 ESLint 规则中禁用 @typescript-eslint/switch-exhaustiveness-check
源代码导入路径整合
src/Slider.tsx, src/Handles/Handle.tsx, src/Handles/index.tsx, src/hooks/useDrag.ts, src/hooks/useRange.ts, src/index.tsx, docs/examples/components/TooltipSlider.tsx
将 KeyCode、useEvent、useLayoutEffect、warning 等工具和钩子的导入从 @rc-component/util/lib/... 深层路径改为从 @rc-component/util 包入口导入,并整合分离的 import type 与默认导入语句。
测试文件导入路径整合
tests/Range.test.tsx, tests/Slider.test.js, tests/common.test.js, tests/marks.test.js
更新测试文件中 KeyCode、spyElementPrototypes、resetWarned 等测试工具的导入来源,从 @rc-component/util/lib/... 改为统一从 @rc-component/util 导入。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • react-component/slider#1065: 同样涉及 @rc-component/util 的导入迁移工作,在 src/Slider.tsxsrc/Handles/Handle.tsx 等文件中调整导入路径。

Suggested reviewers

  • zombieJ

Poem

🐰 深层路径被整合,
包入口齐声响,
React 十八来相助,
ESLint 规则调参配,
导入更简洁!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and specifically describes the main change: refactoring imports to avoid deep paths in rc packages, which aligns with all file modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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

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.

@socket-security
Copy link
Copy Markdown

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

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​testing-library/​react@​16.3.29910010087100

View full report

Copy link
Copy Markdown
Contributor

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@package.json`:
- Around line 59-60: Update the package.json engines.node declaration to match
the minimum Node versions required by `@typescript-eslint/eslint-plugin`,
`@typescript-eslint/parser` and eslint; change the engines.node field (in
package.json) from ">=8.x" to "^12.22.0 || ^14.17.0 || >=16.0.0" so the runtime
constraint aligns with those packages and prevents incompatible Node versions
from being allowed in CI or installs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bfe79f42-be18-4fbe-8761-1ef680884fb8

📥 Commits

Reviewing files that changed from the base of the PR and between 0477cdb and a9c164a.

📒 Files selected for processing (13)
  • .eslintrc.js
  • docs/examples/components/TooltipSlider.tsx
  • package.json
  • src/Handles/Handle.tsx
  • src/Handles/index.tsx
  • src/Slider.tsx
  • src/hooks/useDrag.ts
  • src/hooks/useRange.ts
  • src/index.tsx
  • tests/Range.test.tsx
  • tests/Slider.test.js
  • tests/common.test.js
  • tests/marks.test.js

Comment thread package.json
Comment on lines +59 to +60
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

python - <<'PY'
import json
with open('package.json','r',encoding='utf-8') as f:
    pkg=json.load(f)
print("package.json engines.node =", pkg.get("engines",{}).get("node"))
for name in ["`@typescript-eslint/eslint-plugin`","`@typescript-eslint/parser`","eslint"]:
    print(name, "=>", pkg.get("devDependencies",{}).get(name) or pkg.get("dependencies",{}).get(name))
PY

echo "---- published engines metadata ----"
npm view `@typescript-eslint/eslint-plugin`@5.62.0 engines --json
npm view `@typescript-eslint/parser`@5.62.0 engines --json
npm view eslint@8.54.0 engines --json

Repository: react-component/slider

Length of output: 383


同步提升 Node 引擎声明以匹配 typescript-eslint/eslint 的最低要求

engines.node 仍为 >=8.x,但 @typescript-eslint/eslint-plugin@5.62.0@typescript-eslint/parser@5.62.0(以及 eslint@8.54.0)的发布 engines.node 均要求 ^12.22.0 || ^14.17.0 || >=16.0.0,会导致不兼容 Node 版本被错误放行并在 lint/tsc 阶段失败。建议在本 PR 同步更新下限。

建议修改
  "engines": {
-    "node": ">=8.x"
+    "node": ">=12.22.0"
   }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@package.json` around lines 59 - 60, Update the package.json engines.node
declaration to match the minimum Node versions required by
`@typescript-eslint/eslint-plugin`, `@typescript-eslint/parser` and eslint; change
the engines.node field (in package.json) from ">=8.x" to "^12.22.0 || ^14.17.0
|| >=16.0.0" so the runtime constraint aligns with those packages and prevents
incompatible Node versions from being allowed in CI or installs.

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, including a major version bump for React to v18, and refactors imports across the codebase to avoid deep imports from internal packages like @rc-component/util. Feedback was provided regarding the ESLint configuration change that disables the switch-exhaustiveness-check rule, noting that it reduces type safety and appears unrelated to the primary goal of the PR.

Comment thread .eslintrc.js
'@typescript-eslint/no-explicit-any': 1,
'@typescript-eslint/no-empty-interface': 1,
'@typescript-eslint/no-inferrable-types': 0,
'@typescript-eslint/switch-exhaustiveness-check': 0,
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

Disabling the @typescript-eslint/switch-exhaustiveness-check rule reduces type safety by allowing switch statements on union types or enums to omit cases without a compile-time warning. This change appears unrelated to the primary goal of avoiding deep imports. If this was added to suppress errors from the newly added ESLint plugins, it is better to address the underlying issues or provide a specific reason for disabling it in the PR description.

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