Formatter and Linter style ownership in Biome's shared configuration
0 reputation · 30 May 2023, 18:55 UTC
0 reputation · 30 May 2023, 18:55 UTC
When adopting Biome incrementally, teams must decide whether a particular style concern should be managed by the formatter or the linter. The formatter is intended to own layout‑related rules, while the linter focuses on correctness, but some linter rules can still overlap with formatter output, creating potential conflicts during migration.
The goal is to establish a clear ownership boundary that prevents lint rules from fighting formatter output while preserving the ability to enforce correctness checks. Constraints include the formatter’s design intent, the possibility of rule overlap in edge cases, and the need to coordinate ignores, overrides, and per‑language settings in a single biome.json file.
Which criteria should guide assigning a style rule to the formatter versus the linter? How can conflicting lint rules be suppressed or adjusted without disabling necessary correctness checks? What verification approach ensures that formatter and linter outputs remain compatible throughout the transition?
32275 reputation · 31 May 2023, 04:10 UTC
Assign a rule to the formatter when it only controls layout — indentation, line width, wrapping, spacing, quotes, semicolons, trailing commas. Assign it to the linter when it requires semantic judgment — unused variables, suspicious patterns, accessibility, correctness, or anything needing AST context. If a rule rewrites code deterministically without changing meaning, it belongs to the formatter; if it flags a possible defect, it belongs to the linter. Never let both tools own the same construct.
When a lint rule fights formatter output, suppress narrowly, in this order of preference:
biome.json, not the whole category. Turning off an entire lint group to silence one stylistic conflict also silences real defect checks.biome-ignore comments for genuinely exceptional lines. Scattered suppression comments during migration become permanent noise.Keep biome.json as the single coordination point for formatter settings, linter rules, ignores, and per-language overrides — splitting ownership decisions across multiple files or editor configs is how drift starts.
{
"formatter": { "indentStyle": "space" },
"linter": {
"rules": {
"style": { "useConst": "error" },
"suspicious": { "noExplicitAny": "off" }
}
},
"overrides": [
{
"includes": ["legacy/**"],
"linter": { "rules": { "correctness": { "noUnusedVariables": "warn" } } }
}
]
}Rule names and schema shape are version-sensitive — confirm against your installed Biome release (biome --version) before committing changes.
biome check. Formatter output must not introduce lint failures.biome ci or biome check without --write) so the build fails if formatting triggers correctness rules.One caveat worth flagging: if you move enforcement from the linter to the formatter, make sure CI actually runs the formatter in check mode — otherwise you have silently weakened the gate.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.