Rome is a toolchain for the web: formatter, linter and more for JavaScript, TypeScript, JSON, HTML, Markdown, and CSS
—
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.
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 initUsage Examples:
# Initialize in current directory
rome init
# Creates rome.json with default settingsRome 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"]
}
}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 bytesignore: Array of Unix shell style patterns (glob patterns) to ignoreUsage Examples:
{
"files": {
"maxSize": 2097152, // 2MB limit
"ignore": [
"dist/**", // Ignore dist directory
"**/*.min.js", // Ignore minified files
"test/fixtures/**" // Ignore test fixtures
]
}
}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 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 commasUsage Examples:
{
"javascript": {
"formatter": {
"quoteStyle": "single",
"trailingComma": "es5",
"semicolons": "asNeeded"
}
}
}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
}
}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 disabledJavaScript and TypeScript specific settings.
{
"javascript": {
"formatter": {
// Formatter options (see above)
},
"globals": [ // Global variables available in code
"console",
"process",
"Buffer",
"$",
"jQuery"
]
}
}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=2097152Rome provides JSON schema validation for configuration files:
{
"$schema": "./node_modules/rome/configuration_schema.json",
// ... rest of configuration
}This enables:
Rome searches for configuration in the following order:
rome.json in current directoryrome.json in parent directories (walking up)# Force specific configuration file
rome check src/ --config-path=./custom-rome.json{
"formatter": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
}
}{
"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"
}
}
}{
"$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"]
}
}{
"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
]
}
}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, javascriptUse 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 issuesInstall with Tessl CLI
npx tessl i tessl/npm-rome