Skip to content

Commit 58c4326

Browse files
committed
Fix ESLint errors in convertMessages test
- Use async fs.promises.writeFile instead of sync - Use optional chaining for toolMessage checks - Add eslint-disable for unavoidable any assignment
1 parent ce31610 commit 58c4326

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/utils/messages/convertMessages.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ describe("convertToModelMessages with tools", () => {
2020
0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
2121
]);
2222
const imgPath = path.join(tmpDir, "test.png");
23-
fs.writeFileSync(imgPath, png);
23+
await fs.promises.writeFile(imgPath, png);
2424

2525
// Create tool and execute
2626
const tool = createFileReadTool({ cwd: tmpDir, tempDir: tmpDir });
27+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
2728
const result = await tool.execute!(
2829
{ filePath: imgPath },
2930
{ toolCallId: "test", messages: [] }
@@ -56,7 +57,7 @@ describe("convertToModelMessages with tools", () => {
5657
const withoutTools = convertToModelMessages(messages);
5758
const toolMessage = withoutTools.find((m) => m.role === "tool");
5859
expect(toolMessage).toBeDefined();
59-
if (toolMessage && toolMessage.role === "tool") {
60+
if (toolMessage?.role === "tool") {
6061
const content = toolMessage.content[0];
6162
expect(content.type).toBe("tool-result");
6263
if (content.type === "tool-result") {
@@ -71,7 +72,7 @@ describe("convertToModelMessages with tools", () => {
7172
});
7273
const toolMessageWithTools = withTools.find((m) => m.role === "tool");
7374
expect(toolMessageWithTools).toBeDefined();
74-
if (toolMessageWithTools && toolMessageWithTools.role === "tool") {
75+
if (toolMessageWithTools?.role === "tool") {
7576
const content = toolMessageWithTools.content[0];
7677
expect(content.type).toBe("tool-result");
7778
if (content.type === "tool-result") {

0 commit comments

Comments
 (0)