From 208ce4e774e9025817a459a63ae62301feb4ad94 Mon Sep 17 00:00:00 2001 From: Yongtao Huang Date: Mon, 1 Sep 2025 15:31:59 +0800 Subject: [PATCH] CI: add TS indentation check via esLint (#24810) --- .github/workflows/style.yml | 4 +- web/__tests__/check-i18n.test.ts | 2 +- web/__tests__/description-validation.test.tsx | 4 +- web/__tests__/document-list-sorting.test.tsx | 2 +- .../plugin-tool-workflow-error.test.tsx | 2 +- web/__tests__/real-browser-flicker.test.tsx | 2 +- .../workflow-parallel-limit.test.tsx | 4 +- .../svg-attribute-error-reproduction.spec.tsx | 4 +- .../account-page/AvatarWithEdit.tsx | 2 +- web/app/components/app-sidebar/basic.tsx | 4 +- web/app/components/app-sidebar/index.tsx | 4 +- .../sidebar-animation-issues.spec.tsx | 2 +- web/app/components/app/annotation/index.tsx | 2 +- .../config-var/config-modal/type-select.tsx | 10 +- .../params-config/config-content.tsx | 1 - .../configuration/debug/chat-user-input.tsx | 8 +- web/app/components/app/log/list.tsx | 124 +++++++++--------- web/app/components/app/overview/app-card.tsx | 2 +- .../app/overview/embedded/index.tsx | 8 +- .../app/overview/settings/index.tsx | 2 +- web/app/components/apps/list.tsx | 2 +- .../embedded-chatbot/inputs-form/content.tsx | 12 +- web/app/components/base/checkbox/index.tsx | 12 +- .../base/date-and-time-picker/utils/dayjs.ts | 2 +- .../base/form/form-scenarios/demo/index.tsx | 2 +- web/app/components/base/form/types.ts | 10 +- web/app/components/base/mermaid/index.tsx | 6 +- .../plugins/current-block/component.tsx | 6 +- .../plugins/error-message-block/component.tsx | 6 +- .../plugins/last-run-block/component.tsx | 6 +- web/app/components/base/select/index.tsx | 48 +++---- .../base/tag-management/selector.tsx | 2 +- web/app/components/base/toast/index.tsx | 2 +- .../common/retrieval-param-config/index.tsx | 1 - .../create/website/base/options-wrap.tsx | 1 - .../datasets/create/website/index.tsx | 3 +- .../website/jina-reader/base/options-wrap.tsx | 1 - .../detail/batch-modal/csv-uploader.tsx | 2 +- .../create/InfoPanel.tsx | 6 +- .../components/chunk-detail-modal.tsx | 4 +- .../hooks/use-edit-dataset-metadata.ts | 1 - .../actions/commands/registry.ts | 4 +- .../components/goto-anything/actions/index.ts | 4 +- web/app/components/goto-anything/index.tsx | 2 +- .../data-source-website/index.tsx | 1 - .../add-credential-in-load-balancing.tsx | 6 +- .../model-auth/authorized/index.tsx | 10 +- .../model-load-balancing-modal.tsx | 4 +- .../install-bundle/item/github-item.tsx | 3 - .../install-bundle/steps/install-multi.tsx | 6 - .../install-from-github/steps/loaded.tsx | 1 - .../steps/uploading.tsx | 1 - .../plugins/marketplace/context.tsx | 1 - .../plugins/plugin-auth/authorized/index.tsx | 28 ++-- .../hooks/use-plugin-auth-action.ts | 6 +- .../app-selector/index.tsx | 2 +- .../plugin-detail-panel/detail-header.tsx | 2 +- .../plugin-detail-panel/endpoint-modal.tsx | 4 +- .../multiple-tool-selector/index.tsx | 2 +- .../tool-selector/reasoning-config-form.tsx | 12 +- .../components/plugins/plugin-item/action.tsx | 1 - .../auto-update-setting/index.tsx | 24 ++-- .../auto-update-setting/utils.ts | 12 +- .../update-plugin/downgrade-warning.tsx | 2 +- .../update-plugin/from-market-place.tsx | 76 +++++------ .../components/tools/mcp/detail/content.tsx | 1 - .../components/tools/mcp/mcp-service-card.tsx | 6 +- .../components/tools/utils/to-form-schema.ts | 18 +-- .../workflow-app/hooks/use-workflow-init.ts | 1 - .../workflow/block-selector/all-tools.tsx | 1 - .../market-place-plugin/action.tsx | 1 - .../market-place-plugin/list.tsx | 1 - .../workflow/block-selector/tool/tool.tsx | 1 - .../datasets-detail-store/provider.tsx | 1 - .../workflow/header/header-in-restoring.tsx | 40 +++--- .../header/version-history-button.tsx | 20 +-- .../workflow/hooks-store/provider.tsx | 1 - .../hooks/use-inspect-vars-crud-common.ts | 58 ++++---- .../hooks/use-nodes-available-var-list.ts | 6 +- .../use-workflow-node-started.ts | 2 +- .../components/agent-strategy-selector.tsx | 2 +- .../nodes/_base/components/agent-strategy.tsx | 2 +- .../components/before-run-form/form-item.tsx | 8 +- .../components/input-support-select-var.tsx | 1 - .../mcp-tool-not-support-tooltip.tsx | 2 +- .../nodes/_base/components/variable/utils.ts | 4 +- .../_base/components/variable/var-list.tsx | 10 +- .../variable/var-reference-picker.tsx | 2 +- .../_base/components/workflow-panel/index.tsx | 4 +- .../workflow-panel/last-run/index.tsx | 10 +- .../nodes/_base/hooks/use-output-var-list.ts | 8 +- .../components/workflow/nodes/agent/panel.tsx | 8 +- .../nodes/agent/use-single-run-form-params.ts | 2 +- .../assigner/components/var-list/index.tsx | 2 +- .../nodes/http/hooks/use-key-value-list.ts | 2 - .../workflow/nodes/http/use-config.ts | 1 - .../components/metadata/metadata-trigger.tsx | 1 - .../nodes/knowledge-retrieval/use-config.ts | 3 - .../json-importer.tsx | 1 - .../nodes/parameter-extractor/use-config.ts | 1 - .../components/class-list.tsx | 8 +- .../nodes/question-classifier/use-config.ts | 2 - .../workflow/nodes/tool/use-config.ts | 1 - .../nodes/tool/use-single-run-form-params.ts | 2 +- .../workflow/operator/export-image.tsx | 4 +- .../workflow/panel/inputs-panel.tsx | 2 +- .../workflow/panel/workflow-preview.tsx | 2 +- .../workflow/selection-contextmenu.tsx | 2 +- .../workflow/variable-inspect/empty.tsx | 2 +- .../workflow/variable-inspect/index.tsx | 10 +- web/app/education-apply/hooks.ts | 44 +++---- web/app/install/installForm.tsx | 2 +- web/eslint.config.mjs | 8 +- web/i18n/en-US/workflow.ts | 2 +- web/package.json | 1 + web/service/base.ts | 46 +++---- web/service/use-plugins-auth.ts | 26 ++-- web/utils/navigation.ts | 8 +- 118 files changed, 457 insertions(+), 489 deletions(-) diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index b6c9131c0..9c79dbc57 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -89,7 +89,9 @@ jobs: - name: Web style check if: steps.changed-files.outputs.any_changed == 'true' working-directory: ./web - run: pnpm run lint + run: | + pnpm run lint + pnpm run eslint docker-compose-template: name: Docker Compose Template diff --git a/web/__tests__/check-i18n.test.ts b/web/__tests__/check-i18n.test.ts index b4c4f1540..b579f22d4 100644 --- a/web/__tests__/check-i18n.test.ts +++ b/web/__tests__/check-i18n.test.ts @@ -621,7 +621,7 @@ export default translation && !trimmed.startsWith('//')) break } - else { + else { break } diff --git a/web/__tests__/description-validation.test.tsx b/web/__tests__/description-validation.test.tsx index 85263b035..a78a4e632 100644 --- a/web/__tests__/description-validation.test.tsx +++ b/web/__tests__/description-validation.test.tsx @@ -60,7 +60,7 @@ describe('Description Validation Logic', () => { try { validateDescriptionLength(invalidDescription) } - catch (error) { + catch (error) { expect((error as Error).message).toBe(expectedErrorMessage) } }) @@ -86,7 +86,7 @@ describe('Description Validation Logic', () => { expect(() => validateDescriptionLength(testDescription)).not.toThrow() expect(validateDescriptionLength(testDescription)).toBe(testDescription) } - else { + else { expect(() => validateDescriptionLength(testDescription)).toThrow( 'Description cannot exceed 400 characters.', ) diff --git a/web/__tests__/document-list-sorting.test.tsx b/web/__tests__/document-list-sorting.test.tsx index 1510dbec2..77c0bb60c 100644 --- a/web/__tests__/document-list-sorting.test.tsx +++ b/web/__tests__/document-list-sorting.test.tsx @@ -39,7 +39,7 @@ describe('Document List Sorting', () => { const result = aValue.localeCompare(bValue) return order === 'asc' ? result : -result } - else { + else { const result = aValue - bValue return order === 'asc' ? result : -result } diff --git a/web/__tests__/plugin-tool-workflow-error.test.tsx b/web/__tests__/plugin-tool-workflow-error.test.tsx index 370052bc8..87bda8fa1 100644 --- a/web/__tests__/plugin-tool-workflow-error.test.tsx +++ b/web/__tests__/plugin-tool-workflow-error.test.tsx @@ -196,7 +196,7 @@ describe('Plugin Tool Workflow Integration', () => { const _pluginId = (tool.uniqueIdentifier as any).split(':')[0] }).toThrow() } - else { + else { // Valid tools should work fine expect(() => { const _pluginId = tool.uniqueIdentifier.split(':')[0] diff --git a/web/__tests__/real-browser-flicker.test.tsx b/web/__tests__/real-browser-flicker.test.tsx index cf3abd5f8..52bdf4777 100644 --- a/web/__tests__/real-browser-flicker.test.tsx +++ b/web/__tests__/real-browser-flicker.test.tsx @@ -252,7 +252,7 @@ describe('Real Browser Environment Dark Mode Flicker Test', () => { if (hasStyleChange) console.log('⚠️ Style changes detected - this causes visible flicker') - else + else console.log('✅ No style changes detected') expect(timingData.length).toBeGreaterThan(1) diff --git a/web/__tests__/workflow-parallel-limit.test.tsx b/web/__tests__/workflow-parallel-limit.test.tsx index 0843122ab..64e9d328f 100644 --- a/web/__tests__/workflow-parallel-limit.test.tsx +++ b/web/__tests__/workflow-parallel-limit.test.tsx @@ -15,7 +15,7 @@ const originalEnv = process.env.NEXT_PUBLIC_MAX_PARALLEL_LIMIT function setupEnvironment(value?: string) { if (value) process.env.NEXT_PUBLIC_MAX_PARALLEL_LIMIT = value - else + else delete process.env.NEXT_PUBLIC_MAX_PARALLEL_LIMIT // Clear module cache to force re-evaluation @@ -25,7 +25,7 @@ function setupEnvironment(value?: string) { function restoreEnvironment() { if (originalEnv) process.env.NEXT_PUBLIC_MAX_PARALLEL_LIMIT = originalEnv - else + else delete process.env.NEXT_PUBLIC_MAX_PARALLEL_LIMIT jest.resetModules() diff --git a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/__tests__/svg-attribute-error-reproduction.spec.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/__tests__/svg-attribute-error-reproduction.spec.tsx index a3281be8e..b1e915b2b 100644 --- a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/__tests__/svg-attribute-error-reproduction.spec.tsx +++ b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/__tests__/svg-attribute-error-reproduction.spec.tsx @@ -47,7 +47,7 @@ describe('SVG Attribute Error Reproduction', () => { console.log(` ${index + 1}. ${error.substring(0, 100)}...`) }) } - else { + else { console.log('No inkscape errors found in this render') } @@ -150,7 +150,7 @@ describe('SVG Attribute Error Reproduction', () => { if (problematicKeys.length > 0) console.log(`🚨 PROBLEM: Still found problematic attributes: ${problematicKeys.join(', ')}`) - else + else console.log('✅ No problematic attributes found after normalization') }) }) diff --git a/web/app/account/(commonLayout)/account-page/AvatarWithEdit.tsx b/web/app/account/(commonLayout)/account-page/AvatarWithEdit.tsx index 0408d2ee3..5890c2ea9 100644 --- a/web/app/account/(commonLayout)/account-page/AvatarWithEdit.tsx +++ b/web/app/account/(commonLayout)/account-page/AvatarWithEdit.tsx @@ -106,7 +106,7 @@ const AvatarWithEdit = ({ onSave, ...props }: AvatarWithEditProps) => { onClick={() => { if (hoverArea === 'right' && !onAvatarError) setIsShowDeleteConfirm(true) - else + else setIsShowAvatarPicker(true) }} onMouseMove={(e) => { diff --git a/web/app/components/app-sidebar/basic.tsx b/web/app/components/app-sidebar/basic.tsx index 00357d6c2..77a965c03 100644 --- a/web/app/components/app-sidebar/basic.tsx +++ b/web/app/components/app-sidebar/basic.tsx @@ -45,8 +45,8 @@ const ICON_MAP = { , dataset: , webapp:
- -
, + + , notion: , } diff --git a/web/app/components/app-sidebar/index.tsx b/web/app/components/app-sidebar/index.tsx index c3ff45d6a..c60aa26f5 100644 --- a/web/app/components/app-sidebar/index.tsx +++ b/web/app/components/app-sidebar/index.tsx @@ -62,12 +62,12 @@ const AppDetailNav = ({ title, desc, isExternal, icon, icon_background, navigati }, [appSidebarExpand, setAppSiderbarExpand]) if (inWorkflowCanvas && hideHeader) { - return ( + return (
) -} + } return (
{ })) }) - describe('Issue #1: Toggle Button Position Movement - FIXED', () => { + describe('Issue #1: Toggle Button Position Movement - FIXED', () => { it('should verify consistent padding prevents button position shift', () => { let expanded = false const handleToggle = () => { diff --git a/web/app/components/app/annotation/index.tsx b/web/app/components/app/annotation/index.tsx index bb2a95b0b..afa873270 100644 --- a/web/app/components/app/annotation/index.tsx +++ b/web/app/components/app/annotation/index.tsx @@ -84,7 +84,7 @@ const Annotation: FC = (props) => { setList(data as AnnotationItem[]) setTotal(total) } - finally { + finally { setIsLoading(false) } } diff --git a/web/app/components/app/configuration/config-var/config-modal/type-select.tsx b/web/app/components/app/configuration/config-var/config-modal/type-select.tsx index 3f6a01ed7..beb7b03e3 100644 --- a/web/app/components/app/configuration/config-var/config-modal/type-select.tsx +++ b/web/app/components/app/configuration/config-var/config-modal/type-select.tsx @@ -52,13 +52,13 @@ const TypeSelector: FC = ({ >
- - {selectedItem?.name} - + > + {selectedItem?.name} +
{inputVarTypeToVarType(selectedItem?.value as InputVarType)} diff --git a/web/app/components/app/configuration/dataset-config/params-config/config-content.tsx b/web/app/components/app/configuration/dataset-config/params-config/config-content.tsx index 86025f68f..cb61b927b 100644 --- a/web/app/components/app/configuration/dataset-config/params-config/config-content.tsx +++ b/web/app/components/app/configuration/dataset-config/params-config/config-content.tsx @@ -175,7 +175,6 @@ const ConfigContent: FC = ({ ...datasetConfigs, reranking_enable: enable, }) - // eslint-disable-next-line react-hooks/exhaustive-deps }, [currentRerankModel, datasetConfigs, onChange]) return ( diff --git a/web/app/components/app/configuration/debug/chat-user-input.tsx b/web/app/components/app/configuration/debug/chat-user-input.tsx index ac07691ce..b1161de07 100644 --- a/web/app/components/app/configuration/debug/chat-user-input.tsx +++ b/web/app/components/app/configuration/debug/chat-user-input.tsx @@ -57,10 +57,10 @@ const ChatUserInput = ({ >
{type !== 'checkbox' && ( -
-
{name || key}
- {!required && {t('workflow.panel.optional')}} -
+
+
{name || key}
+ {!required && {t('workflow.panel.optional')}} +
)}
{type === 'string' && ( diff --git a/web/app/components/app/log/list.tsx b/web/app/components/app/log/list.tsx index 67b806574..b73d1f19d 100644 --- a/web/app/components/app/log/list.tsx +++ b/web/app/components/app/log/list.tsx @@ -112,72 +112,72 @@ const getFormattedChatList = (messages: ChatMessage[], conversationId: string, t const newChatList: IChatItem[] = [] try { messages.forEach((item: ChatMessage) => { - const questionFiles = item.message_files?.filter((file: any) => file.belongs_to === 'user') || [] - newChatList.push({ - id: `question-${item.id}`, - content: item.inputs.query || item.inputs.default_input || item.query, // text generation: item.inputs.query; chat: item.query - isAnswer: false, - message_files: getProcessedFilesFromResponse(questionFiles.map((item: any) => ({ ...item, related_id: item.id }))), - parentMessageId: item.parent_message_id || undefined, - }) + const questionFiles = item.message_files?.filter((file: any) => file.belongs_to === 'user') || [] + newChatList.push({ + id: `question-${item.id}`, + content: item.inputs.query || item.inputs.default_input || item.query, // text generation: item.inputs.query; chat: item.query + isAnswer: false, + message_files: getProcessedFilesFromResponse(questionFiles.map((item: any) => ({ ...item, related_id: item.id }))), + parentMessageId: item.parent_message_id || undefined, + }) - const answerFiles = item.message_files?.filter((file: any) => file.belongs_to === 'assistant') || [] - newChatList.push({ - id: item.id, - content: item.answer, - agent_thoughts: addFileInfos(item.agent_thoughts ? sortAgentSorts(item.agent_thoughts) : item.agent_thoughts, item.message_files), - feedback: item.feedbacks.find(item => item.from_source === 'user'), // user feedback - adminFeedback: item.feedbacks.find(item => item.from_source === 'admin'), // admin feedback - feedbackDisabled: false, - isAnswer: true, - message_files: getProcessedFilesFromResponse(answerFiles.map((item: any) => ({ ...item, related_id: item.id }))), - log: [ - ...item.message, - ...(item.message[item.message.length - 1]?.role !== 'assistant' - ? [ - { - role: 'assistant', - text: item.answer, - files: item.message_files?.filter((file: any) => file.belongs_to === 'assistant') || [], - }, - ] - : []), - ] as IChatItem['log'], - workflow_run_id: item.workflow_run_id, - conversationId, - input: { - inputs: item.inputs, - query: item.query, - }, - more: { - time: dayjs.unix(item.created_at).tz(timezone).format(format), - tokens: item.answer_tokens + item.message_tokens, - latency: item.provider_response_latency.toFixed(2), - }, - citation: item.metadata?.retriever_resources, - annotation: (() => { - if (item.annotation_hit_history) { - return { - id: item.annotation_hit_history.annotation_id, - authorName: item.annotation_hit_history.annotation_create_account?.name || 'N/A', - created_at: item.annotation_hit_history.created_at, + const answerFiles = item.message_files?.filter((file: any) => file.belongs_to === 'assistant') || [] + newChatList.push({ + id: item.id, + content: item.answer, + agent_thoughts: addFileInfos(item.agent_thoughts ? sortAgentSorts(item.agent_thoughts) : item.agent_thoughts, item.message_files), + feedback: item.feedbacks.find(item => item.from_source === 'user'), // user feedback + adminFeedback: item.feedbacks.find(item => item.from_source === 'admin'), // admin feedback + feedbackDisabled: false, + isAnswer: true, + message_files: getProcessedFilesFromResponse(answerFiles.map((item: any) => ({ ...item, related_id: item.id }))), + log: [ + ...item.message, + ...(item.message[item.message.length - 1]?.role !== 'assistant' + ? [ + { + role: 'assistant', + text: item.answer, + files: item.message_files?.filter((file: any) => file.belongs_to === 'assistant') || [], + }, + ] + : []), + ] as IChatItem['log'], + workflow_run_id: item.workflow_run_id, + conversationId, + input: { + inputs: item.inputs, + query: item.query, + }, + more: { + time: dayjs.unix(item.created_at).tz(timezone).format(format), + tokens: item.answer_tokens + item.message_tokens, + latency: item.provider_response_latency.toFixed(2), + }, + citation: item.metadata?.retriever_resources, + annotation: (() => { + if (item.annotation_hit_history) { + return { + id: item.annotation_hit_history.annotation_id, + authorName: item.annotation_hit_history.annotation_create_account?.name || 'N/A', + created_at: item.annotation_hit_history.created_at, + } } - } - if (item.annotation) { - return { - id: item.annotation.id, - authorName: item.annotation.account.name, - logAnnotation: item.annotation, - created_at: 0, + if (item.annotation) { + return { + id: item.annotation.id, + authorName: item.annotation.account.name, + logAnnotation: item.annotation, + created_at: 0, + } } - } - return undefined - })(), - parentMessageId: `question-${item.id}`, + return undefined + })(), + parentMessageId: `question-${item.id}`, + }) }) - }) return newChatList } @@ -503,7 +503,7 @@ function DetailPanel({ detail, onFeedback }: IDetailPanel) { setThreadChatItems(getThreadMessages(tree, newAllChatItems.at(-1)?.id)) } - catch (error) { + catch (error) { console.error(error) setHasMore(false) } @@ -522,7 +522,7 @@ function DetailPanel({ detail, onFeedback }: IDetailPanel) { if (outerDiv && outerDiv.scrollHeight > outerDiv.clientHeight) { scrollContainer = outerDiv } - else if (scrollableDiv && scrollableDiv.scrollHeight > scrollableDiv.clientHeight) { + else if (scrollableDiv && scrollableDiv.scrollHeight > scrollableDiv.clientHeight) { scrollContainer = scrollableDiv } else if (chatContainer && chatContainer.scrollHeight > chatContainer.clientHeight) { diff --git a/web/app/components/app/overview/app-card.tsx b/web/app/components/app/overview/app-card.tsx index 8713c8ef7..c6df0ebfd 100644 --- a/web/app/components/app/overview/app-card.tsx +++ b/web/app/components/app/overview/app-card.tsx @@ -167,7 +167,7 @@ function AppCard({ setAppDetail(res) setShowAccessControl(false) } - catch (error) { + catch (error) { console.error('Failed to fetch app detail:', error) } }, [appDetail, setAppDetail]) diff --git a/web/app/components/app/overview/embedded/index.tsx b/web/app/components/app/overview/embedded/index.tsx index cd25c4ca6..6eba993e1 100644 --- a/web/app/components/app/overview/embedded/index.tsx +++ b/web/app/components/app/overview/embedded/index.tsx @@ -40,12 +40,12 @@ const OPTION_MAP = { `