Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: oxlint no unused expressions (#29675)

Angel98518c2f2be6b086f
diff --git a/web/app/components/billing/plan-upgrade-modal/index.tsx b/web/app/components/billing/plan-upgrade-modal/index.tsx
index 4f5d1ed3a62..f7e19b76218 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<Props> = ({
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 afbe0f18af1..32d3e542258 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 abc7d8dbc4c..68b6e530642 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<Props> = ({
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 3be1262e14c..47d80c109f7 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<Props> = ({
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 (
<VarHighlight
diff --git a/web/app/components/workflow/nodes/code/code-parser.ts b/web/app/components/workflow/nodes/code/code-parser.ts
index 216e13eacab..86447a06e50 100644
--- a/web/app/components/workflow/nodes/code/code-parser.ts
+++ b/web/app/components/workflow/nodes/code/code-parser.ts
@@ -10,7 +10,7 @@ export const extractFunctionParams = (code: string, language: CodeLanguage) => {
[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 a5339a1f393..4b9ee56f851 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 d9632f20e14..90cfd404346 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 726908bff1c..97ca7553e87 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]