chore: add prettier config and enforce formatting in CI - #31
Closed
Bilb wants to merge 1 commit into
Closed
Conversation
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.
Collaborator
Author
|
Superseded — Biome 2.1.2 formats JSON and CSS natively, so broadening its |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
biome.jsononly includes**/*.tsand**/*.tsx, sojson,css,md,yamlandjswere formatted by nothing. And theLintworkflow ranbiome lint, which checks lint rules only — formatting was never enforced anywhere.This also fixes a real editor problem: with no
.prettierrcin the repo, anyone whose editor formats on save with the Prettier extension gets Prettier's defaults, which disagree withbiome.jsonin three places —printWidth80 vs 100,trailingCommaallvses5, and embedded-CSS reformatting insidestyled.*templates. Onpages/pro.tsxthat was a 345-line diff on every save.Config
Prettier is pinned to match
biome.jsonrather than compete with it:{ "singleQuote": true, "printWidth": 100, "trailingComma": "es5", "embeddedLanguageFormatting": "off" }Verified: with these options,
prettierandbiome formatproduce byte-identical output on all 109 ts/tsx files. The two tools cannot drift apart on the code they both cover..prettierignoreexcludes thelib/app_localizationsubmodule, the generatedcontentful/export.json, andlocales/(Crowdin exports — they only differ by a missing trailing newline, and formatting them would fail CI on every sync).Enforcement
package.json:lintbiome lint && prettier --check .lint:fixbiome lint --write && prettier --write .formatprettier --write .format:checkprettier --check .The workflow runs the two tools as separate steps with
if: always()on the format check, rather than a singlepnpm run lint. This is deliberate — see below.Note: this PR will show a red
Lintstepbiome lintalready fails onmainwith 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 (
noExplicitAnyacrossservices/,noNonNullAssertion,noDangerouslySetInnerHtml,noExcessiveCognitiveComplexity, unreachable code inlib/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, theCheck formattingstep passes while the Biome step stays red for the pre-existing reasons.Diff
Formatting-only, no semantic changes.
next.config.jsis the bulk of it (quote normalisation + arrow-body wrapping);pages/[slug].tsxis a missing semicolon that Biome also flagged. Confirmednext.config.js,tailwind.config.js,postcss.config.jsstillrequire()to the same shape andtsc --showConfigstill resolves 109 files.