From 5c198f28488ca2a2c8015e4d748d8d2809bd9434 Mon Sep 17 00:00:00 2001 From: Maurice Date: Sat, 10 Oct 2026 20:49:22 +0200 Subject: [PATCH] build(server): lint:mcp-zod counts a z. call that a line break splits from its dot Prettier breaks a long schema into z on one line and .object( on the next, which the count read as nothing: formatting the tool files would have taken 134 hand-written fields out of the tally. Whitespace before the dot counts now. Four files already held such a split call, so their entries rise to what they really hold (atlas 23, doc-sync 1, help 4, transit 16). --- server/scripts/mcp-inline-zod-baseline.json | 7 ++++--- server/scripts/mcp-inline-zod.mjs | 4 +++- server/tests/unit/scripts/error-envelope-ratchets.test.ts | 6 ++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/server/scripts/mcp-inline-zod-baseline.json b/server/scripts/mcp-inline-zod-baseline.json index 7130307d1..5a9292b79 100644 --- a/server/scripts/mcp-inline-zod-baseline.json +++ b/server/scripts/mcp-inline-zod-baseline.json @@ -3,14 +3,15 @@ "src/nest/accommodations/accommodations.mcp.ts": 28, "src/nest/airports/airports.mcp.ts": 3, "src/nest/assignments/assignments.mcp.ts": 10, - "src/nest/atlas/atlas.mcp.ts": 22, + "src/nest/atlas/atlas.mcp.ts": 23, "src/nest/budget/budget.mcp.ts": 36, "src/nest/collab/collab.mcp.ts": 20, "src/nest/collections/collections.mcp.ts": 14, "src/nest/day-notes/day-notes.mcp.ts": 10, "src/nest/days/days.mcp.ts": 2, + "src/nest/doc-sync/doc-sync.mcp.ts": 1, "src/nest/files/files.mcp.ts": 4, - "src/nest/help/help.mcp.ts": 3, + "src/nest/help/help.mcp.ts": 4, "src/nest/integrations/airtrail.mcp.ts": 2, "src/nest/integrations/dawarich.mcp.ts": 13, "src/nest/journey/journey.mcp.ts": 66, @@ -30,7 +31,7 @@ "src/nest/share/share.mcp.ts": 7, "src/nest/tags/tags.mcp.ts": 4, "src/nest/todo/todo.mcp.ts": 14, - "src/nest/transit/transit.mcp.ts": 14, + "src/nest/transit/transit.mcp.ts": 16, "src/nest/trips/trips.mcp.ts": 24, "src/nest/vacay/vacay.mcp.ts": 25, "src/nest/weather/weather.mcp.ts": 8 diff --git a/server/scripts/mcp-inline-zod.mjs b/server/scripts/mcp-inline-zod.mjs index edbae4bb7..29a9373da 100644 --- a/server/scripts/mcp-inline-zod.mjs +++ b/server/scripts/mcp-inline-zod.mjs @@ -18,7 +18,9 @@ */ import { cliMain } from './lib/count-ratchet.mjs'; -const ZOD_CALL = /\bz\./g; +// Whitespace before the dot counts too: Prettier breaks a long chain into `z` +// on one line and `.object(` on the next. +const ZOD_CALL = /\bz\s*\./g; /** The inline zod calls in one file's text, comments included. */ export function countInlineZod(text) { diff --git a/server/tests/unit/scripts/error-envelope-ratchets.test.ts b/server/tests/unit/scripts/error-envelope-ratchets.test.ts index 966a8bd70..cdcfe0173 100644 --- a/server/tests/unit/scripts/error-envelope-ratchets.test.ts +++ b/server/tests/unit/scripts/error-envelope-ratchets.test.ts @@ -65,6 +65,12 @@ describe('the counters', () => { expect(countInlineZod(`${Z}object({ a: ${Z}string(), b: idSchema, c: fizz.x })`)).toBe(2); }); + it('ENV-RATCHET-001b: counts a z. call Prettier broke across lines', () => { + expect(countInlineZod(`const s = z + .object({ a: idSchema }) + .strict();`)).toBe(1); + }); + it('ENV-RATCHET-002: counts the result envelope and HTTP in a service, not a 2xx status', () => { expect( countServiceIdioms(`return { error: 'x', ${STATUS} };\nthrow ${HTTP}{}, 400);\nreturn { status: 200 };`),