Skip to content

fix: write JSON in the repository's own format - #169

Merged
unional merged 1 commit into
mainfrom
up-164-json-format
Oct 11, 2026
Merged

unional merged 1 commit into
mainfrom
up-164-json-format

Conversation

@unional

@unional unional commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Refs #164 (item 4)

What

plugin build, plugin version and publish sync-version used to write every JSON file with JSON.stringify(value, null, indent). That expanded every array and always added a trailing newline, so a repository formatted by biome or prettier failed biome ci after each build or sync. They now write through one serializer, formatJson in src/json.ts, which:

  • keeps the existing file's indentation, line ending (LF/CRLF), and trailing newline, or lack of one
  • copies the original text of every value left unchanged, so an array the formatter collapsed onto one line stays there; only a changed value is laid out fresh
  • for a new file, or one with no indentation to read (single line), takes the indentation .editorconfig sets for that path (new src/editorconfig/), then the previous default: the canonical manifest's indentation for derived files, a tab for authored files
  • reuses no text from a file that isn't strict JSON (comments, trailing commas)

The writers covered: vendor manifests, derived hooks and mcp files, the Copilot namespace hooks file, refreshed catalogs, the plugin.json/package.json writes shared by plugin version and sync-version, and plugin init's plugin.json and package.json writes (including the changesets version script wiring from #168).

Spec

  • plugin/build: a new "Writes keep the repository's JSON format" use case and an "Output format" section in build.feature
  • plugin/init: one sentence in the npm use case
  • plugin/version: a rationale paragraph and two scenarios, with matching edge-table rows and CLI tests

Notes

This repo's biome.json excludes the derived *-plugin/plugin.json files because the old writer and the formatter kept flipping their array wrapping. That exclusion can probably go once this lands. I left it alone to keep this PR to item 4.

🤖 Generated with Claude Code

@changeset-bot

changeset-bot Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 32d8ec6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
universal-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@unional
unional force-pushed the up-164-json-format branch 6 times, most recently from 0427f42 to 055dc48 Compare October 11, 2026 08:50
plugin build, plugin version and publish sync-version now keep the
existing file's indentation, line ending and trailing newline, and copy
the original text of every value they leave unchanged, so a formatter's
collapsed arrays survive a rebuild or sync. A new file, or one with no
indentation to read, takes the indentation .editorconfig sets for it.

Refs #164 (item 4)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@unional
unional force-pushed the up-164-json-format branch from 055dc48 to 32d8ec6 Compare October 11, 2026 08:52
@unional
unional merged commit d5e6c0d into main Oct 11, 2026
6 checks passed
@unional
unional deleted the up-164-json-format branch October 11, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant