rainbow-fmt
Every shade of style. A code formatter that formats code your way.
rainbow-fmt is a highly configurable, pluggable code formatter for HTML,
CSS, SCSS, JavaScript, TypeScript, Svelte, Python, and any other language or
DSL someone cares to describe.
It is deliberately the anti-Prettier / anti-Black. Those tools end style
debates by removing choice. rainbow-fmt ends them by letting a team write
its decisions down once — and then enforcing them consistently, for every
language in the repository.
Status
Alpha (0.2.0). JSON, JSONC, CSS and Python can be formatted from the command line; other
languages are planned (docs/roadmap.md). See
STATUS.md and CHANGELOG.md.
Quick start
pip install rainbow-fmt # Python 3.12 or newer
rainbow-fmt format src/ # rewrite files in place
rainbow-fmt check . # exit 1 if any file would change
rainbow-fmt diff config.json # show the changes
rainbow-fmt options config.json # the options for a file, and where each comes from
Every formatted file is verified before it is written: the syntax tree and
the comments must be unchanged, and formatting the result again must change
nothing (docs/cli.md).
Write your decisions down in rainbow.toml (or pyproject.toml
[tool.rainbow], YAML, or package.json), in the project root:
preset = "rainbow:balanced" # start from a preset (optional)
[core]
max_width = 100
indent_size = 2
[language.json]
object_wrap = "always" # "preserve" | "fit" | "always"
align_values = true
[[override]]
files = ["legacy/**"]
core.indent_size = 4
.editorconfig is read too. All options and the resolution order are in
docs/configuration.md.
Documentation
| Document | Contents |
|---|---|
docs/overview.md |
Vision, principles, non-goals, comparison with existing tools |
docs/architecture.md |
The major pieces and how they fit together |
docs/css.md |
The CSS pack: what it changes, its options |
docs/python.md |
The Python pack: what it changes, its options |
docs/cli.md |
The format, check, diff and options commands |
docs/configuration.md |
Configuration model: options, cascading, presets, preserve |
docs/extending.md |
How new languages and DSLs are added |
docs/doc-ir.md |
Reference for the Doc IR builders and the printer |
docs/benchmark.md |
python -m rainbow_fmt.benchmark and the CI baseline |
docs/releasing.md |
Publishing a release to PyPI |
docs/roadmap.md |
High-level, phased plan and open decisions |
docs/adr/ |
Architecture Decision Records |
Development
Requires Python 3.12 or newer.
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e '.[dev]'
pytest # tests + coverage report
ruff check . && ruff format --check .
mypy # strict; configured in pyproject.toml
The same checks, plus a package build and a benchmark
(python -m rainbow_fmt.benchmark, docs/benchmark.md),
run in GitLab CI on every push and merge request (.gitlab-ci.yml).
Pushing a tag vX.Y.Z that matches __version__ publishes the package to
PyPI (docs/releasing.md).
New features are developed tests-first: the tests describing the intended
API are written and reviewed before the implementation. Architectural
decisions are recorded in docs/adr/.
License
MIT — see LICENSE.
Project tracking
TODO.md (high-level tasks),
TASKS.md (detailed next tasks), STATUS.md
(current state).
Metadata
Release files for rainbow-fmt 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rainbow_fmt-0.2.0.tar.gz | 172.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rainbow_fmt-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 251.9 kB
Release files / rainbow_fmt-0.2.0.tar.gz
| Download URL | rainbow_fmt-0.2.0.tar.gz |
|---|---|
| Size | 172.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a37b4549f8becb4bbee609a533c7cc955d19869712c0bcc9915ed0c46d0ad216
|
|
BLAKE2b-256 checksum How to use checksums |
5019f14c3382c74aae1262a8148eeea677e4ded614cad38e65b4169058d0ddfc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Release files / rainbow_fmt-0.2.0-py3-none-any.whl
| Download URL | rainbow_fmt-0.2.0-py3-none-any.whl |
|---|---|
| Size | 79.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c90a3ea1e0b098ae7c184d71cc97269fde5fbfae2e5dec0f67bdd3b533d67c3a
|
|
BLAKE2b-256 checksum How to use checksums |
957b3fd44af88cf895ec908ef536e08507e1cc369a7a2d3567ad81483f4cf9f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|