chore(lint): enable stricter oxlint rules

This commit is contained in:
Peter Steinberger
2026-05-31 18:43:54 +01:00
parent cb569f6ad9
commit 304e2c83c0
615 changed files with 3603 additions and 3701 deletions

View File

@@ -168,14 +168,14 @@ describe("parseFeishuMessageEvent mentionedBot", () => {
});
it("returns mentionedBot=true for post message with at (no top-level mentions)", () => {
const BOT_OPEN_ID = "ou_bot_123";
const BOT_OPEN_IDLocal = "ou_bot_123";
const event = makePostEvent({
content: [
[{ tag: "at", user_id: BOT_OPEN_ID, user_name: "claw" }],
[{ tag: "at", user_id: BOT_OPEN_IDLocal, user_name: "claw" }],
[{ tag: "text", text: "What does this document say" }],
],
});
const ctx = parseFeishuMessageEvent(event, BOT_OPEN_ID);
const ctx = parseFeishuMessageEvent(event, BOT_OPEN_IDLocal);
expect(ctx.mentionedBot).toBe(true);
});

View File

@@ -162,13 +162,6 @@ function buildDefaultResolveRoute(): ResolvedAgentRoute {
matchedBy: "default",
};
}
function createUnboundConfiguredRoute(
route: NonNullable<ConfiguredBindingRoute>["route"],
): ConfiguredBindingRoute {
return { bindingResolution: null, route };
}
function createFeishuBotRuntime(overrides: DeepPartial<PluginRuntime> = {}): PluginRuntime {
return {
channel: {

View File

@@ -808,10 +808,10 @@ export async function handleFeishuMessage(params: {
if (!isGroup && route.matchedBy === "default") {
const dynamicCfg = feishuCfg?.dynamicAgentCreation as DynamicAgentCreationConfig | undefined;
if (dynamicCfg?.enabled) {
const runtime = getFeishuRuntime();
const runtimeLocal = getFeishuRuntime();
const result = await maybeCreateDynamicAgent({
cfg,
runtime,
runtime: runtimeLocal,
senderOpenId: ctx.senderOpenId,
dynamicCfg,
configWritesAllowed: resolveChannelConfigWrites({
@@ -1387,22 +1387,22 @@ export async function handleFeishuMessage(params: {
.map((id) => (id ? normalizeFeishuAllowEntry(id) : ""))
.find((recipient) => recipient === pinnedMainDmOwner)
: undefined;
const buildFeishuInboundLastRouteUpdate = (params: {
const buildFeishuInboundLastRouteUpdate = (paramsLocal: {
accountId: string;
sessionKey: string;
}) => {
const inboundLastRouteSessionKey =
params.sessionKey === route.sessionKey
paramsLocal.sessionKey === route.sessionKey
? resolveInboundLastRouteSessionKey({
route,
sessionKey: params.sessionKey,
sessionKey: paramsLocal.sessionKey,
})
: params.sessionKey;
: paramsLocal.sessionKey;
return {
sessionKey: inboundLastRouteSessionKey,
channel: "feishu" as const,
to: feishuTo,
accountId: params.accountId,
accountId: paramsLocal.accountId,
...(lastRouteThreadId ? { threadId: lastRouteThreadId } : {}),
mainDmOwnerPin:
!isGroup && inboundLastRouteSessionKey === route.mainSessionKey && pinnedMainDmOwner

View File

@@ -279,7 +279,7 @@ describe("feishuPlugin actions", () => {
});
it("honors the selected Feishu account during discovery", () => {
const cfg = {
const cfgLocal = {
channels: {
feishu: {
enabled: true,
@@ -302,7 +302,7 @@ describe("feishuPlugin actions", () => {
},
} as OpenClawConfig;
expect(getDescribedActions(cfg, "default")).toEqual([
expect(getDescribedActions(cfgLocal, "default")).toEqual([
"send",
"read",
"edit",
@@ -314,7 +314,7 @@ describe("feishuPlugin actions", () => {
"channel-info",
"channel-list",
]);
expect(getDescribedActions(cfg, "work")).toEqual([
expect(getDescribedActions(cfgLocal, "work")).toEqual([
"send",
"read",
"edit",

View File

@@ -276,7 +276,7 @@ describe("feishu_doc image fetch hardening", () => {
const call = blockDescendantCreateMock.mock.calls[0]?.[0];
expect(call?.data.children_id).toEqual(["h1", "p1", "h2", "list1"]);
expect((call?.data.descendants as Array<{ block_id: string }>).map((b) => b.block_id)).toEqual([
expect((call!.data.descendants as Array<{ block_id: string }>).map((b) => b.block_id)).toEqual([
"h1",
"p1",
"h2",

View File

@@ -28,8 +28,6 @@ const {
sendMessageFeishuMock,
withReplyDispatcherMock,
} = getFeishuLifecycleTestMocks();
let handlers: Record<string, (data: unknown) => Promise<void>> = {};
let lastRuntime = createRuntimeEnv();
const originalStateDir = process.env.OPENCLAW_STATE_DIR;
const { cfg: lifecycleConfig, account: lifecycleAccount } = createFeishuLifecycleFixture({
@@ -62,9 +60,7 @@ async function setupLifecycleMonitor() {
lastRuntime = createRuntimeEnv();
return setupFeishuLifecycleHandler({
createEventDispatcherMock,
onRegister: (registered) => {
handlers = registered;
},
onRegister: () => {},
runtime: lastRuntime,
cfg: lifecycleConfig,
account: lifecycleAccount,
@@ -77,7 +73,6 @@ describe("Feishu ACP-init failure lifecycle", () => {
beforeEach(() => {
vi.useRealTimers();
resetFeishuLifecycleTestMocks();
handlers = {};
lastRuntime = createRuntimeEnv();
setFeishuLifecycleStateDir("openclaw-feishu-acp-failure");

View File

@@ -31,8 +31,6 @@ const {
touchBindingMock,
withReplyDispatcherMock,
} = getFeishuLifecycleTestMocks();
let handlers: Record<string, (data: unknown) => Promise<void>> = {};
let lastRuntime = createRuntimeEnv();
const originalStateDir = process.env.OPENCLAW_STATE_DIR;
const lifecycleConfig = createFeishuLifecycleConfig({
@@ -77,9 +75,7 @@ async function setupLifecycleMonitor() {
lastRuntime = createRuntimeEnv();
return setupFeishuLifecycleHandler({
createEventDispatcherMock,
onRegister: (registered) => {
handlers = registered;
},
onRegister: () => {},
runtime: lastRuntime,
cfg: lifecycleConfig,
account: lifecycleAccount,
@@ -92,7 +88,6 @@ describe("Feishu bot-menu lifecycle", () => {
beforeEach(() => {
vi.useRealTimers();
resetFeishuLifecycleTestMocks();
handlers = {};
lastRuntime = createRuntimeEnv();
setFeishuLifecycleStateDir("openclaw-feishu-bot-menu");

View File

@@ -33,8 +33,6 @@ const {
touchBindingMock,
withReplyDispatcherMock,
} = getFeishuLifecycleTestMocks();
let handlers: Record<string, (data: unknown) => Promise<void>> = {};
let lastRuntime = createRuntimeEnv();
const originalStateDir = process.env.OPENCLAW_STATE_DIR;
const lifecycleConfig = createFeishuLifecycleConfig({
@@ -104,9 +102,7 @@ async function setupLifecycleMonitor() {
lastRuntime = createRuntimeEnv();
return setupFeishuLifecycleHandler({
createEventDispatcherMock,
onRegister: (registered) => {
handlers = registered;
},
onRegister: () => {},
runtime: lastRuntime,
cfg: lifecycleConfig,
account: lifecycleAccount,
@@ -143,7 +139,6 @@ describe("Feishu card-action lifecycle", () => {
beforeEach(() => {
vi.useRealTimers();
resetFeishuLifecycleTestMocks();
handlers = {};
lastRuntime = createRuntimeEnv();
resetProcessedFeishuCardActionTokensForTests();
setFeishuLifecycleStateDir("openclaw-feishu-card-action");

View File

@@ -166,8 +166,8 @@ export function createFeishuMessageReceiveHandler({
recordProcessedMessage,
getBotOpenId = () => undefined,
getBotName = () => undefined,
resolveSequentialKey = ({ accountId, event }) =>
`feishu:${accountId}:${event.message.chat_id?.trim() || "unknown"}`,
resolveSequentialKey = ({ accountId: accountIdLocal, event }) =>
`feishu:${accountIdLocal}:${event.message.chat_id?.trim() || "unknown"}`,
}: FeishuMessageReceiveHandlerContext): (data: unknown) => Promise<void> {
const inboundDebounceMs = channelRuntime.debounce.resolveInboundDebounceMs({
cfg,

View File

@@ -440,27 +440,27 @@ export function createFeishuReplyDispatcher(params: CreateFeishuReplyDispatcherP
flushStreamingCardUpdate(buildCombinedStreamText(reasoningText, streamText));
};
const sendChunkedTextReply = async (params: {
const sendChunkedTextReply = async (paramsLocal: {
text: string;
useCard: boolean;
infoKind?: string;
sendChunk: (params: { chunk: string; isFirst: boolean }) => Promise<void>;
}) => {
const chunkSource = params.useCard
? params.text
: core.channel.text.convertMarkdownTables(params.text, tableMode);
const chunkSource = paramsLocal.useCard
? paramsLocal.text
: core.channel.text.convertMarkdownTables(paramsLocal.text, tableMode);
const chunks = resolveTextChunksWithFallback(
chunkSource,
core.channel.text.chunkTextWithMode(chunkSource, textChunkLimit, chunkMode),
);
for (const [index, chunk] of chunks.entries()) {
await params.sendChunk({
await paramsLocal.sendChunk({
chunk,
isFirst: index === 0,
});
}
if (params.infoKind === "final") {
deliveredFinalTexts.add(params.text);
if (paramsLocal.infoKind === "final") {
deliveredFinalTexts.add(paramsLocal.text);
}
};
@@ -744,7 +744,7 @@ export function createFeishuReplyDispatcher(params: CreateFeishuReplyDispatcherP
if (!isChannelProgressDraftWorkToolName(payload.name)) {
return;
}
const statusLine = formatChannelProgressDraftLineForEntry(
const statusLineLocal = formatChannelProgressDraftLineForEntry(
account.config,
{
event: "tool",
@@ -756,8 +756,8 @@ export function createFeishuReplyDispatcher(params: CreateFeishuReplyDispatcherP
detailMode: payload.detailMode,
},
);
if (statusLine) {
updateStreamingStatusLine(statusLine);
if (statusLineLocal) {
updateStreamingStatusLine(statusLineLocal);
}
}
: undefined,

View File

@@ -163,7 +163,7 @@ export function createFeishuThreadBindingManager(params: {
if (!normalizedConversationId || !normalizedTargetSessionKey) {
return null;
}
const existing = getState().bindingsByAccountConversation.get(
const existingLocal = getState().bindingsByAccountConversation.get(
resolveBindingKey({ accountId, conversationId: normalizedConversationId }),
);
const now = Date.now();
@@ -171,29 +171,29 @@ export function createFeishuThreadBindingManager(params: {
accountId,
conversationId: normalizedConversationId,
parentConversationId:
normalizeOptionalString(parentConversationId) ?? existing?.parentConversationId,
normalizeOptionalString(parentConversationId) ?? existingLocal?.parentConversationId,
deliveryTo:
typeof metadata?.deliveryTo === "string" && metadata.deliveryTo.trim()
? metadata.deliveryTo.trim()
: existing?.deliveryTo,
: existingLocal?.deliveryTo,
deliveryThreadId:
typeof metadata?.deliveryThreadId === "string" && metadata.deliveryThreadId.trim()
? metadata.deliveryThreadId.trim()
: existing?.deliveryThreadId,
: existingLocal?.deliveryThreadId,
targetKind: toFeishuTargetKind(targetKind),
targetSessionKey: normalizedTargetSessionKey,
agentId:
typeof metadata?.agentId === "string" && metadata.agentId.trim()
? metadata.agentId.trim()
: (existing?.agentId ?? resolveAgentIdFromSessionKey(normalizedTargetSessionKey)),
: (existingLocal?.agentId ?? resolveAgentIdFromSessionKey(normalizedTargetSessionKey)),
label:
typeof metadata?.label === "string" && metadata.label.trim()
? metadata.label.trim()
: existing?.label,
: existingLocal?.label,
boundBy:
typeof metadata?.boundBy === "string" && metadata.boundBy.trim()
? metadata.boundBy.trim()
: existing?.boundBy,
: existingLocal?.boundBy,
boundAt: now,
lastActivityAt: now,
};

View File

@@ -83,12 +83,14 @@ function lastClientAppId(): string | undefined {
describe("feishu tool account routing", () => {
beforeAll(async () => {
({ registerFeishuBitableTools, registerFeishuDriveTools, registerFeishuPermTools } =
await import("./bitable.js").then(async ({ registerFeishuBitableTools }) => ({
registerFeishuBitableTools,
...(await import("./drive.js")),
...(await import("./perm.js")),
...(await import("./wiki.js")),
})));
await import("./bitable.js").then(
async ({ registerFeishuBitableTools: registerFeishuBitableToolsLocal }) => ({
registerFeishuBitableTools: registerFeishuBitableToolsLocal,
...(await import("./drive.js")),
...(await import("./perm.js")),
...(await import("./wiki.js")),
}),
));
({ registerFeishuWikiTools } = await import("./wiki.js"));
});