#parser #linter #formatter


Biome's formatter shared infrastructure

4 releases (2 breaking)

new 0.3.1 Nov 26, 2023
0.1.0 Sep 28, 2023
0.0.2 Sep 28, 2023
0.0.1 Sep 27, 2023

#15 in #static-code-analysis

Download history 80/week @ 2023-09-24 50/week @ 2023-10-01 18/week @ 2023-10-08 13/week @ 2023-10-15 37/week @ 2023-10-22 21/week @ 2023-10-29 8/week @ 2023-11-05 14/week @ 2023-11-12 66/week @ 2023-11-19

111 downloads per month
Used in 3 crates


25K SLoC

Biome - Toolchain of the web

Discord chat CI cargo version


Biome's formatter implementation. Follow the documentation.


Infrastructure for code formatting

This module defines [FormatElement], an IR to format code documents and provides a mean to print such a document to a string. Objects that know how to format themselves implement the [Format] trait.

Formatting Traits

  • [Format]: Implemented by objects that can be formatted.
  • [FormatRule]: Rule that knows how to format an object of another type. Necessary in the situation where it's necessary to implement [Format] on an object from another crate. This module defines the [FormatRefWithRule] and [FormatOwnedWithRule] structs to pass an item with its corresponding rule.
  • [FormatWithRule] implemented by objects that know how to format another type. Useful for implementing some reusable formatting logic inside of this module if the type itself doesn't implement [Format]

Formatting Macros

This crate defines two macros to construct the IR. These are inspired by Rust's fmt macros

  • format!: Formats a formatable object
  • format_args!: Concatenates a sequence of Format objects.
  • write!: Writes a sequence of formatable objects into an output buffer.


~147K SLoC