From f1d99819e55cf13f99b522a15197177155ad3cdb Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 29 Jun 2026 18:20:12 +0800 Subject: [PATCH 01/20] chore: update maintenance dependencies --- .github/dependabot.yml | 8 +++++ README.md | 2 +- README.zh-CN.md | 2 +- eslint.config.mjs | 79 +++++++++++++++++++++++++++++++++++++++++ examples/no-virtual.tsx | 4 +-- examples/switch.tsx | 4 +-- global.d.ts | 56 +++++++++++++++++++++++++++++ package.json | 30 ++++++++++------ react-compat.d.ts | 16 +++++++++ src/Item.tsx | 2 +- tsconfig.json | 11 +++++- 11 files changed, 196 insertions(+), 18 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 0d63d5f0..33f2d992 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

@rc-component/virtual-list

-

Ant Design Part of the Ant Design ecosystem.

+

Ant Design Part of the Ant Design ecosystem.

📜 Virtual scrolling list component for React.

diff --git a/README.zh-CN.md b/README.zh-CN.md index d0a3192e..d1cbe56b 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -1,6 +1,6 @@

@rc-component/virtual-list

-

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/examples/no-virtual.tsx b/examples/no-virtual.tsx index 793ab907..d48e0dfe 100644 --- a/examples/no-virtual.tsx +++ b/examples/no-virtual.tsx @@ -7,7 +7,7 @@ interface Item { height: number; } -const MyItem: React.FC = ({ id, height }, ref) => { +const MyItem = React.forwardRef(({ id, height }, ref) => { return ( = ({ id, height }, ref) => { {id} ); -}; +}); const ForwardMyItem = React.forwardRef(MyItem as any); diff --git a/examples/switch.tsx b/examples/switch.tsx index 5339e887..5d56dcb4 100644 --- a/examples/switch.tsx +++ b/examples/switch.tsx @@ -6,7 +6,7 @@ interface Item { id: number; } -const MyItem: React.FC = ({ id }, ref) => ( +const MyItem = React.forwardRef(({ id }, ref) => ( = ({ id }, ref) => ( > {id} -); +)); const ForwardMyItem = React.forwardRef(MyItem as any); diff --git a/global.d.ts b/global.d.ts new file mode 100644 index 00000000..e35e1773 --- /dev/null +++ b/global.d.ts @@ -0,0 +1,56 @@ +/// +/// +/// +/// +/// + +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 62e4e0d9..97d861dc 100644 --- a/package.json +++ b/package.json @@ -51,27 +51,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", "@types/warning": "^3.0.4", "dumi": "^2.4.35", - "eslint": "^8.57.1", - "eslint-plugin-unicorn": "^56.0.1", + "eslint": "^9.39.4", + "eslint-plugin-unicorn": "^65.0.1", "father": "^4.6.23", "glob": "^13.0.6", "rc-animate": "^2.9.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", "cross-env": "^10.1.0", "gh-pages": "^6.3.0", "prettier": "^3.9.0", "husky": "^9.1.7", - "lint-staged": "^16.4.0" + "lint-staged": "^17.0.8", + "@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" }, "dependencies": { "@babel/runtime": "^7.20.0", 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/Item.tsx b/src/Item.tsx index 8a8cb6c5..bfc8dce9 100644 --- a/src/Item.tsx +++ b/src/Item.tsx @@ -10,7 +10,7 @@ export function Item({ children, setRef }: ItemProps) { setRef(node); }, []); - return React.cloneElement(children, { + return React.cloneElement(children as React.ReactElement, { ref: refFunc, }); } diff --git a/tsconfig.json b/tsconfig.json index edc503cd..6f2cfaa7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -24,9 +24,18 @@ "src/*" ] }, - "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 18e3af813ba88e4988f197d9aa383f06c43553ac Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 30 Jun 2026 10:21:39 +0800 Subject: [PATCH 02/20] fix: align TypeScript and ESLint compatibility --- eslint.config.mjs | 33 +++++++++++++++++++++------------ global.d.ts | 8 -------- tsconfig.json | 17 ++++++++--------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index b25fb5dd..f556e5a4 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -15,7 +15,9 @@ const compat = new FlatCompat({ allConfig: js.configs.all, }); -const recommendedTsRules = new Set(Object.keys(tsEslintPlugin.configs.recommended.rules || {})); +const recommendedTsRules = new Set( + Object.keys(tsEslintPlugin.configs.recommended.rules || {}), +); const noopRule = { meta: { type: 'problem', docs: {}, schema: [] }, create: () => ({}), @@ -25,16 +27,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) { @@ -43,7 +37,10 @@ function normalizeConfig(config) { if (!ruleName.startsWith('@typescript-eslint/')) { return true; } - return recommendedTsRules.has(ruleName) || ruleName === '@typescript-eslint/ban-types'; + return ( + recommendedTsRules.has(ruleName) || + ruleName === '@typescript-eslint/ban-types' + ); }), ); } @@ -67,6 +64,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 e35e1773..97e90a38 100644 --- a/global.d.ts +++ b/global.d.ts @@ -44,13 +44,5 @@ 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 6f2cfaa7..267591e1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,37 +1,36 @@ { "compilerOptions": { "target": "esnext", - "moduleResolution": "node", - "baseUrl": "./", + "moduleResolution": "bundler", "jsx": "react", "declaration": true, "skipLibCheck": true, "esModuleInterop": true, "paths": { "@/*": [ - "src/*" + "./src/*" ], "@@/*": [ - ".dumi/tmp/*" + "./.dumi/tmp/*" ], "@rc-component/virtual-list": [ - "src/index.ts" + "./src/index.ts" ], "@rc-component/virtual-list/es": [ - "src" + "./src" ], "@rc-component/virtual-list/es/*": [ - "src/*" + "./src/*" ] }, - "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 587c2d472b066dd4de3719eea67af708437600a2 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 30 Jun 2026 10:51:49 +0800 Subject: [PATCH 03/20] chore: use testing-library dom events --- package.json | 33 +++++++++++++++++---------------- tests/list.test.js | 3 ++- tests/scroll.test.js | 3 ++- tests/scrollWidth.test.tsx | 3 ++- tests/touch.test.js | 3 ++- 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 97d861dc..7c7a24b2 100644 --- a/package.json +++ b/package.json @@ -48,8 +48,13 @@ "react-dom": ">=18.0.0" }, "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/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", @@ -57,31 +62,27 @@ "@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", + "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", + "gh-pages": "^6.3.0", "glob": "^13.0.6", + "husky": "^9.1.7", + "lint-staged": "^17.0.8", + "prettier": "^3.9.0", "rc-animate": "^2.9.1", "rc-test": "^7.1.3", "react": "^19.2.7", "react-dom": "^19.2.7", - "typescript": "^6.0.3", - "cross-env": "^10.1.0", - "gh-pages": "^6.3.0", - "prettier": "^3.9.0", - "husky": "^9.1.7", - "lint-staged": "^17.0.8", - "@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" + "typescript": "^6.0.3" }, "dependencies": { "@babel/runtime": "^7.20.0", diff --git a/tests/list.test.js b/tests/list.test.js index d0317b61..0922a97c 100644 --- a/tests/list.test.js +++ b/tests/list.test.js @@ -1,6 +1,7 @@ import '@testing-library/jest-dom'; +import { fireEvent } from '@testing-library/dom'; import { _rs as onLibResize } from '@rc-component/resize-observer/lib/utils/observerUtil'; -import { act, fireEvent, render } from '@testing-library/react'; +import { act, render } from '@testing-library/react'; import React from 'react'; import List from '../src'; import { spyElementPrototypes } from './utils/domHook'; diff --git a/tests/scroll.test.js b/tests/scroll.test.js index a7bb1700..890d857b 100644 --- a/tests/scroll.test.js +++ b/tests/scroll.test.js @@ -1,5 +1,6 @@ import '@testing-library/jest-dom'; -import { act, createEvent, fireEvent, render } from '@testing-library/react'; +import { createEvent, fireEvent } from '@testing-library/dom'; +import { act, render } from '@testing-library/react'; import { _rs as onLibResize } from '@rc-component/resize-observer/lib/utils/observerUtil'; import { resetWarned } from '@rc-component/util/lib/warning'; import React from 'react'; diff --git a/tests/scrollWidth.test.tsx b/tests/scrollWidth.test.tsx index 22326322..367e9f26 100644 --- a/tests/scrollWidth.test.tsx +++ b/tests/scrollWidth.test.tsx @@ -1,5 +1,6 @@ import '@testing-library/jest-dom'; -import { act, fireEvent, render } from '@testing-library/react'; +import { fireEvent } from '@testing-library/dom'; +import { act, render } from '@testing-library/react'; import { _rs as onLibResize } from '@rc-component/resize-observer/lib/utils/observerUtil'; import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook'; import React from 'react'; diff --git a/tests/touch.test.js b/tests/touch.test.js index d0a5072f..cecfb506 100644 --- a/tests/touch.test.js +++ b/tests/touch.test.js @@ -1,4 +1,5 @@ -import { act, fireEvent, render } from '@testing-library/react'; +import { fireEvent } from '@testing-library/dom'; +import { act, render } from '@testing-library/react'; import React from 'react'; import List from '../src'; import { spyElementPrototypes } from './utils/domHook'; From b99f2634fb6407a6b9344d30f9ab3d6f054c4b94 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 30 Jun 2026 11:16:58 +0800 Subject: [PATCH 04/20] test: keep react testing event behavior --- tests/list.test.js | 3 +-- tests/scroll.test.js | 3 +-- tests/scrollWidth.test.tsx | 3 +-- tests/touch.test.js | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/list.test.js b/tests/list.test.js index 0922a97c..d0317b61 100644 --- a/tests/list.test.js +++ b/tests/list.test.js @@ -1,7 +1,6 @@ import '@testing-library/jest-dom'; -import { fireEvent } from '@testing-library/dom'; import { _rs as onLibResize } from '@rc-component/resize-observer/lib/utils/observerUtil'; -import { act, render } from '@testing-library/react'; +import { act, fireEvent, render } from '@testing-library/react'; import React from 'react'; import List from '../src'; import { spyElementPrototypes } from './utils/domHook'; diff --git a/tests/scroll.test.js b/tests/scroll.test.js index 890d857b..a7bb1700 100644 --- a/tests/scroll.test.js +++ b/tests/scroll.test.js @@ -1,6 +1,5 @@ import '@testing-library/jest-dom'; -import { createEvent, fireEvent } from '@testing-library/dom'; -import { act, render } from '@testing-library/react'; +import { act, createEvent, fireEvent, render } from '@testing-library/react'; import { _rs as onLibResize } from '@rc-component/resize-observer/lib/utils/observerUtil'; import { resetWarned } from '@rc-component/util/lib/warning'; import React from 'react'; diff --git a/tests/scrollWidth.test.tsx b/tests/scrollWidth.test.tsx index 367e9f26..22326322 100644 --- a/tests/scrollWidth.test.tsx +++ b/tests/scrollWidth.test.tsx @@ -1,6 +1,5 @@ import '@testing-library/jest-dom'; -import { fireEvent } from '@testing-library/dom'; -import { act, render } from '@testing-library/react'; +import { act, fireEvent, render } from '@testing-library/react'; import { _rs as onLibResize } from '@rc-component/resize-observer/lib/utils/observerUtil'; import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook'; import React from 'react'; diff --git a/tests/touch.test.js b/tests/touch.test.js index cecfb506..d0a5072f 100644 --- a/tests/touch.test.js +++ b/tests/touch.test.js @@ -1,5 +1,4 @@ -import { fireEvent } from '@testing-library/dom'; -import { act, render } from '@testing-library/react'; +import { act, fireEvent, render } from '@testing-library/react'; import React from 'react'; import List from '../src'; import { spyElementPrototypes } from './utils/domHook'; From 9a53eeef94d496a050aaea6421a9de9dacadc7cf Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 30 Jun 2026 19:04:52 +0800 Subject: [PATCH 05/20] chore: address review comments --- eslint.config.mjs | 30 ++++++++++-------------------- react-compat.d.ts | 4 ---- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index f556e5a4..3166a6d9 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -15,13 +15,14 @@ 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 }; @@ -37,10 +38,7 @@ function normalizeConfig(config) { if (!ruleName.startsWith('@typescript-eslint/')) { return true; } - return ( - recommendedTsRules.has(ruleName) || - ruleName === '@typescript-eslint/ban-types' - ); + return recommendedTsRules.has(ruleName); }), ); } @@ -66,20 +64,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 c392e698dd4056b48f1c4410bef736195f2acb4e Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 30 Jun 2026 19:17:29 +0800 Subject: [PATCH 06/20] 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 3166a6d9..0e70eed9 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -23,6 +23,10 @@ const recommendedTsRulesObject = Array.isArray(recommendedTsRulesConfig) ) : recommendedTsRulesConfig?.rules || {}; const recommendedTsRules = new Set(Object.keys(recommendedTsRulesObject)); +const noopRule = { + meta: { type: 'problem', docs: {}, schema: [] }, + create: () => ({}), +}; function normalizeConfig(config) { const next = { ...config }; @@ -64,7 +68,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 d2d4ff5c74ad417b83ccc8213e3e7baaf685baa7 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 30 Jun 2026 19:32:32 +0800 Subject: [PATCH 07/20] chore: address review suggestion --- src/Item.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Item.tsx b/src/Item.tsx index bfc8dce9..2839a539 100644 --- a/src/Item.tsx +++ b/src/Item.tsx @@ -6,9 +6,12 @@ export interface ItemProps { } export function Item({ children, setRef }: ItemProps) { - const refFunc = React.useCallback(node => { - setRef(node); - }, []); + const refFunc = React.useCallback( + node => { + setRef(node); + }, + [setRef], + ); return React.cloneElement(children as React.ReactElement, { ref: refFunc, From 597450f706b45b7ea5290de3df2af60e472f1991 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 12:42:29 +0800 Subject: [PATCH 08/20] chore: enable unused vars warnings --- eslint.config.mjs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 0e70eed9..455a5d23 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -17,10 +17,7 @@ const compat = new FlatCompat({ const recommendedTsRulesConfig = tsEslintPlugin.configs.recommended; const recommendedTsRulesObject = Array.isArray(recommendedTsRulesConfig) - ? recommendedTsRulesConfig.reduce( - (rules, config) => ({ ...rules, ...(config.rules || {}) }), - {}, - ) + ? recommendedTsRulesConfig.reduce((rules, config) => ({ ...rules, ...(config.rules || {}) }), {}) : recommendedTsRulesConfig?.rules || {}; const recommendedTsRules = new Set(Object.keys(recommendedTsRulesObject)); const noopRule = { @@ -82,7 +79,13 @@ export default [ rules: { '@typescript-eslint/no-empty-object-type': 'off', '@typescript-eslint/no-unsafe-function-type': 'off', - '@typescript-eslint/no-unused-vars': 'off', + '@typescript-eslint/no-unused-vars': [ + 'warn', + { + argsIgnorePattern: '^_', + varsIgnorePattern: '^_', + }, + ], }, }, ]; From 45fd1c411254326ae47c54d5eef8083bdae3e6ab Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 12:58:31 +0800 Subject: [PATCH 09/20] chore: update virtual list ref typing --- src/Item.tsx | 4 ++-- src/hooks/useChildren.tsx | 2 +- src/hooks/useHeights.tsx | 4 ++-- tsconfig.json | 28 +++++++--------------------- 4 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/Item.tsx b/src/Item.tsx index 2839a539..6f422a94 100644 --- a/src/Item.tsx +++ b/src/Item.tsx @@ -2,12 +2,12 @@ import * as React from 'react'; export interface ItemProps { children: React.ReactElement; - setRef: (element: HTMLElement) => void; + setRef: (element: HTMLElement | null) => void; } export function Item({ children, setRef }: ItemProps) { const refFunc = React.useCallback( - node => { + (node) => { setRef(node); }, [setRef], diff --git a/src/hooks/useChildren.tsx b/src/hooks/useChildren.tsx index 8c4fdf6d..9767ccf7 100644 --- a/src/hooks/useChildren.tsx +++ b/src/hooks/useChildren.tsx @@ -8,7 +8,7 @@ export default function useChildren( endIndex: number, scrollWidth: number, offsetX: number, - setNodeRef: (item: T, element: HTMLElement) => void, + setNodeRef: (item: T, element: HTMLElement | null) => void, renderFunc: RenderFunc, { getKey }: SharedConfig, ) { diff --git a/src/hooks/useHeights.tsx b/src/hooks/useHeights.tsx index ed13de72..20aa243c 100644 --- a/src/hooks/useHeights.tsx +++ b/src/hooks/useHeights.tsx @@ -13,7 +13,7 @@ export default function useHeights( onItemAdd?: (item: T) => void, onItemRemove?: (item: T) => void, ): [ - setInstanceRef: (item: T, instance: HTMLElement) => void, + setInstanceRef: (item: T, instance: HTMLElement | null) => void, collectHeight: (sync?: boolean) => void, cacheMap: CacheMap, updatedMark: number, @@ -69,7 +69,7 @@ export default function useHeights( } } - function setInstanceRef(item: T, instance: HTMLElement) { + function setInstanceRef(item: T, instance: HTMLElement | null) { const key = getKey(item); const origin = instanceRef.current.get(key); diff --git a/tsconfig.json b/tsconfig.json index 267591e1..390c88da 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,26 +2,16 @@ "compilerOptions": { "target": "esnext", "moduleResolution": "bundler", - "jsx": "react", + "jsx": "react-jsx", "declaration": true, "skipLibCheck": true, "esModuleInterop": true, "paths": { - "@/*": [ - "./src/*" - ], - "@@/*": [ - "./.dumi/tmp/*" - ], - "@rc-component/virtual-list": [ - "./src/index.ts" - ], - "@rc-component/virtual-list/es": [ - "./src" - ], - "@rc-component/virtual-list/es/*": [ - "./src/*" - ] + "@/*": ["./src/*"], + "@@/*": ["./.dumi/tmp/*"], + "@rc-component/virtual-list": ["./src/index.ts"], + "@rc-component/virtual-list/es": ["./src"], + "@rc-component/virtual-list/es/*": ["./src/*"] }, "noImplicitAny": false, "strictNullChecks": false, @@ -41,9 +31,5 @@ "tests", "examples" ], - "exclude": [ - "docs-dist", - "lib", - "es" - ] + "exclude": ["docs-dist", "lib", "es"] } From fe588a01384ca872dcda9474741b0dc5ff87b35b Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 13:09:45 +0800 Subject: [PATCH 10/20] chore: remove react type compatibility shim --- examples/animate.tsx | 2 +- examples/switch.tsx | 2 +- react-compat.d.ts | 12 ------------ src/List.tsx | 19 +++++++------------ src/ScrollBar.tsx | 10 +++++----- src/hooks/useScrollTo.tsx | 2 +- tsconfig.json | 10 +--------- 7 files changed, 16 insertions(+), 41 deletions(-) delete mode 100644 react-compat.d.ts diff --git a/examples/animate.tsx b/examples/animate.tsx index 90939765..a5c78a2f 100644 --- a/examples/animate.tsx +++ b/examples/animate.tsx @@ -130,7 +130,7 @@ const Demo = () => { const [animating, setAnimating] = React.useState(false); const [insertIndex, setInsertIndex] = React.useState(); - const listRef = React.useRef(); + const listRef = React.useRef(null); const onClose = (id: string) => { setCloseMap({ diff --git a/examples/switch.tsx b/examples/switch.tsx index 5d56dcb4..f13899c9 100644 --- a/examples/switch.tsx +++ b/examples/switch.tsx @@ -39,7 +39,7 @@ const Demo = () => { const [height, setHeight] = React.useState(200); const [data, setData] = React.useState(getData(20)); const [fullHeight, setFullHeight] = React.useState(true); - const listRef = React.useRef(); + const listRef = React.useRef(null); return ( 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/List.tsx b/src/List.tsx index 046cae24..a7b438cc 100644 --- a/src/List.tsx +++ b/src/List.tsx @@ -15,12 +15,7 @@ import useHeights from './hooks/useHeights'; import useMobileTouchMove from './hooks/useMobileTouchMove'; import useOriginScroll from './hooks/useOriginScroll'; import useScrollDrag from './hooks/useScrollDrag'; -import type { - ScrollOffset, - ScrollOffsetInfo, - ScrollPos, - ScrollTarget, -} from './hooks/useScrollTo'; +import type { ScrollOffset, ScrollOffsetInfo, ScrollPos, ScrollTarget } from './hooks/useScrollTo'; import useScrollTo from './hooks/useScrollTo'; import type { ExtraRenderInfo, GetKey, RenderFunc, SharedConfig } from './interface'; import type { ScrollBarDirectionType, ScrollBarRef } from './ScrollBar'; @@ -154,9 +149,9 @@ export function RawList(props: ListProps, ref: React.Ref) { const mergedClassName = clsx(prefixCls, { [`${prefixCls}-rtl`]: isRTL }, className); const mergedData = data || EMPTY_DATA; - const componentRef = useRef(); - const fillerInnerRef = useRef(); - const containerRef = useRef(); + const componentRef = useRef(null); + const fillerInnerRef = useRef(null); + const containerRef = useRef(null); // =============================== Item Key =============================== @@ -196,7 +191,7 @@ export function RawList(props: ListProps, ref: React.Ref) { // Put ref here since the range is generate by follow const rangeRef = useRef({ start: 0, end: mergedData.length }); - const diffItemRef = useRef(); + const diffItemRef = useRef(undefined); const [diffItem] = useDiffItem(mergedData, getKey); diffItemRef.current = diffItem; @@ -315,8 +310,8 @@ export function RawList(props: ListProps, ref: React.Ref) { }; // Hack on scrollbar to enable flash call - const verticalScrollBarRef = useRef(); - const horizontalScrollBarRef = useRef(); + const verticalScrollBarRef = useRef(null); + const horizontalScrollBarRef = useRef(null); const horizontalScrollBarSpinSize = React.useMemo( () => getSpinSize(size.width, scrollWidth), diff --git a/src/ScrollBar.tsx b/src/ScrollBar.tsx index ce4ff6fa..3c4533bc 100644 --- a/src/ScrollBar.tsx +++ b/src/ScrollBar.tsx @@ -49,12 +49,12 @@ const ScrollBar = React.forwardRef((props, ref) => const isLTR = !rtl; // ========================= Refs ========================= - const scrollbarRef = React.useRef(); - const thumbRef = React.useRef(); + const scrollbarRef = React.useRef(null); + const thumbRef = React.useRef(null); // ======================= Visible ======================== const [visible, setVisible] = React.useState(showScrollBar); - const visibleTimeoutRef = React.useRef>(); + const visibleTimeoutRef = React.useRef | undefined>(undefined); const delayHidden = () => { if (showScrollBar === true || showScrollBar === false) return; @@ -120,9 +120,9 @@ const ScrollBar = React.forwardRef((props, ref) => }, []); // Pass to effect - const enableScrollRangeRef = React.useRef(); + const enableScrollRangeRef = React.useRef(undefined); enableScrollRangeRef.current = enableScrollRange; - const enableOffsetRangeRef = React.useRef(); + const enableOffsetRangeRef = React.useRef(undefined); enableOffsetRangeRef.current = enableOffsetRange; React.useEffect(() => { diff --git a/src/hooks/useScrollTo.tsx b/src/hooks/useScrollTo.tsx index 8a678067..12553fef 100644 --- a/src/hooks/useScrollTo.tsx +++ b/src/hooks/useScrollTo.tsx @@ -52,7 +52,7 @@ export default function useScrollTo( syncScrollTop: (newTop: number) => void, triggerFlash: () => void, ): (arg: number | ScrollTarget) => void { - const scrollRef = React.useRef(); + const scrollRef = React.useRef(undefined); const [syncState, setSyncState] = React.useState<{ times: number; diff --git a/tsconfig.json b/tsconfig.json index 390c88da..51475053 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,14 +22,6 @@ "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"], "exclude": ["docs-dist", "lib", "es"] } From b975ea15e774c6e880e4fd37bbce029a900a50c8 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 13:20:43 +0800 Subject: [PATCH 11/20] chore: stabilize scrollbar touch handler --- src/ScrollBar.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ScrollBar.tsx b/src/ScrollBar.tsx index 3c4533bc..ade435e2 100644 --- a/src/ScrollBar.tsx +++ b/src/ScrollBar.tsx @@ -1,5 +1,5 @@ import { clsx } from 'clsx'; -import { raf } from '@rc-component/util'; +import { raf, useEvent } from '@rc-component/util'; import * as React from 'react'; import { getPageXY } from './hooks/useScrollDrag'; @@ -88,7 +88,7 @@ const ScrollBar = React.forwardRef((props, ref) => const stateRef = React.useRef({ top, dragging, pageY: pageXY, startTop }); stateRef.current = { top, dragging, pageY: pageXY, startTop }; - const onThumbMouseDown = (e: React.MouseEvent | React.TouchEvent | TouchEvent) => { + const onThumbMouseDown = useEvent((e: React.MouseEvent | React.TouchEvent | TouchEvent) => { setDragging(true); setPageXY(getPageXY(e, horizontal)); setStartTop(stateRef.current.top); @@ -96,7 +96,7 @@ const ScrollBar = React.forwardRef((props, ref) => onStartMove(); e.stopPropagation(); e.preventDefault(); - }; + }); // ======================== Effect ======================== @@ -117,7 +117,7 @@ const ScrollBar = React.forwardRef((props, ref) => scrollbarEle.removeEventListener('touchstart', onScrollbarTouchStart); thumbEle.removeEventListener('touchstart', onThumbMouseDown); }; - }, []); + }, [onThumbMouseDown]); // Pass to effect const enableScrollRangeRef = React.useRef(undefined); From c69a508feaaa13d9347b2a8dadc51b20df6e1da1 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 13:23:46 +0800 Subject: [PATCH 12/20] docs: use ut install for local setup --- README.md | 5 ++--- README.zh-CN.md | 29 ++++++++++++++--------------- vercel.json | 2 +- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 33f2d992..a7f62640 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,6 @@

English | 简体中文

- ## Highlights - Built for React and maintained by the rc-component team. @@ -51,7 +50,7 @@ export default () => ( Run the local dumi site: ```bash -npm install +ut install npm start ``` @@ -78,7 +77,7 @@ Then open `http://localhost:8000`. ## Development ```bash -npm install +ut install npm start npm test npm run build diff --git a/README.zh-CN.md b/README.zh-CN.md index d1cbe56b..7f76362b 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -15,7 +15,6 @@

English | 简体中文

- ## 特性 - 面向 React 构建,并由 rc-component 团队维护。 @@ -51,7 +50,7 @@ export default () => ( 运行本地 dumi 站点: ```bash -npm install +ut install npm start ``` @@ -61,24 +60,24 @@ npm start ### List -| 属性 | 说明 | 类型 | 默认值 | -| ---------- | ---------------------------------------------------------------------------------------------------------------------- | -------------------------------------- | ------- | +| 属性 | 说明 | 类型 | 默认值 | +| ---------- | ------------------------------------------------------------------ | -------------------------------------- | ------- | | children | 每一项的渲染函数。第三个参数包含旧浏览器兼容路径使用的测量 props。 | `(item, index, props) => ReactElement` | - | -| component | 自定义列表容器元素。 | `string` \| `ComponentType` | `div` | -| data | 虚拟列表渲染的数据项。 | `T[]` | - | -| disabled | 禁用滚动位置检查,通常用于配合动画。 | `boolean` | `false` | -| fullHeight | holder 是否保持完整高度。 | `boolean` | `true` | -| height | 可视列表高度。 | `number` | - | -| itemHeight | 用于计算虚拟范围的最小项高度。 | `number` | - | -| itemKey | 数据项 key 字段或 key 获取函数。 | `string` \| `(item) => React.Key` | - | -| onScroll | 列表滚动时调用。 | `React.UIEventHandler` | - | -| styles | 自定义滚动条部位样式。 | `object` | - | -| virtual | 启用虚拟渲染。 | `boolean` | `true` | +| component | 自定义列表容器元素。 | `string` \| `ComponentType` | `div` | +| data | 虚拟列表渲染的数据项。 | `T[]` | - | +| disabled | 禁用滚动位置检查,通常用于配合动画。 | `boolean` | `false` | +| fullHeight | holder 是否保持完整高度。 | `boolean` | `true` | +| height | 可视列表高度。 | `number` | - | +| itemHeight | 用于计算虚拟范围的最小项高度。 | `number` | - | +| itemKey | 数据项 key 字段或 key 获取函数。 | `string` \| `(item) => React.Key` | - | +| onScroll | 列表滚动时调用。 | `React.UIEventHandler` | - | +| styles | 自定义滚动条部位样式。 | `object` | - | +| virtual | 启用虚拟渲染。 | `boolean` | `true` | ## 本地开发 ```bash -npm install +ut install npm start npm test npm run build 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 69bb66927b3ee8e25cbad759d3f5abbdd93c6e2c Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 13:31:15 +0800 Subject: [PATCH 13/20] 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 62e0d2578c47c1c8c883806c5ff2e3c580d6d73b Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 14:04:19 +0800 Subject: [PATCH 14/20] 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 455a5d23..5c5b13fd 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 7c7a24b2..da7a478c 100644 --- a/package.json +++ b/package.json @@ -44,8 +44,8 @@ "prepare": "husky" }, "peerDependencies": { - "react": ">=18.0.0", - "react-dom": ">=18.0.0" + "react": "^19.2.7", + "react-dom": "^19.2.7" }, "devDependencies": { "@babel/eslint-parser": "^7.29.7", @@ -62,22 +62,22 @@ "@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", "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", "gh-pages": "^6.3.0", "glob": "^13.0.6", "husky": "^9.1.7", "lint-staged": "^17.0.8", - "prettier": "^3.9.0", + "prettier": "^3.9.4", "rc-animate": "^2.9.1", "rc-test": "^7.1.3", "react": "^19.2.7", @@ -85,7 +85,7 @@ "typescript": "^6.0.3" }, "dependencies": { - "@babel/runtime": "^7.20.0", + "@babel/runtime": "^7.29.7", "@rc-component/resize-observer": "^1.0.1", "@rc-component/util": "^1.4.0", "clsx": "^2.1.1" From 5e26fec7308e755c6bb504809429c27c55818ea6 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 14:36:17 +0800 Subject: [PATCH 15/20] 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 da7a478c..8b19ee1f 100644 --- a/package.json +++ b/package.json @@ -44,8 +44,8 @@ "prepare": "husky" }, "peerDependencies": { - "react": "^19.2.7", - "react-dom": "^19.2.7" + "react": ">=18.0.0", + "react-dom": ">=18.0.0" }, "devDependencies": { "@babel/eslint-parser": "^7.29.7", From 22d734d4bd09d3a532cbcbfaf32befc89a23c991 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 18:38:14 +0800 Subject: [PATCH 16/20] 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 a7f62640..7f2e4d54 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ export default () => ( Run the local dumi site: ```bash -ut install +npm install npm start ``` @@ -77,7 +77,7 @@ Then open `http://localhost:8000`. ## Development ```bash -ut install +npm install npm start npm test npm run build diff --git a/README.zh-CN.md b/README.zh-CN.md index 7f76362b..4e0f4062 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -50,7 +50,7 @@ export default () => ( 运行本地 dumi 站点: ```bash -ut install +npm install npm start ``` @@ -77,7 +77,7 @@ npm start ## 本地开发 ```bash -ut install +npm install npm start npm test npm run build From cd09b9bad18ea103cc166a91a739e57d231e872b Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 18:47:44 +0800 Subject: [PATCH 17/20] chore: remove redundant strict tsconfig flags --- tsconfig.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 51475053..d6811baf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,13 +13,7 @@ "@rc-component/virtual-list/es": ["./src"], "@rc-component/virtual-list/es/*": ["./src/*"] }, - "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 193ebac30ad7e031980f50daa91bbe429cd9b493 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 19:14:47 +0800 Subject: [PATCH 18/20] chore: remove manual global test declarations --- global.d.ts | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/global.d.ts b/global.d.ts index 97e90a38..e0bd355c 100644 --- a/global.d.ts +++ b/global.d.ts @@ -8,41 +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 51c0c0888624f1d4fc0bd3b042a199a97f9324f1 Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 2 Jul 2026 11:54:09 +0800 Subject: [PATCH 19/20] chore: migrate to native eslint flat config --- .eslintrc.js | 16 ----- eslint.config.mjs | 151 ++++++++++++++++++++++++++-------------------- package.json | 10 +-- 3 files changed, 87 insertions(+), 90 deletions(-) delete mode 100644 .eslintrc.js diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index d71817eb..00000000 --- a/.eslintrc.js +++ /dev/null @@ -1,16 +0,0 @@ -const base = require('@umijs/fabric/dist/eslint'); - -module.exports = { - ...base, - rules: { - ...base.rules, - 'arrow-parens': 0, - '@typescript-eslint/no-explicit-any': 0, - 'react/no-did-update-set-state': 0, - 'react/no-find-dom-node': 0, - 'no-dupe-class-members': 0, - 'react/sort-comp': 0, - 'no-confusing-arrow': 0, - 'no-unused-expressions': 0, - }, -}; diff --git a/eslint.config.mjs b/eslint.config.mjs index 5c5b13fd..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,33 +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-unused-vars': [ - 'warn', - { - argsIgnorePattern: '^_', - varsIgnorePattern: '^_', - }, - ], + '@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 8b19ee1f..98f74ad9 100644 --- a/package.json +++ b/package.json @@ -48,9 +48,6 @@ "react-dom": ">=18.0.0" }, "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/father-plugin": "^2.2.0", "@rc-component/np": "^1.0.4", @@ -62,8 +59,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", "cross-env": "^10.1.0", "dumi": "^2.4.38", "eslint": "^9.39.4", @@ -71,10 +66,10 @@ "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", "gh-pages": "^6.3.0", "glob": "^13.0.6", + "globals": "^17.7.0", "husky": "^9.1.7", "lint-staged": "^17.0.8", "prettier": "^3.9.4", @@ -82,7 +77,8 @@ "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" }, "dependencies": { "@babel/runtime": "^7.29.7", From 6f978c9fd0e2fa01b8548eee39911822601e5f65 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 3 Jul 2026 10:58:16 +0800 Subject: [PATCH 20/20] chore: address review comments --- eslint.config.mjs | 10 +++++++--- examples/no-virtual.tsx | 2 +- examples/switch.tsx | 2 +- 3 files changed, 9 insertions(+), 5 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/examples/no-virtual.tsx b/examples/no-virtual.tsx index d48e0dfe..b817514f 100644 --- a/examples/no-virtual.tsx +++ b/examples/no-virtual.tsx @@ -25,7 +25,7 @@ const MyItem = React.forwardRef(({ id, height }, ref) => ); }); -const ForwardMyItem = React.forwardRef(MyItem as any); +const ForwardMyItem = MyItem; const data: Item[] = []; for (let i = 0; i < 100; i += 1) { diff --git a/examples/switch.tsx b/examples/switch.tsx index f13899c9..7d804de1 100644 --- a/examples/switch.tsx +++ b/examples/switch.tsx @@ -23,7 +23,7 @@ const MyItem = React.forwardRef(({ id }, ref) => ( )); -const ForwardMyItem = React.forwardRef(MyItem as any); +const ForwardMyItem = MyItem; function getData(count: number) { const data: Item[] = [];