From 22f29ec9d4f929b314c0611ab807cc8420b88d30 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 29 Jun 2026 18:19:19 +0800 Subject: [PATCH 01/18] chore: update maintenance dependencies --- .github/dependabot.yml | 8 ++++ README.md | 2 +- README.zh-CN.md | 2 +- eslint.config.mjs | 79 +++++++++++++++++++++++++++++++++++ global.d.ts | 58 +++++++++++++++++++++++++ package.json | 29 +++++++++---- react-compat.d.ts | 16 +++++++ src/utils/legacyUtil.ts | 8 ++-- src/utils/warningPropsUtil.ts | 26 ++++++------ tsconfig.json | 19 ++++++++- 10 files changed, 217 insertions(+), 30 deletions(-) create mode 100644 eslint.config.mjs create mode 100644 global.d.ts create mode 100644 react-compat.d.ts diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3b730ef9..5e6c7faa 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,6 +8,10 @@ updates: time: '21:00' timezone: Asia/Shanghai open-pull-requests-limit: 10 + groups: + npm-dependencies: + patterns: + - '*' - package-ecosystem: github-actions directory: '/' @@ -17,3 +21,7 @@ updates: time: '21:00' timezone: Asia/Shanghai open-pull-requests-limit: 10 + groups: + github-actions: + patterns: + - '*' diff --git a/README.md b/README.md index e48b94ed..7906ed19 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

@rc-component/select

-

Ant Design Part of the Ant Design ecosystem.

+

Ant Design Part of the Ant Design ecosystem.

🎯 Composable Select component for React, with search, async-friendly option data, custom rendering, and virtual scrolling.

diff --git a/README.zh-CN.md b/README.zh-CN.md index b84b8763..63759d62 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -1,6 +1,6 @@

@rc-component/select

-

Ant Design Ant Design 生态的一部分。

+

Ant Design Ant Design 生态的一部分。

🎯 React 选择器组件,支持单选、多选、搜索、标签和自定义渲染。

diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..b25fb5dd --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,79 @@ +import { FlatCompat } from '@eslint/eslintrc'; +import js from '@eslint/js'; +import tsEslintPlugin from '@typescript-eslint/eslint-plugin'; +import { createRequire } from 'node:module'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const require = createRequire(import.meta.url); + +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all, +}); + +const recommendedTsRules = new Set(Object.keys(tsEslintPlugin.configs.recommended.rules || {})); +const noopRule = { + meta: { type: 'problem', docs: {}, schema: [] }, + create: () => ({}), +}; + +function normalizeConfig(config) { + const next = { ...config }; + + if (next.plugins?.['@typescript-eslint']) { + next.plugins = { + ...next.plugins, + '@typescript-eslint': { + ...next.plugins['@typescript-eslint'], + rules: { + ...next.plugins['@typescript-eslint'].rules, + 'ban-types': noopRule, + }, + }, + }; + } + + if (next.rules) { + next.rules = Object.fromEntries( + Object.entries(next.rules).filter(([ruleName]) => { + if (!ruleName.startsWith('@typescript-eslint/')) { + return true; + } + return recommendedTsRules.has(ruleName) || ruleName === '@typescript-eslint/ban-types'; + }), + ); + } + + return next; +} + +export default [ + { + ignores: [ + 'node_modules/', + 'coverage/', + 'es/', + 'lib/', + 'dist/', + 'docs-dist/', + '.dumi/', + '.doc/', + '.vercel/', + '.eslintrc.js', + 'src/index.d.ts', + ], + }, + ...compat.config(require('./.eslintrc.js')).map(normalizeConfig), + { + rules: { + '@typescript-eslint/ban-types': 'off', + '@typescript-eslint/no-empty-object-type': 'off', + '@typescript-eslint/no-unsafe-function-type': 'off', + '@typescript-eslint/no-unused-vars': 'off', + }, + }, +]; diff --git a/global.d.ts b/global.d.ts new file mode 100644 index 00000000..e4a99d8a --- /dev/null +++ b/global.d.ts @@ -0,0 +1,58 @@ +/// +/// +/// +/// +/// + +declare module '*.css'; +declare module '*.less'; +declare module 'jsonp'; + +declare namespace JSX { + type Element = React.JSX.Element; + interface ElementClass extends React.JSX.ElementClass {} + interface ElementAttributesProperty extends React.JSX.ElementAttributesProperty {} + interface ElementChildrenAttribute extends React.JSX.ElementChildrenAttribute {} + type LibraryManagedAttributes = React.JSX.LibraryManagedAttributes; + interface IntrinsicAttributes extends React.JSX.IntrinsicAttributes {} + interface IntrinsicClassAttributes extends React.JSX.IntrinsicClassAttributes {} + interface IntrinsicElements extends React.JSX.IntrinsicElements {} +} + +declare namespace jest { + interface Matchers { + lastCalledWith(...expected: unknown[]): R; + nthCalledWith(nthCall: number, ...expected: unknown[]): R; + toBeCalled(): R; + toBeCalledTimes(expected: number): R; + toBeCalledWith(...expected: unknown[]): R; + } +} + +declare const vi: { + fn: any = (...args: any[]) => any>( + implementation?: T, + ) => jest.MockedFunction; + mock: (moduleName: string, factory?: (importOriginal: () => Promise) => unknown) => void; + spyOn: typeof jest.spyOn; + useFakeTimers: () => void; + useRealTimers: () => void; + advanceTimersByTime: (msToRun: number) => void; + clearAllTimers: () => void; + runAllTimers: () => void; + importActual: (moduleName: string) => Promise; + clearAllMocks: () => void; + resetAllMocks: () => void; + restoreAllMocks: () => void; +}; + +declare const describe: any; +declare const it: any; +declare const test: any; +declare const beforeEach: any; +declare const afterEach: any; +declare const beforeAll: any; +declare const afterAll: any; +declare const expect: any; + +declare module 'moment/locale/zh-cn'; diff --git a/package.json b/package.json index c0570d6d..400f93f8 100644 --- a/package.json +++ b/package.json @@ -59,26 +59,37 @@ "@rc-component/father-plugin": "^2.2.0", "@rc-component/np": "^1.0.4", "@testing-library/jest-dom": "^6.9.1", - "@testing-library/react": "^15.0.7", - "@types/jest": "^29.5.14", + "@testing-library/react": "^16.3.2", + "@types/jest": "^30.0.0", "@types/node": "^26.0.1", - "@types/react": "^18.3.31", - "@types/react-dom": "^18.3.7", + "@types/react": "^19.2.17", + "@types/react-dom": "^19.2.3", "@umijs/fabric": "^4.0.1", "babel-jest": "^29.7.0", "dumi": "^2.4.35", - "eslint": "^8.57.1", + "eslint": "^9.39.4", "father": "^4.6.23", "husky": "^9.1.7", "jsonp": "^0.2.1", "less": "^4.6.7", - "lint-staged": "^16.4.0", + "lint-staged": "^17.0.8", "prettier": "^3.9.0", "querystring": "^0.2.1", "rc-test": "^7.1.3", - "react": "^18.3.1", - "react-dom": "^18.3.1", - "typescript": "^5.9.3" + "react": "^19.2.7", + "react-dom": "^19.2.7", + "typescript": "^6.0.3", + "@eslint/eslintrc": "^3.3.5", + "@eslint/js": "^9.39.4", + "eslint-plugin-react": "^7.37.5", + "eslint-plugin-react-hooks": "^7.1.1", + "eslint-config-prettier": "^10.1.8", + "@babel/eslint-parser": "^7.29.7", + "@babel/eslint-plugin": "^7.29.7", + "@typescript-eslint/eslint-plugin": "^8.62.0", + "@typescript-eslint/parser": "^8.62.0", + "eslint-plugin-jest": "^29.15.3", + "eslint-plugin-unicorn": "^65.0.1" }, "publishConfig": { "access": "public" diff --git a/react-compat.d.ts b/react-compat.d.ts new file mode 100644 index 00000000..ff05aa1b --- /dev/null +++ b/react-compat.d.ts @@ -0,0 +1,16 @@ +import * as React from 'react'; + +declare module 'react' { + type ReactText = string | number; + function useRef(): React.MutableRefObject; + function isValidElement

