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

configuration.mddocs/

Configuration

Rome's configuration system provides extensive customization options through the rome.json file, with sensible defaults and the ability to override settings via command-line arguments.

Capabilities

Project Initialization

Initialize a new Rome project with default configuration.

/**
 * Bootstrap a new rome project
 * 
 * Usage: rome init
 * 
 * Creates a rome.json configuration file in the current directory
 */
rome init

Usage Examples:

# Initialize in current directory
rome init

# Creates rome.json with default settings

Configuration File Structure

Rome uses a rome.json file for project configuration with the following structure:

{
  "$schema": "./node_modules/rome/configuration_schema.json",
  "files": {
    "maxSize": 1048576,
    "ignore": ["dist/**", "node_modules/**"]
  },
  "formatter": {
    "enabled": true,
    "formatWithErrors": false,
    "indentStyle": "tabs",
    "indentSize": 2,
    "lineWidth": 80,
    "ignore": []
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true,
      "a11y": { "recommended": true },
      "complexity": { "recommended": true },
      "correctness": { "recommended": true },
      "performance": { "recommended": true },
      "security": { "recommended": true },
      "style": { "recommended": true },
      "suspicious": { "recommended": true }
    },
    "ignore": []
  },
  "javascript": {
    "formatter": {
      "quoteStyle": "double",
      "quoteProperties": "asNeeded", 
      "trailingComma": "all",
      "semicolons": "always"
    },
    "globals": ["console", "process"]
  }
}

Configuration Sections

Files Configuration

Global file handling settings that apply to all Rome tools.

{
  "files": {
    "maxSize": 1048576,     // Maximum file size in bytes (default: 1MB)
    "ignore": [             // Files and patterns to ignore globally
      "dist/**",
      "build/**",
      "node_modules/**",
      "*.min.js",
      "coverage/**"
    ]
  }
}

Properties:

  • maxSize: Maximum allowed size for source code files in bytes
  • ignore: Array of Unix shell style patterns (glob patterns) to ignore

Usage Examples:

{
  "files": {
    "maxSize": 2097152,     // 2MB limit
    "ignore": [
      "dist/**",            // Ignore dist directory
      "**/*.min.js",        // Ignore minified files
      "test/fixtures/**"    // Ignore test fixtures
    ]
  }
}

Formatter Configuration

Settings for Rome's code formatter.

{
  "formatter": {
    "enabled": true,           // Enable/disable formatter (default: true)
    "formatWithErrors": false, // Format files with syntax errors (default: false)
    "indentStyle": "tabs",     // "tabs" | "space" (default: "tabs")
    "indentSize": 2,          // Number of spaces when indentStyle is "space" (default: 2)
    "lineWidth": 80,          // Maximum line width (default: 80)
    "ignore": []              // Files to exclude from formatting
  }
}

Usage Examples:

{
  "formatter": {
    "enabled": true,
    "indentStyle": "space",
    "indentSize": 4,
    "lineWidth": 120,
    "ignore": ["src/legacy/**"]
  }
}

JavaScript Formatter Configuration

JavaScript and TypeScript specific formatting options.

{
  "javascript": {
    "formatter": {
      "quoteStyle": "double",        // "single" | "double" (default: "double")
      "quoteProperties": "asNeeded", // "asNeeded" | "preserve" (default: "asNeeded")
      "trailingComma": "all",        // "all" | "es5" | "none" (default: "all")  
      "semicolons": "always"         // "always" | "asNeeded" (default: "always")
    }
  }
}

Trailing Comma Options:

  • "all": Trailing commas wherever possible (including function parameters)
  • "es5": Trailing commas where valid in ES5 (objects, arrays)
  • "none": No trailing commas

Usage Examples:

{
  "javascript": {
    "formatter": {
      "quoteStyle": "single",
      "trailingComma": "es5",
      "semicolons": "asNeeded"
    }
  }
}

Linter Configuration

Settings for Rome's linter and rule configuration.

{
  "linter": {
    "enabled": true,        // Enable/disable linter (default: true)
    "rules": {
      "recommended": true,  // Enable all recommended rules
      "all": false         // Enable all available rules (overrides recommended)
    },
    "ignore": []           // Files to exclude from linting
  }
}

Rule Group Configuration

Configure entire rule groups or individual rules.

