Skip to content

chore: add prettier config and enforce formatting in CI - #31

Closed
Bilb wants to merge 1 commit into
mainfrom
chore/prettier
Closed

chore: add prettier config and enforce formatting in CI#31
Bilb wants to merge 1 commit into
mainfrom
chore/prettier

Conversation

@Bilb

@Bilb Bilb commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Why

biome.json only includes **/*.ts and **/*.tsx, so json, css, md, yaml and js were formatted by nothing. And the Lint workflow ran biome lint, which checks lint rules only — formatting was never enforced anywhere.

This also fixes a real editor problem: with no .prettierrc in the repo, anyone whose editor formats on save with the Prettier extension gets Prettier's defaults, which disagree with biome.json in three places — printWidth 80 vs 100, trailingComma all vs es5, and embedded-CSS reformatting inside styled.* templates. On pages/pro.tsx that was a 345-line diff on every save.

Config

Prettier is pinned to match biome.json rather than compete with it:

{
  "singleQuote": true,
  "printWidth": 100,
  "trailingComma": "es5",
  "embeddedLanguageFormatting": "off"
}

Verified: with these options, prettier and biome format produce byte-identical output on all 109 ts/tsx files. The two tools cannot drift apart on the code they both cover.

.prettierignore excludes the lib/app_localization submodule, the generated contentful/export.json, and locales/ (Crowdin exports — they only differ by a missing trailing newline, and formatting them would fail CI on every sync).

Enforcement

package.json:

script command
lint biome lint && prettier --check .
lint:fix biome lint --write && prettier --write .
format prettier --write .
format:check prettier --check .

The workflow runs the two tools as separate steps with if: always() on the format check, rather than a single pnpm run lint. This is deliberate — see below.

Note: this PR will show a red Lint step

biome lint already fails on main with 12 errors, and has since the workflow was added — run 33366786839 failed on the merge of #30, and the PR that introduced it failed too. The gate has never passed.

Those errors are pre-existing and unrelated to formatting (noExplicitAny across services/, noNonNullAssertion, noDangerouslySetInnerHtml, noExcessiveCognitiveComplexity, unreachable code in lib/proBackend.ts). They involve real code decisions, so I left them for a separate PR.

This is exactly why the workflow uses two steps: with a single biome lint && prettier --check ., the always-failing Biome step would short-circuit and the Prettier check would silently never run. Split, the Check formatting step passes while the Biome step stays red for the pre-existing reasons.

Diff

Formatting-only, no semantic changes. next.config.js is the bulk of it (quote normalisation + arrow-body wrapping); pages/[slug].tsx is a missing semicolon that Biome also flagged. Confirmed next.config.js, tailwind.config.js, postcss.config.js still require() to the same shape and tsc --showConfig still resolves 109 files.

Biome's formatter only covers ts/tsx, so json, css, md, yaml and js were
formatted by nothing, and no CI step enforced formatting at all.

Prettier's options are pinned to match biome.json rather than compete with
it: printWidth 100, trailingComma es5 and embeddedLanguageFormatting off
produce byte-identical output to `biome format` on all 109 ts/tsx files.

The workflow runs biome and prettier as separate steps so that a failure in
one does not mask the other.
@Bilb

Bilb commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded — Biome 2.1.2 formats JSON and CSS natively, so broadening its includes covers 121 of the 124 relevant files. Adding Prettier bought only README.md and two YAML files, at the cost of a second formatter config to keep in lockstep. Redoing this as a Biome-only change.

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