From bf2ff4eee1eff0c9fb77b7ced9af841abee57801 Mon Sep 17 00:00:00 2001 From: bowen tan Date: Wed, 23 Oct 2024 15:51:43 +0800 Subject: [PATCH] fix: fix lint error --- .github/workflows/ci-check.yml | 2 + .../src/components/Form/useFieldsConfig.ts | 2 +- .../refine/src/components/Form/useYamlForm.ts | 4 +- .../components/InternalBaseTable/index.tsx | 8 --- .../components/PVCDistributeStorage/index.tsx | 5 +- .../refine/src/components/PodLog/index.tsx | 71 ++++++++++--------- .../src/pages/daemonsets/list/index.tsx | 2 +- .../src/pages/deployments/list/index.tsx | 2 +- .../src/pages/deployments/show/index.tsx | 2 +- packages/refine/src/types/modal.d.ts | 2 - packages/refine/src/types/resource.ts | 2 +- 11 files changed, 48 insertions(+), 54 deletions(-) diff --git a/.github/workflows/ci-check.yml b/.github/workflows/ci-check.yml index 169ffa0d..d61d95ed 100644 --- a/.github/workflows/ci-check.yml +++ b/.github/workflows/ci-check.yml @@ -28,6 +28,8 @@ jobs: - name: Install deps run: yarn install --frozen-lockfile timeout-minutes: 15 + - name: Lint + run: cd packages/refine && yarn lint - name: Test run: cd packages/refine && yarn jest - name: Build diff --git a/packages/refine/src/components/Form/useFieldsConfig.ts b/packages/refine/src/components/Form/useFieldsConfig.ts index 5f94ef81..fab398d9 100644 --- a/packages/refine/src/components/Form/useFieldsConfig.ts +++ b/packages/refine/src/components/Form/useFieldsConfig.ts @@ -1,5 +1,5 @@ -import { ResourceModel } from 'src/models'; import { useList, useShow } from '@refinedev/core'; +import { ResourceModel } from 'src/models'; import { ResourceConfig } from 'src/types'; function useFieldsConfig(config?: ResourceConfig, resourceId?: string) { diff --git a/packages/refine/src/components/Form/useYamlForm.ts b/packages/refine/src/components/Form/useYamlForm.ts index aa5cb6e4..3ab7e412 100644 --- a/packages/refine/src/components/Form/useYamlForm.ts +++ b/packages/refine/src/components/Form/useYamlForm.ts @@ -16,8 +16,10 @@ import { FormInstance, FormProps } from 'antd/lib/form'; import yaml from 'js-yaml'; import { JSONSchema7 } from 'json-schema'; import { Unstructured } from 'k8s-api-provider'; +import { get, uniq } from 'lodash-es'; import React, { useRef, useState, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; +import { RefineFormValidator } from 'src/components/Form/type'; import { type YamlEditorHandle, type YamlEditorProps } from 'src/components/YamlEditor'; import useK8sYamlEditor from 'src/hooks/useK8sYamlEditor'; import { useSchema } from 'src/hooks/useSchema'; @@ -25,8 +27,6 @@ import { pruneBeforeEdit } from 'src/utils/k8s'; import { generateYamlBySchema } from 'src/utils/yaml'; import { useForm as useFormSF } from 'sunflower-antd'; import { useGlobalStore } from '../../hooks/useGlobalStore'; -import { RefineFormValidator } from 'src/components/Form/type' -import { get, uniq } from 'lodash-es'; type EditorProps = YamlEditorProps & { ref: React.RefObject; diff --git a/packages/refine/src/components/InternalBaseTable/index.tsx b/packages/refine/src/components/InternalBaseTable/index.tsx index 73171559..7ec5c0b5 100644 --- a/packages/refine/src/components/InternalBaseTable/index.tsx +++ b/packages/refine/src/components/InternalBaseTable/index.tsx @@ -73,14 +73,6 @@ function Table(props: InternalTableProps) { const auxiliaryLineRef = useRef(null); const wrapperRef = useRef(null); - const pagination = useMemo( - () => ({ - current: currentPage, - pageSize: defaultSize, - onChange: onPageChange, - }), - [currentPage, defaultSize, onPageChange] - ); const finalColumns = useMemo(() => { if (RowMenu) { const actionColumn: Column = { diff --git a/packages/refine/src/components/PVCDistributeStorage/index.tsx b/packages/refine/src/components/PVCDistributeStorage/index.tsx index bd409703..8b530c4b 100644 --- a/packages/refine/src/components/PVCDistributeStorage/index.tsx +++ b/packages/refine/src/components/PVCDistributeStorage/index.tsx @@ -1,6 +1,5 @@ import { Fields, Form, Units } from '@cloudtower/eagle'; import { useResource, useUpdate } from '@refinedev/core'; -import { isNil } from 'lodash-es'; import React, { useCallback, useImperativeHandle, useMemo, useRef, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { EditField } from 'src/components/EditField'; @@ -101,8 +100,8 @@ export const DistributeStorageForm = React.forwardRef { }, - onFocus: () => { }, + onBlur: () => undefined, + onFocus: () => undefined, }} min={1} meta={{}} diff --git a/packages/refine/src/components/PodLog/index.tsx b/packages/refine/src/components/PodLog/index.tsx index 5693419f..c2166712 100644 --- a/packages/refine/src/components/PodLog/index.tsx +++ b/packages/refine/src/components/PodLog/index.tsx @@ -1,7 +1,7 @@ import { SegmentControl, Select, AntdOption, Checkbox, Button } from '@cloudtower/eagle'; import { SuspendedPause16GradientBlueIcon, - RecoverContinue16GradientBlueIcon + RecoverContinue16GradientBlueIcon, } from '@cloudtower/icons-react'; import { css } from '@linaria/core'; import { LogViewer } from '@patternfly/react-log-viewer'; @@ -48,7 +48,6 @@ export const PodLog: React.FC<{ pod: PodModel }> = ({ pod }) => { const [currentItemCount, setCurrentItemCount] = useState(0); const [paused, setPaused] = useState(false); const [wrap, setWrap] = useState(false); - const [linesBehind, setLinesBehind] = useState(0); const logViewerRef = useRef<{ scrollToBottom: () => void }>(null); const abortControllerRef = useRef(null); @@ -63,10 +62,6 @@ export const PodLog: React.FC<{ pod: PodModel }> = ({ pod }) => { if (logViewerRef && logViewerRef.current) { logViewerRef.current.scrollToBottom(); } - } else if (logs.length !== currentItemCount) { - setLinesBehind(logs.length - currentItemCount); - } else { - setLinesBehind(0); } }, [paused, logs, currentItemCount]); @@ -92,11 +87,11 @@ export const PodLog: React.FC<{ pod: PodModel }> = ({ pod }) => { } }; - const fetchLogsByUrl = useCallback(async (url) => { + const fetchLogsByUrl = useCallback(async url => { abortControllerRef.current = new AbortController(); const { signal } = abortControllerRef.current; - fetch(url, { signal }).then(async (response) => { + fetch(url, { signal }).then(async response => { if (response.status !== 200) { setLogs([]); return; @@ -158,7 +153,14 @@ export const PodLog: React.FC<{ pod: PodModel }> = ({ pod }) => { } else if (logType === 'previous') { fetchLogsByUrl(`${url}&previous=true`); } - }, [pod.metadata?.namespace, pod.metadata?.name, selectedContainer, logType, apiUrl, fetchLogsByUrl]); + }, [ + pod.metadata?.namespace, + pod.metadata?.name, + selectedContainer, + logType, + apiUrl, + fetchLogsByUrl, + ]); const stopFetchingLogs = useCallback(() => { if (abortControllerRef.current) { @@ -182,15 +184,15 @@ export const PodLog: React.FC<{ pod: PodModel }> = ({ pod }) => { options={[ { label: t('dovetail.realtime_log'), - value: 'realtime' + value: 'realtime', }, { label: t('dovetail.previous_log'), - value: 'previous' + value: 'previous', }, ]} value={logType} - onChange={(value) => { + onChange={value => { setLogType(value as 'realtime' | 'previous'); setLogs([]); }} @@ -202,7 +204,6 @@ export const PodLog: React.FC<{ pod: PodModel }> = ({ pod }) => { setSelectedContainer(newValue as string); setLogs([]); setPaused(false); - setLinesBehind(0); }, value: selectedContainer, }} @@ -225,34 +226,36 @@ export const PodLog: React.FC<{ pod: PodModel }> = ({ pod }) => { -
- { - logType === 'previous' && !logs.length ? ( - - ) : ( - - ) - } - + {logType === 'previous' && !logs.length ? ( + + ) : ( + + )}
); diff --git a/packages/refine/src/pages/daemonsets/list/index.tsx b/packages/refine/src/pages/daemonsets/list/index.tsx index 507664c2..f61e1409 100644 --- a/packages/refine/src/pages/daemonsets/list/index.tsx +++ b/packages/refine/src/pages/daemonsets/list/index.tsx @@ -1,8 +1,8 @@ import { IResourceComponentsProps } from '@refinedev/core'; import React from 'react'; import { useTranslation } from 'react-i18next'; -import { ListPage } from 'src/components/ListPage'; import { WorkloadDropdown } from 'src/components/Dropdowns/WorkloadDropdown'; +import { ListPage } from 'src/components/ListPage'; import { useEagleTable } from 'src/hooks/useEagleTable'; import { AgeColumnRenderer, diff --git a/packages/refine/src/pages/deployments/list/index.tsx b/packages/refine/src/pages/deployments/list/index.tsx index fd3a47e3..b5f1747e 100644 --- a/packages/refine/src/pages/deployments/list/index.tsx +++ b/packages/refine/src/pages/deployments/list/index.tsx @@ -1,8 +1,8 @@ import { IResourceComponentsProps } from '@refinedev/core'; import React from 'react'; import { useTranslation } from 'react-i18next'; -import { ListPage } from 'src/components/ListPage'; import { ReplicasDropdown } from 'src/components/Dropdowns/ReplicasDropdown'; +import { ListPage } from 'src/components/ListPage'; import { useEagleTable } from 'src/hooks/useEagleTable'; import { AgeColumnRenderer, diff --git a/packages/refine/src/pages/deployments/show/index.tsx b/packages/refine/src/pages/deployments/show/index.tsx index e0b13f0c..bfaf856c 100644 --- a/packages/refine/src/pages/deployments/show/index.tsx +++ b/packages/refine/src/pages/deployments/show/index.tsx @@ -1,6 +1,7 @@ import { IResourceComponentsProps } from '@refinedev/core'; import React from 'react'; import { useTranslation } from 'react-i18next'; +import { WorkloadDropdown } from '../../../components/Dropdowns/WorkloadDropdown'; import { PageShow } from '../../../components/PageShow'; import { ImageField, @@ -10,7 +11,6 @@ import { ConditionsGroup, EventsTab } from '../../../components/ShowContent'; -import { WorkloadDropdown } from '../../../components/Dropdowns/WorkloadDropdown'; import { WorkloadModel } from '../../../models'; export const DeploymentShow: React.FC = () => { diff --git a/packages/refine/src/types/modal.d.ts b/packages/refine/src/types/modal.d.ts index f9c0c6f0..8832d53a 100644 --- a/packages/refine/src/types/modal.d.ts +++ b/packages/refine/src/types/modal.d.ts @@ -11,8 +11,6 @@ type ModalProps = { }; declare module '@cloudtower/eagle' { - interface IModalProps extends ModalProps { } - export declare function pushModal( modal: ModalType ): void; diff --git a/packages/refine/src/types/resource.ts b/packages/refine/src/types/resource.ts index a26cf048..bd11fa7a 100644 --- a/packages/refine/src/types/resource.ts +++ b/packages/refine/src/types/resource.ts @@ -1,8 +1,8 @@ import { UseFormProps } from '@refinedev/react-hook-form'; import { YamlFormProps } from '../components'; import { RefineFormField } from '../components/Form'; -import { ShowConfig } from '../components/ShowContent'; import { Column, InternalTableProps } from '../components/InternalBaseTable'; +import { ShowConfig } from '../components/ShowContent'; import { ResourceModel } from '../models'; export enum RESOURCE_GROUP {