From e769af57ff7b9f5e3f3d0e925f360143937eac22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E8=89=B3=E5=85=B5?= Date: Wed, 20 May 2026 11:33:33 +0800 Subject: [PATCH 1/2] chore: avoid rc deep imports --- .eslintrc.js | 15 +++++++++++++++ package.json | 4 ++-- src/Collapse.tsx | 3 +-- src/Panel.tsx | 2 +- src/hooks/useItems.tsx | 2 +- tests/index.spec.tsx | 2 +- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index c96e286a..0eeb1a23 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,13 +1,28 @@ const base = require('@umijs/fabric/dist/eslint'); +const disabledTypeScriptRules = { + '@typescript-eslint/ban-types': 0, + '@typescript-eslint/no-parameter-properties': 0, + '@typescript-eslint/no-throw-literal': 0, + '@typescript-eslint/type-annotation-spacing': 0, +}; + module.exports = { ...base, + overrides: base.overrides.map((override) => ({ + ...override, + rules: { + ...override.rules, + ...disabledTypeScriptRules, + }, + })), rules: { ...base.rules, 'no-template-curly-in-string': 0, 'prefer-promise-reject-errors': 0, 'react/no-array-index-key': 0, 'react/sort-comp': 0, + ...disabledTypeScriptRules, '@typescript-eslint/no-explicit-any': 0, 'jsx-a11y/role-supports-aria-props': 0, 'jsx-a11y/label-has-associated-control': 0, diff --git a/package.json b/package.json index 7b64aca2..e936676d 100644 --- a/package.json +++ b/package.json @@ -47,11 +47,11 @@ "dependencies": { "@babel/runtime": "^7.10.1", "@rc-component/motion": "^1.1.4", - "@rc-component/util": "^1.3.0", + "@rc-component/util": "^1.11.1", "clsx": "^2.1.1" }, "devDependencies": { - "@rc-component/father-plugin": "^2.0.1", + "@rc-component/father-plugin": "^2.2.0", "@rc-component/np": "^1.0.4", "@testing-library/jest-dom": "^6.1.4", "@testing-library/react": "^16.3.0", diff --git a/src/Collapse.tsx b/src/Collapse.tsx index 5348fd3a..c1a47e5e 100644 --- a/src/Collapse.tsx +++ b/src/Collapse.tsx @@ -1,11 +1,10 @@ import { clsx } from 'clsx'; import { useControlledState, useEvent } from '@rc-component/util'; -import warning from '@rc-component/util/lib/warning'; +import { pickAttrs, warning } from '@rc-component/util'; import React from 'react'; import useItems from './hooks/useItems'; import type { CollapseProps } from './interface'; import CollapsePanel from './Panel'; -import pickAttrs from '@rc-component/util/lib/pickAttrs'; function getActiveKeysArray(activeKey: React.Key | React.Key[]): React.Key[] { let currentActiveKey = activeKey; diff --git a/src/Panel.tsx b/src/Panel.tsx index 4fa1e34e..5dd97aca 100644 --- a/src/Panel.tsx +++ b/src/Panel.tsx @@ -1,6 +1,6 @@ import { clsx } from 'clsx'; import CSSMotion from '@rc-component/motion'; -import KeyCode from '@rc-component/util/lib/KeyCode'; +import { KeyCode } from '@rc-component/util'; import React from 'react'; import type { CollapsePanelProps } from './interface'; import PanelContent from './PanelContent'; diff --git a/src/hooks/useItems.tsx b/src/hooks/useItems.tsx index 1ee76f73..d3647e4c 100644 --- a/src/hooks/useItems.tsx +++ b/src/hooks/useItems.tsx @@ -1,4 +1,4 @@ -import toArray from '@rc-component/util/lib/Children/toArray'; +import { toArray } from '@rc-component/util'; import React from 'react'; import type { CollapsePanelProps, CollapseProps, ItemType } from '../interface'; import CollapsePanel from '../Panel'; diff --git a/tests/index.spec.tsx b/tests/index.spec.tsx index 1b2e1fc1..c509cb3c 100644 --- a/tests/index.spec.tsx +++ b/tests/index.spec.tsx @@ -1,6 +1,6 @@ import type { RenderResult } from '@testing-library/react'; import { fireEvent, render } from '@testing-library/react'; -import KeyCode from '@rc-component/util/lib/KeyCode'; +import { KeyCode } from '@rc-component/util'; import React, { Fragment } from 'react'; import Collapse, { Panel } from '../src/index'; import type { CollapseProps, ItemType } from '../src/interface'; From 49ba9fdbe2d90c2ee427643e044318bca8d78741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E8=89=B3=E5=85=B5?= Date: Wed, 20 May 2026 11:41:47 +0800 Subject: [PATCH 2/2] chore: address review comments --- .eslintrc.js | 2 +- src/Collapse.tsx | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 0eeb1a23..ecddee63 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -9,7 +9,7 @@ const disabledTypeScriptRules = { module.exports = { ...base, - overrides: base.overrides.map((override) => ({ + overrides: (base.overrides || []).map((override) => ({ ...override, rules: { ...override.rules, diff --git a/src/Collapse.tsx b/src/Collapse.tsx index c1a47e5e..43afc326 100644 --- a/src/Collapse.tsx +++ b/src/Collapse.tsx @@ -1,6 +1,5 @@ import { clsx } from 'clsx'; -import { useControlledState, useEvent } from '@rc-component/util'; -import { pickAttrs, warning } from '@rc-component/util'; +import { pickAttrs, useControlledState, useEvent, warning } from '@rc-component/util'; import React from 'react'; import useItems from './hooks/useItems'; import type { CollapseProps } from './interface';