Skip to content

Commit 3b093be

Browse files
authored
chore: update maintenance dependencies (#367)
* chore: update maintenance dependencies * fix: align TypeScript and ESLint compatibility * chore: use testing-library dom events * test: keep react testing event behavior * chore: address review comments * fix: keep compatible eslint export rule * chore: address review suggestion * chore: enable unused vars warnings * chore: update virtual list ref typing * chore: remove react type compatibility shim * chore: stabilize scrollbar touch handler * docs: use ut install for local setup * chore: restore vercel install command * chore: align maintenance dependencies * fix: preserve React peer dependency range * docs: use npm install in README * chore: remove redundant strict tsconfig flags * chore: remove manual global test declarations * chore: migrate to native eslint flat config * chore: address review comments
1 parent cf92789 commit 3b093be

17 files changed

Lines changed: 219 additions & 118 deletions

‎.eslintrc.js‎

Lines changed: 0 additions & 16 deletions
This file was deleted.

‎.github/dependabot.yml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ updates:
88
time: '21:00'
99
timezone: Asia/Shanghai
1010
open-pull-requests-limit: 10
11+
groups:
12+
npm-dependencies:
13+
patterns:
14+
- '*'
1115

1216
- package-ecosystem: github-actions
1317
directory: '/'
@@ -17,3 +21,7 @@ updates:
1721
time: '21:00'
1822
timezone: Asia/Shanghai
1923
open-pull-requests-limit: 10
24+
groups:
25+
github-actions:
26+
patterns:
27+
- '*'

‎README.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div align="center">
22
<h1>@rc-component/virtual-list</h1>
3-
<p><sub><img alt="Ant Design" height="14" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style="vertical-align: -0.125em;" /> Part of the Ant Design ecosystem.</sub></p>
3+
<p><sub><a href="https://ant.design"><img alt="Ant Design" height="14" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style="vertical-align: -0.125em;" /></a> Part of the Ant Design ecosystem.</sub></p>
44
<p>📜 Virtual scrolling list component for React.</p>
55

66
<p>
@@ -15,7 +15,6 @@
1515

1616
<p align="center">English | <a href="./README.zh-CN.md">简体中文</a></p>
1717

18-
1918
## Highlights
2019

2120
- Built for React and maintained by the rc-component team.

‎README.zh-CN.md‎

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div align="center">
22
<h1>@rc-component/virtual-list</h1>
3-
<p><sub><img alt="Ant Design" height="14" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style="vertical-align: -0.125em;" /> Ant Design 生态的一部分。</sub></p>
3+
<p><sub><a href="https://ant.design"><img alt="Ant Design" height="14" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style="vertical-align: -0.125em;" /></a> Ant Design 生态的一部分。</sub></p>
44
<p>📜 React 虚拟列表组件,用于高性能渲染长列表。</p>
55

66
<p>
@@ -15,7 +15,6 @@
1515

1616
<p align="center"><a href="./README.md">English</a> | 简体中文</p>
1717

18-
1918
## 特性
2019

2120
- 面向 React 构建,并由 rc-component 团队维护。
@@ -61,19 +60,19 @@ npm start
6160

6261
### List
6362

64-
| 属性 | 说明 | 类型 | 默认值 |
65-
| ---------- | ---------------------------------------------------------------------------------------------------------------------- | -------------------------------------- | ------- |
63+
| 属性 | 说明 | 类型 | 默认值 |
64+
| ---------- | ------------------------------------------------------------------ | -------------------------------------- | ------- |
6665
| children | 每一项的渲染函数。第三个参数包含旧浏览器兼容路径使用的测量 props。 | `(item, index, props) => ReactElement` | - |
67-
| component | 自定义列表容器元素。 | `string` \| `ComponentType` | `div` |
68-
| data | 虚拟列表渲染的数据项。 | `T[]` | - |
69-
| disabled | 禁用滚动位置检查,通常用于配合动画。 | `boolean` | `false` |
70-
| fullHeight | holder 是否保持完整高度。 | `boolean` | `true` |
71-
| height | 可视列表高度。 | `number` | - |
72-
| itemHeight | 用于计算虚拟范围的最小项高度。 | `number` | - |
73-
| itemKey | 数据项 key 字段或 key 获取函数。 | `string` \| `(item) => React.Key` | - |
74-
| onScroll | 列表滚动时调用。 | `React.UIEventHandler<HTMLElement>` | - |
75-
| styles | 自定义滚动条部位样式。 | `object` | - |
76-
| virtual | 启用虚拟渲染。 | `boolean` | `true` |
66+
| component | 自定义列表容器元素。 | `string` \| `ComponentType` | `div` |
67+
| data | 虚拟列表渲染的数据项。 | `T[]` | - |
68+
| disabled | 禁用滚动位置检查,通常用于配合动画。 | `boolean` | `false` |
69+
| fullHeight | holder 是否保持完整高度。 | `boolean` | `true` |
70+
| height | 可视列表高度。 | `number` | - |
71+
| itemHeight | 用于计算虚拟范围的最小项高度。 | `number` | - |
72+
| itemKey | 数据项 key 字段或 key 获取函数。 | `string` \| `(item) => React.Key` | - |
73+
| onScroll | 列表滚动时调用。 | `React.UIEventHandler<HTMLElement>` | - |
74+
| styles | 自定义滚动条部位样式。 | `object` | - |
75+
| virtual | 启用虚拟渲染。 | `boolean` | `true` |
7776

7877
## 本地开发
7978

‎eslint.config.mjs‎

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import js from '@eslint/js';
2+
import { defineConfig } from 'eslint/config';
3+
import { dirname } from 'node:path';
4+
import { fileURLToPath } from 'node:url';
5+
import prettier from 'eslint-config-prettier';
6+
import jest from 'eslint-plugin-jest';
7+
import react from 'eslint-plugin-react';
8+
import reactHooks from 'eslint-plugin-react-hooks';
9+
import globals from 'globals';
10+
import tseslint from 'typescript-eslint';
11+
12+
const tsconfigRootDir = dirname(fileURLToPath(import.meta.url));
13+
14+
export default defineConfig([
15+
{
16+
plugins: {
17+
'@typescript-eslint': tseslint.plugin,
18+
},
19+
},
20+
{
21+
linterOptions: {
22+
reportUnusedDisableDirectives: 'warn',
23+
},
24+
},
25+
{
26+
ignores: [
27+
'node_modules/',
28+
'coverage/',
29+
'es/',
30+
'lib/',
31+
'dist/',
32+
'docs-dist/',
33+
'.docs-dist/',
34+
'.dumi/',
35+
'.doc/',
36+
'.vercel/',
37+
],
38+
},
39+
{
40+
files: ['**/*.{js,jsx,ts,tsx}'],
41+
extends: [
42+
js.configs.recommended,
43+
react.configs.flat.recommended,
44+
react.configs.flat['jsx-runtime'],
45+
prettier,
46+
],
47+
plugins: {
48+
'react-hooks': reactHooks,
49+
},
50+
languageOptions: {
51+
globals: {
52+
...globals.browser,
53+
...globals.node,
54+
},
55+
},
56+
settings: {
57+
react: {
58+
version: 'detect',
59+
},
60+
},
61+
rules: {
62+
'no-async-promise-executor': 'off',
63+
'no-empty-pattern': 'off',
64+
'no-irregular-whitespace': 'off',
65+
'no-prototype-builtins': 'off',
66+
'no-useless-escape': 'off',
67+
'no-extra-boolean-cast': 'off',
68+
'no-undef': 'off',
69+
'no-unused-vars': 'off',
70+
'react/no-find-dom-node': 'off',
71+
'react/display-name': 'off',
72+
'react/no-unknown-property': 'off',
73+
'react/prop-types': 'off',
74+
'react-hooks/exhaustive-deps': 'warn',
75+
'react-hooks/rules-of-hooks': 'error',
76+
},
77+
},
78+
{
79+
files: ['**/*.{ts,tsx}'],
80+
extends: [...tseslint.configs.recommended],
81+
rules: {
82+
'@typescript-eslint/ban-ts-comment': 'off',
83+
'@typescript-eslint/no-empty-object-type': 'off',
84+
'@typescript-eslint/no-explicit-any': 'off',
85+
'@typescript-eslint/no-unsafe-function-type': 'off',
86+
'@typescript-eslint/no-unnecessary-type-constraint': 'off',
87+
'@typescript-eslint/no-unused-vars': 'off',
88+
},
89+
},
90+
{
91+
files: ['src/**/*.{ts,tsx}'],
92+
languageOptions: {
93+
parserOptions: {
94+
projectService: true,
95+
tsconfigRootDir,
96+
},
97+
},
98+
},
99+
{
100+
files: ['tests/**/*.{js,jsx,ts,tsx}', '**/*.{test,spec}.{js,jsx,ts,tsx}'],
101+
extends: [jest.configs['flat/recommended']],
102+
rules: {
103+
'jest/no-disabled-tests': 'off',
104+
'jest/no-done-callback': 'off',
105+
'jest/no-identical-title': 'off',
106+
'jest/expect-expect': 'off',
107+
'jest/no-alias-methods': 'off',
108+
'jest/no-conditional-expect': 'off',
109+
'jest/no-export': 'off',
110+
'jest/no-standalone-expect': 'off',
111+
'jest/valid-expect': 'off',
112+
'jest/valid-title': 'off',
113+
},
114+
},
115+
]);

‎examples/animate.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ const Demo = () => {
130130
const [animating, setAnimating] = React.useState(false);
131131
const [insertIndex, setInsertIndex] = React.useState<number>();
132132

133-
const listRef = React.useRef<ListRef>();
133+
const listRef = React.useRef<ListRef>(null);
134134

135135
const onClose = (id: string) => {
136136
setCloseMap({

‎examples/no-virtual.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface Item {
77
height: number;
88
}
99

10-
const MyItem: React.FC<Item> = ({ id, height }, ref) => {
10+
const MyItem = React.forwardRef<HTMLSpanElement, Item>(({ id, height }, ref) => {
1111
return (
1212
<span
1313
ref={ref}
@@ -23,9 +23,9 @@ const MyItem: React.FC<Item> = ({ id, height }, ref) => {
2323
{id}
2424
</span>
2525
);
26-
};
26+
});
2727

28-
const ForwardMyItem = React.forwardRef(MyItem as any);
28+
const ForwardMyItem = MyItem;
2929

3030
const data: Item[] = [];
3131
for (let i = 0; i < 100; i += 1) {

‎examples/switch.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ interface Item {
66
id: number;
77
}
88

9-
const MyItem: React.FC<Item> = ({ id }, ref) => (
9+
const MyItem = React.forwardRef<HTMLSpanElement, Item>(({ id }, ref) => (
1010
<span
1111
ref={ref}
1212
style={{
@@ -21,9 +21,9 @@ const MyItem: React.FC<Item> = ({ id }, ref) => (
2121
>
2222
{id}
2323
</span>
24-
);
24+
));
2525

26-
const ForwardMyItem = React.forwardRef(MyItem as any);
26+
const ForwardMyItem = MyItem;
2727

2828
function getData(count: number) {
2929
const data: Item[] = [];
@@ -39,7 +39,7 @@ const Demo = () => {
3939
const [height, setHeight] = React.useState(200);
4040
const [data, setData] = React.useState(getData(20));
4141
const [fullHeight, setFullHeight] = React.useState(true);
42-
const listRef = React.useRef<ListRef>();
42+
const listRef = React.useRef<ListRef>(null);
4343

4444
return (
4545
<React.StrictMode>

‎global.d.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// <reference types="jest" />
2+
/// <reference types="node" />
3+
/// <reference types="react" />
4+
/// <reference types="react-dom" />
5+
/// <reference types="@testing-library/jest-dom" />
6+
7+
declare module '*.css';
8+
declare module '*.less';
9+
declare module 'jsonp';
10+
11+
declare module 'moment/locale/zh-cn';

‎package.json‎

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,33 +48,40 @@
4848
"react-dom": ">=18.0.0"
4949
},
5050
"devDependencies": {
51+
"@eslint/js": "^9.39.4",
5152
"@rc-component/father-plugin": "^2.2.0",
5253
"@rc-component/np": "^1.0.4",
54+
"@testing-library/dom": "^10.4.1",
5355
"@testing-library/jest-dom": "^6.9.1",
54-
"@testing-library/react": "^15.0.7",
55-
"@types/jest": "^29.5.14",
56+
"@testing-library/react": "^16.3.2",
57+
"@types/jest": "^30.0.0",
5658
"@types/node": "^26.0.1",
57-
"@types/react": "^18.3.31",
58-
"@types/react-dom": "^18.3.7",
59+
"@types/react": "^19.2.17",
60+
"@types/react-dom": "^19.2.3",
5961
"@types/warning": "^3.0.4",
60-
"dumi": "^2.4.35",
61-
"eslint": "^8.57.1",
62-
"eslint-plugin-unicorn": "^56.0.1",
63-
"father": "^4.6.23",
64-
"glob": "^13.0.6",
65-
"rc-animate": "^2.9.1",
66-
"rc-test": "^7.1.3",
67-
"react": "^18.3.1",
68-
"react-dom": "^18.3.1",
69-
"typescript": "^5.9.3",
7062
"cross-env": "^10.1.0",
63+
"dumi": "^2.4.38",
64+
"eslint": "^9.39.4",
65+
"eslint-config-prettier": "^10.1.8",
66+
"eslint-plugin-jest": "^29.15.4",
67+
"eslint-plugin-react": "^7.37.5",
68+
"eslint-plugin-react-hooks": "^7.1.1",
69+
"father": "^4.6.24",
7170
"gh-pages": "^6.3.0",
72-
"prettier": "^3.9.0",
71+
"glob": "^13.0.6",
72+
"globals": "^17.7.0",
7373
"husky": "^9.1.7",
74-
"lint-staged": "^16.4.0"
74+
"lint-staged": "^17.0.8",
75+
"prettier": "^3.9.4",
76+
"rc-animate": "^2.9.1",
77+
"rc-test": "^7.1.3",
78+
"react": "^19.2.7",
79+
"react-dom": "^19.2.7",
80+
"typescript": "^6.0.3",
81+
"typescript-eslint": "^8.62.1"
7582
},
7683
"dependencies": {
77-
"@babel/runtime": "^7.20.0",
84+
"@babel/runtime": "^7.29.7",
7885
"@rc-component/resize-observer": "^1.0.1",
7986
"@rc-component/util": "^1.4.0",
8087
"clsx": "^2.1.1"

0 commit comments

Comments
 (0)