diff --git a/ui/eslint.config.mjs b/ui/eslint.config.mjs index 54f86403..39721b4f 100644 --- a/ui/eslint.config.mjs +++ b/ui/eslint.config.mjs @@ -120,8 +120,14 @@ export default defineConfig( // React { name: "react", - extends: [reactHooksPlugin.configs.flat["recommended"], reactRefreshPlugin.configs["vite"]], + extends: [reactHooksPlugin.configs.flat["recommended-latest"], reactRefreshPlugin.configs["vite"]], rules: { + "react-hooks/exhaustive-deps": ["warn"], + "react-hooks/immutability": ["warn"], + "react-hooks/refs": ["warn"], + "react-hooks/preserve-manual-memoization": ["warn"], + "react-hooks/set-state-in-effect": ["warn"], + "react-hooks/set-state-in-render": ["warn"], "react-refresh/only-export-components": [ "warn", { diff --git a/ui/src/components/access/AccessEditDrawer.tsx b/ui/src/components/access/AccessEditDrawer.tsx index faff133c..17536893 100644 --- a/ui/src/components/access/AccessEditDrawer.tsx +++ b/ui/src/components/access/AccessEditDrawer.tsx @@ -4,11 +4,11 @@ import { IconX } from "@tabler/icons-react"; import { useControllableValue, useGetState } from "ahooks"; import { App, Button, Drawer, Flex, Form } from "antd"; +import { notifyTest } from "@/api/notify"; import AccessProviderPicker from "@/components/provider/AccessProviderPicker"; import Show from "@/components/Show"; import { type AccessModel } from "@/domain/access"; import { ACCESS_USAGES } from "@/domain/provider"; -import { notifyTest } from "@/api/notify"; import { useTriggerElement, useZustandShallowSelector } from "@/hooks"; import { useAccessesStore } from "@/stores/access"; import { getErrMsg } from "@/utils/error"; @@ -126,7 +126,7 @@ const AccessEditDrawer = ({ afterSubmit, mode, data, loading, trigger, usage, .. } try { - await notifyTest({ provider: fieldProvider, accessId: data?.id! }); + await notifyTest({ provider: fieldProvider, accessId: data!.id }); message.success(t("common.text.operation_succeeded")); } catch (err) { notification.error({ message: t("common.text.request_error"), description: getErrMsg(err) }); diff --git a/ui/src/components/provider/_shared.ts b/ui/src/components/provider/_shared.ts index 9f47e4c4..ec72f09c 100644 --- a/ui/src/components/provider/_shared.ts +++ b/ui/src/components/provider/_shared.ts @@ -19,7 +19,7 @@ export interface SharedSelectProps export const useSelectDataSource = ({ dataSource, filters, - deps, + deps = [], }: { dataSource: T[]; filters?: Array<(value: string, option: T) => boolean>; @@ -39,7 +39,7 @@ export const useSelectDataSource = ({ return true; }); - }, [dataSource, filters, ...(deps ?? [])]); + }, [dataSource, filters, deps]); const availableDataSource = useMemo(() => { return filteredDataSource.filter((provider) => { @@ -49,11 +49,11 @@ export const useSelectDataSource = ({ return access.provider === provider.type; }); }); - }, [accesses, filteredDataSource, ...(deps ?? [])]); + }, [accesses, filteredDataSource, deps]); const unavailableDataSource = useMemo(() => { return filteredDataSource.filter((item) => !availableDataSource.includes(item)); - }, [filteredDataSource, availableDataSource, ...(deps ?? [])]); + }, [filteredDataSource, availableDataSource, deps]); return { raw: dataSource, @@ -94,7 +94,7 @@ export const usePickerDataSource = ({ dataSource, filters, keyword, - deps, + deps = [], }: { dataSource: T[]; filters?: Array<(value: string, option: T) => boolean>; @@ -126,7 +126,7 @@ export const usePickerDataSource = ({ return true; }); - }, [dataSource, filters, keyword, ...(deps ?? [])]); + }, [dataSource, filters, keyword, deps]); const availableDataSource = useMemo(() => { return filteredDataSource.filter((provider) => { @@ -136,11 +136,11 @@ export const usePickerDataSource = ({ return access.provider === provider.type; }); }); - }, [accesses, filteredDataSource, ...(deps ?? [])]); + }, [accesses, filteredDataSource, deps]); const unavailableDataSource = useMemo(() => { return filteredDataSource.filter((item) => !availableDataSource.includes(item)); - }, [filteredDataSource, availableDataSource, ...(deps ?? [])]); + }, [filteredDataSource, availableDataSource, deps]); return { raw: dataSource, diff --git a/ui/src/components/workflow/designer/Designer.tsx b/ui/src/components/workflow/designer/Designer.tsx index 7eea4b14..85c7b2b5 100644 --- a/ui/src/components/workflow/designer/Designer.tsx +++ b/ui/src/components/workflow/designer/Designer.tsx @@ -4,10 +4,10 @@ import { EditorRenderer, EditorState, FixedLayoutEditorProvider, - FlowLayoutDefault, type FixedLayoutPluginContext, type FixedLayoutProps, type FlowDocumentJSON, + FlowLayoutDefault, type FlowNodeEntity, FlowTextKey, } from "@flowgram.ai/fixed-layout-editor"; diff --git a/ui/src/components/workflow/designer/forms/BizDeployNodeConfigFieldsProviderTencentCloudEO.tsx b/ui/src/components/workflow/designer/forms/BizDeployNodeConfigFieldsProviderTencentCloudEO.tsx index c7180e0b..f16130fb 100644 --- a/ui/src/components/workflow/designer/forms/BizDeployNodeConfigFieldsProviderTencentCloudEO.tsx +++ b/ui/src/components/workflow/designer/forms/BizDeployNodeConfigFieldsProviderTencentCloudEO.tsx @@ -93,10 +93,7 @@ const getSchema = ({ i18n = getI18n() }: { i18n?: ReturnType }) return z.object({ endpoint: z.string().nullish(), zoneId: z.string().nonempty(t("workflow_node.deploy.form.tencentcloud_eo_zone_id.placeholder")), - matchPattern: z.enum( - [MATCH_PATTERN_EXACT, MATCH_PATTERN_WILDCARD], - t("workflow_node.deploy.form.shared_domain_match_pattern.placeholder") - ), + matchPattern: z.enum([MATCH_PATTERN_EXACT, MATCH_PATTERN_WILDCARD], t("workflow_node.deploy.form.shared_domain_match_pattern.placeholder")), domains: z.string().refine((v) => { if (!v) return false; return String(v) diff --git a/ui/src/pages/accesses/AccessList.tsx b/ui/src/pages/accesses/AccessList.tsx index 6fb9d639..70b29290 100644 --- a/ui/src/pages/accesses/AccessList.tsx +++ b/ui/src/pages/accesses/AccessList.tsx @@ -302,7 +302,7 @@ const AccessList = () => { return draft; }); getAccess(access.id).then((data) => { - createDrawer.open({ data: copier(data), loading: true }); + createDrawer.open({ data: copier(data) }); }); }; diff --git a/ui/src/pages/workflows/WorkflowDetailDesign.tsx b/ui/src/pages/workflows/WorkflowDetailDesign.tsx index 6ad9f31e..21f6de0a 100644 --- a/ui/src/pages/workflows/WorkflowDetailDesign.tsx +++ b/ui/src/pages/workflows/WorkflowDetailDesign.tsx @@ -29,7 +29,7 @@ const WorkflowDetailDesign = () => { const designerRef = useRef(null); const designerPending = useRef(false); // 保存中时阻止刷新画布 - const [designerError, setDesignerError] = useState(); + const [designerError, setDesignerError] = useState(); useDeepCompareEffect(() => { if (designerRef.current == null || designerRef.current.document.disposed) return; if (designerPending.current) return; @@ -212,7 +212,7 @@ const WorkflowDetailDesign = () => { - {designerError && ( + {!!designerError && (