Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ module.exports = {
'no-unused-expressions': 'off',
'no-bitwise': 'off',
'no-useless-return': 'off',
'default-param-last': 'off',
'class-methods-use-this': 'off',
'no-plusplus': [
'error',
{
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@
"cz-conventional-changelog": "^3.3.0",
"dom-parser": "^0.1.6",
"esbuild": "^0.14.9",
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint": "^8.57.1",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^9.1.0",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/Tencent/tdesign-react/pull/4303/changes#r3496794260

前段时间这个 PR 讨论过...应该不需要 eslint-config-prettier 这个包 🤔? @RSS1102

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

之前从common 子仓带入了,现屏蔽后,没装报错

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

报什么错?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "~7.28.0",
"eslint-plugin-react-hooks": "^4.0.0",
Expand Down Expand Up @@ -147,7 +148,6 @@
"@popperjs/core": "~2.11.2",
"@tdesign-react/chat": "workspace:^",
"@tdesign/ai-chat-engine": "workspace:^",
"@tdesign/common": "workspace:^",
"@tdesign/common-docs": "workspace:^",
"@tdesign/common-js": "workspace:^",
"@tdesign/common-style": "workspace:^",
Expand Down
3 changes: 2 additions & 1 deletion packages/components/affix/Affix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ const Affix = forwardRef<AffixRef, AffixProps>((props, ref) => {
}
} else {
const containerHeight =
scrollContainer.current?.[isWindow(scrollContainer.current) ? 'innerHeight' : 'clientHeight'] - wrapHeight;
(scrollContainer.current?.[isWindow(scrollContainer.current) ? 'innerHeight' : 'clientHeight'] ?? 0) -
wrapHeight;
const calcBottom = containerToTop + containerHeight - (offsetBottom ?? 0); // 计算 bottom 相对应的 top 值
if (calcTop <= offsetTop) {
// top 的触发
Expand Down
4 changes: 3 additions & 1 deletion packages/components/dialog/_example/async.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import React, { useState } from 'react';
import { Button, Dialog, DialogPlugin } from 'tdesign-react';

async function delay(time) {
return new Promise((resolve) => setTimeout(resolve, time * 1000));
return new Promise((resolve) => {
setTimeout(resolve, time * 1000);
});
}

export default function BasicUsage() {
Expand Down
6 changes: 4 additions & 2 deletions packages/components/dropdown/DropdownMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const DropdownMenu: React.FC<DropdownProps> = (props) => {
setPanelTopContentHeight(panelTopHeight || 0);
}
});
const menuHeight = menuChildren?.length * 30;
const menuHeight = menuChildren.length * 30;
if (menuHeight >= maxHeight) setIsOverMaxHeight(true);
}
}, [maxHeight, panelTopContent]);
Expand Down Expand Up @@ -142,7 +142,9 @@ const DropdownMenu: React.FC<DropdownProps> = (props) => {
? () => null
: (
value: string | number | { [key: string]: any },
context: { e: React.MouseEvent<HTMLDivElement, MouseEvent> },
context: {
e: React.MouseEvent<HTMLDivElement, MouseEvent>;
},
) => handleItemClick({ data: optionItem, context })
}
>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/form/hooks/useWatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function useWatch(name: NamePath, form: InternalFormInstance) {
useEffect(() => {
if (!isValidForm) return;

const { registerWatch = noop } = form.getInternalHooks?.(HOOK_MARK);
const { registerWatch = noop } = form.getInternalHooks?.(HOOK_MARK) || {};

const cancelRegister = registerWatch(() => {
const allFieldsValue = form.getFieldsValue?.(true);
Expand Down
6 changes: 3 additions & 3 deletions packages/components/progress/Progress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@ const Progress = forwardRef<HTMLDivElement, ProgressProps>((props, ref) => {
return diameter;
}
switch (size) {
default:
diameter = Number(size);
break;
case 'small':
diameter = 72;
break;
Expand All @@ -145,6 +142,9 @@ const Progress = forwardRef<HTMLDivElement, ProgressProps>((props, ref) => {
case 'large':
diameter = 160;
break;
default:
diameter = Number(size);
break;
}
return diameter;
};
Expand Down
32 changes: 27 additions & 5 deletions packages/components/radio/__tests__/radio.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,27 @@ describe('RadioGroup [basic api]', () => {
describe('RadioGroup [primary-filled bg-block]', () => {
const MOCK_SIZES = [
{ selector: '.t-radio-group', width: 300, height: 40, left: 0, top: 0 },
{ selector: '.t-radio-button:nth-child(1)', width: 60, height: 32, left: 4, top: 4 },
{ selector: '.t-radio-button:nth-child(2)', width: 60, height: 32, left: 68, top: 4 },
{ selector: '.t-radio-button:nth-child(3)', width: 60, height: 32, left: 132, top: 4 },
{
selector: '.t-radio-button:nth-child(1)',
width: 60,
height: 32,
left: 4,
top: 4,
},
{
selector: '.t-radio-button:nth-child(2)',
width: 60,
height: 32,
left: 68,
top: 4,
},
{
selector: '.t-radio-button:nth-child(3)',
width: 60,
height: 32,
left: 132,
top: 4,
},
];

// 根据选项索引获取对应按钮的尺寸数据
Expand Down Expand Up @@ -218,7 +236,9 @@ describe('RadioGroup [primary-filled bg-block]', () => {
expect(container.querySelector('.t-radio-group__bg-block')).not.toBeInTheDocument();

await act(async () => {
await new Promise((resolve) => setTimeout(resolve, 150));
await new Promise((resolve) => {
setTimeout(resolve, 150);
});
});

const bgBlock = container.querySelector('.t-radio-group__bg-block') as HTMLElement;
Expand Down Expand Up @@ -302,7 +322,9 @@ describe('RadioGroup [primary-filled bg-block]', () => {
}

await act(async () => {
await new Promise((resolve) => setTimeout(resolve, 100));
await new Promise((resolve) => {
setTimeout(resolve, 100);
});
});

const bgBlock = container.querySelector('.t-radio-group__bg-block') as HTMLElement;
Expand Down
8 changes: 6 additions & 2 deletions packages/components/switch/__tests__/switch.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ describe('Switch 组件测试', () => {
});
const { container } = render(<Switch onChange={clickFn} beforeChange={beforeChangeResolve} />);
fireEvent.click(container.firstChild);
await new Promise((resolve) => setTimeout(resolve, 100));
await new Promise((resolve) => {
setTimeout(resolve, 100);
});
expect(container.firstChild.classList.contains('t-is-checked')).toBeTruthy();
});
test('beforeChange reject', async () => {
Expand All @@ -70,7 +72,9 @@ describe('Switch 组件测试', () => {
});
const { container } = render(<Switch onChange={clickFn} beforeChange={beforeChangeResolve} />);
fireEvent.click(container.firstChild);
await new Promise((resolve) => setTimeout(resolve, 100));
await new Promise((resolve) => {
setTimeout(resolve, 100);
});
expect(container.firstChild.classList.contains('t-is-checked')).toBeFalsy();
});
});
21 changes: 15 additions & 6 deletions packages/components/tabs/__tests__/tabs.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ describe('Tabs 组件测试', () => {
label: string;
value: string;
}[]
>((re) =>
>((re) => {
setTimeout(() => {
re([
{ label: 'A', value: 'a' },
{ label: 'B', value: 'b' },
]);
}, 1000),
),
}, 1000);
}),
);

const useFetch = <F extends () => Promise<any>>(func: F) => {
Expand Down Expand Up @@ -127,7 +127,9 @@ describe('Tabs 组件测试', () => {
const getNavItems = () => tabInstance.querySelectorAll('.t-tabs__nav-item');

expect(getNavItems().length).toBe(0);
await new Promise((resolve) => setTimeout(resolve, 1000));
await new Promise((resolve) => {
setTimeout(resolve, 1000);
});
expect(getNavItems().length).toBe(2);
expect(() => tabInstance.querySelector('.t-tabs__bar')).not.toBe(null);
const tabBar = tabInstance.querySelector('.t-tabs__bar');
Expand Down Expand Up @@ -193,11 +195,18 @@ describe('Tabs 组件测试', () => {
expect(onTabRemoveFn).toHaveBeenCalledTimes(1);
expect(onTabPanelRemoveFn).toHaveBeenCalledTimes(1);

expect(onTabRemoveFn).toHaveBeenCalledWith({ value: 'a', e: expect.any(Object), index: 0 });
expect(onTabRemoveFn).toHaveBeenCalledWith({
value: 'a',
e: expect.any(Object),
index: 0,
});
const tabRemoveFnArg = onTabRemoveFn.mock.calls[0][0];
expect(tabRemoveFnArg.e.nativeEvent).toBeInstanceOf(MouseEvent);

expect(onTabPanelRemoveFn).toHaveBeenCalledWith({ value: 'a', e: expect.any(Object) });
expect(onTabPanelRemoveFn).toHaveBeenCalledWith({
value: 'a',
e: expect.any(Object),
});
const tabPanelRemoveFnArg = onTabPanelRemoveFn.mock.calls[0][0];
expect(tabPanelRemoveFnArg.e.nativeEvent).toBeInstanceOf(MouseEvent);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/components/time-picker/panel/SinglePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const SinglePanel: FC<SinglePanelProps> = (props) => {

let val: number | string;
let formattedVal: string;
const scrollTop = colsRef.current[idx]?.scrollTop + panelOffset.top;
const scrollTop = (colsRef.current[idx]?.scrollTop ?? 0) + panelOffset.top;
const { offsetHeight, margin } = getItemHeight();
const timeItemTotalHeight = offsetHeight + margin;
let colStep = Math.abs(Math.round(scrollTop / timeItemTotalHeight + 0.5));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ export default function ServiceConfig() {
onAbort: async () => {
console.log('用户中止对话');
// 可以执行清理操作
await new Promise((resolve) => setTimeout(resolve, 100));
await new Promise((resolve) => {
setTimeout(resolve, 100);
});
},

// 7. 错误处理
Expand Down
8 changes: 4 additions & 4 deletions packages/tdesign-react-aigc/site/site.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ export const docs = [
titleEn: 'Theme Customization',
name: 'custom-theme',
path: '/react-chat/custom-theme',
component: () => import('@tdesign/common/docs/web/theme.md'),
componentEn: () => import('@tdesign/common/docs/web/theme.en-US.md'),
component: () => import('@tdesign/common-docs/web/theme.md'),
componentEn: () => import('@tdesign/common-docs/web/theme.en-US.md'),
},
{
title: '深色模式',
titleEn: 'Dark Mode',
name: 'dark-mode',
path: '/react-chat/dark-mode',
component: () => import('@tdesign/common/docs/dark-mode.md'),
componentEn: () => import('@tdesign/common/docs/dark-mode.en-US.md'),
component: () => import('@tdesign/common-docs/dark-mode.md'),
componentEn: () => import('@tdesign/common-docs/dark-mode.en-US.md'),
},
{
title: '自定义样式',
Expand Down
16 changes: 8 additions & 8 deletions packages/tdesign-react/site/site.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ export const docs = [
titleEn: 'Overview',
name: 'overview',
path: '/react/overview',
component: () => import('@tdesign/common/docs/web/overview.md'),
componentEn: () => import('@tdesign/common/docs/web/overview.en-US.md'),
component: () => import('@tdesign/common-docs/web/overview.md'),
componentEn: () => import('@tdesign/common-docs/web/overview.en-US.md'),
},
{
title: 'MCP',
titleEn: 'MCP',
name: 'mcp',
path: '/react/mcp',
component: () => import('@tdesign/common/docs/mcp.md'),
componentEn: () => import('@tdesign/common/docs/mcp.en-US.md'),
component: () => import('@tdesign/common-docs/mcp.md'),
componentEn: () => import('@tdesign/common-docs/mcp.en-US.md'),
},
],
},
Expand All @@ -64,16 +64,16 @@ export const docs = [
titleEn: 'Theme Customization',
name: 'custom-theme',
path: '/react/custom-theme',
component: () => import('@tdesign/common/docs/web/theme.md'),
componentEn: () => import('@tdesign/common/docs/web/theme.en-US.md'),
component: () => import('@tdesign/common-docs/web/theme.md'),
componentEn: () => import('@tdesign/common-docs/web/theme.en-US.md'),
},
{
title: '深色模式',
titleEn: 'Dark Mode',
name: 'dark-mode',
path: '/react/dark-mode',
component: () => import('@tdesign/common/docs/dark-mode.md'),
componentEn: () => import('@tdesign/common/docs/dark-mode.en-US.md'),
component: () => import('@tdesign/common-docs/dark-mode.md'),
componentEn: () => import('@tdesign/common-docs/dark-mode.en-US.md'),
},
],
},
Expand Down
12 changes: 7 additions & 5 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
packages:
- 'packages/**'
- 'internal/**'
- 'test'

- "packages/**"
- "internal/**"
- "test"
- "!packages/common"
- "!packages/ai-core"

# 提升依赖项到根目录,以避免重复安装相同的包
shamefullyHoist: true
shamefullyHoist: true
16 changes: 7 additions & 9 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@
"checkJs": true,
"downlevelIteration": true,
"esModuleInterop": true,
"skipLibCheck": true
"skipLibCheck": true,
"types": [
"node",
"vitest/globals",
"@testing-library/jest-dom",
"@testing-library/react"
]
},
"include": [
"./packages/components",
Expand All @@ -58,13 +64,5 @@
"cjs",
"es"
],
"types": [
"node",
"jest",
"vitest/globals",
"@testing-library/jest-dom",
"@testing-library/react-hooks",
"@testing-library/react"
],
"compileOnSave": false
}
Loading