Configuration
The configuration file is considered optional, Rome has good defaults. Use the configuration file to change those defaults.
The Rome configuration file is named rome.json
and should be placed in the root directory of your project. The root directory is usually the directory containing your project’s package.json
.
Here’s an example:
rome.json
{
"formatter": {
"enabled": true,
"indentStyle": "tab",
"lineWidth": 120
},
"linter": {
"enabled": false
}
}
This configuration file enables the formatter and sets the preferred indent style and width. The linter is disabled.
$schema
Allows to pass a path to a JSON schema file.
Since version 11.0.0
, a JSON schema file for the rome.json
is published.
You can specify a relative path to the schema of the rome
npm package if rome
is installed in the node_modules
folder:
rome.json
{
"$schema": "./node_modules/rome/configuration_schema.json"
}
files
files.maxSize
The maximum allowed size for source code files in bytes. Files above this limit will be ignored for performance reason.
Default: 1024*1024 (1MB)
files.ignore
A list of Unix shell style patterns. Rome ignores files and folders that match these patterns.
rome.json
{
"files": {
"ignore": ["scripts/*.js"]
}
}
linter
linter.enabled
Enables Rome’s linter
Default:
true
linter.ignore
An array of Unix shell style patterns.
rome.json
{
"linter": {
"ignore": ["scripts/*.js"]
}
}
linter.rules.recommended
Enables the recommended rules for all categories.
Default:
true
linter.rules.[category]
Options that influence the rules of a single category. Rome supports the following categories:
- `Accessibility`: Rules focused on preventing accessibility problems. - `Complexity`: Rules that focus on inspecting complex code that could be simplified. - `Correctness`: Rules that detect incorrect or useless code. - `Security`: Rules that detect potential security flaws. - `Style`: Rules enforcing a consistent way of writing your code. - `Nursery`: New rules that are still under development. Nursery rules require explicit opt-in via configuration because they may still have bugs or performance problems. Nursery rules get promoted to other groups once they become stable or may be removed. Rules that belong to this group are not subject to semantic version.linter.rules.[category].recommended
Enables the recommended rules for a single category.
Example:
rome.json
{
"linter": {
"enabled": true,
"rules": {
"nursery": {
"recommended": true
}
}
}
}
formatter
These options apply to all languages. There are additional language-specific formatting options below.
formatter.enabled
Enables Rome’s formatter
Default:
true
formatter.ignore
An array of Unix shell style patterns.
rome.json
{
"formatter": {
"ignore": ["scripts/*.js"]
}
}
formatter.formatWithErrors
Allows to format a document that has syntax errors.
rome.json
{
"formatter": {
"formatWithErrors": true
}
}
Default:
false
formatter.indentStyle
The style of the indentation. It can be "tab"
or "space"
.
Default:
tab
Rome’s default is "tab"
.
formatter.indentSize
How big the indentation should be.
Default:
2
formatter.lineWidth
How many characters can be written on a single line.
Default:
80
javascript
These options apply only to JavaScript (and TypeScript) files.
javascript.formatter.quoteStyle
The type of quote used when representing string literals. It can be single
or double
.
Default:
double
javascript.formatter.quoteProperties
When properties inside objects should be quoted. It can be asNeeded
or preserve
.
Default:
asNeeded
javascript.formatter.trailingComma
Print trailing commas wherever possible in multi-line comma-separated syntactic structures. Possible values:
all
, the trailing comma is always addedes5
, the trailing comma is added only in places where it’s supported by older version of JavaScriptnone
, trailing commas are never added
Default:
all
javascript.formatter.semicolons
It configures where the formatter prints semicolons:
always
, the semicolons is always added at the end of each statement;asNeeded
, the semicolons are added only in places where it’s needed, to protect from ASI
Default:
always
Example:
rome.json
{
"javascript": {
"formatter": {
"semicolons": "asNeeded"
}
}
}