From d249cb4ae90f24529783ec7d0df30d7119e23baa Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Tue, 15 Jul 2025 20:59:10 +0200 Subject: [PATCH] eslint magic --- eslint.config.js | 24 ++++++++++---------- src/outline.ts | 6 +---- src/tools/collection.ts | 16 +++---------- src/tools/document.ts | 50 +++++++++-------------------------------- 4 files changed, 26 insertions(+), 70 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 21b49e4..989de07 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -8,10 +8,19 @@ import tsPlugin from "typescript-eslint"; /** @type {import('eslint').Linter.Config[]} */ export default [ + { + ignores: [ + "node_modules/**", + "dist/**", + "build/**", + "coverage/**", + "*.min.js", + "src/gen/**", // Exclude generated API files + ], + }, securityPlugin.configs.recommended, { - files: ["**/*.ts"], - ignores: ["src/gen/**"], + files: ["src/**/*.ts"], }, { languageOptions: { globals: globals.node }, @@ -60,16 +69,7 @@ export default [ "import/order": [ "error", { - groups: [ - "builtin", - "external", - "internal", - "parent", - "sibling", - "index", - "object", - "type", - ], + groups: ["builtin", "external", "internal", "parent", "sibling", "index", "object", "type"], "newlines-between": "always", alphabetize: { order: "asc", diff --git a/src/outline.ts b/src/outline.ts index 6aaf857..a14ef89 100644 --- a/src/outline.ts +++ b/src/outline.ts @@ -7,11 +7,7 @@ import { registerDocumentTools } from "./tools/document"; import type { Logger } from "pino"; -const createOutlineClient = ( - baseUrl: string, - apiKey: string, - logger: Logger -) => { +const createOutlineClient = (baseUrl: string, apiKey: string, logger: Logger) => { const config = new Configuration({ basePath: baseUrl, accessToken: () => Promise.resolve(apiKey), diff --git a/src/tools/collection.ts b/src/tools/collection.ts index ea1b16d..27e8f59 100644 --- a/src/tools/collection.ts +++ b/src/tools/collection.ts @@ -6,11 +6,7 @@ import type { ToolsFactory } from "./toolsFactory"; import type { CollectionsApi } from "../gen/api/outline"; import type { Logger } from "pino"; -export const registerCollectionTools: ToolsFactory = ( - server: McpServer, - client: CollectionsApi, - logger: Logger -) => { +export const registerCollectionTools: ToolsFactory = (server: McpServer, client: CollectionsApi, logger: Logger) => { server.registerTool( "collections_list", { @@ -21,15 +17,9 @@ export const registerCollectionTools: ToolsFactory = ( async () => { try { const response = await client.collectionsList(); - return handleSuccess( - response, - logger.child({ tool: "collections_list" }) - ); + return handleSuccess(response, logger.child({ tool: "collections_list" })); } catch (err) { - const error = handleError( - err, - logger.child({ tool: "collections_list" }) - ); + const error = handleError(err, logger.child({ tool: "collections_list" })); logger.error(error); return error; } diff --git a/src/tools/document.ts b/src/tools/document.ts index de4ba1f..8c1e04c 100644 --- a/src/tools/document.ts +++ b/src/tools/document.ts @@ -1,45 +1,22 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { z } from "zod"; -import type { Logger } from "pino"; -import { - backlinkDocumentId, - collectionId, - direction, - limit, - offset, - parentDocumentId, - sort, - userId, -} from "./common"; +import { backlinkDocumentId, collectionId, direction, limit, offset, parentDocumentId, sort, userId } from "./common"; import { handleSuccess, handleError } from "./utils"; + import type { ToolsFactory } from "./toolsFactory"; import type { DocumentsApi } from "../gen/api/outline"; +import type { Logger } from "pino"; -export const registerDocumentTools: ToolsFactory = ( - server: McpServer, - client: DocumentsApi, - logger: Logger -): void => { +export const registerDocumentTools: ToolsFactory = (server: McpServer, client: DocumentsApi, logger: Logger): void => { server.registerTool( "documents_info", { title: "Get Document Info", - description: - "Retrieve a document by its UUID, urlId, or shareId. At least one of these parameters must be provided.", + description: "Retrieve a document by its UUID, urlId, or shareId. At least one of these parameters must be provided.", inputSchema: { - id: z - .string() - .optional() - .describe( - "Unique identifier for the document. Either the UUID or the urlId is acceptable." - ), - shareId: z - .string() - .optional() - .describe( - "Unique identifier for a document share, a shareId may be used in place of a document UUID" - ), + id: z.string().optional().describe("Unique identifier for the document. Either the UUID or the urlId is acceptable."), + shareId: z.string().optional().describe("Unique identifier for a document share, a shareId may be used in place of a document UUID"), }, }, async (args) => { @@ -50,10 +27,7 @@ export const registerDocumentTools: ToolsFactory = ( shareId: args?.shareId, }, }); - return handleSuccess( - response, - logger.child({ tool: "documents_info" }) - ); + return handleSuccess(response, logger.child({ tool: "documents_info" })); } catch (error) { return handleError(error, logger.child({ tool: "documents_info" })); } @@ -76,8 +50,7 @@ export const registerDocumentTools: ToolsFactory = ( "documents_list", { title: "List Documents", - description: - "This method will list all published documents and draft documents belonging to the current user.", + description: "This method will list all published documents and draft documents belonging to the current user.", inputSchema: documentsListSchema.shape, }, async (args) => { @@ -86,10 +59,7 @@ export const registerDocumentTools: ToolsFactory = ( const response = await client.documentsList({ documentsListRequest: validatedArgs, }); - return handleSuccess( - response, - logger.child({ tool: "documents_list" }) - ); + return handleSuccess(response, logger.child({ tool: "documents_list" })); } catch (error) { return handleError(error, logger.child({ tool: "documents_list" })); }