From b9dc323734d0fa6d45054ca6d8686af2467773f8 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Wed, 23 Apr 2025 16:03:30 +0200 Subject: [PATCH] chore: enable @typescript-eslint/no-floating-promises rule (#260) --- eslint.config.mjs | 4 ++++ src/program.ts | 2 +- tests/fixtures.ts | 2 +- tests/network.spec.ts | 4 ++-- tsconfig.all.json | 4 ++++ 5 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 tsconfig.all.json diff --git a/eslint.config.mjs b/eslint.config.mjs index abedf47..3ab4df5 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -33,6 +33,7 @@ const plugins = { }; export const baseRules = { + "@typescript-eslint/no-floating-promises": "error", "@typescript-eslint/no-unused-vars": [ 2, { args: "none", caughtErrors: "none" }, @@ -184,6 +185,9 @@ const languageOptions = { parser: tsParser, ecmaVersion: 9, sourceType: "module", + parserOptions: { + project: path.join(fileURLToPath(import.meta.url), "..", "tsconfig.all.json"), + } }; export default [ diff --git a/src/program.ts b/src/program.ts index f8a3870..17e074a 100644 --- a/src/program.ts +++ b/src/program.ts @@ -74,7 +74,7 @@ function setupExitWatchdog(serverList: ServerList) { program.parse(process.argv); -async function startSSEServer(port: number, serverList: ServerList) { +function startSSEServer(port: number, serverList: ServerList) { const sessions = new Map(); const httpServer = http.createServer(async (req, res) => { if (req.method === 'POST') { diff --git a/tests/fixtures.ts b/tests/fixtures.ts index 5fd4c46..43b8d9b 100644 --- a/tests/fixtures.ts +++ b/tests/fixtures.ts @@ -53,7 +53,7 @@ export const test = baseTest.extend({ const userDataDir = testInfo.outputPath('user-data-dir'); let client: StdioClientTransport | undefined; - use(async options => { + await use(async options => { const args = ['--user-data-dir', userDataDir]; if (mcpHeadless) args.push('--headless'); diff --git a/tests/network.spec.ts b/tests/network.spec.ts index b202903..45c3280 100644 --- a/tests/network.spec.ts +++ b/tests/network.spec.ts @@ -42,8 +42,8 @@ test('browser_network_requests', async ({ client, server }) => { }, }); - expect.poll(() => client.callTool({ + await expect.poll(() => client.callTool({ name: 'browser_network_requests', arguments: {}, - })).toHaveTextContent(`[GET] http://localhost:8907/json => [200] OK`); + })).toHaveTextContent(`[GET] http://localhost:${server.PORT}/json => [200] OK`); }); diff --git a/tsconfig.all.json b/tsconfig.all.json new file mode 100644 index 0000000..2e60f02 --- /dev/null +++ b/tsconfig.all.json @@ -0,0 +1,4 @@ +{ + "extends": "./tsconfig.json", + "include": ["**/*.ts", "**/*.js"], +}