(object: {} | null | undefined): object is React.ReactElement

; + function cloneElement

( + element: React.ReactElement

, + props?: (Partial

& React.Attributes) | null, + ...children: React.ReactNode[] + ): React.ReactElement

; +} + +declare module 'react-dom' { + function hydrate(element: React.ReactNode, container: Element | DocumentFragment): void; +} diff --git a/src/utils/legacyUtil.ts b/src/utils/legacyUtil.ts index 3e9a449a..cd069edb 100644 --- a/src/utils/legacyUtil.ts +++ b/src/utils/legacyUtil.ts @@ -3,12 +3,12 @@ import { toArray } from '@rc-component/util'; import type { BaseOptionType, DefaultOptionType } from '../Select'; function convertNodeToOption( - node: React.ReactElement, + node: React.ReactElement, ): OptionType { const { key, props: { children, value, ...restProps }, - } = node as React.ReactElement; + } = node as React.ReactElement; return { key, value: value !== undefined ? value : key, children, ...restProps }; } @@ -18,7 +18,7 @@ export function convertChildrenToData { + .map((node: React.ReactElement, index: number): OptionType | null => { if (!React.isValidElement(node) || !node.type) { return null; } @@ -27,7 +27,7 @@ export function convertChildrenToData & { type: { isSelectOptGroup?: boolean } }; if (optionOnly || !isSelectOptGroup) { return convertNodeToOption(node); diff --git a/src/utils/warningPropsUtil.ts b/src/utils/warningPropsUtil.ts index c5560894..e6f96ae3 100644 --- a/src/utils/warningPropsUtil.ts +++ b/src/utils/warningPropsUtil.ts @@ -116,19 +116,19 @@ function warningProps(props: SelectProps) { return false; } if (type.isSelectOptGroup) { - const allChildrenValid = toNodeArray(node.props.children).every( - (subNode: React.ReactElement) => { - if ( - !React.isValidElement(subNode) || - !node.type || - (subNode.type as { isSelectOption?: boolean }).isSelectOption - ) { - return true; - } - invalidateChildType = subNode.type; - return false; - }, - ); + const allChildrenValid = toNodeArray( + (node as React.ReactElement).props.children, + ).every((subNode: React.ReactElement) => { + if ( + !React.isValidElement(subNode) || + !node.type || + (subNode.type as { isSelectOption?: boolean }).isSelectOption + ) { + return true; + } + invalidateChildType = subNode.type; + return false; + }); if (allChildrenValid) { return false; diff --git a/tsconfig.json b/tsconfig.json index eec0a112..f8433c73 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,7 +12,22 @@ "@@/*": [".dumi/tmp/*"], "@rc-component/select": ["src/index.ts"] }, - "ignoreDeprecations": "5.0" + "ignoreDeprecations": "6.0", + "noImplicitAny": false, + "strictNullChecks": false, + "strictPropertyInitialization": false, + "strictFunctionTypes": false, + "strict": false, + "noImplicitThis": false, + "strictBindCallApply": false }, - "include": [".dumirc.ts", ".fatherrc.ts", "src", "tests", "docs"] + "include": [ + "react-compat.d.ts", + "global.d.ts", + ".dumirc.ts", + ".fatherrc.ts", + "src", + "tests", + "docs" + ] } From 26d3e8e6f72fdd1455f80af10a84711b093ff065 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 30 Jun 2026 10:20:53 +0800 Subject: [PATCH 02/18] fix: align TypeScript and ESLint compatibility --- eslint.config.mjs | 24 ++++++++++++++---------- global.d.ts | 9 --------- tsconfig.json | 13 ++++++------- 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index b25fb5dd..d85381ec 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -25,16 +25,8 @@ function normalizeConfig(config) { const next = { ...config }; if (next.plugins?.['@typescript-eslint']) { - next.plugins = { - ...next.plugins, - '@typescript-eslint': { - ...next.plugins['@typescript-eslint'], - rules: { - ...next.plugins['@typescript-eslint'].rules, - 'ban-types': noopRule, - }, - }, - }; + next.plugins = { ...next.plugins }; + delete next.plugins['@typescript-eslint']; } if (next.rules) { @@ -67,6 +59,18 @@ export default [ 'src/index.d.ts', ], }, + { + plugins: { + '@typescript-eslint': { + ...tsEslintPlugin, + rules: { + ...tsEslintPlugin.rules, + 'ban-types': noopRule, + 'consistent-type-exports': noopRule, + }, + }, + }, + }, ...compat.config(require('./.eslintrc.js')).map(normalizeConfig), { rules: { diff --git a/global.d.ts b/global.d.ts index e4a99d8a..85e4e4e7 100644 --- a/global.d.ts +++ b/global.d.ts @@ -46,13 +46,4 @@ declare const vi: { restoreAllMocks: () => void; }; -declare const describe: any; -declare const it: any; -declare const test: any; -declare const beforeEach: any; -declare const afterEach: any; -declare const beforeAll: any; -declare const afterAll: any; -declare const expect: any; - declare module 'moment/locale/zh-cn'; diff --git a/tsconfig.json b/tsconfig.json index f8433c73..31eb4b16 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,25 +1,24 @@ { "compilerOptions": { "target": "esnext", - "moduleResolution": "node", - "baseUrl": "./", + "moduleResolution": "bundler", "jsx": "preserve", "declaration": true, "skipLibCheck": true, "esModuleInterop": true, "paths": { - "@/*": ["src/*"], - "@@/*": [".dumi/tmp/*"], - "@rc-component/select": ["src/index.ts"] + "@/*": ["./src/*"], + "@@/*": ["./.dumi/tmp/*"], + "@rc-component/select": ["./src/index.ts"] }, - "ignoreDeprecations": "6.0", "noImplicitAny": false, "strictNullChecks": false, "strictPropertyInitialization": false, "strictFunctionTypes": false, "strict": false, "noImplicitThis": false, - "strictBindCallApply": false + "strictBindCallApply": false, + "module": "ESNext" }, "include": [ "react-compat.d.ts", From d0b16cc5dd7e334f9ea037fdd353b6b99b1e540f Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 30 Jun 2026 10:51:05 +0800 Subject: [PATCH 03/18] chore: use testing-library dom events --- package.json | 25 +++++++++++++------------ tests/Accessibility.test.tsx | 3 ++- tests/BaseSelect.test.tsx | 3 ++- tests/Combobox.test.tsx | 3 ++- tests/Custom.test.tsx | 3 ++- tests/Field.test.tsx | 3 ++- tests/Group.test.tsx | 3 ++- tests/Multiple.test.tsx | 3 ++- tests/OptionList.test.tsx | 3 ++- tests/Popup.test.tsx | 3 ++- tests/Select.test.tsx | 9 ++------- tests/Tags.test.tsx | 3 ++- tests/components.test.tsx | 3 ++- tests/focus.test.tsx | 3 ++- tests/shared/allowClearTest.tsx | 3 ++- tests/shared/blurTest.tsx | 3 ++- tests/shared/hoverTest.tsx | 3 ++- tests/shared/inputFilterTest.tsx | 3 ++- tests/shared/keyDownTest.tsx | 3 ++- tests/utils/common.ts | 2 +- 20 files changed, 50 insertions(+), 37 deletions(-) diff --git a/package.json b/package.json index 400f93f8..4bf83498 100644 --- a/package.json +++ b/package.json @@ -55,19 +55,31 @@ "clsx": "^2.1.1" }, "devDependencies": { + "@babel/eslint-parser": "^7.29.7", + "@babel/eslint-plugin": "^7.29.7", + "@eslint/eslintrc": "^3.3.5", + "@eslint/js": "^9.39.4", "@rc-component/dialog": "^1.10.0", "@rc-component/father-plugin": "^2.2.0", "@rc-component/np": "^1.0.4", + "@testing-library/dom": "^10.4.1", "@testing-library/jest-dom": "^6.9.1", "@testing-library/react": "^16.3.2", "@types/jest": "^30.0.0", "@types/node": "^26.0.1", "@types/react": "^19.2.17", "@types/react-dom": "^19.2.3", + "@typescript-eslint/eslint-plugin": "^8.62.0", + "@typescript-eslint/parser": "^8.62.0", "@umijs/fabric": "^4.0.1", "babel-jest": "^29.7.0", "dumi": "^2.4.35", "eslint": "^9.39.4", + "eslint-config-prettier": "^10.1.8", + "eslint-plugin-jest": "^29.15.3", + "eslint-plugin-react": "^7.37.5", + "eslint-plugin-react-hooks": "^7.1.1", + "eslint-plugin-unicorn": "^65.0.1", "father": "^4.6.23", "husky": "^9.1.7", "jsonp": "^0.2.1", @@ -78,18 +90,7 @@ "rc-test": "^7.1.3", "react": "^19.2.7", "react-dom": "^19.2.7", - "typescript": "^6.0.3", - "@eslint/eslintrc": "^3.3.5", - "@eslint/js": "^9.39.4", - "eslint-plugin-react": "^7.37.5", - "eslint-plugin-react-hooks": "^7.1.1", - "eslint-config-prettier": "^10.1.8", - "@babel/eslint-parser": "^7.29.7", - "@babel/eslint-plugin": "^7.29.7", - "@typescript-eslint/eslint-plugin": "^8.62.0", - "@typescript-eslint/parser": "^8.62.0", - "eslint-plugin-jest": "^29.15.3", - "eslint-plugin-unicorn": "^65.0.1" + "typescript": "^6.0.3" }, "publishConfig": { "access": "public" diff --git a/tests/Accessibility.test.tsx b/tests/Accessibility.test.tsx index ef8b90c1..ad3f02c7 100644 --- a/tests/Accessibility.test.tsx +++ b/tests/Accessibility.test.tsx @@ -1,8 +1,9 @@ +import { fireEvent } from '@testing-library/dom'; import * as React from 'react'; import { KeyCode } from '@rc-component/util'; import Select from '../src'; import { injectRunAllTimers, expectOpen, keyDown } from './utils/common'; -import { act, fireEvent, render } from '@testing-library/react'; +import { act, render } from '@testing-library/react'; describe('Select.Accessibility', () => { injectRunAllTimers(jest); diff --git a/tests/BaseSelect.test.tsx b/tests/BaseSelect.test.tsx index d107743d..075fe968 100644 --- a/tests/BaseSelect.test.tsx +++ b/tests/BaseSelect.test.tsx @@ -1,5 +1,6 @@ +import { fireEvent } from '@testing-library/dom'; import type { OptionListProps, RefOptionListProps } from '../src/OptionList'; -import { fireEvent, render } from '@testing-library/react'; +import { render } from '@testing-library/react'; import { forwardRef, act } from 'react'; import BaseSelect from '../src/BaseSelect'; import { waitFakeTimer } from './utils/common'; diff --git a/tests/Combobox.test.tsx b/tests/Combobox.test.tsx index 9b93fafc..a8ff04ad 100644 --- a/tests/Combobox.test.tsx +++ b/tests/Combobox.test.tsx @@ -1,7 +1,8 @@ +import { createEvent, fireEvent } from '@testing-library/dom'; /* eslint-disable max-classes-per-file */ import '@testing-library/jest-dom'; -import { createEvent, fireEvent, render } from '@testing-library/react'; +import { render } from '@testing-library/react'; import { KeyCode, resetWarned } from '@rc-component/util'; import React, { act } from 'react'; import type { SelectProps } from '../src'; diff --git a/tests/Custom.test.tsx b/tests/Custom.test.tsx index 5a60d839..ef6ea7b5 100644 --- a/tests/Custom.test.tsx +++ b/tests/Custom.test.tsx @@ -1,7 +1,8 @@ +import { fireEvent } from '@testing-library/dom'; import * as React from 'react'; import Select from '../src'; import { injectRunAllTimers, waitFakeTimer } from './utils/common'; -import { fireEvent, render } from '@testing-library/react'; +import { render } from '@testing-library/react'; describe('Select.Custom', () => { injectRunAllTimers(jest); diff --git a/tests/Field.test.tsx b/tests/Field.test.tsx index e9e0537e..11a49e4c 100644 --- a/tests/Field.test.tsx +++ b/tests/Field.test.tsx @@ -1,8 +1,9 @@ +import { fireEvent } from '@testing-library/dom'; import React, { act } from 'react'; import Select from '../src'; import type { SelectProps } from '../src'; import { injectRunAllTimers } from './utils/common'; -import { fireEvent, render } from '@testing-library/react'; +import { render } from '@testing-library/react'; describe('Select.Field', () => { injectRunAllTimers(jest); diff --git a/tests/Group.test.tsx b/tests/Group.test.tsx index 50f87178..f65fbb6c 100644 --- a/tests/Group.test.tsx +++ b/tests/Group.test.tsx @@ -1,6 +1,7 @@ +import { fireEvent } from '@testing-library/dom'; import * as React from 'react'; import Select, { OptGroup, Option } from '../src'; -import { fireEvent, render } from '@testing-library/react'; +import { render } from '@testing-library/react'; describe('Select.Group', () => { it('group name support search', () => { diff --git a/tests/Multiple.test.tsx b/tests/Multiple.test.tsx index e234ae83..39f20047 100644 --- a/tests/Multiple.test.tsx +++ b/tests/Multiple.test.tsx @@ -1,3 +1,4 @@ +import { fireEvent } from '@testing-library/dom'; import { KeyCode } from '@rc-component/util'; import React from 'react'; import Select, { Option, OptGroup } from '../src'; @@ -19,7 +20,7 @@ import { keyUp, } from './utils/common'; import allowClearTest from './shared/allowClearTest'; -import { act, fireEvent, render, screen } from '@testing-library/react'; +import { act, render, screen } from '@testing-library/react'; describe('Select.Multiple', () => { injectRunAllTimers(jest); diff --git a/tests/OptionList.test.tsx b/tests/OptionList.test.tsx index 745ca872..5654796e 100644 --- a/tests/OptionList.test.tsx +++ b/tests/OptionList.test.tsx @@ -1,3 +1,4 @@ +import { createEvent, fireEvent } from '@testing-library/dom'; import { KeyCode, spyElementPrototypes } from '@rc-component/util'; import React, { act } from 'react'; import { BaseSelectContext } from '../src/hooks/useBaseProps'; @@ -6,7 +7,7 @@ import OptionList from '../src/OptionList'; import SelectContext from '../src/SelectContext'; import { fillFieldNames, flattenOptions } from '../src/utils/valueUtil'; import { injectRunAllTimers } from './utils/common'; -import { createEvent, fireEvent, render, waitFor } from '@testing-library/react'; +import { render, waitFor } from '@testing-library/react'; import Select from '../src'; jest.mock('../src/utils/platformUtil'); diff --git a/tests/Popup.test.tsx b/tests/Popup.test.tsx index 8b2a371f..69b6f548 100644 --- a/tests/Popup.test.tsx +++ b/tests/Popup.test.tsx @@ -1,4 +1,5 @@ -import { fireEvent, render } from '@testing-library/react'; +import { fireEvent } from '@testing-library/dom'; +import { render } from '@testing-library/react'; import React from 'react'; import Select from '../src'; import { injectRunAllTimers } from './utils/common'; diff --git a/tests/Select.test.tsx b/tests/Select.test.tsx index 922aa495..f91951ff 100644 --- a/tests/Select.test.tsx +++ b/tests/Select.test.tsx @@ -1,11 +1,6 @@ +import { createEvent, fireEvent } from '@testing-library/dom'; import type { LabelInValueType } from '@/Select'; -import { - createEvent, - fireEvent, - render, - render as testingRender, - act, -} from '@testing-library/react'; +import { render, render as testingRender, act } from '@testing-library/react'; import { KeyCode, resetWarned, spyElementPrototypes } from '@rc-component/util'; import type { ScrollConfig } from '@rc-component/virtual-list'; import React, { StrictMode } from 'react'; diff --git a/tests/Tags.test.tsx b/tests/Tags.test.tsx index 5a4ad6e6..246a0990 100644 --- a/tests/Tags.test.tsx +++ b/tests/Tags.test.tsx @@ -1,4 +1,5 @@ -import { createEvent, fireEvent, render } from '@testing-library/react'; +import { createEvent, fireEvent } from '@testing-library/dom'; +import { render } from '@testing-library/react'; import { KeyCode } from '@rc-component/util'; import { clsx } from 'clsx'; import * as React from 'react'; diff --git a/tests/components.test.tsx b/tests/components.test.tsx index 8d88e694..bc5b2339 100644 --- a/tests/components.test.tsx +++ b/tests/components.test.tsx @@ -1,4 +1,5 @@ -import { createEvent, fireEvent, render } from '@testing-library/react'; +import { createEvent, fireEvent } from '@testing-library/dom'; +import { render } from '@testing-library/react'; import React from 'react'; import Select from '../src'; import { injectRunAllTimers } from './utils/common'; diff --git a/tests/focus.test.tsx b/tests/focus.test.tsx index dc13cc52..13685a1b 100644 --- a/tests/focus.test.tsx +++ b/tests/focus.test.tsx @@ -1,6 +1,7 @@ +import { fireEvent } from '@testing-library/dom'; import React, { useState, act } from 'react'; import Select from '../src'; -import { fireEvent, render } from '@testing-library/react'; +import { render } from '@testing-library/react'; describe('Select.Focus', () => { beforeEach(() => { diff --git a/tests/shared/allowClearTest.tsx b/tests/shared/allowClearTest.tsx index 012f79fc..acdb63bf 100644 --- a/tests/shared/allowClearTest.tsx +++ b/tests/shared/allowClearTest.tsx @@ -1,6 +1,7 @@ +import { createEvent, fireEvent } from '@testing-library/dom'; import * as React from 'react'; import Select, { Option } from '../../src'; -import { createEvent, fireEvent, render } from '@testing-library/react'; +import { render } from '@testing-library/react'; export default function allowClearTest(mode: any, value: any) { describe('allowClear', () => { diff --git a/tests/shared/blurTest.tsx b/tests/shared/blurTest.tsx index 61c5503d..a953d8eb 100644 --- a/tests/shared/blurTest.tsx +++ b/tests/shared/blurTest.tsx @@ -1,8 +1,9 @@ +import { fireEvent, createEvent } from '@testing-library/dom'; import React from 'react'; import Option from '../../src/Option'; import Select from '../../src/Select'; import { injectRunAllTimers } from '../utils/common'; -import { type RenderResult, render, fireEvent, createEvent, act } from '@testing-library/react'; +import { type RenderResult, render, act } from '@testing-library/react'; export default function blurTest(mode: any) { describe(`blur of ${mode}`, () => { diff --git a/tests/shared/hoverTest.tsx b/tests/shared/hoverTest.tsx index 0c0f39ae..2e1821c7 100644 --- a/tests/shared/hoverTest.tsx +++ b/tests/shared/hoverTest.tsx @@ -1,6 +1,7 @@ +import { fireEvent } from '@testing-library/dom'; import * as React from 'react'; import Select, { Option } from '../../src'; -import { fireEvent, render } from '@testing-library/react'; +import { render } from '@testing-library/react'; export default function hoverTest(mode: any) { it('triggers mouseEnter and mouseLeave', () => { diff --git a/tests/shared/inputFilterTest.tsx b/tests/shared/inputFilterTest.tsx index f189f609..2a54e487 100644 --- a/tests/shared/inputFilterTest.tsx +++ b/tests/shared/inputFilterTest.tsx @@ -1,7 +1,8 @@ +import { fireEvent } from '@testing-library/dom'; import * as React from 'react'; import Option from '../../src/Option'; import Select from '../../src/Select'; -import { act, fireEvent, render } from '@testing-library/react'; +import { act, render } from '@testing-library/react'; export default function inputFilterTest(mode: any) { it('should keep input filter after select when autoClearSearchValue is false', () => { diff --git a/tests/shared/keyDownTest.tsx b/tests/shared/keyDownTest.tsx index 9061de54..28f6f77c 100644 --- a/tests/shared/keyDownTest.tsx +++ b/tests/shared/keyDownTest.tsx @@ -1,7 +1,8 @@ +import { fireEvent } from '@testing-library/dom'; import * as React from 'react'; import Option from '../../src/Option'; import Select from '../../src/Select'; -import { fireEvent, render } from '@testing-library/react'; +import { render } from '@testing-library/react'; export default function keyDownTest(mode: any) { it('triggers keyDown', () => { diff --git a/tests/utils/common.ts b/tests/utils/common.ts index a8da1cce..37060b9e 100644 --- a/tests/utils/common.ts +++ b/tests/utils/common.ts @@ -1,5 +1,5 @@ +import { createEvent, fireEvent } from '@testing-library/dom'; import { act } from 'react'; -import { createEvent, fireEvent } from '@testing-library/react'; export function expectOpen(wrapper: any, open: boolean = true) { if (wrapper instanceof HTMLElement) { From 5f5786a081a37723c39d7c422876e2110411155c Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 30 Jun 2026 11:16:11 +0800 Subject: [PATCH 04/18] test: keep react testing event behavior --- tests/Accessibility.test.tsx | 3 +-- tests/BaseSelect.test.tsx | 3 +-- tests/Combobox.test.tsx | 3 +-- tests/Custom.test.tsx | 3 +-- tests/Field.test.tsx | 3 +-- tests/Group.test.tsx | 3 +-- tests/Multiple.test.tsx | 3 +-- tests/OptionList.test.tsx | 3 +-- tests/Popup.test.tsx | 3 +-- tests/Select.test.tsx | 9 +++++++-- tests/Tags.test.tsx | 3 +-- tests/__snapshots__/ssr.test.tsx.snap | 2 +- tests/components.test.tsx | 3 +-- tests/focus.test.tsx | 3 +-- tests/shared/allowClearTest.tsx | 3 +-- tests/shared/blurTest.tsx | 3 +-- tests/shared/hoverTest.tsx | 3 +-- tests/shared/inputFilterTest.tsx | 3 +-- tests/shared/keyDownTest.tsx | 3 +-- tests/utils/common.ts | 2 +- 20 files changed, 26 insertions(+), 38 deletions(-) diff --git a/tests/Accessibility.test.tsx b/tests/Accessibility.test.tsx index ad3f02c7..ef8b90c1 100644 --- a/tests/Accessibility.test.tsx +++ b/tests/Accessibility.test.tsx @@ -1,9 +1,8 @@ -import { fireEvent } from '@testing-library/dom'; import * as React from 'react'; import { KeyCode } from '@rc-component/util'; import Select from '../src'; import { injectRunAllTimers, expectOpen, keyDown } from './utils/common'; -import { act, render } from '@testing-library/react'; +import { act, fireEvent, render } from '@testing-library/react'; describe('Select.Accessibility', () => { injectRunAllTimers(jest); diff --git a/tests/BaseSelect.test.tsx b/tests/BaseSelect.test.tsx index 075fe968..d107743d 100644 --- a/tests/BaseSelect.test.tsx +++ b/tests/BaseSelect.test.tsx @@ -1,6 +1,5 @@ -import { fireEvent } from '@testing-library/dom'; import type { OptionListProps, RefOptionListProps } from '../src/OptionList'; -import { render } from '@testing-library/react'; +import { fireEvent, render } from '@testing-library/react'; import { forwardRef, act } from 'react'; import BaseSelect from '../src/BaseSelect'; import { waitFakeTimer } from './utils/common'; diff --git a/tests/Combobox.test.tsx b/tests/Combobox.test.tsx index a8ff04ad..9b93fafc 100644 --- a/tests/Combobox.test.tsx +++ b/tests/Combobox.test.tsx @@ -1,8 +1,7 @@ -import { createEvent, fireEvent } from '@testing-library/dom'; /* eslint-disable max-classes-per-file */ import '@testing-library/jest-dom'; -import { render } from '@testing-library/react'; +import { createEvent, fireEvent, render } from '@testing-library/react'; import { KeyCode, resetWarned } from '@rc-component/util'; import React, { act } from 'react'; import type { SelectProps } from '../src'; diff --git a/tests/Custom.test.tsx b/tests/Custom.test.tsx index ef6ea7b5..5a60d839 100644 --- a/tests/Custom.test.tsx +++ b/tests/Custom.test.tsx @@ -1,8 +1,7 @@ -import { fireEvent } from '@testing-library/dom'; import * as React from 'react'; import Select from '../src'; import { injectRunAllTimers, waitFakeTimer } from './utils/common'; -import { render } from '@testing-library/react'; +import { fireEvent, render } from '@testing-library/react'; describe('Select.Custom', () => { injectRunAllTimers(jest); diff --git a/tests/Field.test.tsx b/tests/Field.test.tsx index 11a49e4c..e9e0537e 100644 --- a/tests/Field.test.tsx +++ b/tests/Field.test.tsx @@ -1,9 +1,8 @@ -import { fireEvent } from '@testing-library/dom'; import React, { act } from 'react'; import Select from '../src'; import type { SelectProps } from '../src'; import { injectRunAllTimers } from './utils/common'; -import { render } from '@testing-library/react'; +import { fireEvent, render } from '@testing-library/react'; describe('Select.Field', () => { injectRunAllTimers(jest); diff --git a/tests/Group.test.tsx b/tests/Group.test.tsx index f65fbb6c..50f87178 100644 --- a/tests/Group.test.tsx +++ b/tests/Group.test.tsx @@ -1,7 +1,6 @@ -import { fireEvent } from '@testing-library/dom'; import * as React from 'react'; import Select, { OptGroup, Option } from '../src'; -import { render } from '@testing-library/react'; +import { fireEvent, render } from '@testing-library/react'; describe('Select.Group', () => { it('group name support search', () => { diff --git a/tests/Multiple.test.tsx b/tests/Multiple.test.tsx index 39f20047..e234ae83 100644 --- a/tests/Multiple.test.tsx +++ b/tests/Multiple.test.tsx @@ -1,4 +1,3 @@ -import { fireEvent } from '@testing-library/dom'; import { KeyCode } from '@rc-component/util'; import React from 'react'; import Select, { Option, OptGroup } from '../src'; @@ -20,7 +19,7 @@ import { keyUp, } from './utils/common'; import allowClearTest from './shared/allowClearTest'; -import { act, render, screen } from '@testing-library/react'; +import { act, fireEvent, render, screen } from '@testing-library/react'; describe('Select.Multiple', () => { injectRunAllTimers(jest); diff --git a/tests/OptionList.test.tsx b/tests/OptionList.test.tsx index 5654796e..745ca872 100644 --- a/tests/OptionList.test.tsx +++ b/tests/OptionList.test.tsx @@ -1,4 +1,3 @@ -import { createEvent, fireEvent } from '@testing-library/dom'; import { KeyCode, spyElementPrototypes } from '@rc-component/util'; import React, { act } from 'react'; import { BaseSelectContext } from '../src/hooks/useBaseProps'; @@ -7,7 +6,7 @@ import OptionList from '../src/OptionList'; import SelectContext from '../src/SelectContext'; import { fillFieldNames, flattenOptions } from '../src/utils/valueUtil'; import { injectRunAllTimers } from './utils/common'; -import { render, waitFor } from '@testing-library/react'; +import { createEvent, fireEvent, render, waitFor } from '@testing-library/react'; import Select from '../src'; jest.mock('../src/utils/platformUtil'); diff --git a/tests/Popup.test.tsx b/tests/Popup.test.tsx index 69b6f548..8b2a371f 100644 --- a/tests/Popup.test.tsx +++ b/tests/Popup.test.tsx @@ -1,5 +1,4 @@ -import { fireEvent } from '@testing-library/dom'; -import { render } from '@testing-library/react'; +import { fireEvent, render } from '@testing-library/react'; import React from 'react'; import Select from '../src'; import { injectRunAllTimers } from './utils/common'; diff --git a/tests/Select.test.tsx b/tests/Select.test.tsx index f91951ff..922aa495 100644 --- a/tests/Select.test.tsx +++ b/tests/Select.test.tsx @@ -1,6 +1,11 @@ -import { createEvent, fireEvent } from '@testing-library/dom'; import type { LabelInValueType } from '@/Select'; -import { render, render as testingRender, act } from '@testing-library/react'; +import { + createEvent, + fireEvent, + render, + render as testingRender, + act, +} from '@testing-library/react'; import { KeyCode, resetWarned, spyElementPrototypes } from '@rc-component/util'; import type { ScrollConfig } from '@rc-component/virtual-list'; import React, { StrictMode } from 'react'; diff --git a/tests/Tags.test.tsx b/tests/Tags.test.tsx index 246a0990..5a4ad6e6 100644 --- a/tests/Tags.test.tsx +++ b/tests/Tags.test.tsx @@ -1,5 +1,4 @@ -import { createEvent, fireEvent } from '@testing-library/dom'; -import { render } from '@testing-library/react'; +import { createEvent, fireEvent, render } from '@testing-library/react'; import { KeyCode } from '@rc-component/util'; import { clsx } from 'clsx'; import * as React from 'react'; diff --git a/tests/__snapshots__/ssr.test.tsx.snap b/tests/__snapshots__/ssr.test.tsx.snap index 9f1c6c0f..52f5328b 100644 --- a/tests/__snapshots__/ssr.test.tsx.snap +++ b/tests/__snapshots__/ssr.test.tsx.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Select.SSR should work 1`] = `"

"`; +exports[`Select.SSR should work 1`] = `"
"`; diff --git a/tests/components.test.tsx b/tests/components.test.tsx index bc5b2339..8d88e694 100644 --- a/tests/components.test.tsx +++ b/tests/components.test.tsx @@ -1,5 +1,4 @@ -import { createEvent, fireEvent } from '@testing-library/dom'; -import { render } from '@testing-library/react'; +import { createEvent, fireEvent, render } from '@testing-library/react'; import React from 'react'; import Select from '../src'; import { injectRunAllTimers } from './utils/common'; diff --git a/tests/focus.test.tsx b/tests/focus.test.tsx index 13685a1b..dc13cc52 100644 --- a/tests/focus.test.tsx +++ b/tests/focus.test.tsx @@ -1,7 +1,6 @@ -import { fireEvent } from '@testing-library/dom'; import React, { useState, act } from 'react'; import Select from '../src'; -import { render } from '@testing-library/react'; +import { fireEvent, render } from '@testing-library/react'; describe('Select.Focus', () => { beforeEach(() => { diff --git a/tests/shared/allowClearTest.tsx b/tests/shared/allowClearTest.tsx index acdb63bf..012f79fc 100644 --- a/tests/shared/allowClearTest.tsx +++ b/tests/shared/allowClearTest.tsx @@ -1,7 +1,6 @@ -import { createEvent, fireEvent } from '@testing-library/dom'; import * as React from 'react'; import Select, { Option } from '../../src'; -import { render } from '@testing-library/react'; +import { createEvent, fireEvent, render } from '@testing-library/react'; export default function allowClearTest(mode: any, value: any) { describe('allowClear', () => { diff --git a/tests/shared/blurTest.tsx b/tests/shared/blurTest.tsx index a953d8eb..61c5503d 100644 --- a/tests/shared/blurTest.tsx +++ b/tests/shared/blurTest.tsx @@ -1,9 +1,8 @@ -import { fireEvent, createEvent } from '@testing-library/dom'; import React from 'react'; import Option from '../../src/Option'; import Select from '../../src/Select'; import { injectRunAllTimers } from '../utils/common'; -import { type RenderResult, render, act } from '@testing-library/react'; +import { type RenderResult, render, fireEvent, createEvent, act } from '@testing-library/react'; export default function blurTest(mode: any) { describe(`blur of ${mode}`, () => { diff --git a/tests/shared/hoverTest.tsx b/tests/shared/hoverTest.tsx index 2e1821c7..0c0f39ae 100644 --- a/tests/shared/hoverTest.tsx +++ b/tests/shared/hoverTest.tsx @@ -1,7 +1,6 @@ -import { fireEvent } from '@testing-library/dom'; import * as React from 'react'; import Select, { Option } from '../../src'; -import { render } from '@testing-library/react'; +import { fireEvent, render } from '@testing-library/react'; export default function hoverTest(mode: any) { it('triggers mouseEnter and mouseLeave', () => { diff --git a/tests/shared/inputFilterTest.tsx b/tests/shared/inputFilterTest.tsx index 2a54e487..f189f609 100644 --- a/tests/shared/inputFilterTest.tsx +++ b/tests/shared/inputFilterTest.tsx @@ -1,8 +1,7 @@ -import { fireEvent } from '@testing-library/dom'; import * as React from 'react'; import Option from '../../src/Option'; import Select from '../../src/Select'; -import { act, render } from '@testing-library/react'; +import { act, fireEvent, render } from '@testing-library/react'; export default function inputFilterTest(mode: any) { it('should keep input filter after select when autoClearSearchValue is false', () => { diff --git a/tests/shared/keyDownTest.tsx b/tests/shared/keyDownTest.tsx index 28f6f77c..9061de54 100644 --- a/tests/shared/keyDownTest.tsx +++ b/tests/shared/keyDownTest.tsx @@ -1,8 +1,7 @@ -import { fireEvent } from '@testing-library/dom'; import * as React from 'react'; import Option from '../../src/Option'; import Select from '../../src/Select'; -import { render } from '@testing-library/react'; +import { fireEvent, render } from '@testing-library/react'; export default function keyDownTest(mode: any) { it('triggers keyDown', () => { diff --git a/tests/utils/common.ts b/tests/utils/common.ts index 37060b9e..a8da1cce 100644 --- a/tests/utils/common.ts +++ b/tests/utils/common.ts @@ -1,5 +1,5 @@ -import { createEvent, fireEvent } from '@testing-library/dom'; import { act } from 'react'; +import { createEvent, fireEvent } from '@testing-library/react'; export function expectOpen(wrapper: any, open: boolean = true) { if (wrapper instanceof HTMLElement) { From 2bc3527bd95b119505f62c44183ee5b2af9004be Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 30 Jun 2026 19:04:18 +0800 Subject: [PATCH 05/18] chore: address review comments --- eslint.config.mjs | 22 +++++++--------------- react-compat.d.ts | 4 ---- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index d85381ec..e8504e27 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -15,11 +15,11 @@ const compat = new FlatCompat({ allConfig: js.configs.all, }); -const recommendedTsRules = new Set(Object.keys(tsEslintPlugin.configs.recommended.rules || {})); -const noopRule = { - meta: { type: 'problem', docs: {}, schema: [] }, - create: () => ({}), -}; +const recommendedTsRulesConfig = tsEslintPlugin.configs.recommended; +const recommendedTsRulesObject = Array.isArray(recommendedTsRulesConfig) + ? recommendedTsRulesConfig.reduce((rules, config) => ({ ...rules, ...(config.rules || {}) }), {}) + : recommendedTsRulesConfig?.rules || {}; +const recommendedTsRules = new Set(Object.keys(recommendedTsRulesObject)); function normalizeConfig(config) { const next = { ...config }; @@ -35,7 +35,7 @@ function normalizeConfig(config) { if (!ruleName.startsWith('@typescript-eslint/')) { return true; } - return recommendedTsRules.has(ruleName) || ruleName === '@typescript-eslint/ban-types'; + return recommendedTsRules.has(ruleName); }), ); } @@ -61,20 +61,12 @@ export default [ }, { plugins: { - '@typescript-eslint': { - ...tsEslintPlugin, - rules: { - ...tsEslintPlugin.rules, - 'ban-types': noopRule, - 'consistent-type-exports': noopRule, - }, - }, + '@typescript-eslint': tsEslintPlugin, }, }, ...compat.config(require('./.eslintrc.js')).map(normalizeConfig), { rules: { - '@typescript-eslint/ban-types': 'off', '@typescript-eslint/no-empty-object-type': 'off', '@typescript-eslint/no-unsafe-function-type': 'off', '@typescript-eslint/no-unused-vars': 'off', diff --git a/react-compat.d.ts b/react-compat.d.ts index ff05aa1b..c509fe40 100644 --- a/react-compat.d.ts +++ b/react-compat.d.ts @@ -10,7 +10,3 @@ declare module 'react' { ...children: React.ReactNode[] ): React.ReactElement

; } - -declare module 'react-dom' { - function hydrate(element: React.ReactNode, container: Element | DocumentFragment): void; -} From bc8c10a5f3a21bb734e818910c96ab470beb9a50 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 30 Jun 2026 19:16:45 +0800 Subject: [PATCH 06/18] fix: keep compatible eslint export rule --- eslint.config.mjs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index e8504e27..7f8ca4ce 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -20,6 +20,10 @@ const recommendedTsRulesObject = Array.isArray(recommendedTsRulesConfig) ? recommendedTsRulesConfig.reduce((rules, config) => ({ ...rules, ...(config.rules || {}) }), {}) : recommendedTsRulesConfig?.rules || {}; const recommendedTsRules = new Set(Object.keys(recommendedTsRulesObject)); +const noopRule = { + meta: { type: 'problem', docs: {}, schema: [] }, + create: () => ({}), +}; function normalizeConfig(config) { const next = { ...config }; @@ -61,7 +65,13 @@ export default [ }, { plugins: { - '@typescript-eslint': tsEslintPlugin, + '@typescript-eslint': { + ...tsEslintPlugin, + rules: { + ...tsEslintPlugin.rules, + 'consistent-type-exports': noopRule, + }, + }, }, }, ...compat.config(require('./.eslintrc.js')).map(normalizeConfig), From 95dcb860411313922f2afa9abce9f1bc62dc372e Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 30 Jun 2026 19:32:32 +0800 Subject: [PATCH 07/18] chore: address review suggestion --- src/utils/legacyUtil.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/legacyUtil.ts b/src/utils/legacyUtil.ts index cd069edb..644806d8 100644 --- a/src/utils/legacyUtil.ts +++ b/src/utils/legacyUtil.ts @@ -8,7 +8,7 @@ function convertNodeToOption; + } = node; return { key, value: value !== undefined ? value : key, children, ...restProps }; } From 1dada046352ba9245f3f64ea55bba950d1e609d3 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 12:53:30 +0800 Subject: [PATCH 08/18] chore: preserve local eslint rule overrides --- eslint.config.mjs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 7f8ca4ce..e2474c04 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -15,11 +15,23 @@ const compat = new FlatCompat({ allConfig: js.configs.all, }); +const legacyConfig = require('./.eslintrc.js'); const recommendedTsRulesConfig = tsEslintPlugin.configs.recommended; const recommendedTsRulesObject = Array.isArray(recommendedTsRulesConfig) ? recommendedTsRulesConfig.reduce((rules, config) => ({ ...rules, ...(config.rules || {}) }), {}) : recommendedTsRulesConfig?.rules || {}; const recommendedTsRules = new Set(Object.keys(recommendedTsRulesObject)); + +function hasCurrentTsRule(ruleName) { + const tsRuleName = ruleName.replace('@typescript-eslint/', ''); + return Boolean(tsEslintPlugin.rules[tsRuleName]); +} +const localTsRules = new Set( + Object.keys(legacyConfig.rules || {}).filter( + (ruleName) => ruleName.startsWith('@typescript-eslint/') && hasCurrentTsRule(ruleName), + ), +); + const noopRule = { meta: { type: 'problem', docs: {}, schema: [] }, create: () => ({}), @@ -39,7 +51,7 @@ function normalizeConfig(config) { if (!ruleName.startsWith('@typescript-eslint/')) { return true; } - return recommendedTsRules.has(ruleName); + return recommendedTsRules.has(ruleName) || localTsRules.has(ruleName); }), ); } @@ -74,7 +86,7 @@ export default [ }, }, }, - ...compat.config(require('./.eslintrc.js')).map(normalizeConfig), + ...compat.config(legacyConfig).map(normalizeConfig), { rules: { '@typescript-eslint/no-empty-object-type': 'off', From 6b7805d675fb99c4c94d38adc258ee3a0fbc5fe7 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 13:09:31 +0800 Subject: [PATCH 09/18] chore: remove react type compatibility shim --- react-compat.d.ts | 12 ------------ src/Select.tsx | 2 +- src/hooks/useRefFunc.ts | 2 +- tsconfig.json | 10 +--------- 4 files changed, 3 insertions(+), 23 deletions(-) delete mode 100644 react-compat.d.ts diff --git a/react-compat.d.ts b/react-compat.d.ts deleted file mode 100644 index c509fe40..00000000 --- a/react-compat.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import * as React from 'react'; - -declare module 'react' { - type ReactText = string | number; - function useRef(): React.MutableRefObject; - function isValidElement

(object: {} | null | undefined): object is React.ReactElement

; - function cloneElement

( - element: React.ReactElement

, - props?: (Partial

& React.Attributes) | null, - ...children: React.ReactNode[] - ): React.ReactElement

; -} diff --git a/src/Select.tsx b/src/Select.tsx index 41bd66cc..2489e2a3 100644 --- a/src/Select.tsx +++ b/src/Select.tsx @@ -539,7 +539,7 @@ const Select = React.forwardRef>(); + const activeEventRef = React.useRef | undefined>(undefined); const onActiveValue: OnActiveValue = React.useCallback( (active, index, { source = 'keyboard' } = {}) => { diff --git a/src/hooks/useRefFunc.ts b/src/hooks/useRefFunc.ts index 720f972c..993e9021 100644 --- a/src/hooks/useRefFunc.ts +++ b/src/hooks/useRefFunc.ts @@ -5,7 +5,7 @@ import * as React from 'react'; * but redirect to real function. */ export default function useRefFunc any>(callback: T): T { - const funcRef = React.useRef(); + const funcRef = React.useRef(callback); funcRef.current = callback; const cacheFn = React.useCallback((...args: any[]) => { diff --git a/tsconfig.json b/tsconfig.json index 31eb4b16..e1449e6f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,13 +20,5 @@ "strictBindCallApply": false, "module": "ESNext" }, - "include": [ - "react-compat.d.ts", - "global.d.ts", - ".dumirc.ts", - ".fatherrc.ts", - "src", - "tests", - "docs" - ] + "include": ["global.d.ts", ".dumirc.ts", ".fatherrc.ts", "src", "tests", "docs"] } From bcda87e1f274baed0b837279e3a00e72518eea39 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 13:23:00 +0800 Subject: [PATCH 10/18] docs: use ut install for local setup --- README.md | 4 ++-- README.zh-CN.md | 4 ++-- vercel.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7906ed19..5ba243f8 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ export default () => ( Run the local dumi site: ```bash -npm install +ut install npm start ``` @@ -145,7 +145,7 @@ Select also accepts public props from `BaseSelect`, except `showSearch`, which i ## Development ```bash -npm install +ut install npm start npm test npm run lint diff --git a/README.zh-CN.md b/README.zh-CN.md index 63759d62..a37f6f54 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -54,7 +54,7 @@ export default () => ( 运行本地 dumi 站点: ```bash -npm install +ut install npm start ``` @@ -145,7 +145,7 @@ Select 还接受来自 `BaseSelect` 的公共属性,但由 Select 重新定义 ## 本地开发 ```bash -npm install +ut install npm start npm test npm run lint diff --git a/vercel.json b/vercel.json index 5f9139ef..20b1714f 100644 --- a/vercel.json +++ b/vercel.json @@ -1,6 +1,6 @@ { "framework": "umijs", - "installCommand": "npm install", + "installCommand": "ut install", "buildCommand": "npm run build", "outputDirectory": "docs-dist" } From 99ae61f2b65c76a28873171ffef95e7d97b174c5 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 13:30:30 +0800 Subject: [PATCH 11/18] chore: restore vercel install command --- vercel.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vercel.json b/vercel.json index 20b1714f..5f9139ef 100644 --- a/vercel.json +++ b/vercel.json @@ -1,6 +1,6 @@ { "framework": "umijs", - "installCommand": "ut install", + "installCommand": "npm install", "buildCommand": "npm run build", "outputDirectory": "docs-dist" } From ff1ee1ba40ca35a5aed45a3ee74c21a55139bbb8 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 14:03:29 +0800 Subject: [PATCH 12/18] chore: align maintenance dependencies --- eslint.config.mjs | 3 +++ package.json | 18 +++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index e2474c04..7fabcb28 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -48,6 +48,9 @@ function normalizeConfig(config) { if (next.rules) { next.rules = Object.fromEntries( Object.entries(next.rules).filter(([ruleName]) => { + if (ruleName.startsWith('@babel/')) { + return false; + } if (!ruleName.startsWith('@typescript-eslint/')) { return true; } diff --git a/package.json b/package.json index 1ab6f697..86fa73ad 100644 --- a/package.json +++ b/package.json @@ -44,8 +44,8 @@ "*": "prettier --write --ignore-unknown" }, "peerDependencies": { - "react": "*", - "react-dom": "*" + "react": "^19.2.7", + "react-dom": "^19.2.7" }, "dependencies": { "@rc-component/overflow": "^1.0.0", @@ -69,23 +69,23 @@ "@types/node": "^26.0.1", "@types/react": "^19.2.17", "@types/react-dom": "^19.2.3", - "@typescript-eslint/eslint-plugin": "^8.62.0", - "@typescript-eslint/parser": "^8.62.0", + "@typescript-eslint/eslint-plugin": "^8.62.1", + "@typescript-eslint/parser": "^8.62.1", "@umijs/fabric": "^4.0.1", - "babel-jest": "^29.7.0", - "dumi": "^2.4.35", + "babel-jest": "^30.4.1", + "dumi": "^2.4.38", "eslint": "^9.39.4", "eslint-config-prettier": "^10.1.8", - "eslint-plugin-jest": "^29.15.3", + "eslint-plugin-jest": "^29.15.4", "eslint-plugin-react": "^7.37.5", "eslint-plugin-react-hooks": "^7.1.1", "eslint-plugin-unicorn": "^65.0.1", - "father": "^4.6.23", + "father": "^4.6.24", "husky": "^9.1.7", "jsonp": "^0.2.1", "less": "^4.6.7", "lint-staged": "^17.0.8", - "prettier": "^3.9.0", + "prettier": "^3.9.4", "querystring": "^0.2.1", "rc-test": "^7.1.3", "react": "^19.2.7", From ea117485d6fd3bba51b0e70a25107e3853c7dbe4 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 14:24:59 +0800 Subject: [PATCH 13/18] chore: fix upgraded test tooling --- tests/__snapshots__/Combobox.test.tsx.snap | 2 +- tests/__snapshots__/Multiple.test.tsx.snap | 2 +- tests/__snapshots__/OptionList.test.tsx.snap | 2 +- tests/__snapshots__/Select.test.tsx.snap | 2 +- tests/__snapshots__/Tags.test.tsx.snap | 2 +- tests/__snapshots__/ssr.test.tsx.snap | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/__snapshots__/Combobox.test.tsx.snap b/tests/__snapshots__/Combobox.test.tsx.snap index 4e4b3601..6eac14f0 100644 --- a/tests/__snapshots__/Combobox.test.tsx.snap +++ b/tests/__snapshots__/Combobox.test.tsx.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`Select.Combobox renders controlled correctly 1`] = `

diff --git a/tests/__snapshots__/Select.test.tsx.snap b/tests/__snapshots__/Select.test.tsx.snap index 5ec0a630..b94d30ad 100644 --- a/tests/__snapshots__/Select.test.tsx.snap +++ b/tests/__snapshots__/Select.test.tsx.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`Select.Basic does not filter when filterOption value is false 1`] = `
diff --git a/tests/__snapshots__/ssr.test.tsx.snap b/tests/__snapshots__/ssr.test.tsx.snap index 77df0eed..1bdd9301 100644 --- a/tests/__snapshots__/ssr.test.tsx.snap +++ b/tests/__snapshots__/ssr.test.tsx.snap @@ -1,3 +1,3 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`Select.SSR should work 1`] = `"
"`; From 3c21a6c159b708840daabf9ce4054f03f1e4e319 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 14:35:33 +0800 Subject: [PATCH 14/18] fix: preserve React peer dependency range --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 86fa73ad..eec2ad88 100644 --- a/package.json +++ b/package.json @@ -44,8 +44,8 @@ "*": "prettier --write --ignore-unknown" }, "peerDependencies": { - "react": "^19.2.7", - "react-dom": "^19.2.7" + "react": "*", + "react-dom": "*" }, "dependencies": { "@rc-component/overflow": "^1.0.0", From 3c898ad8316d687b138ba8d8fa69afb621a6f251 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 18:37:21 +0800 Subject: [PATCH 15/18] docs: use npm install in README --- README.md | 4 ++-- README.zh-CN.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5ba243f8..7906ed19 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ export default () => ( Run the local dumi site: ```bash -ut install +npm install npm start ``` @@ -145,7 +145,7 @@ Select also accepts public props from `BaseSelect`, except `showSearch`, which i ## Development ```bash -ut install +npm install npm start npm test npm run lint diff --git a/README.zh-CN.md b/README.zh-CN.md index a37f6f54..63759d62 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -54,7 +54,7 @@ export default () => ( 运行本地 dumi 站点: ```bash -ut install +npm install npm start ``` @@ -145,7 +145,7 @@ Select 还接受来自 `BaseSelect` 的公共属性,但由 Select 重新定义 ## 本地开发 ```bash -ut install +npm install npm start npm test npm run lint From ec51695e87169be78cb45bd2daf3c14fbb1be381 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 18:47:02 +0800 Subject: [PATCH 16/18] chore: remove redundant strict tsconfig flags --- tsconfig.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index e1449e6f..cd160b40 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,13 +11,7 @@ "@@/*": ["./.dumi/tmp/*"], "@rc-component/select": ["./src/index.ts"] }, - "noImplicitAny": false, - "strictNullChecks": false, - "strictPropertyInitialization": false, - "strictFunctionTypes": false, "strict": false, - "noImplicitThis": false, - "strictBindCallApply": false, "module": "ESNext" }, "include": ["global.d.ts", ".dumirc.ts", ".fatherrc.ts", "src", "tests", "docs"] From 30f21bd4d356ee376b15b4a8f4b245c36c0cf1a5 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 19:13:49 +0800 Subject: [PATCH 17/18] chore: remove manual global test declarations --- global.d.ts | 38 -------------------------------------- src/BaseSelect/index.tsx | 4 ++-- 2 files changed, 2 insertions(+), 40 deletions(-) diff --git a/global.d.ts b/global.d.ts index 85e4e4e7..e0bd355c 100644 --- a/global.d.ts +++ b/global.d.ts @@ -8,42 +8,4 @@ declare module '*.css'; declare module '*.less'; declare module 'jsonp'; -declare namespace JSX { - type Element = React.JSX.Element; - interface ElementClass extends React.JSX.ElementClass {} - interface ElementAttributesProperty extends React.JSX.ElementAttributesProperty {} - interface ElementChildrenAttribute extends React.JSX.ElementChildrenAttribute {} - type LibraryManagedAttributes = React.JSX.LibraryManagedAttributes; - interface IntrinsicAttributes extends React.JSX.IntrinsicAttributes {} - interface IntrinsicClassAttributes extends React.JSX.IntrinsicClassAttributes {} - interface IntrinsicElements extends React.JSX.IntrinsicElements {} -} - -declare namespace jest { - interface Matchers { - lastCalledWith(...expected: unknown[]): R; - nthCalledWith(nthCall: number, ...expected: unknown[]): R; - toBeCalled(): R; - toBeCalledTimes(expected: number): R; - toBeCalledWith(...expected: unknown[]): R; - } -} - -declare const vi: { - fn: any = (...args: any[]) => any>( - implementation?: T, - ) => jest.MockedFunction; - mock: (moduleName: string, factory?: (importOriginal: () => Promise) => unknown) => void; - spyOn: typeof jest.spyOn; - useFakeTimers: () => void; - useRealTimers: () => void; - advanceTimersByTime: (msToRun: number) => void; - clearAllTimers: () => void; - runAllTimers: () => void; - importActual: (moduleName: string) => Promise; - clearAllMocks: () => void; - resetAllMocks: () => void; - restoreAllMocks: () => void; -}; - declare module 'moment/locale/zh-cn'; diff --git a/src/BaseSelect/index.tsx b/src/BaseSelect/index.tsx index 44f27812..2fe6f4b5 100644 --- a/src/BaseSelect/index.tsx +++ b/src/BaseSelect/index.tsx @@ -171,9 +171,9 @@ export interface BaseSelectProps // >>> Customize Input /** @private Internal usage. Do not use in your production. */ - getInputElement?: () => JSX.Element; + getInputElement?: () => React.JSX.Element; /** @private Internal usage. Do not use in your production. */ - getRawInputElement?: () => JSX.Element; + getRawInputElement?: () => React.JSX.Element; // >>> Selector maxTagTextLength?: number; From 43a1b5e0bfcfc84f10b097a1f817e3e53ed44411 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 19:32:30 +0800 Subject: [PATCH 18/18] fix: address review type compatibility --- src/BaseSelect/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BaseSelect/index.tsx b/src/BaseSelect/index.tsx index 2fe6f4b5..a4569e5e 100644 --- a/src/BaseSelect/index.tsx +++ b/src/BaseSelect/index.tsx @@ -171,9 +171,9 @@ export interface BaseSelectProps // >>> Customize Input /** @private Internal usage. Do not use in your production. */ - getInputElement?: () => React.JSX.Element; + getInputElement?: () => React.ReactElement; /** @private Internal usage. Do not use in your production. */ - getRawInputElement?: () => React.JSX.Element; + getRawInputElement?: () => React.ReactElement; // >>> Selector maxTagTextLength?: number;