From d65fa50323162c5602a57db156f4815fd402dfc9 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 29 Jun 2026 18:19:56 +0800 Subject: [PATCH 01/17] 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 | 34 ++++++++++------- react-compat.d.ts | 16 ++++++++ src/utils/legacyUtil.tsx | 8 ++-- tsconfig.json | 23 +++++++----- 9 files changed, 201 insertions(+), 29 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 36653f79..1850ed53 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

@rc-component/tree-select

-

Ant Design Part of the Ant Design ecosystem.

+

Ant Design Part of the Ant Design ecosystem.

🌳 React TreeSelect component for choosing values from tree data, with search, checkable nodes, async loading, and virtual scrolling.

diff --git a/README.zh-CN.md b/README.zh-CN.md index 9f64d291..9a4ba242 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -1,6 +1,6 @@

@rc-component/tree-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 d7bc5f57..d6ce8924 100644 --- a/package.json +++ b/package.json @@ -55,29 +55,37 @@ "@rc-component/np": "^1.0.4", "@rc-component/trigger": "^3.0.0", "@rc-component/virtual-list": "^1.0.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", "@types/warning": "^3.0.4", - "@typescript-eslint/eslint-plugin": "^5.62.0", - "@typescript-eslint/parser": "^5.62.0", + "@typescript-eslint/eslint-plugin": "^8.62.0", + "@typescript-eslint/parser": "^8.62.0", "@umijs/fabric": "^4.0.1", "cross-env": "^10.1.0", "dumi": "^2.4.35", - "eslint": "^8.57.1", - "eslint-plugin-jest": "^27.9.0", - "eslint-plugin-unicorn": "^56.0.1", + "eslint": "^9.39.4", + "eslint-plugin-jest": "^29.15.3", + "eslint-plugin-unicorn": "^65.0.1", "father": "^4.6.23", "glob": "^13.0.6", "husky": "^9.1.7", - "lint-staged": "^16.4.0", + "lint-staged": "^17.0.8", "prettier": "^3.9.0", "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", + "@testing-library/jest-dom": "^6.9.1" }, "peerDependencies": { "react": "*", 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.tsx b/src/utils/legacyUtil.tsx index c5583f45..576c4a37 100644 --- a/src/utils/legacyUtil.tsx +++ b/src/utils/legacyUtil.tsx @@ -11,7 +11,7 @@ import TreeNode from '../TreeNode'; export function convertChildrenToData(nodes: React.ReactNode): DataNode[] { return toArray(nodes) - .map((node: React.ReactElement) => { + .map((node: React.ReactElement) => { if (!React.isValidElement(node) || !node.type) { return null; } @@ -19,7 +19,7 @@ export function convertChildrenToData(nodes: React.ReactNode): DataNode[] { const { key, props: { children, value, ...restProps }, - } = node as React.ReactElement; + } = node as React.ReactElement; const data = { key, @@ -119,12 +119,12 @@ export function fillAdditionalInfo( node: { props: { value: val1 }, }, - }, + }: { node: React.ReactElement }, { node: { props: { value: val2 }, }, - }, + }: { node: React.ReactElement }, ) => { const index1 = checkedValues.indexOf(val1); const index2 = checkedValues.indexOf(val2); diff --git a/tsconfig.json b/tsconfig.json index 3d5da56b..b5416974 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,19 +8,22 @@ "skipLibCheck": true, "esModuleInterop": true, "paths": { - "@/*": [ - "src/*" - ], - "@@/*": [ - ".dumi/tmp/*" - ], - "@rc-component/tree-select": [ - "src/index.tsx" - ] + "@/*": ["src/*"], + "@@/*": [".dumi/tmp/*"], + "@rc-component/tree-select": ["src/index.tsx"] }, - "ignoreDeprecations": "5.0" + "ignoreDeprecations": "6.0", + "noImplicitAny": false, + "strictNullChecks": false, + "strictPropertyInitialization": false, + "strictFunctionTypes": false, + "strict": false, + "noImplicitThis": false, + "strictBindCallApply": false }, "include": [ + "react-compat.d.ts", + "global.d.ts", ".dumirc.ts", ".fatherrc.ts", "src", From 47eae4ef6ce75bd6ad939a3e7adcf0b57b5e9892 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 30 Jun 2026 10:21:25 +0800 Subject: [PATCH 02/17] 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 b5416974..6a01dccd 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/tree-select": ["src/index.tsx"] + "@/*": ["./src/*"], + "@@/*": ["./.dumi/tmp/*"], + "@rc-component/tree-select": ["./src/index.tsx"] }, - "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 c91afaae43f544db760314b2c779de252e93a7bf Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 30 Jun 2026 10:51:36 +0800 Subject: [PATCH 03/17] chore: use testing-library dom events --- package.json | 19 ++++++++++--------- tests/Select.SearchInput.spec.js | 3 ++- tests/Select.checkable.spec.tsx | 3 ++- tests/Select.loadData.spec.tsx | 3 ++- tests/Select.maxCount.spec.tsx | 3 ++- tests/Select.multiple.spec.js | 3 ++- tests/Select.props.spec.js | 3 ++- tests/Select.spec.tsx | 3 ++- tests/Select.tree.spec.js | 3 ++- tests/Select.tree.treeExpandAction.spec.js | 3 ++- tests/util.tsx | 3 ++- 11 files changed, 30 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index d6ce8924..24662ce5 100644 --- a/package.json +++ b/package.json @@ -49,12 +49,18 @@ "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.2.0", "@rc-component/father-plugin": "^2.2.0", "@rc-component/form": "^1.4.0", "@rc-component/np": "^1.0.4", "@rc-component/trigger": "^3.0.0", "@rc-component/virtual-list": "^1.0.1", + "@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", @@ -67,7 +73,10 @@ "cross-env": "^10.1.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", "glob": "^13.0.6", @@ -77,15 +86,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", - "@testing-library/jest-dom": "^6.9.1" + "typescript": "^6.0.3" }, "peerDependencies": { "react": "*", diff --git a/tests/Select.SearchInput.spec.js b/tests/Select.SearchInput.spec.js index df0f0e65..2363f64a 100644 --- a/tests/Select.SearchInput.spec.js +++ b/tests/Select.SearchInput.spec.js @@ -1,6 +1,7 @@ +import { fireEvent } from '@testing-library/dom'; /* eslint-disable no-undef */ import React, { useState } from 'react'; -import { render, fireEvent } from '@testing-library/react'; +import { render } from '@testing-library/react'; import TreeSelect, { TreeNode } from '../src'; import { KeyCode } from '@rc-component/util'; import { getInput, search, selectNode } from './util'; diff --git a/tests/Select.checkable.spec.tsx b/tests/Select.checkable.spec.tsx index 181c200a..8d010eb1 100644 --- a/tests/Select.checkable.spec.tsx +++ b/tests/Select.checkable.spec.tsx @@ -1,5 +1,6 @@ +import { fireEvent } from '@testing-library/dom'; /* eslint-disable no-undef, react/no-multi-comp, max-classes-per-file */ -import { fireEvent, render } from '@testing-library/react'; +import { render } from '@testing-library/react'; import React from 'react'; import TreeSelect, { SHOW_ALL, SHOW_PARENT, TreeNode } from '../src'; import { diff --git a/tests/Select.loadData.spec.tsx b/tests/Select.loadData.spec.tsx index c938d95c..a58581c0 100644 --- a/tests/Select.loadData.spec.tsx +++ b/tests/Select.loadData.spec.tsx @@ -1,6 +1,7 @@ +import { fireEvent } from '@testing-library/dom'; /* eslint-disable no-undef, react/no-multi-comp, no-console */ import React from 'react'; -import { render, fireEvent, act } from '@testing-library/react'; +import { render, act } from '@testing-library/react'; import TreeSelect from '../src'; diff --git a/tests/Select.maxCount.spec.tsx b/tests/Select.maxCount.spec.tsx index 99aaf319..936c5d6b 100644 --- a/tests/Select.maxCount.spec.tsx +++ b/tests/Select.maxCount.spec.tsx @@ -1,4 +1,5 @@ -import { render, fireEvent, within } from '@testing-library/react'; +import { fireEvent } from '@testing-library/dom'; +import { render, within } from '@testing-library/react'; import { KeyCode } from '@rc-component/util'; import { keyDown, keyUp } from './util'; import React from 'react'; diff --git a/tests/Select.multiple.spec.js b/tests/Select.multiple.spec.js index 72239f9c..568f99db 100644 --- a/tests/Select.multiple.spec.js +++ b/tests/Select.multiple.spec.js @@ -1,5 +1,6 @@ +import { fireEvent } from '@testing-library/dom'; /* eslint-disable no-undef */ -import { render, fireEvent, within, screen } from '@testing-library/react'; +import { render, within, screen } from '@testing-library/react'; import { KeyCode } from '@rc-component/util'; import React from 'react'; import TreeSelect, { TreeNode } from '../src'; diff --git a/tests/Select.props.spec.js b/tests/Select.props.spec.js index 70b964a9..a0c75ddb 100644 --- a/tests/Select.props.spec.js +++ b/tests/Select.props.spec.js @@ -1,7 +1,8 @@ +import { fireEvent } from '@testing-library/dom'; /* eslint-disable no-undef, react/no-multi-comp, no-console */ import { TreeNode } from '@rc-component/tree'; import React from 'react'; -import { render, fireEvent } from '@testing-library/react'; +import { render } from '@testing-library/react'; import TreeSelect, { SHOW_ALL, SHOW_CHILD, SHOW_PARENT, TreeNode as SelectNode } from '../src'; import { diff --git a/tests/Select.spec.tsx b/tests/Select.spec.tsx index fd22a4e2..85a88a0f 100644 --- a/tests/Select.spec.tsx +++ b/tests/Select.spec.tsx @@ -1,4 +1,5 @@ -import { act, createEvent, render, fireEvent } from '@testing-library/react'; +import { createEvent, fireEvent } from '@testing-library/dom'; +import { act, render } from '@testing-library/react'; import { KeyCode } from '@rc-component/util'; import React from 'react'; import TreeSelect, { TreeNode } from '../src'; diff --git a/tests/Select.tree.spec.js b/tests/Select.tree.spec.js index 9989bec2..bef853d1 100644 --- a/tests/Select.tree.spec.js +++ b/tests/Select.tree.spec.js @@ -1,6 +1,7 @@ +import { fireEvent } from '@testing-library/dom'; /* eslint-disable no-undef, react/no-multi-comp, no-console */ import React from 'react'; -import { render, fireEvent, act } from '@testing-library/react'; +import { render, act } from '@testing-library/react'; import { resetWarned } from '@rc-component/util'; import TreeSelect, { TreeNode as SelectNode } from '../src'; import { getVisibleTreeNodes, selectNode, triggerOpen, expectOpen } from './util'; diff --git a/tests/Select.tree.treeExpandAction.spec.js b/tests/Select.tree.treeExpandAction.spec.js index bc5f3bed..c58f3b4d 100644 --- a/tests/Select.tree.treeExpandAction.spec.js +++ b/tests/Select.tree.treeExpandAction.spec.js @@ -1,6 +1,7 @@ +import { fireEvent } from '@testing-library/dom'; /* eslint-disable no-undef, react/no-multi-comp, no-console */ import React from 'react'; -import { fireEvent, render } from '@testing-library/react'; +import { render } from '@testing-library/react'; import TreeSelect from '../src'; describe('treeExpandAction with selectable props', () => { diff --git a/tests/util.tsx b/tests/util.tsx index cc17ef8e..4dd447cb 100644 --- a/tests/util.tsx +++ b/tests/util.tsx @@ -1,4 +1,5 @@ -import { fireEvent, createEvent, act } from '@testing-library/react'; +import { fireEvent, createEvent } from '@testing-library/dom'; +import { act } from '@testing-library/react'; import { KeyCode } from '@rc-component/util'; const keyMap: Record = { From da0c522e24cd37c5d10cf8f1d5aad3879068c1ee Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 30 Jun 2026 11:16:45 +0800 Subject: [PATCH 04/17] test: keep react testing event behavior --- tests/Select.SearchInput.spec.js | 3 +-- tests/Select.checkable.spec.tsx | 3 +-- tests/Select.loadData.spec.tsx | 3 +-- tests/Select.maxCount.spec.tsx | 3 +-- tests/Select.multiple.spec.js | 3 +-- tests/Select.props.spec.js | 3 +-- tests/Select.spec.tsx | 3 +-- tests/Select.tree.spec.js | 3 +-- tests/Select.tree.treeExpandAction.spec.js | 3 +-- tests/util.tsx | 3 +-- 10 files changed, 10 insertions(+), 20 deletions(-) diff --git a/tests/Select.SearchInput.spec.js b/tests/Select.SearchInput.spec.js index 2363f64a..df0f0e65 100644 --- a/tests/Select.SearchInput.spec.js +++ b/tests/Select.SearchInput.spec.js @@ -1,7 +1,6 @@ -import { fireEvent } from '@testing-library/dom'; /* eslint-disable no-undef */ import React, { useState } from 'react'; -import { render } from '@testing-library/react'; +import { render, fireEvent } from '@testing-library/react'; import TreeSelect, { TreeNode } from '../src'; import { KeyCode } from '@rc-component/util'; import { getInput, search, selectNode } from './util'; diff --git a/tests/Select.checkable.spec.tsx b/tests/Select.checkable.spec.tsx index 8d010eb1..181c200a 100644 --- a/tests/Select.checkable.spec.tsx +++ b/tests/Select.checkable.spec.tsx @@ -1,6 +1,5 @@ -import { fireEvent } from '@testing-library/dom'; /* eslint-disable no-undef, react/no-multi-comp, max-classes-per-file */ -import { render } from '@testing-library/react'; +import { fireEvent, render } from '@testing-library/react'; import React from 'react'; import TreeSelect, { SHOW_ALL, SHOW_PARENT, TreeNode } from '../src'; import { diff --git a/tests/Select.loadData.spec.tsx b/tests/Select.loadData.spec.tsx index a58581c0..c938d95c 100644 --- a/tests/Select.loadData.spec.tsx +++ b/tests/Select.loadData.spec.tsx @@ -1,7 +1,6 @@ -import { fireEvent } from '@testing-library/dom'; /* eslint-disable no-undef, react/no-multi-comp, no-console */ import React from 'react'; -import { render, act } from '@testing-library/react'; +import { render, fireEvent, act } from '@testing-library/react'; import TreeSelect from '../src'; diff --git a/tests/Select.maxCount.spec.tsx b/tests/Select.maxCount.spec.tsx index 936c5d6b..99aaf319 100644 --- a/tests/Select.maxCount.spec.tsx +++ b/tests/Select.maxCount.spec.tsx @@ -1,5 +1,4 @@ -import { fireEvent } from '@testing-library/dom'; -import { render, within } from '@testing-library/react'; +import { render, fireEvent, within } from '@testing-library/react'; import { KeyCode } from '@rc-component/util'; import { keyDown, keyUp } from './util'; import React from 'react'; diff --git a/tests/Select.multiple.spec.js b/tests/Select.multiple.spec.js index 568f99db..72239f9c 100644 --- a/tests/Select.multiple.spec.js +++ b/tests/Select.multiple.spec.js @@ -1,6 +1,5 @@ -import { fireEvent } from '@testing-library/dom'; /* eslint-disable no-undef */ -import { render, within, screen } from '@testing-library/react'; +import { render, fireEvent, within, screen } from '@testing-library/react'; import { KeyCode } from '@rc-component/util'; import React from 'react'; import TreeSelect, { TreeNode } from '../src'; diff --git a/tests/Select.props.spec.js b/tests/Select.props.spec.js index a0c75ddb..70b964a9 100644 --- a/tests/Select.props.spec.js +++ b/tests/Select.props.spec.js @@ -1,8 +1,7 @@ -import { fireEvent } from '@testing-library/dom'; /* eslint-disable no-undef, react/no-multi-comp, no-console */ import { TreeNode } from '@rc-component/tree'; import React from 'react'; -import { render } from '@testing-library/react'; +import { render, fireEvent } from '@testing-library/react'; import TreeSelect, { SHOW_ALL, SHOW_CHILD, SHOW_PARENT, TreeNode as SelectNode } from '../src'; import { diff --git a/tests/Select.spec.tsx b/tests/Select.spec.tsx index 85a88a0f..fd22a4e2 100644 --- a/tests/Select.spec.tsx +++ b/tests/Select.spec.tsx @@ -1,5 +1,4 @@ -import { createEvent, fireEvent } from '@testing-library/dom'; -import { act, render } from '@testing-library/react'; +import { act, createEvent, render, fireEvent } from '@testing-library/react'; import { KeyCode } from '@rc-component/util'; import React from 'react'; import TreeSelect, { TreeNode } from '../src'; diff --git a/tests/Select.tree.spec.js b/tests/Select.tree.spec.js index bef853d1..9989bec2 100644 --- a/tests/Select.tree.spec.js +++ b/tests/Select.tree.spec.js @@ -1,7 +1,6 @@ -import { fireEvent } from '@testing-library/dom'; /* eslint-disable no-undef, react/no-multi-comp, no-console */ import React from 'react'; -import { render, act } from '@testing-library/react'; +import { render, fireEvent, act } from '@testing-library/react'; import { resetWarned } from '@rc-component/util'; import TreeSelect, { TreeNode as SelectNode } from '../src'; import { getVisibleTreeNodes, selectNode, triggerOpen, expectOpen } from './util'; diff --git a/tests/Select.tree.treeExpandAction.spec.js b/tests/Select.tree.treeExpandAction.spec.js index c58f3b4d..bc5f3bed 100644 --- a/tests/Select.tree.treeExpandAction.spec.js +++ b/tests/Select.tree.treeExpandAction.spec.js @@ -1,7 +1,6 @@ -import { fireEvent } from '@testing-library/dom'; /* eslint-disable no-undef, react/no-multi-comp, no-console */ import React from 'react'; -import { render } from '@testing-library/react'; +import { fireEvent, render } from '@testing-library/react'; import TreeSelect from '../src'; describe('treeExpandAction with selectable props', () => { diff --git a/tests/util.tsx b/tests/util.tsx index 4dd447cb..cc17ef8e 100644 --- a/tests/util.tsx +++ b/tests/util.tsx @@ -1,5 +1,4 @@ -import { fireEvent, createEvent } from '@testing-library/dom'; -import { act } from '@testing-library/react'; +import { fireEvent, createEvent, act } from '@testing-library/react'; import { KeyCode } from '@rc-component/util'; const keyMap: Record = { From 2099718df52cfc83caa9143681d9a13394d9bcc5 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 30 Jun 2026 19:04:45 +0800 Subject: [PATCH 05/17] 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 98dcf634ac7b599c2549f174f932817db82a7c4d Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 30 Jun 2026 19:17:15 +0800 Subject: [PATCH 06/17] 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 e1b696a64d36a34a8b733ce92a0368519d3e5f5b Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 13:09:40 +0800 Subject: [PATCH 07/17] chore: remove react type compatibility shim --- react-compat.d.ts | 12 ------------ src/OptionList.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/OptionList.tsx b/src/OptionList.tsx index b1efdac5..a08fa783 100644 --- a/src/OptionList.tsx +++ b/src/OptionList.tsx @@ -79,7 +79,7 @@ const OptionList: React.ForwardRefRenderFunction = (_, keyEntities, } = React.useContext(LegacyContext); - const treeRef = React.useRef(); + const treeRef = React.useRef(null); const memoTreeData = useMemo( () => treeData, 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 6a01dccd..fd634ae2 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", - "examples" - ] + "include": ["global.d.ts", ".dumirc.ts", ".fatherrc.ts", "src", "tests", "examples"] } From 1a25b8803bd90dd800e4025f4c9ee37c35983d34 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 13:23:27 +0800 Subject: [PATCH 08/17] 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 1850ed53..69a60028 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ export default () => Date: Wed, 1 Jul 2026 13:30:54 +0800 Subject: [PATCH 09/17] 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 8b04d37bf3f7a380846170db72a2bd1c32113f18 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 14:03:59 +0800 Subject: [PATCH 10/17] chore: align maintenance dependencies --- eslint.config.mjs | 3 +++ package.json | 16 ++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 7f8ca4ce..76ab8dac 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -36,6 +36,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 24662ce5..aca9588e 100644 --- a/package.json +++ b/package.json @@ -67,30 +67,30 @@ "@types/react": "^19.2.17", "@types/react-dom": "^19.2.3", "@types/warning": "^3.0.4", - "@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", "cross-env": "^10.1.0", - "dumi": "^2.4.35", + "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", "glob": "^13.0.6", "husky": "^9.1.7", "lint-staged": "^17.0.8", - "prettier": "^3.9.0", + "prettier": "^3.9.4", "rc-test": "^7.1.3", "react": "^19.2.7", "react-dom": "^19.2.7", "typescript": "^6.0.3" }, "peerDependencies": { - "react": "*", - "react-dom": "*" + "react": "^19.2.7", + "react-dom": "^19.2.7" }, "publishConfig": { "access": "public" From 2e2eda4e41da5f10d012e0388bc05fec89d280fc Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 14:25:23 +0800 Subject: [PATCH 11/17] chore: fix upgraded test tooling --- tests/__snapshots__/Select.checkable.spec.tsx.snap | 2 +- tests/__snapshots__/Select.multiple.spec.js.snap | 2 +- tests/__snapshots__/Select.spec.tsx.snap | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/__snapshots__/Select.checkable.spec.tsx.snap b/tests/__snapshots__/Select.checkable.spec.tsx.snap index e65699e8..0a044f28 100644 --- a/tests/__snapshots__/Select.checkable.spec.tsx.snap +++ b/tests/__snapshots__/Select.checkable.spec.tsx.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`TreeSelect.checkable uncheck remove by selector not treeCheckStrictly 1`] = `

diff --git a/tests/__snapshots__/Select.multiple.spec.js.snap b/tests/__snapshots__/Select.multiple.spec.js.snap index 74db1c9c..713cd8d4 100644 --- a/tests/__snapshots__/Select.multiple.spec.js.snap +++ b/tests/__snapshots__/Select.multiple.spec.js.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`TreeSelect.multiple can hide search box by showSearch = false 1`] = `
Date: Wed, 1 Jul 2026 14:36:04 +0800 Subject: [PATCH 12/17] 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 aca9588e..cee3893f 100644 --- a/package.json +++ b/package.json @@ -89,8 +89,8 @@ "typescript": "^6.0.3" }, "peerDependencies": { - "react": "^19.2.7", - "react-dom": "^19.2.7" + "react": "*", + "react-dom": "*" }, "publishConfig": { "access": "public" From 597db8d188b6f13eabab0203d59c093fdbf73d45 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 18:37:58 +0800 Subject: [PATCH 13/17] 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 69a60028..1850ed53 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ export default () => Date: Wed, 1 Jul 2026 18:47:33 +0800 Subject: [PATCH 14/17] chore: remove redundant strict tsconfig flags --- tsconfig.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index fd634ae2..e8d135c4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,13 +11,7 @@ "@@/*": ["./.dumi/tmp/*"], "@rc-component/tree-select": ["./src/index.tsx"] }, - "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", "examples"] From 49f720d849b2926e1385956fe42e4a2e929653ad Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 19:14:27 +0800 Subject: [PATCH 15/17] chore: remove manual global test declarations --- global.d.ts | 38 -------------------------------------- 1 file changed, 38 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'; From fa65455f4470e0264707a1e2aba4161f969ceb9a Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 2 Jul 2026 11:54:08 +0800 Subject: [PATCH 16/17] chore: migrate to native eslint flat config --- .eslintrc.js | 13 ----- eslint.config.mjs | 143 +++++++++++++++++++++++++++------------------- package.json | 11 +--- 3 files changed, 86 insertions(+), 81 deletions(-) delete mode 100644 .eslintrc.js diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index ed4ad53d..00000000 --- a/.eslintrc.js +++ /dev/null @@ -1,13 +0,0 @@ -const base = require('@umijs/fabric/dist/eslint'); - -module.exports = { - ...base, - rules: { - ...base.rules, - 'react/sort-comp': 0, - 'default-case': 0, - 'eslint-comments/disable-enable-pair': 0, - 'jsx-a11y/interactive-supports-focus': 0, - '@typescript-eslint/no-object-literal-type-assertion': 0, - }, -}; diff --git a/eslint.config.mjs b/eslint.config.mjs index 76ab8dac..d19be2a6 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,56 +1,23 @@ -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'; +import { defineConfig } from 'eslint/config'; +import prettier from 'eslint-config-prettier'; +import jest from 'eslint-plugin-jest'; +import react from 'eslint-plugin-react'; +import reactHooks from 'eslint-plugin-react-hooks'; +import globals from 'globals'; +import tseslint from 'typescript-eslint'; -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 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)); -const noopRule = { - meta: { type: 'problem', docs: {}, schema: [] }, - create: () => ({}), -}; - -function normalizeConfig(config) { - const next = { ...config }; - - if (next.plugins?.['@typescript-eslint']) { - next.plugins = { ...next.plugins }; - delete next.plugins['@typescript-eslint']; - } - - 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; - } - return recommendedTsRules.has(ruleName); - }), - ); - } - - return next; -} - -export default [ +export default defineConfig([ + { + plugins: { + '@typescript-eslint': tseslint.plugin, + }, + }, + { + linterOptions: { + reportUnusedDisableDirectives: 'off', + }, + }, { ignores: [ 'node_modules/', @@ -62,27 +29,83 @@ export default [ '.dumi/', '.doc/', '.vercel/', - '.eslintrc.js', 'src/index.d.ts', ], }, { + files: ['**/*.{js,jsx,ts,tsx}'], + extends: [ + js.configs.recommended, + react.configs.flat.recommended, + react.configs.flat['jsx-runtime'], + prettier, + ], plugins: { - '@typescript-eslint': { - ...tsEslintPlugin, - rules: { - ...tsEslintPlugin.rules, - 'consistent-type-exports': noopRule, - }, + 'react-hooks': reactHooks, + }, + languageOptions: { + globals: { + ...globals.browser, + ...globals.node, + }, + }, + settings: { + react: { + version: 'detect', }, }, + rules: { + 'no-async-promise-executor': 'off', + 'no-empty-pattern': 'off', + 'no-irregular-whitespace': 'off', + 'no-prototype-builtins': 'off', + 'no-useless-escape': 'off', + 'no-extra-boolean-cast': 'off', + 'no-undef': 'off', + 'no-unused-vars': 'off', + 'react/no-find-dom-node': 'off', + 'react/display-name': 'off', + 'react/no-unknown-property': 'off', + 'react/prop-types': 'off', + 'react-hooks/exhaustive-deps': 'warn', + 'react-hooks/rules-of-hooks': 'error', + }, }, - ...compat.config(require('./.eslintrc.js')).map(normalizeConfig), { + files: ['**/*.{ts,tsx}'], + extends: [...tseslint.configs.recommended], rules: { + '@typescript-eslint/ban-ts-comment': 'off', '@typescript-eslint/no-empty-object-type': 'off', + '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-unsafe-function-type': 'off', + '@typescript-eslint/no-unnecessary-type-constraint': 'off', '@typescript-eslint/no-unused-vars': 'off', }, }, -]; + { + files: ['src/**/*.{ts,tsx}'], + languageOptions: { + parserOptions: { + projectService: true, + tsconfigRootDir: import.meta.dirname, + }, + }, + }, + { + files: ['tests/**/*.{js,jsx,ts,tsx}', '**/*.{test,spec}.{js,jsx,ts,tsx}'], + extends: [jest.configs['flat/recommended']], + rules: { + 'jest/no-disabled-tests': 'off', + 'jest/no-done-callback': 'off', + 'jest/no-identical-title': 'off', + 'jest/expect-expect': 'off', + 'jest/no-alias-methods': 'off', + 'jest/no-conditional-expect': 'off', + 'jest/no-export': 'off', + 'jest/no-standalone-expect': 'off', + 'jest/valid-expect': 'off', + 'jest/valid-title': 'off', + }, + }, +]); diff --git a/package.json b/package.json index cee3893f..6e2df107 100644 --- a/package.json +++ b/package.json @@ -49,9 +49,6 @@ "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.2.0", "@rc-component/father-plugin": "^2.2.0", @@ -67,9 +64,6 @@ "@types/react": "^19.2.17", "@types/react-dom": "^19.2.3", "@types/warning": "^3.0.4", - "@typescript-eslint/eslint-plugin": "^8.62.1", - "@typescript-eslint/parser": "^8.62.1", - "@umijs/fabric": "^4.0.1", "cross-env": "^10.1.0", "dumi": "^2.4.38", "eslint": "^9.39.4", @@ -77,16 +71,17 @@ "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.24", "glob": "^13.0.6", + "globals": "^17.7.0", "husky": "^9.1.7", "lint-staged": "^17.0.8", "prettier": "^3.9.4", "rc-test": "^7.1.3", "react": "^19.2.7", "react-dom": "^19.2.7", - "typescript": "^6.0.3" + "typescript": "^6.0.3", + "typescript-eslint": "^8.62.1" }, "peerDependencies": { "react": "*", From f1ef94d6af8752b19e01c0c518b80d882342227a Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 3 Jul 2026 10:58:14 +0800 Subject: [PATCH 17/17] chore: address review comments --- eslint.config.mjs | 10 +++++++--- src/OptionList.tsx | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index d19be2a6..40f08ec9 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,5 +1,7 @@ import js from '@eslint/js'; import { defineConfig } from 'eslint/config'; +import { dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; import prettier from 'eslint-config-prettier'; import jest from 'eslint-plugin-jest'; import react from 'eslint-plugin-react'; @@ -7,6 +9,8 @@ import reactHooks from 'eslint-plugin-react-hooks'; import globals from 'globals'; import tseslint from 'typescript-eslint'; +const tsconfigRootDir = dirname(fileURLToPath(import.meta.url)); + export default defineConfig([ { plugins: { @@ -15,7 +19,7 @@ export default defineConfig([ }, { linterOptions: { - reportUnusedDisableDirectives: 'off', + reportUnusedDisableDirectives: 'warn', }, }, { @@ -26,10 +30,10 @@ export default defineConfig([ 'lib/', 'dist/', 'docs-dist/', + '.docs-dist/', '.dumi/', '.doc/', '.vercel/', - 'src/index.d.ts', ], }, { @@ -88,7 +92,7 @@ export default defineConfig([ languageOptions: { parserOptions: { projectService: true, - tsconfigRootDir: import.meta.dirname, + tsconfigRootDir, }, }, }, diff --git a/src/OptionList.tsx b/src/OptionList.tsx index a08fa783..ea5fc8bf 100644 --- a/src/OptionList.tsx +++ b/src/OptionList.tsx @@ -79,7 +79,7 @@ const OptionList: React.ForwardRefRenderFunction = (_, keyEntities, } = React.useContext(LegacyContext); - const treeRef = React.useRef(null); + const treeRef = React.useRef(null); const memoTreeData = useMemo( () => treeData,