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

ci-integration.mddocs/

CI Integration

Rome's CI command provides combined formatting and linting checks optimized for continuous integration environments. It performs both format checking and linting in a single command, making it ideal for build pipelines and automated quality gates.

Capabilities

CI Command

The comprehensive CI command that runs both formatter and linter checks.

/**
 * Run the linter and formatter check on a set of files
 * 
 * Usage: rome ci [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 ci <INPUTS...>

Core Options:

--formatter-enabled       # Allow to enable or disable the formatter check (default: true)
--linter-enabled         # Allow to enable or disable the linter check (default: true)  
--max-diagnostics <number> # Cap the amount of diagnostics displayed (default: 50)
--verbose                # Print additional verbose advice on diagnostics

All formatting options are also available (see Formatting for complete list):

--indent-style <tabs|space>              # Change indentation character (default: tabs)
--indent-size <number>                   # Spaces for indentation when using space style (default: 2)
--line-width <number>                    # Maximum characters per line (default: 80)
--quote-style <single|double>            # Quotation character for strings (default: double)
--quote-properties <as-needed|preserve>  # When properties should be quoted (default: as-needed)
--trailing-comma <all|es5|none>          # Trailing commas in multi-line structures (default: all)
--semicolons <always|as-needed>          # When to print semicolons (default: always)

Feature Control

Selectively enable or disable parts of the CI check:

# Run only formatter check
rome ci src/ --linter-enabled=false

# Run only linter check  
rome ci src/ --formatter-enabled=false

# Run both (default behavior)
rome ci src/

Usage Examples

Basic CI Usage

# Standard CI check with both formatter and linter
rome ci src/

# Check specific files
rome ci src/index.js src/utils.ts

# Check with custom formatting rules
rome ci src/ --indent-style=space --line-width=120

# Verbose output for debugging
rome ci src/ --verbose

Selective Checks

# Only check formatting (skip linting)
rome ci src/ --linter-enabled=false

# Only check linting (skip formatting)
rome ci src/ --formatter-enabled=false

# Custom diagnostic limits for CI logs
rome ci src/ --max-diagnostics=20

CI Pipeline Integration

# GitHub Actions example
- name: Run Rome CI
  run: rome ci src/

# With custom settings
- name: Run Rome CI with custom rules
  run: rome ci src/ --line-width=100 --max-diagnostics=30

Configuration File Usage

CI behavior can be configured in rome.json:

{
  "formatter": {
    "enabled": true,
    "indentStyle": "space",
    "indentSize": 2,
    "lineWidth": 100
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true
    }
  },
  "files": {
    "ignore": [
      "dist/**",
      "build/**",
      "node_modules/**"
    ]
  }
}

CI-Specific Features

Performance Optimizations

The CI command is optimized for build environments:

  • Parallel processing: Processes multiple files concurrently
  • Memory efficient: Optimized memory usage for large codebases
  • Fast exit: Stops on first error when appropriate
  • Reduced output: Less verbose by default than interactive commands

Diagnostic Management

--max-diagnostics <number>  # Cap diagnostics to prevent log overflow (default: 50)
--verbose                  # Enable detailed diagnostic output when needed

Exit Codes

The CI command uses standard exit codes for integration:

  • 0: All checks passed
  • 1: Formatting or linting issues found
  • 2: Configuration or runtime error

Common CI Patterns

GitHub Actions

name: Code Quality
on: [push, pull_request]

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: '18'
      - run: npm ci
      - run: rome ci src/

GitLab CI

code_quality:
  stage: test
  script:
    - npm ci
    - rome ci src/
  only:
    - merge_requests
    - main

Jenkins

pipeline {
    agent any
    stages {
        stage('Code Quality') {
            steps {
                sh 'npm ci'
                sh 'rome ci src/'
            }
        }
    }
}

Azure DevOps

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '18'
- script: npm ci
- script: rome ci src/
  displayName: 'Run Rome CI'

Output Formats

Human-Readable (Default)

Standard terminal output with colors and formatting:

rome ci src/

JSON Output

Structured output for tooling integration:

rome ci src/ --json

JSON output includes:

  • File-level results
  • Rule violations with locations
  • Formatting differences
  • Summary statistics
  • Error details

Error Handling

Formatter Errors

  • Syntax errors: Reports files that cannot be parsed
  • Write permissions: Handles read-only files gracefully
  • Binary files: Automatically skips non-text files

Linter Errors

  • Rule violations: Reports all configured rule violations
  • Configuration errors: Clear messages for config issues
  • File processing: Continues with other files on individual failures

Build Integration

# Fail build on any issues
rome ci src/ || exit 1

# Allow warnings but fail on errors (requires configuration)
rome ci src/

# Generate reports for analysis
rome ci src/ --json > rome-report.json

Performance Considerations

Large Codebases

# Limit file size to avoid processing large generated files
rome ci src/ --files-max-size=1048576

# Use file ignoring for performance
# Configure in rome.json:
{
  "files": {
    "ignore": ["**/*.min.js", "dist/**", "coverage/**"]
  }
}

Parallel Processing

Rome automatically uses multiple CPU cores for processing, but you can influence performance:

  • File organization: Group related files in directories
  • Ignore patterns: Exclude unnecessary files early
  • Daemon mode: Use --use-server for repeated runs

Memory Usage

For memory-constrained environments:

# Process smaller batches
rome ci src/components/
rome ci src/utils/
rome ci src/pages/

# Use daemon mode to amortize startup costs
rome start
rome ci src/ --use-server
rome stop

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