erbfmt

Reference

CLI

Format, check, and lint HTML+ERB files from a terminal or CI.

Usage

erbfmt [OPTIONS] [FILE]...
erbfmt init [--force]

At least one file path is required for formatting, checking, or linting. Standard input is not currently supported. A single file can use any mode; multiple files require --write, --check, or --lint.

Shell glob expansion can provide multiple paths:

erbfmt --write app/views/**/*.html.erb

Modes

erbfmt FILEstdout · one file

Formats one file and prints the result to standard output without changing the source file.

--writeone or more files

Formats each file in place. A successful write prints one confirmation line per file.

--checkone or more files

Checks whether formatting would change each file without writing it. The command fails when any file is not formatted.

--lintone or more files

Runs lint diagnostics without formatting. Error diagnostics fail the command; warning-only results succeed.

--write, --check, and --lint are mutually exclusive.

Options

--config PATH

Uses the specified erbfmt.json. Without this option, erbfmt searches the current directory and then its parents. If no config is found, built-in defaults are used.

-h, --help

Prints command help and exits.

-V, --version

Prints the installed erbfmt version and exits.

See the configuration reference for every formatter and linter setting.

Init

Create the default erbfmt.json in the current directory:

erbfmt init

The command refuses to replace an existing file. Overwrite it explicitly with:

erbfmt init --force

Exit status

0success

Formatting or writing completed, every checked file was formatted, or lint found no error-level diagnostics.

1operation failed

A checked file needs formatting, lint found an error, a required file was missing, or file/config parsing failed.

2invalid CLI usage

An option was invalid or mutually exclusive mode flags were combined.

CI examples

erbfmt --check app/views/**/*.html.erb
erbfmt --lint app/views/**/*.html.erb