From 75f722a959f2ddfc97a37047e89a580e049dd557 Mon Sep 17 00:00:00 2001 From: Matri Qi Date: Tue, 5 Aug 2025 11:12:30 +0800 Subject: [PATCH] lint: fix issue of no-unused-vars (#23375) --- web/app/(commonLayout)/datasets/create/page.tsx | 4 +--- .../app/annotation/header-opts/index.tsx | 3 ++- .../components/workflow/nodes/answer/utils.ts | 2 +- .../components/workflow/nodes/assigner/utils.ts | 2 +- web/app/components/workflow/nodes/end/utils.ts | 2 +- .../components/condition-list/condition-item.tsx | 2 +- web/app/components/workflow/nodes/llm/panel.tsx | 2 +- web/app/components/workflow/nodes/llm/utils.ts | 4 ++-- .../components/workflow/nodes/loop/use-config.ts | 7 +------ web/app/components/workflow/nodes/start/utils.ts | 2 +- .../workflow/nodes/template-transform/utils.ts | 2 +- web/app/components/workflow/nodes/tool/utils.ts | 2 +- .../store/workflow/debug/inspect-vars-slice.ts | 16 ++++++++-------- web/eslint.config.mjs | 1 + 14 files changed, 23 insertions(+), 28 deletions(-) diff --git a/web/app/(commonLayout)/datasets/create/page.tsx b/web/app/(commonLayout)/datasets/create/page.tsx index 663a83066..50fd1f5a1 100644 --- a/web/app/(commonLayout)/datasets/create/page.tsx +++ b/web/app/(commonLayout)/datasets/create/page.tsx @@ -1,9 +1,7 @@ import React from 'react' import DatasetUpdateForm from '@/app/components/datasets/create' -type Props = {} - -const DatasetCreation = async (props: Props) => { +const DatasetCreation = async () => { return ( ) diff --git a/web/app/components/app/annotation/header-opts/index.tsx b/web/app/components/app/annotation/header-opts/index.tsx index 463ae58ac..7347caa2f 100644 --- a/web/app/components/app/annotation/header-opts/index.tsx +++ b/web/app/components/app/annotation/header-opts/index.tsx @@ -88,7 +88,8 @@ const HeaderOptions: FC = ({ await clearAllAnnotations(appId) onAdded() } - catch (_) { + catch (e) { + console.error(`failed to clear all annotations, ${e}`) } finally { setShowClearConfirm(false) diff --git a/web/app/components/workflow/nodes/answer/utils.ts b/web/app/components/workflow/nodes/answer/utils.ts index 8c3424815..a77faa5c7 100644 --- a/web/app/components/workflow/nodes/answer/utils.ts +++ b/web/app/components/workflow/nodes/answer/utils.ts @@ -1,5 +1,5 @@ import type { AnswerNodeType } from './types' -export const checkNodeValid = (payload: AnswerNodeType) => { +export const checkNodeValid = (_payload: AnswerNodeType) => { return true } diff --git a/web/app/components/workflow/nodes/assigner/utils.ts b/web/app/components/workflow/nodes/assigner/utils.ts index c9fe12377..d5177787b 100644 --- a/web/app/components/workflow/nodes/assigner/utils.ts +++ b/web/app/components/workflow/nodes/assigner/utils.ts @@ -1,7 +1,7 @@ import type { AssignerNodeType } from './types' import { AssignerNodeInputType, WriteMode } from './types' -export const checkNodeValid = (payload: AssignerNodeType) => { +export const checkNodeValid = (_payload: AssignerNodeType) => { return true } diff --git a/web/app/components/workflow/nodes/end/utils.ts b/web/app/components/workflow/nodes/end/utils.ts index f214d30c5..6ca87aa23 100644 --- a/web/app/components/workflow/nodes/end/utils.ts +++ b/web/app/components/workflow/nodes/end/utils.ts @@ -1,5 +1,5 @@ import type { EndNodeType } from './types' -export const checkNodeValid = (payload: EndNodeType) => { +export const checkNodeValid = (_payload: EndNodeType) => { return true } diff --git a/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx b/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx index eabc10b16..d20bd3112 100644 --- a/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx +++ b/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx @@ -202,7 +202,7 @@ const ConditionItem = ({ onRemoveCondition?.(caseId, condition.id) }, [caseId, condition, conditionId, isSubVariableKey, onRemoveCondition, onRemoveSubVariableCondition]) - const handleVarChange = useCallback((valueSelector: ValueSelector, varItem: Var) => { + const handleVarChange = useCallback((valueSelector: ValueSelector, _varItem: Var) => { const resolvedVarType = getVarType({ valueSelector, availableNodes, diff --git a/web/app/components/workflow/nodes/llm/panel.tsx b/web/app/components/workflow/nodes/llm/panel.tsx index b47542926..1206e5873 100644 --- a/web/app/components/workflow/nodes/llm/panel.tsx +++ b/web/app/components/workflow/nodes/llm/panel.tsx @@ -82,7 +82,7 @@ const Panel: FC> = ({ Toast.notify({ type: 'warning', message: `${t('common.modelProvider.parametersInvalidRemoved')}: ${keys.map(k => `${k} (${removedDetails[k]})`).join(', ')}` }) handleCompletionParamsChange(filtered) } - catch (e) { + catch { Toast.notify({ type: 'error', message: t('common.error') }) handleCompletionParamsChange({}) } diff --git a/web/app/components/workflow/nodes/llm/utils.ts b/web/app/components/workflow/nodes/llm/utils.ts index b29646de6..fd943d1fa 100644 --- a/web/app/components/workflow/nodes/llm/utils.ts +++ b/web/app/components/workflow/nodes/llm/utils.ts @@ -5,7 +5,7 @@ import { Validator } from 'jsonschema' import produce from 'immer' import { z } from 'zod' -export const checkNodeValid = (payload: LLMNodeType) => { +export const checkNodeValid = (_payload: LLMNodeType) => { return true } @@ -280,7 +280,7 @@ const validator = new Validator() export const validateSchemaAgainstDraft7 = (schemaToValidate: any) => { const schema = produce(schemaToValidate, (draft: any) => { - // Make sure the schema has the $schema property for draft-07 + // Make sure the schema has the $schema property for draft-07 if (!draft.$schema) draft.$schema = 'http://json-schema.org/draft-07/schema#' }) diff --git a/web/app/components/workflow/nodes/loop/use-config.ts b/web/app/components/workflow/nodes/loop/use-config.ts index 965fe2b39..4c6e07c9c 100644 --- a/web/app/components/workflow/nodes/loop/use-config.ts +++ b/web/app/components/workflow/nodes/loop/use-config.ts @@ -6,7 +6,6 @@ import produce from 'immer' import { v4 as uuid4 } from 'uuid' import { useIsChatMode, - useIsNodeInLoop, useNodesReadOnly, useWorkflow, } from '../../hooks' @@ -20,10 +19,8 @@ import type { HandleAddCondition, HandleAddSubVariableCondition, HandleRemoveCon import useIsVarFileAttribute from './use-is-var-file-attribute' import { useStore } from '@/app/components/workflow/store' -const DELIMITER = '@@@@@' const useConfig = (id: string, payload: LoopNodeType) => { const { nodesReadOnly: readOnly } = useNodesReadOnly() - const { isNodeInLoop } = useIsNodeInLoop(id) const isChatMode = useIsChatMode() const conversationVariables = useStore(s => s.conversationVariables) @@ -39,10 +36,8 @@ const useConfig = (id: string, payload: LoopNodeType) => { }, []) // output - const { getLoopNodeChildren, getBeforeNodesInSameBranch } = useWorkflow() - const beforeNodes = getBeforeNodesInSameBranch(id) + const { getLoopNodeChildren } = useWorkflow() const loopChildrenNodes = [{ id, data: payload } as any, ...getLoopNodeChildren(id)] - const canChooseVarNodes = [...beforeNodes, ...loopChildrenNodes] const childrenNodeVars = toNodeOutputVars(loopChildrenNodes, isChatMode, undefined, [], conversationVariables) const { diff --git a/web/app/components/workflow/nodes/start/utils.ts b/web/app/components/workflow/nodes/start/utils.ts index 037b52a16..16743d617 100644 --- a/web/app/components/workflow/nodes/start/utils.ts +++ b/web/app/components/workflow/nodes/start/utils.ts @@ -1,5 +1,5 @@ import type { StartNodeType } from './types' -export const checkNodeValid = (payload: StartNodeType) => { +export const checkNodeValid = (_payload: StartNodeType) => { return true } diff --git a/web/app/components/workflow/nodes/template-transform/utils.ts b/web/app/components/workflow/nodes/template-transform/utils.ts index 0ca4849a0..874ee2c1a 100644 --- a/web/app/components/workflow/nodes/template-transform/utils.ts +++ b/web/app/components/workflow/nodes/template-transform/utils.ts @@ -1,5 +1,5 @@ import type { TemplateTransformNodeType } from './types' -export const checkNodeValid = (payload: TemplateTransformNodeType) => { +export const checkNodeValid = (_payload: TemplateTransformNodeType) => { return true } diff --git a/web/app/components/workflow/nodes/tool/utils.ts b/web/app/components/workflow/nodes/tool/utils.ts index 5ef2c537e..c55d2f380 100644 --- a/web/app/components/workflow/nodes/tool/utils.ts +++ b/web/app/components/workflow/nodes/tool/utils.ts @@ -1,5 +1,5 @@ import type { ToolNodeType } from './types' -export const checkNodeValid = (payload: ToolNodeType) => { +export const checkNodeValid = (_payload: ToolNodeType) => { return true } diff --git a/web/app/components/workflow/store/workflow/debug/inspect-vars-slice.ts b/web/app/components/workflow/store/workflow/debug/inspect-vars-slice.ts index 51f66bee1..291ed86ba 100644 --- a/web/app/components/workflow/store/workflow/debug/inspect-vars-slice.ts +++ b/web/app/components/workflow/store/workflow/debug/inspect-vars-slice.ts @@ -23,7 +23,7 @@ type InspectVarsActions = { export type InspectVarsSliceShape = InspectVarsState & InspectVarsActions -export const createInspectVarsSlice: StateCreator = (set, get) => { +export const createInspectVarsSlice: StateCreator = (set) => { return ({ currentFocusNodeId: null, nodesWithInspectVars: [], @@ -75,11 +75,11 @@ export const createInspectVarsSlice: StateCreator = (set, if (!targetNode) return const targetVar = targetNode.vars.find(varItem => varItem.id === varId) - if(!targetVar) + if (!targetVar) return targetVar.value = value targetVar.edited = true - }, + }, ) return { nodesWithInspectVars: nodes, @@ -93,11 +93,11 @@ export const createInspectVarsSlice: StateCreator = (set, if (!targetNode) return const targetVar = targetNode.vars.find(varItem => varItem.id === varId) - if(!targetVar) + if (!targetVar) return targetVar.value = value targetVar.edited = false - }, + }, ) return { nodesWithInspectVars: nodes, @@ -111,11 +111,11 @@ export const createInspectVarsSlice: StateCreator = (set, if (!targetNode) return const targetVar = targetNode.vars.find(varItem => varItem.id === varId) - if(!targetVar) + if (!targetVar) return targetVar.name = selector[1] targetVar.selector = selector - }, + }, ) return { nodesWithInspectVars: nodes, @@ -131,7 +131,7 @@ export const createInspectVarsSlice: StateCreator = (set, const needChangeVarIndex = targetNode.vars.findIndex(varItem => varItem.id === varId) if (needChangeVarIndex !== -1) targetNode.vars.splice(needChangeVarIndex, 1) - }, + }, ) return { nodesWithInspectVars: nodes, diff --git a/web/eslint.config.mjs b/web/eslint.config.mjs index 8f1598e87..dda2beff0 100644 --- a/web/eslint.config.mjs +++ b/web/eslint.config.mjs @@ -82,6 +82,7 @@ export default combine( '**/.next/', '**/public/*', '**/*.json', + '**/*.js', ], }, {