toml/indent
enforce consistent indentation
- ⚙️ This rule is included in
"plugin:toml/standard"
. - 🔧 The
--fix
option on the command line can automatically fix some of the problems reported by this rule.
📖 Rule Details
This rule reports enforces a consistent indentation style. The default style is 2 spaces.
# eslint toml/indent: 'error'
# ✓ GOOD
"good" = [
1,
2
]
# ✗ BAD
"bad" = [
1,
2
]
🔧 Options
yaml
toml/indent:
- error
- 2 # number of spaces or "tab"
- subTables: 0
keyValuePairs: 0
- First Option
- Number option ... The number of spaces used for indentation.
"tab"
... Use tabs for indentation.
- Second Option
subTables
... The multiplier of indentation for sub-tables. Default is0
.keyValuePairs
... The multiplier of indentation for key/value pairs. Default is0
.
# ✓ GOOD
# eslint toml/indent: [error, 2, { subTables: 1, keyValuePairs: 1 }]
# Taken from https://toml.io/
# This is a TOML document
title = "TOML Example"
[owner]
name = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00-08:00
[database]
enabled = true
ports = [ 8001, 8001, 8002 ]
data = [ ["delta", "phi"], [3.14] ]
temp_targets = { cpu = 79.5, case = 72.0 }
[servers]
[servers.alpha]
ip = "10.0.0.1"
role = "frontend"
[servers.beta]
ip = "10.0.0.2"
role = "backend"
# ✗ BAD
# eslint toml/indent: [error, 2, { subTables: 1, keyValuePairs: 1 }]
# Taken from https://toml.io/
# This is a TOML document
title = "TOML Example"
[owner]
name = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00-08:00
[database]
enabled = true
ports = [ 8001, 8001, 8002 ]
data = [ ["delta", "phi"], [3.14] ]
temp_targets = { cpu = 79.5, case = 72.0 }
[servers]
[servers.alpha]
ip = "10.0.0.1"
role = "frontend"
[servers.beta]
ip = "10.0.0.2"
role = "backend"
👫 Related rules
🚀 Version
This rule was introduced in eslint-plugin-toml v0.1.0