接入 ESLint 并清理未使用代码

- 前后端接入 ESLint 10 扁平配置(typescript-eslint 类型感知检查 + react-hooks/react-refresh),新增 lint / lint:check / lint:fix 脚本并纳入 check 链路
- 清理全部 no-unused-vars 与 no-useless-assignment 警告,修复 floating promises、正则转义等问题
- 删除确认无引用的死代码(markKuaishouCloudBindUrlRefreshFailed、未使用 helper 等)
This commit is contained in:
yml2213
2026-08-16 18:04:55 +08:00
parent 5c7c3e14e3
commit 81ae04dae0
55 changed files with 3031 additions and 628 deletions
@@ -197,7 +197,7 @@ export async function syncAffiliateDashTaskStatus(
let resultMessage = task.result_message
let lastError = task.last_error
const nextFlow = mergeAffiliateDashOrder(flow, order, { syncedAt: now })
let nextIndustryVoucher = taskContext.kuaishouIndustryVoucher
const nextIndustryVoucher = taskContext.kuaishouIndustryVoucher
switch (order.orderStatus) {
case 'paid':
@@ -96,7 +96,7 @@ export async function selectCloudtentaclesSourceForFulfillment(
const ranked = []
let lastCapacityError: unknown = null
for (const [index, context] of contexts.entries()) {
let occupiedCount = 0
let occupiedCount
try {
// CT's VN list is the authoritative count; DB counters can lag after crashes/restarts.
const listed = await listVirtualNumbers({
@@ -78,7 +78,7 @@ export async function prepareKuaishouCloudBindResourceWithFallback(input: JsonOb
for (const vnKey of candidates) {
let vnId = 0
let vnPhone = ''
let vnPhone
const cooldownKey = `${sourceKey}|${vnKey}`
const cooldownUntil = appointQuotaCooldowns.get(cooldownKey) || 0
@@ -1,11 +1,8 @@
import { createTaskEvent } from '../../../repositories/task-event-repo.js'
import { updateTask } from '../../../repositories/task-repo.js'
import { probeCloudtentaclesBindUrl } from '../../platforms/cloudtentacles/virtual-number-service.js'
import { resolveCloudtentaclesConfig } from '../../platforms/cloudtentacles/helpers.js'
import { notifyKuaishouCloudBindUrlRefreshFailed } from '../../notification/domain-notifications.js'
import { createHttpError } from '../../../utils/http.js'
import { nowIso } from '../../../utils/time.js'
import { TASK_STATUS } from '../../../domain/task-status.js'
import {
isKuaishouCloudBindUrlFresh,
isKuaishouCloudBindingMutationFrozen,
@@ -14,8 +11,7 @@ import {
normalizeKuaishouCloudRoleInfo,
type JsonObject,
} from './domain.js'
import { resolvePersistedCloudtentaclesContextBySourceKeys } from './cloudtentacles-context.js'
import { normalizeActor, parseTaskContext } from './task-context.js'
import { parseTaskContext } from './task-context.js'
import { buildRoleStateFromCurrentInfo } from './role-state.js'
import { refreshKuaishouCloudTaskBindUrl } from './prepare-fulfillment.js'
import type { TaskRow } from '../../../types/repository/rows.js'
@@ -118,70 +114,3 @@ export async function probeKuaishouCloudTaskBindUrl(task: TaskRow, options: Json
probe,
}
}
/**
* @param {any} task
* @param {{ taskContext?: any, flow?: any, now?: string, actor?: any, error?: unknown }} [input]
*/
async function markKuaishouCloudBindUrlRefreshFailed(
task: TaskRow,
{ taskContext, flow, now, actor, error }: JsonObject = {},
) {
const errorMessage =
error instanceof Error ? error.message : String(error || '新绑定链接准备失败')
const nextContext = {
...taskContext,
kuaishouCloudFulfillment: {
...flow,
binding: {
...flow.binding,
prepareStatus: 'pending',
vnId: 0,
vnPhone: '',
bindUrl: '',
bindPreparedAt: null,
bindExpiresAt: null,
bindProbeAt: now,
bindProbeStatus: 'refresh_failed',
bindProbeMessage: errorMessage,
roleName: '',
roleId: '',
},
role: {
status: 'pending',
name: '',
rid: '',
refreshedAt: now,
errorMessage: '绑定链接已过期,旧号码已退还,新链接准备失败,请稍后刷新或联系客服处理',
rawInfo: null,
},
},
}
const updatedTask = await updateTask(task.id, {
task_status: TASK_STATUS.PENDING_BINDING_PREPARE,
role_id: '',
role_name: '',
last_error: `绑定链接过期,旧号码已退还,新链接准备失败:${errorMessage}`,
context_json: JSON.stringify(nextContext),
updated_at: now,
})
await createTaskEvent(
task.id,
'kuaishou_cloud_bind_url_refresh_failed',
{
source: 'system_refresh_expired_bind_url',
errorMessage,
actor,
},
now,
)
await notifyKuaishouCloudBindUrlRefreshFailed({
task: updatedTask,
errorMessage,
})
return updatedTask
}
@@ -188,7 +188,6 @@ export async function rebindKuaishouCloudTaskRole(task: TaskRow, options: JsonOb
now,
)
} catch (error) {
oldNumberBackStatus = 'failed'
oldNumberBackError = error instanceof Error ? error.message : String(error || '退号失败')
const wrapped = wrapCloudtentaclesOperationError(error, {
action: 'vn_back',
@@ -451,7 +450,7 @@ async function rebindByRefreshingExistingVnBindUrl(input: {
now,
} = input
let bindUrl = ''
let bindUrl
try {
const bindUrlResult = await getCloudtentaclesBindUrl({
...cloudContext,
@@ -84,7 +84,7 @@ export async function returnKuaishouCloudFulfillmentTask(task: TaskRow, options:
}
const ticketCode = String(flow.ticket.code || '').trim()
let consumeStatus = 'pending'
let consumeStatus
let consumeErrorMessage = ''
let consumedAt: string | null = null
let nextTaskStatus: TaskStatus = TASK_STATUS.COMPLETED