From a25a0cf4735041005dcb4f4573fd2a729d5f07aa Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 7 Jul 2025 17:22:24 +0800 Subject: [PATCH] chore: fix biome lint errors --- biome.json | 3 ++- package.json | 8 ++++++-- src/global.style.ts | 2 +- src/pages/account/center/_mock.ts | 6 +++--- src/pages/account/center/index.tsx | 3 +-- src/pages/account/settings/_mock.ts | 2 +- src/pages/account/settings/components/base.tsx | 2 +- .../account/settings/components/security.tsx | 4 +--- src/pages/account/settings/index.tsx | 2 +- src/pages/dashboard/analysis/_mock.ts | 4 ++-- .../components/Charts/ChartCard/index.tsx | 17 ++++++----------- .../components/Charts/WaterWave/index.tsx | 8 ++++++-- .../dashboard/analysis/components/TopSearch.tsx | 2 -- src/pages/dashboard/analysis/index.tsx | 12 ++++++------ .../monitor/components/ActiveChart/index.tsx | 10 +++++----- .../components/Charts/WaterWave/index.tsx | 8 ++++++-- .../dashboard/monitor/components/Map/index.tsx | 2 +- src/pages/dashboard/monitor/index.tsx | 7 +++---- src/pages/dashboard/workplace/_mock.ts | 4 ++-- .../form/advanced-form/components/TableForm.tsx | 4 ++-- src/pages/form/advanced-form/index.tsx | 6 +++--- src/pages/list/basic-list/_mock.ts | 6 +++--- .../basic-list/components/OperationModal.tsx | 2 +- src/pages/list/card-list/_mock.ts | 4 ++-- src/pages/list/card-list/index.tsx | 2 +- src/pages/list/search/applications/_mock.ts | 4 ++-- .../applications/components/TagSelect/index.tsx | 5 ++--- src/pages/list/search/applications/index.tsx | 15 ++++++++++----- src/pages/list/search/articles/_mock.ts | 4 ++-- .../articles/components/TagSelect/index.tsx | 5 ++--- src/pages/list/search/articles/index.tsx | 17 +++++++++++------ src/pages/list/search/projects/_mock.ts | 4 ++-- .../projects/components/AvatarList/index.tsx | 4 ++-- .../projects/components/TagSelect/index.tsx | 5 ++--- src/pages/list/search/projects/index.tsx | 15 ++++++++++----- src/pages/list/table-list/_mock.ts | 4 ++-- src/pages/list/table-list/index.tsx | 8 ++++---- src/pages/profile/advanced/_mock.ts | 2 +- src/pages/table-list/index.tsx | 2 +- src/pages/user/login/login.test.tsx | 3 +-- src/pages/user/register/index.tsx | 4 ++-- 41 files changed, 122 insertions(+), 109 deletions(-) diff --git a/biome.json b/biome.json index 24487d51..e7d474b2 100644 --- a/biome.json +++ b/biome.json @@ -30,7 +30,8 @@ }, "a11y": { "noStaticElementInteractions": "off", - "useValidAnchor": "off" + "useValidAnchor": "off", + "useKeyWithClickEvents": "off" } } }, diff --git a/package.json b/package.json index 4e2918c6..1f69c76f 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,11 @@ "classnames": "^2.5.1", "dayjs": "^1.11.13", "react": "^19.1.0", - "react-dom": "^19.1.0" + "react-dom": "^19.1.0", + "@ant-design/plots": "^2.6.0", + "@antv/l7-react": "^2.4.3", + "@antv/l7": "^2.22.7", + "numeral": "^2.0.6" }, "devDependencies": { "@ant-design/pro-cli": "^3.3.0", @@ -104,4 +108,4 @@ "create-umi" ] } -} +} \ No newline at end of file diff --git a/src/global.style.ts b/src/global.style.ts index d037918a..193148ff 100644 --- a/src/global.style.ts +++ b/src/global.style.ts @@ -1,6 +1,6 @@ import { createStyles } from 'antd-style'; -const useStyles = createStyles(({}) => { +const useStyles = createStyles(() => { return { colorWeak: { filter: 'invert(80%)', diff --git a/src/pages/account/center/_mock.ts b/src/pages/account/center/_mock.ts index 43f203a4..a2fa9b6c 100644 --- a/src/pages/account/center/_mock.ts +++ b/src/pages/account/center/_mock.ts @@ -180,8 +180,8 @@ function fakeList(count: number): ListItemDataType[] { percent: Math.ceil(Math.random() * 50) + 50, logo: avatars[i % 8], href: 'https://ant.design', - updatedAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i).getTime(), - createdAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i).getTime(), + updatedAt: new Date(Date.now()- 1000 * 60 * 60 * 2 * i).getTime(), + createdAt: new Date(Date.now()- 1000 * 60 * 60 * 2 * i).getTime(), subDescription: desc[i % 5], description: '在中台产品的研发过程中,会出现不同的设计规范和实现方式,但其中往往存在很多类似的页面和组件,这些类似的组件会被抽离成一套标准规范。', @@ -229,7 +229,7 @@ function getFakeList(req: Request, res: Response) { } // 获取用户信息 -function getCurrentUser(req: Request, res: Response) { +function getCurrentUser(_req: Request, res: Response) { return res.json({ data: currentUseDetail, }); diff --git a/src/pages/account/center/index.tsx b/src/pages/account/center/index.tsx index 0b99fe67..d73c1c01 100644 --- a/src/pages/account/center/index.tsx +++ b/src/pages/account/center/index.tsx @@ -223,8 +223,7 @@ const Center: React.FC = () => {
团队
- {currentUser.notice && - currentUser.notice.map((item) => ( + {currentUser.notice?.map((item) => ( diff --git a/src/pages/account/settings/_mock.ts b/src/pages/account/settings/_mock.ts index 66e6e25d..e0ab541d 100644 --- a/src/pages/account/settings/_mock.ts +++ b/src/pages/account/settings/_mock.ts @@ -15,7 +15,7 @@ function getCity(req: Request, res: Response) { }); } -function getCurrentUse(req: Request, res: Response) { +function getCurrentUse(_req: Request, res: Response) { return res.json({ data: { name: 'Serati Ma', diff --git a/src/pages/account/settings/components/base.tsx b/src/pages/account/settings/components/base.tsx index 37448e94..8e02506e 100644 --- a/src/pages/account/settings/components/base.tsx +++ b/src/pages/account/settings/components/base.tsx @@ -13,7 +13,7 @@ import React from 'react'; import { queryCity, queryCurrent, queryProvince } from '../service'; import useStyles from './index.style'; -const validatorPhone = (rule: any, value: string[], callback: (message?: string) => void) => { +const validatorPhone = (_rule: any, value: string[], callback: (message?: string) => void) => { if (!value[0]) { callback('Please input your area code!'); } diff --git a/src/pages/account/settings/components/security.tsx b/src/pages/account/settings/components/security.tsx index a66f78a5..3a1507d8 100644 --- a/src/pages/account/settings/components/security.tsx +++ b/src/pages/account/settings/components/security.tsx @@ -45,8 +45,7 @@ const SecurityView: React.FC = () => { const data = getData(); return ( - <> - > + > itemLayout="horizontal" dataSource={data} renderItem={(item) => ( @@ -55,7 +54,6 @@ const SecurityView: React.FC = () => { )} /> - ); }; diff --git a/src/pages/account/settings/index.tsx b/src/pages/account/settings/index.tsx index 84a7e491..72874883 100644 --- a/src/pages/account/settings/index.tsx +++ b/src/pages/account/settings/index.tsx @@ -51,7 +51,7 @@ const Settings: React.FC = () => { return () => { window.removeEventListener('resize', resize); }; - }, [dom.current]); + }, [resize]); const getMenu = () => { return Object.keys(menuMap).map((item) => ({ key: item, label: menuMap[item] })); }; diff --git a/src/pages/dashboard/analysis/_mock.ts b/src/pages/dashboard/analysis/_mock.ts index 787e2f22..ffd294ae 100644 --- a/src/pages/dashboard/analysis/_mock.ts +++ b/src/pages/dashboard/analysis/_mock.ts @@ -4,7 +4,7 @@ import type { AnalysisData, DataItem, RadarData } from './data.d'; // mock data const visitData: DataItem[] = []; -const beginDay = new Date().getTime(); +const beginDay = Date.now(); const fakeY = [7, 5, 4, 2, 4, 7, 5, 6, 5, 9, 6, 3, 1, 5, 3, 6, 5]; for (let i = 0; i < fakeY.length; i += 1) { @@ -126,7 +126,7 @@ for (let i = 0; i < 10; i += 1) { } const offlineChartData = []; for (let i = 0; i < 20; i += 1) { - const date = dayjs(new Date().getTime() + 1000 * 60 * 30 * i).format('HH:mm'); + const date = dayjs(Date.now()+ 1000 * 60 * 30 * i).format('HH:mm'); offlineChartData.push({ date, type: '客流量', diff --git a/src/pages/dashboard/analysis/components/Charts/ChartCard/index.tsx b/src/pages/dashboard/analysis/components/Charts/ChartCard/index.tsx index 95d30d2f..f527c0e4 100644 --- a/src/pages/dashboard/analysis/components/Charts/ChartCard/index.tsx +++ b/src/pages/dashboard/analysis/components/Charts/ChartCard/index.tsx @@ -22,7 +22,7 @@ const ChartCard: React.FC = (props) => { if (!total && total !== 0) { return null; } - let totalDom; + let totalDom: React.ReactNode | null = null; switch (typeof total) { case 'undefined': totalDom = null; @@ -63,7 +63,7 @@ const ChartCard: React.FC = (props) => { height: contentHeight || 'auto', }} > -
{children}
+
{children}
)} {footer && ( @@ -81,20 +81,15 @@ const ChartCard: React.FC = (props) => { const { loading = false, - contentHeight, - title, - avatar, - action, - total, - footer, - children, ...rest } = props; return ( diff --git a/src/pages/dashboard/analysis/components/Charts/WaterWave/index.tsx b/src/pages/dashboard/analysis/components/Charts/WaterWave/index.tsx index 3a976180..ed4bae7d 100644 --- a/src/pages/dashboard/analysis/components/Charts/WaterWave/index.tsx +++ b/src/pages/dashboard/analysis/components/Charts/WaterWave/index.tsx @@ -185,7 +185,9 @@ class WaterWave extends Component { return (
(this.root = n)} + ref={(n) => { + this.root = n; + }} style={{ transform: `scale(${radio})`, }} @@ -199,7 +201,9 @@ class WaterWave extends Component { > (this.node = n)} + ref={(n) => { + this.node = n; + }} width={height * 2} height={height * 2} /> diff --git a/src/pages/dashboard/analysis/components/TopSearch.tsx b/src/pages/dashboard/analysis/components/TopSearch.tsx index 2cda898e..94c985a3 100644 --- a/src/pages/dashboard/analysis/components/TopSearch.tsx +++ b/src/pages/dashboard/analysis/components/TopSearch.tsx @@ -4,7 +4,6 @@ import { Card, Col, Row, Table, Tooltip } from 'antd'; import numeral from 'numeral'; import React from 'react'; import type { DataItem } from '../data.d'; -import useStyles from '../style.style'; import NumberInfo from './NumberInfo'; import Trend from './Trend'; @@ -19,7 +18,6 @@ const TopSearch = ({ dropdownGroup: React.ReactNode; searchData: DataItem[]; }) => { - const { styles } = useStyles(); const columns = [ { title: '排名', diff --git a/src/pages/dashboard/analysis/index.tsx b/src/pages/dashboard/analysis/index.tsx index c3344740..e3f69364 100644 --- a/src/pages/dashboard/analysis/index.tsx +++ b/src/pages/dashboard/analysis/index.tsx @@ -18,7 +18,8 @@ import type { AnalysisData } from './data.d'; import { fakeChartData } from './service'; import useStyles from './style.style'; import { getTimeDistance } from './utils/utils'; -type RangePickerValue = RangePickerProps['value']; +type RangePickerValue = RangePickerProps[ + 'value']; type AnalysisProps = { dashboardAndanalysis: AnalysisData; loading: boolean; @@ -58,8 +59,7 @@ const Analysis: FC = () => { return ''; }; - let salesPieData; - + let salesPieData: any; if (salesType === 'all') { salesPieData = data?.salesTypeData; } else { @@ -93,10 +93,10 @@ const Analysis: FC = () => { const handleTabChange = (key: string) => { setCurrentTabKey(key); }; - const activeKey = currentTabKey || (data?.offlineData[0] && data?.offlineData[0].name) || ''; + const activeKey = currentTabKey || (data?.offlineData[0]?.name) || ''; return ( - <> + }> @@ -150,7 +150,7 @@ const Analysis: FC = () => { handleTabChange={handleTabChange} /> - + ); }; diff --git a/src/pages/dashboard/monitor/components/ActiveChart/index.tsx b/src/pages/dashboard/monitor/components/ActiveChart/index.tsx index 2e0b1ffa..6f3c8b64 100644 --- a/src/pages/dashboard/monitor/components/ActiveChart/index.tsx +++ b/src/pages/dashboard/monitor/components/ActiveChart/index.tsx @@ -1,6 +1,6 @@ import { Area } from '@ant-design/plots'; import { Statistic } from 'antd'; -import { useEffect, useRef, useState } from 'react'; +import { useEffect, useRef, useState, useCallback } from 'react'; import useStyles from './index.style'; function fixedZero(val: number) { return val * 1 < 10 ? `0${val}` : val; @@ -21,24 +21,24 @@ const ActiveChart = () => { const requestRef = useRef(null); const { styles } = useStyles(); const [activeData, setActiveData] = useState<{ x: string; y: number }[]>([]); - const loopData = () => { + const loopData = useCallback(() => { requestRef.current = requestAnimationFrame(() => { timerRef.current = window.setTimeout(() => { setActiveData(getActiveData()); loopData(); }, 2000); }); - }; + }, []); useEffect(() => { loopData(); return () => { - clearTimeout(timerRef.current!); + clearTimeout(timerRef.current as number); if (requestRef.current) { cancelAnimationFrame(requestRef.current); } }; - }, []); + }, [loopData]); return (
diff --git a/src/pages/dashboard/monitor/components/Charts/WaterWave/index.tsx b/src/pages/dashboard/monitor/components/Charts/WaterWave/index.tsx index 3a976180..ed4bae7d 100644 --- a/src/pages/dashboard/monitor/components/Charts/WaterWave/index.tsx +++ b/src/pages/dashboard/monitor/components/Charts/WaterWave/index.tsx @@ -185,7 +185,9 @@ class WaterWave extends Component { return (
(this.root = n)} + ref={(n) => { + this.root = n; + }} style={{ transform: `scale(${radio})`, }} @@ -199,7 +201,9 @@ class WaterWave extends Component { > (this.node = n)} + ref={(n) => { + this.node = n; + }} width={height * 2} height={height * 2} /> diff --git a/src/pages/dashboard/monitor/components/Map/index.tsx b/src/pages/dashboard/monitor/components/Map/index.tsx index 9459fa83..b434a9f0 100644 --- a/src/pages/dashboard/monitor/components/Map/index.tsx +++ b/src/pages/dashboard/monitor/components/Map/index.tsx @@ -3,7 +3,7 @@ import { HeatmapLayer, MapboxScene, PointLayer } from '@antv/l7-react'; import * as React from 'react'; const colors = ['#eff3ff', '#c6dbef', '#9ecae1', '#6baed6', '#4292c6', '#2171b5', '#084594']; -export default class Map extends React.Component { +export default class MonitorMap extends React.Component { state = { data: null, grid: null, diff --git a/src/pages/dashboard/monitor/index.tsx b/src/pages/dashboard/monitor/index.tsx index 4cbe4a88..61847969 100644 --- a/src/pages/dashboard/monitor/index.tsx +++ b/src/pages/dashboard/monitor/index.tsx @@ -5,7 +5,7 @@ import { Card, Col, Progress, Row, Statistic } from 'antd'; import numeral from 'numeral'; import type { FC } from 'react'; import ActiveChart from './components/ActiveChart'; -import Map from './components/Map'; +import MonitorMap from './components/Map'; import { queryTags } from './service'; import useStyles from './style.style'; @@ -24,7 +24,6 @@ const Monitor: FC = () => { }); return ( - <> {
- +
@@ -178,7 +177,7 @@ const Monitor: FC = () => { - +
); }; diff --git a/src/pages/dashboard/workplace/_mock.ts b/src/pages/dashboard/workplace/_mock.ts index b1ddfb53..75b8fcf5 100644 --- a/src/pages/dashboard/workplace/_mock.ts +++ b/src/pages/dashboard/workplace/_mock.ts @@ -4,7 +4,7 @@ import type { DataItem, OfflineDataType, SearchDataType } from './data.d'; // mock data const visitData: DataItem[] = []; -const beginDay = new Date().getTime(); +const beginDay = Date.now(); const fakeY = [7, 5, 4, 2, 4, 7, 5, 6, 5, 9, 6, 3, 1, 5, 3, 6, 5]; for (let i = 0; i < fakeY.length; i += 1) { @@ -127,7 +127,7 @@ for (let i = 0; i < 10; i += 1) { const offlineChartData: DataItem[] = []; for (let i = 0; i < 20; i += 1) { offlineChartData.push({ - x: new Date().getTime() + 1000 * 60 * 30 * i, + x: Date.now()+ 1000 * 60 * 30 * i, y1: Math.floor(Math.random() * 100) + 10, y2: Math.floor(Math.random() * 100) + 10, }); diff --git a/src/pages/form/advanced-form/components/TableForm.tsx b/src/pages/form/advanced-form/components/TableForm.tsx index e0e613b8..b98256c1 100644 --- a/src/pages/form/advanced-form/components/TableForm.tsx +++ b/src/pages/form/advanced-form/components/TableForm.tsx @@ -72,7 +72,7 @@ const TableForm: FC = ({ value, onChange }) => { ) => { const newData = [...(data as TableFormDateType[])]; const target = getRowByKey(key, newData); - if (target && target[fieldName]) { + if (target?.[fieldName]) { target[fieldName as 'key'] = e.target.value; setData(newData); } @@ -191,7 +191,7 @@ const TableForm: FC = ({ value, onChange }) => { { title: '操作', key: 'action', - render: (text: string, record: TableFormDateType) => { + render: (_text: string, record: TableFormDateType) => { if (!!record.editable && loading) { return null; } diff --git a/src/pages/form/advanced-form/index.tsx b/src/pages/form/advanced-form/index.tsx index c9000111..a1d05fd7 100644 --- a/src/pages/form/advanced-form/index.tsx +++ b/src/pages/form/advanced-form/index.tsx @@ -97,7 +97,7 @@ const AdvancedForm: FC> = () => { overlayClassName={styles.errorPopover} trigger="click" getPopupContainer={(trigger: HTMLElement) => { - if (trigger && trigger.parentNode) { + if (trigger?.parentNode) { return trigger.parentNode as HTMLElement; } return trigger; @@ -144,7 +144,7 @@ const AdvancedForm: FC> = () => { title: '操作', key: 'action', valueType: 'option', - render: (_, record: TableFormDateType, index, action) => { + render: (_, record: TableFormDateType, _index, action) => { return [
> = () => { layout="vertical" hideRequiredMark submitter={{ - render: (props, dom) => { + render: (_props, dom) => { return ( {getErrorInfo(error)} diff --git a/src/pages/list/basic-list/_mock.ts b/src/pages/list/basic-list/_mock.ts index 0654dfb5..88ee6eb7 100644 --- a/src/pages/list/basic-list/_mock.ts +++ b/src/pages/list/basic-list/_mock.ts @@ -66,8 +66,8 @@ function fakeList(count: number): BasicListItemDataType[] { percent: Math.ceil(Math.random() * 50) + 50, logo: avatars[i % 8], href: 'https://ant.design', - updatedAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i).getTime(), - createdAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i).getTime(), + updatedAt: new Date(Date.now()- 1000 * 60 * 60 * 2 * i).getTime(), + createdAt: new Date(Date.now()- 1000 * 60 * 60 * 2 * i).getTime(), subDescription: desc[i % 5], description: '在中台产品的研发过程中,会出现不同的设计规范和实现方式,但其中往往存在很多类似的页面和组件,这些类似的组件会被抽离成一套标准规范。', @@ -139,7 +139,7 @@ function postFakeList(req: Request, res: Response) { result.unshift({ ...body, id: `fake-list-${result.length}`, - createdAt: new Date().getTime(), + createdAt: Date.now(), }); break; default: diff --git a/src/pages/list/basic-list/components/OperationModal.tsx b/src/pages/list/basic-list/components/OperationModal.tsx index 1b837b49..bc0921cf 100644 --- a/src/pages/list/basic-list/components/OperationModal.tsx +++ b/src/pages/list/basic-list/components/OperationModal.tsx @@ -36,7 +36,7 @@ const OperationModal: FC = (props) => { submitter={{ render: (_, dom) => (done ? null : dom), }} - trigger={<>{children}} + trigger={children} modalProps={{ onCancel: () => onDone(), destroyOnClose: true, diff --git a/src/pages/list/card-list/_mock.ts b/src/pages/list/card-list/_mock.ts index fb5c2f79..ad5c1fb1 100644 --- a/src/pages/list/card-list/_mock.ts +++ b/src/pages/list/card-list/_mock.ts @@ -66,8 +66,8 @@ function fakeList(count: number): CardListItemDataType[] { percent: Math.ceil(Math.random() * 50) + 50, logo: avatars[i % 8], href: 'https://ant.design', - updatedAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i).getTime(), - createdAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i).getTime(), + updatedAt: new Date(Date.now()- 1000 * 60 * 60 * 2 * i).getTime(), + createdAt: new Date(Date.now()- 1000 * 60 * 60 * 2 * i).getTime(), subDescription: desc[i % 5], description: '在中台产品的研发过程中,会出现不同的设计规范和实现方式,但其中往往存在很多类似的页面和组件,这些类似的组件会被抽离成一套标准规范。', diff --git a/src/pages/list/card-list/index.tsx b/src/pages/list/card-list/index.tsx index 92fc658b..19e619c7 100644 --- a/src/pages/list/card-list/index.tsx +++ b/src/pages/list/card-list/index.tsx @@ -62,7 +62,7 @@ const CardList = () => { }} dataSource={[nullData, ...list]} renderItem={(item) => { - if (item && item.id) { + if (item?.id) { return ( & { onChange && onChange(value, state)} + onChange={(state) => onChange?.(value, state)} > {children} @@ -58,8 +58,7 @@ const TagSelect: FC & { }); const isTagSelectOption = (node: TagSelectOptionElement) => - node && - node.type && + node?.type && (node.type.isTagSelectOption || node.type.displayName === 'TagSelectOption'); const getAllTags = () => { const childrenArray = React.Children.toArray(children) as TagSelectOptionElement[]; diff --git a/src/pages/list/search/applications/index.tsx b/src/pages/list/search/applications/index.tsx index 42da94ad..1a4dc6bf 100644 --- a/src/pages/list/search/applications/index.tsx +++ b/src/pages/list/search/applications/index.tsx @@ -95,11 +95,16 @@ export const Applications: FC> = () => { > - {categoryOptions.map((category) => ( - - {category.label} - - ))} + {categoryOptions + .filter( + (category): category is { value: string | number; label: string } => + category.value !== undefined && category.value !== null + ) + .map((category) => ( + + {category.label} + + ))} diff --git a/src/pages/list/search/articles/_mock.ts b/src/pages/list/search/articles/_mock.ts index fd588355..3390a701 100644 --- a/src/pages/list/search/articles/_mock.ts +++ b/src/pages/list/search/articles/_mock.ts @@ -65,8 +65,8 @@ function fakeList(count: number): ListItemDataType[] { percent: Math.ceil(Math.random() * 50) + 50, logo: avatars[i % 8], href: 'https://ant.design', - updatedAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i).getTime(), - createdAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i).getTime(), + updatedAt: new Date(Date.now()- 1000 * 60 * 60 * 2 * i).getTime(), + createdAt: new Date(Date.now()- 1000 * 60 * 60 * 2 * i).getTime(), subDescription: desc[i % 5], description: '在中台产品的研发过程中,会出现不同的设计规范和实现方式,但其中往往存在很多类似的页面和组件,这些类似的组件会被抽离成一套标准规范。', diff --git a/src/pages/list/search/articles/components/TagSelect/index.tsx b/src/pages/list/search/articles/components/TagSelect/index.tsx index 0032d76c..c49deeb4 100644 --- a/src/pages/list/search/articles/components/TagSelect/index.tsx +++ b/src/pages/list/search/articles/components/TagSelect/index.tsx @@ -18,7 +18,7 @@ const TagSelectOption: React.FC & { onChange && onChange(value, state)} + onChange={(state) => onChange?.(value, state)} > {children} @@ -58,8 +58,7 @@ const TagSelect: FC & { }); const isTagSelectOption = (node: TagSelectOptionElement) => - node && - node.type && + node?.type && (node.type.isTagSelectOption || node.type.displayName === 'TagSelectOption'); const getAllTags = () => { const childrenArray = React.Children.toArray(children) as TagSelectOptionElement[]; diff --git a/src/pages/list/search/articles/index.tsx b/src/pages/list/search/articles/index.tsx index 3b18ea67..381e29de 100644 --- a/src/pages/list/search/articles/index.tsx +++ b/src/pages/list/search/articles/index.tsx @@ -122,7 +122,7 @@ const Articles: FC = () => { label: item.name, value: item.id, })), - [owners], + [], ); return ( @@ -139,11 +139,16 @@ const Articles: FC = () => { - {categoryOptions.map((category) => ( - - {category.label} - - ))} + {categoryOptions + .filter( + (category): category is { value: string | number; label: string } => + category.value !== undefined && category.value !== null + ) + .map((category) => ( + + {category.label} + + ))} diff --git a/src/pages/list/search/projects/_mock.ts b/src/pages/list/search/projects/_mock.ts index 4f9f4a36..8e97b66f 100644 --- a/src/pages/list/search/projects/_mock.ts +++ b/src/pages/list/search/projects/_mock.ts @@ -65,8 +65,8 @@ function fakeList(count: number): ListItemDataType[] { percent: Math.ceil(Math.random() * 50) + 50, logo: avatars[i % 8], href: 'https://ant.design', - updatedAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i).getTime(), - createdAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i).getTime(), + updatedAt: new Date(Date.now()- 1000 * 60 * 60 * 2 * i).getTime(), + createdAt: new Date(Date.now()- 1000 * 60 * 60 * 2 * i).getTime(), subDescription: desc[i % 5], description: '在中台产品的研发过程中,会出现不同的设计规范和实现方式,但其中往往存在很多类似的页面和组件,这些类似的组件会被抽离成一套标准规范。', diff --git a/src/pages/list/search/projects/components/AvatarList/index.tsx b/src/pages/list/search/projects/components/AvatarList/index.tsx index cba28329..fe9b0051 100644 --- a/src/pages/list/search/projects/components/AvatarList/index.tsx +++ b/src/pages/list/search/projects/components/AvatarList/index.tsx @@ -28,7 +28,7 @@ const avatarSizeToClassName = (size: SizeType | 'mini', styles: any) => const Item: React.FC = ({ src, size, tips, onClick = () => {} }) => { const { styles } = useStyles(); - const cls = avatarSizeToClassName(size!, styles); + const cls = avatarSizeToClassName(size || 'default', styles); return (
  • @@ -62,7 +62,7 @@ const AvatarList: React.FC & { }), ); if (numToShow < numOfChildren) { - const cls = avatarSizeToClassName(size!, styles); + const cls = avatarSizeToClassName(size || 'default', styles); childrenWithProps.push(
  • {`+${numOfChildren - maxLength}`} diff --git a/src/pages/list/search/projects/components/TagSelect/index.tsx b/src/pages/list/search/projects/components/TagSelect/index.tsx index 0032d76c..c49deeb4 100644 --- a/src/pages/list/search/projects/components/TagSelect/index.tsx +++ b/src/pages/list/search/projects/components/TagSelect/index.tsx @@ -18,7 +18,7 @@ const TagSelectOption: React.FC & { onChange && onChange(value, state)} + onChange={(state) => onChange?.(value, state)} > {children} @@ -58,8 +58,7 @@ const TagSelect: FC & { }); const isTagSelectOption = (node: TagSelectOptionElement) => - node && - node.type && + node?.type && (node.type.isTagSelectOption || node.type.displayName === 'TagSelectOption'); const getAllTags = () => { const childrenArray = React.Children.toArray(children) as TagSelectOptionElement[]; diff --git a/src/pages/list/search/projects/index.tsx b/src/pages/list/search/projects/index.tsx index 432c72a0..c4744048 100644 --- a/src/pages/list/search/projects/index.tsx +++ b/src/pages/list/search/projects/index.tsx @@ -103,11 +103,16 @@ const Projects: FC = () => { > - {categoryOptions.map((category) => ( - - {category.label} - - ))} + {categoryOptions + .filter( + (category): category is { value: string | number; label: string } => + category.value !== undefined && category.value !== null + ) + .map((category) => ( + + {category.label} + + ))} diff --git a/src/pages/list/table-list/_mock.ts b/src/pages/list/table-list/_mock.ts index 9ff423aa..45e5cbb1 100644 --- a/src/pages/list/table-list/_mock.ts +++ b/src/pages/list/table-list/_mock.ts @@ -1,5 +1,5 @@ import type { Request, Response } from 'express'; -import { parse } from 'url'; +import { parse } from 'node:url'; import type { TableListItem, TableListParams } from './data.d'; // mock tableListDataSource @@ -109,7 +109,7 @@ function postRule(req: Request, res: Response, u: string, b: Request) { realUrl = req.url; } - const body = (b && b.body) || req.body; + const body = (b?.body) || req.body; const { name, desc, key } = body; switch (req.method) { diff --git a/src/pages/list/table-list/index.tsx b/src/pages/list/table-list/index.tsx index f403dfc0..d8737683 100644 --- a/src/pages/list/table-list/index.tsx +++ b/src/pages/list/table-list/index.tsx @@ -29,7 +29,7 @@ const handleAdd = async (fields: TableListItem) => { hide(); message.success('添加成功'); return true; - } catch (error) { + } catch (_error) { hide(); message.error('添加失败请重试!'); return false; @@ -52,7 +52,7 @@ const handleUpdate = async (fields: FormValueType, currentRow?: TableListItem) = hide(); message.success('配置成功'); return true; - } catch (error) { + } catch (_error) { hide(); message.error('配置失败请重试!'); return false; @@ -75,7 +75,7 @@ const handleRemove = async (selectedRows: TableListItem[]) => { hide(); message.success('删除成功,即将刷新'); return true; - } catch (error) { + } catch (_error) { hide(); message.error('删除失败,请重试'); return false; @@ -229,7 +229,7 @@ const TableList: React.FC = () => { {' '} 项    - 服务调用次数总计 {selectedRowsState.reduce((pre, item) => pre + item.callNo!, 0)} 万 + 服务调用次数总计 {selectedRowsState.reduce((pre, item) => pre + (item.callNo ?? 0), 0)} 万
  • } diff --git a/src/pages/profile/advanced/_mock.ts b/src/pages/profile/advanced/_mock.ts index 1bf3b384..cc13c2f2 100644 --- a/src/pages/profile/advanced/_mock.ts +++ b/src/pages/profile/advanced/_mock.ts @@ -65,7 +65,7 @@ const advancedOperation3 = [ }, ]; -function getProfileAdvancedData(req: Request, res: Response) { +function getProfileAdvancedData(_req: Request, res: Response) { const result = { data: { advancedOperation1, diff --git a/src/pages/table-list/index.tsx b/src/pages/table-list/index.tsx index 80e8a774..08303246 100644 --- a/src/pages/table-list/index.tsx +++ b/src/pages/table-list/index.tsx @@ -215,7 +215,7 @@ const TableList: React.FC = () => { }, }); }, - [delRun], + [delRun, messageApi.warning], ); return ( diff --git a/src/pages/user/login/login.test.tsx b/src/pages/user/login/login.test.tsx index 5f215e2a..36eb6210 100644 --- a/src/pages/user/login/login.test.tsx +++ b/src/pages/user/login/login.test.tsx @@ -1,5 +1,4 @@ -// @ts-ignore -import { startMock } from '@@/requestRecordMock'; +import { startMock } from '@@/requestRecordMock'; import { TestBrowser } from '@@/testBrowser'; import { fireEvent, render } from '@testing-library/react'; import React, { act } from 'react'; diff --git a/src/pages/user/register/index.tsx b/src/pages/user/register/index.tsx index eb762751..0a8e6a8a 100644 --- a/src/pages/user/register/index.tsx +++ b/src/pages/user/register/index.tsx @@ -123,7 +123,7 @@ const Register: FC = () => { const renderPasswordProgress = () => { const value = form.getFieldValue('password'); const passwordStatus = getPasswordStatus(); - return value && value.length ? ( + return value?.length ? (
    { { - if (node && node.parentNode) { + if (node?.parentNode) { return node.parentNode as HTMLElement; } return node;