CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-rome

Rome is a toolchain for the web: formatter, linter and more for JavaScript, TypeScript, JSON, HTML, Markdown, and CSS

Pending
Overview
Eval results
Files

formatting.mddocs/

Formatting

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.

Capabilities

Format Command

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 format

Usage 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 --write

Indentation Options

Control 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 --write

Line Length Options

Control 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 --write

Quote Style Options

Control 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 --write

Trailing Comma Options

Control 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 commas

Usage 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 --write

Semicolon Options

Control 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 --write

Configuration File Usage

All 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"
    }
  }
}

Language-Specific Behavior

JavaScript/TypeScript

Rome formats JavaScript and TypeScript files with full syntax support including:

  • Modern syntax: ES2022+ features, TypeScript types
  • JSX support: React JSX and TSX files
  • Module formats: ESM imports/exports, CommonJS require/module.exports
  • Decorators: Experimental and legacy decorator syntax
  • Async/await: Proper formatting for async functions and expressions

JSON

Rome formats JSON files with:

  • Trailing commas: Configurable support for trailing commas in JSON
  • Comments: Support for JSONC (JSON with Comments) files
  • Consistent indentation: Proper alignment and spacing
  • Array/object formatting: Intelligent multi-line formatting

CSS

Rome provides basic CSS formatting support including:

  • Property alignment: Consistent spacing around colons and semicolons
  • Selector formatting: Proper indentation and line breaks
  • Declaration blocks: Organized property ordering

Error Handling

The formatter handles various error conditions:

Syntax Errors

# Skip files with syntax errors
rome format src/ --skip-errors --write

# Default behavior: report syntax errors
rome format src/

File Access Errors

  • Permission errors: Reports files that cannot be read/written
  • Large files: Respects --files-max-size limit
  • Binary files: Automatically skips non-text files

Output Formats

# Human-readable output (default)
rome format src/

# JSON output for tooling integration
rome format src/ --json

Install with Tessl CLI

npx tessl i tessl/npm-rome

docs

ci-integration.md

configuration.md

daemon-mode.md

formatting.md

index.md

linting.md

tile.json