alofmt – fast deterministic Ruby formatter

alofmt is a fast, deterministic formatter for Ruby source code. It uses Prism to understand Ruby syntax and implements its formatting engine in Rust, combining source-aware formatting with an emphasis on predictable and repeatable output.

The formatter takes a strict approach to problematic input. Instead of attempting to produce partially formatted output when syntax cannot be handled safely, it reports the problem. Formatting policy can be kept with the project, giving teams a reproducible style without embedding formatting logic into their own tooling.

This is free and open source software.

Key Features

  • Formats Ruby .rb files and Ruby interface .rbi files.
  • Rewrites discovered files in place with its write mode.
  • Checks whether files are correctly formatted without changing them.
  • Can display a diff when a formatting check detects changes.
  • Processes directory discovery and formatting work in parallel.
  • Respects .gitignore when scanning project trees.
  • Reads Ruby source from standard input and can print formatted single-file output.
  • Uses Prism for Ruby parsing.
  • Stores project formatting policy in .alofmt.toml.
  • Searches the current directory and its parents for the nearest configuration file.
  • Allows command-line options to override project configuration for an individual run.
  • Provides settings for line width, indentation width, quotation style and trailing commas.
  • Treats invalid input, parser failures, unsupported syntax and misspelled configuration keys as explicit errors.
  • Returns an error for unsupported Prism nodes rather than silently producing partial or lossy formatting.
  • Exposes the formatter as a Rust library for embedding in other development tools.
  • Provides allocation-free checks through its library interface where appropriate.
  • Produces stable reporting even though formatting work can run concurrently.

Website: github.com/StileEducation/alofmt
Support:
Developer: Stile Education
License: MIT License

alofmt is written in Rust. Learn Rust with our recommended free books and free tutorials.


Related Software

Ruby Code Formatters
RuboCopChecks style, detects potential problems, and autocorrects offences
Standard RubyCombines linting and automatic fixes with a shared set of rules
rubyfmtApplies a consistent style with minimal configuration required
Syntax TreeToolkit for parsing, inspecting, and transforming source files
RufoKeeps source files tidy with an opinionated approach to style
alofmtDelivers fast, deterministic formatting for consistent results

Read our verdict in the software roundup.


Best Free and Open Source Software LinuxLinks helps you discover the best free and open source software for Linux. Explore our extensive collection of recommended applications, including alternatives to popular proprietary software.

We also publish software reviews, Linux tutorials, hardware reviews, free programming books and articles covering the wider open source community. Browse our Linux resources to discover more.

Know a useful free and open source Linux application we haven't covered? Suggest a program for inclusion.

Has your software been featured on LinuxLinks? Display one of our Featured on LinuxLinks badges on your website or GitHub README.
Subscribe

Please read our Comment Policy before commenting.

Notify of
guest
0 Comments
Oldest
Newest Most Voted