@immediately-run/prettier-config
v0.1.0
Published
The shared Prettier configuration for immediately.run's core repositories.
Readme
@immediately-run/prettier-config
The shared Prettier configuration for immediately.run's core repositories:
sandbox,
immediately-run-sdk,
immediately-run-site-main
and immediately-run-backend.
Why this package exists
Before it, exactly one of the four repos had Prettier at all, and that one had drifted 106 files from its own config with nothing able to catch it. The post-mortem found four independent causes, and this package is aimed at the two that a per-repo config cannot fix by itself:
- The formatter version floated.
prettier: ^2.6.2resolved to 2.8.8, which formatstypeof steps[number]as(typeof steps)[number]. A caret range on a formatter is a slow-motion reformat. The version is therefore a peer dependency pinned exactly here, so moving it is a deliberate release of this package rather than a side effect of someone runningnpm install. - Two styles coexisted in one tree.
trailingCommawas unset, so Prettier 2 used"es5"while contributors' editors — bundling Prettier 3 — used"all". Every setting is now explicit rather than defaulted, because a default is a value that changes when the tool does.
The remaining two causes were per-repo and are fixed in each repo: a format script
that could not fail (prettier --write with --check appended exits 0), and an
abandoned import-sort plugin that silently stripped inline type modifiers.
Use it
npm i -D @immediately-run/prettier-config prettierPoint at it from package.json — no .prettierrc file needed:
{
"prettier": "@immediately-run/prettier-config"
}Then give the repo a check that can actually fail, and wire it into CI:
{
"scripts": {
"format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json}\"",
"format:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx,json}\""
}
}
format:checkis the CI step — notformat -- --check. Appending--checkto a--writescript does not make it read-only: Prettier rewrites the tree and exits 0. That is precisely how the drift went unnoticed, so it is worth checking your CI runs the right one.
Each repo keeps its own .prettierignore — generated bundles, vendored artifacts and
test fixtures are per-repo facts, not shared style. One rule is shared, though:
anything generated at build time belongs in .prettierignore, or format:check
passes in CI (which runs before the generators) and fails locally (which runs after).
Changing the config
Any change here reformats four repositories, so treat it as a release:
- Change
index.json, bump the version, open a PR. The tests assert the settings that caused the original drift, so an accidental edit fails rather than propagates. - Merging to
mainpublishes only when the version is new, and only after theproductionenvironment approval — the deliberate release act is the version bump, not the merge (TESTING_AUTOMATION_SPECR-TA-1). The release job refuses to publish if no human approval is recorded on the run. - Land the resulting reformat in each consumer as its own commit, and add that
commit to the repo's
.git-blame-ignore-revssogit blameskips it.
Bumping Prettier itself
The peer pin makes this deliberate, and in one repo it is more than a chore:
sandbox's Prettier is also the product's formatter — src/services/authoring/
format.ts bundles prettier/standalone into the shipped authoring worker, which the
platform serves to users' apps through authoring:format. Prettier 3 made format()
async and moved the parsers to prettier/plugins/*, so a v3 bump rewrites a kernel
service. That is a product change with its own testing story, not a formatting chore.
Licence
MIT.
