ci: format fetch-spec-types output with prettier#1782
ci: format fetch-spec-types output with prettier#1782felixweinberger wants to merge 2 commits intomainfrom
Conversation
The nightly update-spec-types workflow is failing because lefthook's pre-push hook (added in #1003) runs `pnpm run lint:all`, which rejects the freshly-fetched spec.types.ts for not matching prettier style. Format the output via prettier's Node API using the project config before writing it to disk. This also reduces nightly PR diffs to only semantic changes, not formatting noise.
|
@modelcontextprotocol/client
@modelcontextprotocol/server
@modelcontextprotocol/express
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
There was a problem hiding this comment.
LGTM, straightforward fix to format fetched spec types with prettier before writing.
Extended reasoning...
Overview
This PR modifies a single CI script (scripts/fetch-spec-types.ts) to run prettier on the fetched spec types before writing them to disk. The change adds 3 lines of prettier API calls (resolveConfig, format) and removes the direct writeFileSync of unformatted content. This fixes the nightly update-spec-types workflow which has been failing since lefthook pre-push hooks were added.
Security risks
None. This is a build/CI script that formats code before writing it locally. No user input, no network-facing code, no auth changes.
Level of scrutiny
Low scrutiny appropriate. This is a small, mechanical change to a CI helper script. The prettier API usage is standard and idiomatic (resolveConfig + format with filepath for parser inference). The script is not production code — it runs during development/CI to sync upstream spec types.
Other factors
- No bugs were found by the automated analysis.
- No outstanding reviewer comments to address.
- No changeset needed since this is a CI-only change with no version bump implications.
- The code correctly uses spread to merge the resolved config with the filepath option, which is the standard prettier Node API pattern.
There was a problem hiding this comment.
LGTM — straightforward fix to format fetched spec types with prettier so the nightly CI workflow stops failing on lint.
Extended reasoning...
Overview
This PR modifies a single CI script (scripts/fetch-spec-types.ts) to add prettier formatting before writing the fetched spec types to disk. The change is 3 lines of new code: importing prettier, resolving the project config, and formatting the content before writing. This fixes the nightly update-spec-types workflow which has been failing because lefthook runs lint checks on push.
Security risks
None. This is a build/CI script that runs locally or in CI, not production code. The prettier API usage is standard (resolveConfig + format) with no user-controlled inputs beyond what was already there.
Level of scrutiny
Low scrutiny appropriate. This is a small, mechanical change to a CI helper script. The implementation follows the standard prettier Node API pattern and the motivation is clearly explained with a concrete CI failure example.
Other factors
- No outstanding reviewer comments to address
- No bugs found by the bug hunting system
- No changeset needed (CI-only change, no version bump)
- The PR description helpfully notes a downstream effect (JSONObject vs object reversion) which shows good communication but is not a concern with this PR itself
- prettier is already a devDependency in the project
Formats the output of
scripts/fetch-spec-types.tswith prettier before writing to disk, so the nightlyupdate-spec-typesworkflow produces lint-clean output.Motivation and Context
The nightly
update-spec-typesworkflow has been failing since lefthook was added in #1003. The pre-push hook runspnpm run lint:all, which rejects the freshly-fetchedspec.types.tsbecause it uses the upstream spec repo's formatting (double quotes, different line wrapping) rather than this repo's prettier config.Last night's run (March 26) failed with:
This also means nightly PRs will now show only semantic diffs instead of ~100KB of formatting noise.
How Has This Been Tested?
Ran
pnpm run fetch:spec-typeslocally — output now passespnpm --filter @modelcontextprotocol/core lint. The resulting diff against main is 6 lines (commit SHA header +@nullable+@maxItems 100annotations) instead of 118KB.Breaking Changes
None.
Types of changes
Checklist
Additional context
Uses prettier's Node API (
resolveConfig+format) to pick up.prettierrc.jsonautomatically, so any future config changes apply without touching this script.Heads up: once this lands and the nightly runs, the resulting PR will revert
extensions?: { [key: string]: JSONObject }back to{ [key: string]: object }inClientCapabilities/ServerCapabilities— theJSONObjectvariant was a manual edit in #1630 that diverges from the upstream spec. IfJSONObjectis the intended type, it should be changed inschema/draft/schema.tsupstream.