fix: oxlint no unused expressions (#29675)

Co-authored-by: daniel <daniel@example.com>
This commit is contained in:
Angel98518
2025-12-16 18:00:04 +08:00
committed by GitHub
parent b7649f61f8
commit c2f2be6b08
8 changed files with 16 additions and 8 deletions

View File

@@ -33,7 +33,10 @@ const PlanUpgradeModal: FC<Props> = ({
const handleUpgrade = useCallback(() => {
onClose()
onUpgrade ? onUpgrade() : setShowPricingModal()
if (onUpgrade)
onUpgrade()
else
setShowPricingModal()
}, [onClose, onUpgrade, setShowPricingModal])
return (

View File

@@ -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 }
}

View File

@@ -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)

View File

@@ -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

View File

@@ -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]) {

View File

@@ -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

View File

@@ -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'
}

View File

@@ -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]