Skip to content

hyphens

What this rule does

Controls the number of spaces between the hyphen (-) and the value in block sequences.

Why this matters

  • Alignment. Consistent spacing keeps sequence items lined up under the same column, which matters for readability of long lists.
  • Diff stability. Editors that "fix" hyphen spacing during a save produce noisy diffs when the rule is unset.

Configuration

[lint.rules.hyphens]
level = "error"
max-spaces-after = 1
dash-on-own-line = false
Option Default Description
max-spaces-after 1 Maximum spaces between the - and the item value.
dash-on-own-line false Require the - on its own line when the entry is a block mapping (ryl-only; TOML config only).

dash-on-own-line is configured in TOML only; YAML config rejects it.

Examples

✅ Allowed (defaults)

list:
  - first
  - second

❌ Reported (defaults)

list:
  -  first
  -   second

✅ Allowed (with max-spaces-after: 3)

list:
  -   first
  -   second

❌ Reported (with dash-on-own-line: true)

The mapping starts on the dash's line, so the - is not on its own line:

items:
  - name: web
    port: 80

✅ Allowed (with dash-on-own-line: true)

The - stands alone and the mapping body is indented below it (a dash carrying only an anchor/tag or a comment is also accepted, since the keys remain below):

items:
  -
    name: web
    port: 80

Automatic fixing

ryl check --fix trims the spaces after - to max-spaces-after, never below one. ryl format leaves exactly one. ryl check --fix leaves a - alone when the block mapping or sequence it opens continues on later lines, because the spaces set that collection's indentation; ryl format closes the gap and re-indents the collection with it:

# before
-   name: web
    port: 80
# after, with `ryl format`
- name: web
  port: 80

ryl check --fix does not fix dash-on-own-line. ryl format joins - and its block mapping onto one line, or with [format] dash-on-own-line = true breaks the mapping onto the line below; a dash line carrying an anchor, tag or comment is left as it is.

  • indentation — controls how sequence items are indented relative to their parent key.
  • brackets and commas — the flow sequence equivalents.