From fec80a1ff7034d21e898fde1b456fc7692cfb1b9 Mon Sep 17 00:00:00 2001 From: "DESKTOP-31IBRMI\\Administrator" <1509326266@qq.com> Date: Mon, 9 Sep 2024 15:02:54 +0800 Subject: [PATCH] fix(projects): fix eslint errors --- build/plugins/router.ts | 1 + packages/materials/src/libs/page-tab/SvgClose.tsx | 6 ++---- packages/materials/src/libs/page-tab/index.tsx | 4 ++-- src/layouts/modules/global-breadcrumb/index.tsx | 8 ++++---- .../modules/global-menu/components/FirstLevelMenu.tsx | 2 +- src/pages/about/index.tsx | 4 ++-- src/pages/function/request/index.tsx | 1 + src/pages/function/tab/index.tsx | 1 + src/utils/service.ts | 2 +- 9 files changed, 15 insertions(+), 14 deletions(-) diff --git a/build/plugins/router.ts b/build/plugins/router.ts index 8d408e7..1c6b294 100644 --- a/build/plugins/router.ts +++ b/build/plugins/router.ts @@ -1,6 +1,7 @@ import ElegantReactRouter from '@ohh-889/react-auto-route/vite'; import type { RouteKey } from '@elegant-router/types'; +// eslint-disable-next-line @typescript-eslint/no-empty-object-type interface RouteMeta extends Record {} export function setupElegantRouter() { diff --git a/packages/materials/src/libs/page-tab/SvgClose.tsx b/packages/materials/src/libs/page-tab/SvgClose.tsx index 8bb5f79..edbfcdd 100644 --- a/packages/materials/src/libs/page-tab/SvgClose.tsx +++ b/packages/materials/src/libs/page-tab/SvgClose.tsx @@ -2,9 +2,7 @@ import type { FC, TouchEvent } from 'react'; import React, { useState } from 'react'; import classNames from 'classnames'; -interface SvgCloseProps extends React.ComponentProps<'div'> {} - -const SvgClose: FC = ({ className, onClick, ...props }) => { +const SvgClose: FC> = ({ className, onClick, ...props }) => { const [touchStart, setTouchStart] = useState(false); // 处理触摸开始事件 @@ -15,7 +13,7 @@ const SvgClose: FC = ({ className, onClick, ...props }) => { // 处理触摸结束事件 const handleTouchEnd = (event: TouchEvent) => { if (touchStart) { - onClick && onClick(event as any); + if (onClick) onClick(event as any); } // 重置触摸状态 diff --git a/packages/materials/src/libs/page-tab/index.tsx b/packages/materials/src/libs/page-tab/index.tsx index 7b3b742..a8ecb09 100644 --- a/packages/materials/src/libs/page-tab/index.tsx +++ b/packages/materials/src/libs/page-tab/index.tsx @@ -45,13 +45,13 @@ const PageTab: FC = ({ function closeTab(event: React.MouseEvent | TouchEvent) { event.stopPropagation(); - handleClose && handleClose(); + if (handleClose) handleClose(); } function handleMouseup(e: React.MouseEvent) { // close tab by mouse wheel button click if (e.button === 1) { - handleClose && handleClose(); + if (handleClose) handleClose(); } } diff --git a/src/layouts/modules/global-breadcrumb/index.tsx b/src/layouts/modules/global-breadcrumb/index.tsx index d0e60f1..4d5aada 100644 --- a/src/layouts/modules/global-breadcrumb/index.tsx +++ b/src/layouts/modules/global-breadcrumb/index.tsx @@ -15,7 +15,7 @@ function BreadcrumbContent({ label, icon }: { label: JSX.Element; icon: JSX.Elem ); } -const GlobalBreadcrumb: FC> = memo(props => { +const GlobalBreadcrumb: FC> = props => { const { allMenus: menus, route } = useMixMenuContext(); const routerPush = useRouterPush(); @@ -52,8 +52,8 @@ const GlobalBreadcrumb: FC> = memo(props => { + /> ); -}); +}; -export default GlobalBreadcrumb; +export default memo(GlobalBreadcrumb); diff --git a/src/layouts/modules/global-menu/components/FirstLevelMenu.tsx b/src/layouts/modules/global-menu/components/FirstLevelMenu.tsx index ebb06e4..3c07428 100644 --- a/src/layouts/modules/global-menu/components/FirstLevelMenu.tsx +++ b/src/layouts/modules/global-menu/components/FirstLevelMenu.tsx @@ -39,7 +39,7 @@ function MixMenuItem(Props: MixMenuItemProps) { setActiveFirstLevelMenuKey(key); if (children?.length) { - onClick && onClick(); + if (onClick) onClick(); } else { router.routerPushByKeyWithMetaQuery(key as RouteKey); } diff --git a/src/pages/about/index.tsx b/src/pages/about/index.tsx index 74a78ac..0db5fe9 100644 --- a/src/pages/about/index.tsx +++ b/src/pages/about/index.tsx @@ -31,8 +31,8 @@ function transformVersionData(tuple: [string, string]): PkgVersionInfo { const pkgJson: PkgJson = { name, version, - dependencies: Object.entries(dependencies).map(item => transformVersionData(item)), - devDependencies: Object.entries(devDependencies).map(item => transformVersionData(item)) + dependencies: Object.entries(dependencies).map(transformVersionData), + devDependencies: Object.entries(devDependencies).map(transformVersionData) }; export function Component() { diff --git a/src/pages/function/request/index.tsx b/src/pages/function/request/index.tsx index 1b6f257..b06e8f7 100644 --- a/src/pages/function/request/index.tsx +++ b/src/pages/function/request/index.tsx @@ -1,5 +1,6 @@ import { Button, Card, Space } from 'antd'; import { fetchCustomBackendError } from '@/service/api'; + export function Component() { const { t } = useTranslation(); async function logout() { diff --git a/src/pages/function/tab/index.tsx b/src/pages/function/tab/index.tsx index 9a7d8a8..7e33e98 100644 --- a/src/pages/function/tab/index.tsx +++ b/src/pages/function/tab/index.tsx @@ -7,6 +7,7 @@ export function Component() { const { t } = useTranslation(); const dispatch = useAppDispatch(); + function changeTabLabel(value: string) { dispatch(setTabLabel(value)); } diff --git a/src/utils/service.ts b/src/utils/service.ts index 3586c64..a275b39 100644 --- a/src/utils/service.ts +++ b/src/utils/service.ts @@ -11,7 +11,7 @@ export function createServiceConfig(env: Env.ImportMeta) { let other = {} as Record; try { other = json5.parse(VITE_OTHER_SERVICE_BASE_URL); - } catch (error) { + } catch { // eslint-disable-next-line no-console console.error('VITE_OTHER_SERVICE_BASE_URL is not a valid json5 string'); }