mirror of https://github.com/langgenius/dify.git
fix: oxlint no unused expressions (#29675)
Co-authored-by: daniel <daniel@example.com>
This commit is contained in:
parent
b7649f61f8
commit
c2f2be6b08
|
|
@ -33,7 +33,10 @@ const PlanUpgradeModal: FC<Props> = ({
|
||||||
|
|
||||||
const handleUpgrade = useCallback(() => {
|
const handleUpgrade = useCallback(() => {
|
||||||
onClose()
|
onClose()
|
||||||
onUpgrade ? onUpgrade() : setShowPricingModal()
|
if (onUpgrade)
|
||||||
|
onUpgrade()
|
||||||
|
else
|
||||||
|
setShowPricingModal()
|
||||||
}, [onClose, onUpgrade, setShowPricingModal])
|
}, [onClose, onUpgrade, setShowPricingModal])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,8 @@ export const pluginManifestInMarketToPluginProps = (pluginManifest: PluginManife
|
||||||
}
|
}
|
||||||
|
|
||||||
export const parseGitHubUrl = (url: string): GitHubUrlInfo => {
|
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 }
|
return match ? { isValid: true, owner: match[1], repo: match[2] } : { isValid: false }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,8 @@ const CodeEditor: FC<Props> = ({
|
||||||
|
|
||||||
const getUniqVarName = (varName: string) => {
|
const getUniqVarName = (varName: string) => {
|
||||||
if (varList.find(v => v.variable === varName)) {
|
if (varList.find(v => v.variable === varName)) {
|
||||||
const match = varName.match(/_(\d+)$/)
|
const varNameRegex = /_(\d+)$/
|
||||||
|
const match = varNameRegex.exec(varName)
|
||||||
|
|
||||||
const index = (() => {
|
const index = (() => {
|
||||||
if (match)
|
if (match)
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ const SupportVarInput: FC<Props> = ({
|
||||||
const renderSafeContent = (inputValue: string) => {
|
const renderSafeContent = (inputValue: string) => {
|
||||||
const parts = inputValue.split(/(\{\{[^}]+\}\}|\n)/g)
|
const parts = inputValue.split(/(\{\{[^}]+\}\}|\n)/g)
|
||||||
return parts.map((part, index) => {
|
return parts.map((part, index) => {
|
||||||
const variableMatch = part.match(/^\{\{([^}]+)\}\}$/)
|
const variableRegex = /^\{\{([^}]+)\}\}$/
|
||||||
|
const variableMatch = variableRegex.exec(part)
|
||||||
if (variableMatch) {
|
if (variableMatch) {
|
||||||
return (
|
return (
|
||||||
<VarHighlight
|
<VarHighlight
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ export const extractFunctionParams = (code: string, language: CodeLanguage) => {
|
||||||
[CodeLanguage.python3]: /def\s+main\s*\((.*?)\)/,
|
[CodeLanguage.python3]: /def\s+main\s*\((.*?)\)/,
|
||||||
[CodeLanguage.javascript]: /function\s+main\s*\((.*?)\)/,
|
[CodeLanguage.javascript]: /function\s+main\s*\((.*?)\)/,
|
||||||
}
|
}
|
||||||
const match = code.match(patterns[language])
|
const match = patterns[language].exec(code)
|
||||||
const params: string[] = []
|
const params: string[] = []
|
||||||
|
|
||||||
if (match?.[1]) {
|
if (match?.[1]) {
|
||||||
|
|
|
||||||
|
|
@ -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"`
|
// To support command like `curl -F "file=@/path/to/file;type=application/zip"`
|
||||||
// the `;type=application/zip` should translate to `Content-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) {
|
if (typeMatch) {
|
||||||
const [, actualValue, mimeType] = typeMatch
|
const [, actualValue, mimeType] = typeMatch
|
||||||
value = actualValue
|
value = actualValue
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,8 @@ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD'
|
||||||
export type ArrayElementType = 'string' | 'number' | 'boolean' | 'object'
|
export type ArrayElementType = 'string' | 'number' | 'boolean' | 'object'
|
||||||
|
|
||||||
export const getArrayElementType = (arrayType: `array[${ArrayElementType}]`): ArrayElementType => {
|
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'
|
return (match?.[1] as ArrayElementType) || 'string'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ export function getLoopStartNode(loopId: string): Node {
|
||||||
|
|
||||||
export const genNewNodeTitleFromOld = (oldTitle: string) => {
|
export const genNewNodeTitleFromOld = (oldTitle: string) => {
|
||||||
const regex = /^(.+?)\s*\((\d+)\)\s*$/
|
const regex = /^(.+?)\s*\((\d+)\)\s*$/
|
||||||
const match = oldTitle.match(regex)
|
const match = regex.exec(oldTitle)
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
const title = match[1]
|
const title = match[1]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue