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 groups.
Default:
true
linter.rules.all
Enable or disable all rules for all groups.
If recommended
and all
are both true
, Rome will emit a diagnostic and fallback to its defaults.
rome.json
{
"linter": {
"enabled": true,
"rules": {
"all": true
}
}
}
It’s also possible to combine this flag to enable/disable different rule groups:
rome.json
{
"linter": {
"enabled": true,
"rules": {
"all": true,
"style": {
"all": false
},
"complexity": {
"all": false
}
}
}
}
In the previous example, Rome will enable all rules, exception for rules that belong to the style
and complexity
groups.
linter.rules.[group]
Options that influence the rules of a single group. Rome supports the following groups:
accessibility
: Rules focused on preventing accessibility problems.complexity
: Rules that focus on inspecting complex code that could be simplified.correctness
: Rules that detect code that is guaranteed to be incorrect or useless.performance
: Rules catching ways your code could be written to run faster, or generally be more efficient.security
: Rules that detect potential security flaws.style
: Rules enforcing a consistent and idiomatic way of writing your code.suspicious
: Rules that detect code that is likely to be incorrect or useless.nursery
: New rules that are still under development. Nursery rules require explicit opt-in via configuration on stable versions because they may still have bugs or performance problems. They are enabled by default on nightly builds, but as they are unstable their diagnostic severity may be set to either error or warning, depending on whether we intend for the rule to be recommended or not when it eventually gets stabilized. 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.[group].recommended
Enables the recommended rules for a single group.
Example:
rome.json
{
"linter": {
"enabled": true,
"rules": {
"nursery": {
"recommended": true
}
}
}
}
linter.rules.[group].all
Enables all rules for a single group.
Example:
rome.json
{
"linter": {
"enabled": true,
"rules": {
"nursery": {
"all": 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
organizeImports
organizeImports.enabled
(experimental)
Enables Rome’s sort imports.
organizeImports.ignore
A list of Unix shell style patterns. Rome ignores files and folders that match these patterns.
rome.json
{
"organizeImports": {
"enabled": true,
"ignore": ["scripts/*.js"]
}
}
Default:
false
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"
}
}
}
javascript.globals
A list of global names that Rome should ignore (analyzer, linter, etc.)
rome.json
{
"javascript": {
"globals": ["$", "_", "externalVariable"]
}
}