Rome is a toolchain for the web: formatter, linter and more for JavaScript, TypeScript, JSON, HTML, Markdown, and CSS
—
Rome's formatter provides automatic code formatting that replaces Prettier, with support for JavaScript, TypeScript, JSON, and CSS files. It focuses on opinionated defaults while allowing key customizations.
The primary formatting command that processes files and directories.
/**
* Format files according to Rome's style rules
*
* Usage: rome format [OPTIONS] <INPUTS...>
*
* INPUTS can be one or more filesystem paths, each pointing to a single file
* or an entire directory to be searched recursively for supported files
*/
rome format <INPUTS...>Core Options:
--write # Edit files in place instead of printing diff to console
--skip-errors # Skip files with syntax errors instead of emitting error diagnostic
--max-diagnostics <number> # Cap the amount of diagnostics displayed (default: 50)
--verbose # Print additional verbose advice on diagnostics
--stdin-file-path <string> # File name with extension for reading from stdin
--json # Output results in JSON formatUsage Examples:
# Format and display diff
rome format src/
# Format files in place
rome format src/ --write
# Format single file
rome format src/index.js --write
# Format from stdin with file extension
echo 'const x=1;' | rome format --stdin-file-path=file.js
# Format with verbose output
rome format src/ --verbose
# Skip files with syntax errors
rome format src/ --skip-errors --writeControl how code is indented.
--indent-style <tabs|space> # Change indentation character (default: tabs)
--indent-size <number> # Spaces for indentation when using space style (default: 2)Usage Examples:
# Use spaces instead of tabs
rome format src/ --indent-style=space --write
# Use 4 spaces for indentation
rome format src/ --indent-style=space --indent-size=4 --write
# Use tabs (default)
rome format src/ --indent-style=tabs --writeControl line wrapping behavior.
--line-width <number> # Maximum characters the formatter is allowed per line (default: 80)Usage Examples:
# Allow longer lines
rome format src/ --line-width=120 --write
# Shorter lines for readability
rome format src/ --line-width=60 --writeControl quotation marks in strings and object properties.
--quote-style <single|double> # Quotation character for strings (default: double)
--quote-properties <as-needed|preserve> # When properties in objects should be quoted (default: as-needed)Usage Examples:
# Use single quotes for strings
rome format src/ --quote-style=single --write
# Always preserve existing property quotes
rome format src/ --quote-properties=preserve --write
# Minimal property quoting (default)
rome format src/ --quote-properties=as-needed --writeControl trailing comma behavior in multi-line structures.
--trailing-comma <all|es5|none> # Changes trailing commas in multi-line comma-separated syntactic structures (default: all)Values:
all - Trailing commas wherever possible (including function parameters)es5 - Trailing commas where valid in ES5 (objects, arrays)none - No trailing commasUsage Examples:
# Trailing commas everywhere
rome format src/ --trailing-comma=all --write
# ES5-compatible trailing commas
rome format src/ --trailing-comma=es5 --write
# No trailing commas
rome format src/ --trailing-comma=none --writeControl semicolon usage in statements.
--semicolons <always|as-needed> # When to print semicolons for statements (default: always)Usage Examples:
# Always use semicolons (default)
rome format src/ --semicolons=always --write
# Only use semicolons when required
rome format src/ --semicolons=as-needed --writeAll formatting options can be specified in rome.json:
{
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentSize": 2,
"lineWidth": 100,
"ignore": ["dist/**"]
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"quoteProperties": "asNeeded",
"trailingComma": "all",
"semicolons": "always"
}
}
}Rome formats JavaScript and TypeScript files with full syntax support including:
Rome formats JSON files with:
Rome provides basic CSS formatting support including:
The formatter handles various error conditions:
# Skip files with syntax errors
rome format src/ --skip-errors --write
# Default behavior: report syntax errors
rome format src/--files-max-size limit# Human-readable output (default)
rome format src/
# JSON output for tooling integration
rome format src/ --jsonInstall with Tessl CLI
npx tessl i tessl/npm-rome