{
  "linter": {
    "rules": {
      "a11y": {
        "recommended": true,           // Enable recommended accessibility rules
        "noAutofocus": "error",       // Individual rule: "error" | "warn" | "off"
        "noBlankTarget": "warn",
        "useAltText": "off"
      },
      "correctness": {
        "recommended": true,
        "noUnusedVariables": "error",
        "noConstAssign": "error"
      },
      "style": {
        "recommended": false,         // Disable entire group
        "useConst": "error"          // But enable specific rules
      }
    }
  }
}

Rule Severity Levels:

  • "error": Rule violation causes build failure
  • "warn": Rule violation reported as warning
  • "off": Rule disabled

JavaScript Configuration

JavaScript and TypeScript specific settings.

{
  "javascript": {
    "formatter": {
      // Formatter options (see above)
    },
    "globals": [           // Global variables available in code
      "console",
      "process", 
      "Buffer",
      "$",
      "jQuery"
    ]
  }
}

Command Line Overrides

Configuration file settings can be overridden via command-line arguments:

# Override formatter settings
rome format src/ --indent-style=space --line-width=120

# Override linter settings  
rome check src/ --max-diagnostics=50

# Override file size limits
rome check src/ --files-max-size=2097152

Schema Validation

Rome provides JSON schema validation for configuration files:

{
  "$schema": "./node_modules/rome/configuration_schema.json",
  // ... rest of configuration
}

This enables:

  • IDE support: Autocomplete and validation in editors
  • Error detection: Invalid configuration detection
  • Documentation: Inline help for configuration options

Configuration Discovery

Rome searches for configuration in the following order:

  1. rome.json in current directory
  2. rome.json in parent directories (walking up)
  3. Default configuration if no file found
# Force specific configuration file
rome check src/ --config-path=./custom-rome.json

Example Configurations

Minimal Configuration

{
  "formatter": {
    "enabled": true
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true
    }
  }
}

Strict Configuration

{
  "files": {
    "maxSize": 524288,
    "ignore": ["dist/**", "coverage/**"]
  },
  "formatter": {
    "enabled": true,
    "indentStyle": "space",
    "indentSize": 2,
    "lineWidth": 100
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true,
      "correctness": {
        "recommended": true,
        "noUnusedVariables": "error"
      },
      "suspicious": {
        "recommended": true,
        "noExplicitAny": "error"
      }
    }
  },
  "javascript": {
    "formatter": {
      "quoteStyle": "single",
      "semicolons": "always"
    }
  }
}

Team Configuration

{
  "$schema": "./node_modules/rome/configuration_schema.json",
  "files": {
    "ignore": [
      "dist/**",
      "build/**", 
      "node_modules/**",
      "*.min.js",
      "coverage/**",
      "docs/**"
    ]
  },
  "formatter": {
    "enabled": true,
    "indentStyle": "space",
    "indentSize": 2,
    "lineWidth": 120
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true,
      "a11y": {
        "recommended": true
      },
      "correctness": {
        "recommended": true,
        "noUnusedVariables": "error"
      },
      "style": {
        "recommended": true,
        "useConst": "error",
        "noVar": "error"
      }
    }
  },
  "javascript": {
    "formatter": {
      "quoteStyle": "single",
      "trailingComma": "es5",
      "semicolons": "always"
    },
    "globals": ["process", "console", "Buffer"]
  }
}

Gradual Adoption Configuration

{
  "formatter": {
    "enabled": false    // Disable formatter initially
  },
  "linter": {
    "enabled": true,
    "rules": {
      "correctness": {
        "recommended": true,
        "noUnusedVariables": "warn"  // Start with warnings
      },
      "suspicious": {
        "recommended": false,
        "noDebugger": "error"        // Enable critical rules only
      }
    },
    "ignore": [
      "src/legacy/**"     // Ignore legacy code initially
    ]
  }
}

Configuration Validation

Rome validates configuration files and provides helpful error messages:

# Check configuration validity
rome check src/

# Example error for invalid configuration:
# Configuration error: Unknown property "invalidOption" at root level
# Valid properties are: files, formatter, linter, javascript

Environment-Specific Configuration

Use different configurations for different environments:

{
  "formatter": {
    "enabled": true
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true,
      "suspicious": {
        "noDebugger": "warn"    // Warn in development
      }
    }
  }
}

Then override for production:

# Production CI with strict rules
rome ci src/ --max-diagnostics=0  # Fail on any issues

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