From c2f2be6b086f0a15eab8961fcddc53cb353d10a5 Mon Sep 17 00:00:00 2001 From: Angel98518 Date: Tue, 16 Dec 2025 18:00:04 +0800 Subject: [PATCH] fix: oxlint no unused expressions (#29675) Co-authored-by: daniel --- web/app/components/billing/plan-upgrade-modal/index.tsx | 5 ++++- web/app/components/plugins/install-plugin/utils.ts | 3 ++- .../components/editor/code-editor/editor-support-vars.tsx | 3 ++- .../nodes/_base/components/support-var-input/index.tsx | 3 ++- web/app/components/workflow/nodes/code/code-parser.ts | 2 +- .../components/workflow/nodes/http/components/curl-panel.tsx | 3 ++- web/app/components/workflow/nodes/trigger-webhook/types.ts | 3 ++- web/app/components/workflow/utils/node.ts | 2 +- 8 files changed, 16 insertions(+), 8 deletions(-) diff --git a/web/app/components/billing/plan-upgrade-modal/index.tsx b/web/app/components/billing/plan-upgrade-modal/index.tsx index 4f5d1ed3a6..f7e19b7621 100644 --- a/web/app/components/billing/plan-upgrade-modal/index.tsx +++ b/web/app/components/billing/plan-upgrade-modal/index.tsx @@ -33,7 +33,10 @@ const PlanUpgradeModal: FC = ({ const handleUpgrade = useCallback(() => { onClose() - onUpgrade ? onUpgrade() : setShowPricingModal() + if (onUpgrade) + onUpgrade() + else + setShowPricingModal() }, [onClose, onUpgrade, setShowPricingModal]) return ( diff --git a/web/app/components/plugins/install-plugin/utils.ts b/web/app/components/plugins/install-plugin/utils.ts index afbe0f18af..32d3e54225 100644 --- a/web/app/components/plugins/install-plugin/utils.ts +++ b/web/app/components/plugins/install-plugin/utils.ts @@ -61,7 +61,8 @@ export const pluginManifestInMarketToPluginProps = (pluginManifest: PluginManife } export const parseGitHubUrl = (url: string): GitHubUrlInfo => { - const match = url.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+)\/?$/) + const githubUrlRegex = /^https:\/\/github\.com\/([^/]+)\/([^/]+)\/?$/ + const match = githubUrlRegex.exec(url) return match ? { isValid: true, owner: match[1], repo: match[2] } : { isValid: false } } diff --git a/web/app/components/workflow/nodes/_base/components/editor/code-editor/editor-support-vars.tsx b/web/app/components/workflow/nodes/_base/components/editor/code-editor/editor-support-vars.tsx index abc7d8dbc4..68b6e53064 100644 --- a/web/app/components/workflow/nodes/_base/components/editor/code-editor/editor-support-vars.tsx +++ b/web/app/components/workflow/nodes/_base/components/editor/code-editor/editor-support-vars.tsx @@ -84,7 +84,8 @@ const CodeEditor: FC = ({ const getUniqVarName = (varName: string) => { if (varList.find(v => v.variable === varName)) { - const match = varName.match(/_(\d+)$/) + const varNameRegex = /_(\d+)$/ + const match = varNameRegex.exec(varName) const index = (() => { if (match) diff --git a/web/app/components/workflow/nodes/_base/components/support-var-input/index.tsx b/web/app/components/workflow/nodes/_base/components/support-var-input/index.tsx index 3be1262e14..47d80c109f 100644 --- a/web/app/components/workflow/nodes/_base/components/support-var-input/index.tsx +++ b/web/app/components/workflow/nodes/_base/components/support-var-input/index.tsx @@ -25,7 +25,8 @@ const SupportVarInput: FC = ({ const renderSafeContent = (inputValue: string) => { const parts = inputValue.split(/(\{\{[^}]+\}\}|\n)/g) return parts.map((part, index) => { - const variableMatch = part.match(/^\{\{([^}]+)\}\}$/) + const variableRegex = /^\{\{([^}]+)\}\}$/ + const variableMatch = variableRegex.exec(part) if (variableMatch) { return ( { [CodeLanguage.python3]: /def\s+main\s*\((.*?)\)/, [CodeLanguage.javascript]: /function\s+main\s*\((.*?)\)/, } - const match = code.match(patterns[language]) + const match = patterns[language].exec(code) const params: string[] = [] if (match?.[1]) { diff --git a/web/app/components/workflow/nodes/http/components/curl-panel.tsx b/web/app/components/workflow/nodes/http/components/curl-panel.tsx index a5339a1f39..4b9ee56f85 100644 --- a/web/app/components/workflow/nodes/http/components/curl-panel.tsx +++ b/web/app/components/workflow/nodes/http/components/curl-panel.tsx @@ -75,7 +75,8 @@ const parseCurl = (curlCommand: string): { node: HttpNodeType | null; error: str // To support command like `curl -F "file=@/path/to/file;type=application/zip"` // the `;type=application/zip` should translate to `Content-Type: application/zip` - const typeMatch = value.match(/^(.+?);type=(.+)$/) + const typeRegex = /^(.+?);type=(.+)$/ + const typeMatch = typeRegex.exec(value) if (typeMatch) { const [, actualValue, mimeType] = typeMatch value = actualValue diff --git a/web/app/components/workflow/nodes/trigger-webhook/types.ts b/web/app/components/workflow/nodes/trigger-webhook/types.ts index d9632f20e1..90cfd40434 100644 --- a/web/app/components/workflow/nodes/trigger-webhook/types.ts +++ b/web/app/components/workflow/nodes/trigger-webhook/types.ts @@ -5,7 +5,8 @@ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' export type ArrayElementType = 'string' | 'number' | 'boolean' | 'object' export const getArrayElementType = (arrayType: `array[${ArrayElementType}]`): ArrayElementType => { - const match = arrayType.match(/^array\[(.+)\]$/) + const arrayRegex = /^array\[(.+)\]$/ + const match = arrayRegex.exec(arrayType) return (match?.[1] as ArrayElementType) || 'string' } diff --git a/web/app/components/workflow/utils/node.ts b/web/app/components/workflow/utils/node.ts index 726908bff1..97ca7553e8 100644 --- a/web/app/components/workflow/utils/node.ts +++ b/web/app/components/workflow/utils/node.ts @@ -105,7 +105,7 @@ export function getLoopStartNode(loopId: string): Node { export const genNewNodeTitleFromOld = (oldTitle: string) => { const regex = /^(.+?)\s*\((\d+)\)\s*$/ - const match = oldTitle.match(regex) + const match = regex.exec(oldTitle) if (match) { const title = match[1]