mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 21:41:24 +00:00
fix(feishu): add targeted eslint-disable comments for SDK integration
Add line-specific eslint-disable-next-line comments for SDK type casts and union type issues, rather than file-level disables. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,13 +19,19 @@ function json(data: unknown) {
|
||||
async function getRootFolderToken(client: Lark.Client): Promise<string> {
|
||||
// Use generic HTTP client to call the root folder meta API
|
||||
// as it's not directly exposed in the SDK
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- accessing internal SDK property
|
||||
const domain = (client as any).domain ?? "https://open.feishu.cn";
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- accessing internal SDK property
|
||||
const res = (await (client as any).httpInstance.get(
|
||||
`${domain}/open-apis/drive/explorer/v2/root_folder/meta`,
|
||||
)) as { code: number; msg?: string; data?: { token?: string } };
|
||||
if (res.code !== 0) throw new Error(res.msg ?? "Failed to get root folder");
|
||||
if (res.code !== 0) {
|
||||
throw new Error(res.msg ?? "Failed to get root folder");
|
||||
}
|
||||
const token = res.data?.token;
|
||||
if (!token) throw new Error("Root folder token not found");
|
||||
if (!token) {
|
||||
throw new Error("Root folder token not found");
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
@@ -35,7 +41,9 @@ async function listFolder(client: Lark.Client, folderToken?: string) {
|
||||
const res = await client.drive.file.list({
|
||||
params: validFolderToken ? { folder_token: validFolderToken } : {},
|
||||
});
|
||||
if (res.code !== 0) throw new Error(res.msg);
|
||||
if (res.code !== 0) {
|
||||
throw new Error(res.msg);
|
||||
}
|
||||
|
||||
return {
|
||||
files:
|
||||
@@ -57,7 +65,9 @@ async function getFileInfo(client: Lark.Client, fileToken: string, folderToken?:
|
||||
const res = await client.drive.file.list({
|
||||
params: folderToken ? { folder_token: folderToken } : {},
|
||||
});
|
||||
if (res.code !== 0) throw new Error(res.msg);
|
||||
if (res.code !== 0) {
|
||||
throw new Error(res.msg);
|
||||
}
|
||||
|
||||
const file = res.data?.files?.find((f) => f.token === fileToken);
|
||||
if (!file) {
|
||||
@@ -94,7 +104,9 @@ async function createFolder(client: Lark.Client, name: string, folderToken?: str
|
||||
folder_token: effectiveToken,
|
||||
},
|
||||
});
|
||||
if (res.code !== 0) throw new Error(res.msg);
|
||||
if (res.code !== 0) {
|
||||
throw new Error(res.msg);
|
||||
}
|
||||
|
||||
return {
|
||||
token: res.data?.token,
|
||||
@@ -118,7 +130,9 @@ async function moveFile(client: Lark.Client, fileToken: string, type: string, fo
|
||||
folder_token: folderToken,
|
||||
},
|
||||
});
|
||||
if (res.code !== 0) throw new Error(res.msg);
|
||||
if (res.code !== 0) {
|
||||
throw new Error(res.msg);
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
@@ -142,7 +156,9 @@ async function deleteFile(client: Lark.Client, fileToken: string, type: string)
|
||||
| "shortcut",
|
||||
},
|
||||
});
|
||||
if (res.code !== 0) throw new Error(res.msg);
|
||||
if (res.code !== 0) {
|
||||
throw new Error(res.msg);
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
@@ -190,6 +206,7 @@ export function registerFeishuDriveTools(api: OpenClawPluginApi) {
|
||||
case "delete":
|
||||
return json(await deleteFile(client, p.file_token, p.type));
|
||||
default:
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- exhaustive check fallback
|
||||
return json({ error: `Unknown action: ${(p as any).action}` });
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user