chore(frontend): upgrade ESLint config to v10 and migrate formatting (#522)

* chore(deps-dev): bump @antfu/eslint-config in /frontend

Bumps [@antfu/eslint-config](https://github.com/antfu/eslint-config) from 9.5.1 to 10.0.0.
- [Release notes](https://github.com/antfu/eslint-config/releases)
- [Commits](https://github.com/antfu/eslint-config/compare/v9.5.1...v10.0.0)

---
updated-dependencies:
- dependency-name: "@antfu/eslint-config"
  dependency-version: 10.0.0
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore(frontend): migrate formatting to ESLint v10

Co-authored-by: Codex <noreply@openai.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Zyy <zyycn@users.noreply.github.com>
Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
dependabot[bot]
2026-10-26 11:34:32 +08:00
committed by GitHub
co-authored by Codex Zyy
parent dffc417b9f
commit f0484c4e11
224 changed files with 6822 additions and 1659 deletions
+3 -1
View File
@@ -1,2 +1,4 @@
export const API_BASE_URL = import.meta.env.DEV ? '/dev' : ''
export const API_BASE_URL = import.meta.env.DEV
? '/dev'
: ''
export const API_TIMEOUT_MS = 120_000
+4 -1
View File
@@ -711,7 +711,10 @@ export function startAccountOAuth(data: AccountOAuthStartParam, options: Request
function providerInputBody(data: object) {
// Provider 文档是不透明 JSON,先编码,避免 HTTP 客户端合并配置时过滤特殊字段名。
return { headers: { 'Content-Type': 'application/json' }, data: JSON.stringify(data) }
return {
headers: { 'Content-Type': 'application/json' },
data: JSON.stringify(data),
}
}
export function completeAccountOAuth(data: AccountOAuthCompleteParam, options: RequestOptions = {}) {
@@ -92,12 +92,16 @@ export function callPluginManagementRoute(
call: PluginManagementRawRequest,
options: RequestOptions = {},
) {
const query = call.query ? `?${call.query}` : ''
const query = call.query
? `?${call.query}`
: ''
return requestPluginManagementRaw({
url: `${pluginManagementTargetPath(target)}/api/${encodePluginPath(call.path)}${query}`,
method: call.method,
data: call.body?.byteLength ? call.body : undefined,
headers: call.contentType ? { 'Content-Type': call.contentType } : undefined,
headers: call.contentType
? { 'Content-Type': call.contentType }
: undefined,
timeout: PLUGIN_MANAGEMENT_TIMEOUT_MS,
...options,
})
+22 -4
View File
@@ -33,10 +33,21 @@ const http = axios.create({
})
// 从外到内:提示、会话恢复、重试、错误归一化、原始响应处理、实际传输
const plugins: RequestPlugin[] = [feedbackPlugin, sessionPlugin, retryPlugin, errorPlugin, rawPlugin]
const plugins: RequestPlugin[] = [
feedbackPlugin,
sessionPlugin,
retryPlugin,
errorPlugin,
rawPlugin,
]
function execute(config: RequestConfig, raw?: RawResponseOptions, stream = false) {
const context: RequestContext = { config, raw, stream, isCurrent: () => !config.signal?.aborted }
const context: RequestContext = {
config,
raw,
stream,
isCurrent: () => !config.signal?.aborted,
}
const transport: RequestNext = () => http.request<unknown>(context.config)
return plugins.reduceRight<RequestNext>((next, plugin) => () => plugin(context, next), transport)()
}
@@ -57,9 +68,16 @@ export async function requestRaw(config: RequestConfig, options: RawResponseOpti
export async function requestStream(config: RequestConfig, options: RawResponseOptions): Promise<Response> {
// 成功正文保持流式交付;宿主错误仍由同一管线识别和恢复,禁止网络错误重放写操作
const controller = new AbortController()
const signal = config.signal ? AbortSignal.any([config.signal, controller.signal]) : controller.signal
const signal = config.signal
? AbortSignal.any([config.signal, controller.signal])
: controller.signal
try {
const { data } = await execute({ ...config, adapter: 'fetch', retry: false, signal }, options, true)
const { data } = await execute({
...config,
adapter: 'fetch',
retry: false,
signal,
}, options, true)
return data as Response
}
catch (error) {
+18 -6
View File
@@ -19,7 +19,9 @@ export async function errorPlugin(_context: RequestContext, next: RequestNext) {
return response
}
catch (error) {
throw isAxiosError(error) ? normalizeApiError(error) : error
throw isAxiosError(error)
? normalizeApiError(error)
: error
}
}
@@ -64,7 +66,9 @@ export function normalizeApiResponseError(response: AxiosResponse<unknown>) {
const envelope = adminErrorEnvelope(response.data)
if (!envelope || envelope.code === 200)
return undefined
const message = adminErrorMessage(envelope) || httpFallback(response.status >= 400 ? response.status : 0)
const message = adminErrorMessage(envelope) || httpFallback(response.status >= 400
? response.status
: 0)
return new ApiError(
message,
response.status,
@@ -80,7 +84,9 @@ function adminErrorEnvelope(value: unknown): AdminErrorEnvelope | null {
const record = value as Record<string, unknown>
if (typeof record.code !== 'number' || !Number.isSafeInteger(record.code))
return null
const message = typeof record.message === 'string' ? record.message.trim() : ''
const message = typeof record.message === 'string'
? record.message.trim()
: ''
return { code: record.code, message }
}
@@ -109,8 +115,12 @@ function responseHeader(
) {
if (!headers)
return undefined
const value = typeof headers.get === 'function' ? headers.get(name) : headers[name]
return typeof value === 'string' && value ? value : undefined
const value = typeof headers.get === 'function'
? headers.get(name)
: headers[name]
return typeof value === 'string' && value
? value
: undefined
}
function httpFallback(status: number) {
@@ -144,7 +154,9 @@ function httpFallback(status: number) {
case 504:
return t('common.errors.upstreamTimeout')
default:
return status > 0 ? t('common.errors.http', { status }) : t('common.errors.request')
return status > 0
? t('common.errors.http', { status })
: t('common.errors.request')
}
}
+9 -3
View File
@@ -70,7 +70,9 @@ export async function rawPlugin(context: RequestContext, next: RequestNext) {
if (normalized)
throw normalized
throw new ApiError(
response.status >= 400 ? t('common.errors.http', { status: response.status }) : t('common.errors.unsupportedResponse'),
response.status >= 400
? t('common.errors.http', { status: response.status })
: t('common.errors.unsupportedResponse'),
response.status,
undefined,
rawHeader(response.headers, 'x-request-id'),
@@ -111,8 +113,12 @@ function rawHeader(headers: unknown, name: string) {
if (!headers || typeof headers !== 'object')
return undefined
const source = headers as { get?: (key: string) => unknown, [key: string]: unknown }
const value = typeof source.get === 'function' ? source.get(name) : source[name]
return typeof value === 'string' && value ? value : undefined
const value = typeof source.get === 'function'
? source.get(name)
: source[name]
return typeof value === 'string' && value
? value
: undefined
}
function decodeRawEnvelope(body: ArrayBuffer): unknown {
+3 -1
View File
@@ -84,7 +84,9 @@ export async function sessionPlugin(context: RequestContext, send: RequestNext)
if (!isSessionRequired(error) || config.signal?.aborted || generation !== sessionGeneration)
throw error
if (!config.skipSessionRecovery && sessionRecoveryHandler
&& await (sessionRecovery ?? (successfulRecoveries !== recovered ? true : recoverSession()))) {
&& await (sessionRecovery ?? (successfulRecoveries !== recovered
? true
: recoverSession()))) {
// 迟到的 40101 也须等待当前续期;Cookie 更新完成后原请求最多重放一次
if (config.signal?.aborted || generation !== sessionGeneration)
throw error