Skip to content
Edit this page View source of this page

Formatter

ryl format rewrites YAML files in place to a consistent layout. The formatter edits only the spans that are off-style rather than reprinting the document, so the first run on an existing project produces a small diff, and every later run on formatted files changes nothing.

Biome does not format YAML, so there is no Biome YAML style to migrate.

ryl format

# Format every YAML file under the current directory, in place
ryl format .

# Write nothing; exit 1 if any file would change, showing the change
ryl format --check .

# Write nothing; print a unified diff of the changes
ryl format --diff path/to/file.yaml

# Read stdin, write the formatted text to stdout
cat file.yaml | ryl format - --stdin-filename file.yaml

Inputs, file discovery, .gitignore handling and config discovery are the same as ryl check. Unlike ryl check, ryl format needs no config: with none it formats with the defaults below.

--check reports each file ryl format would change as one unformatted finding at its first change, as ruff does. The standard and colored formats show the diff under the finding. It uses the same reporters as ryl check, so it honours --output-format and [output] and picks the GitHub format in GitHub Actions. --check and --diff end with a summary on stderr, such as 1 file would be reformatted, 2 files already formatted.

Already formatted files are skipped on later runs through the content-hash cache. --check can also reuse a clean result; --diff always generates the requested diff.

Guarantees

Every edit ryl format makes is checked by property tests to be:

  • Value-preserving. The document loads to the same data, with the same tags, anchors, aliases, key order and duplicate keys, resolved under the document's YAML version.
  • Comment-safe. Every comment stays beside the node it annotates. With schema directives enabled, comment spacing also preserves active and near-modeline spellings. Schema loading never runs during formatting.
  • Idempotent. Formatting formatted output changes nothing.

Syntax repairs and file handling

Root strings such as '---' and '...' retain their quotes because the plain spellings are document markers. Marker prefixes followed by Unicode whitespace also keep quotes for reference-parser compatibility.

Input rejected by strict YAML parsing is left alone and reported on stderr as skipped by ryl format, with one exception: spec-invalid indentation, or a flow ? key with no space before the next indicator ([?,]), accepted by the parser's relaxed mode can be repaired when the repaired text parses strictly and preserves the relaxed input's values, tags, anchors and structure. [?,] becomes [? ]. Repairs print input was YAML the spec rejects; repaired it; --check exits 1. An unsafe or disabled repair leaves the entire file unchanged with a syntax skip.

ryl check and LSP diagnostics parse strictly and report the original indentation as a syntax error. check --fix/--diff, LSP formatting and Fix All allow the same guarded repair; lint fixes otherwise keep their existing rule selection. Syntax repair in check --fix/--diff requires the default lint.fixable = ["ALL"], honors indentation ignore settings and uses formatter indentation targets. Per-rule editor fixes leave syntax repair to Format Document or Fix All.

See File encodings for encoding preservation and --check/--diff behavior when a text patch cannot be emitted. A document-prefix BOM stays before an added --- marker, including in later documents; the BOM does not count toward indentation. Diagnostic columns still count a document-prefix BOM that remains in the source text. The same exit behavior applies when a patch is skipped because the YAML ends in a bare carriage return or the filename cannot be represented in a diff header.

Jinja templates

ryl neither formats nor lints a Jinja template, since the rendered values can break quotes ryl chose. A template is a file whose first line is a Salt renderer header that runs Jinja, such as #!jinja|yaml or #!yaml_jinja. A directory scan skips one silently, as it skips a .j2 file; naming one, or piping one to stdin, exits 2. A file without the header is YAML, {{ }} included.

Configuration

ryl format reads the [format] table of the same .ryl.toml, ryl.toml or pyproject.toml ([tool.ryl.format]) that ryl check uses. A YAML config cannot set it, so YAML-configured projects get the defaults.

[format]
quote-style = "single"
keep-quotes = false
line-ending = "lf"
document-start = "preserve"
document-end = "preserve"
prose-wrap = "preserve"
brace-spacing = false
comment-spacing = 2
comment-starting-space = "add"
max-blank-lines = 2
preview = false
sequence-style = "preserve"
mapping-style = "preserve"
sequence-expand = "preserve"
mapping-expand = "preserve"
property-order = "preserve"
indent-sequences = true
dash-on-own-line = false

Choose settings by goal

Set the keys below inside [format]; line-length stays at the top level. Here *-style and *-expand mean the corresponding sequence- and mapping- keys.

Goal Settings Result
Block collections sequence-style = "block", mapping-style = "block" Convert eligible flow collections to block
Short flow, long block sequence-style = "flow", mapping-style = "flow" Choose style by line-length
One entry per line in existing flow sequence-expand = "always", mapping-expand = "always" Keep block collections block
Wrap existing flow to fit sequence-expand = "auto", mapping-expand = "auto" Try in place, below the key, then spread
Wrap prose and retain quotes prose-wrap = "always", keep-quotes = true Join and wrap paragraphs without dropping optional quotes

No single setting converts block collections to flow with one entry per line: *-style = "flow" combined with *-expand = "always" leaves block collections block.

Option reference

Key Default Values What it sets
quote-style "single" "single", "double", "preserve" The quote used where a string needs quoting; "preserve" leaves all quoting alone. See Quote style.
keep-quotes false true, false Keep existing optional quotes while quote-style selects their character.
line-ending "lf" "lf", "cr-lf", "native", "auto" Line endings, including the final newline; "native" is the platform's, and "auto" keeps the ending most of the file's lines use ("lf" on a tie or a file without line breaks).
document-start "preserve" "add", "preserve", "remove" Add missing --- markers, preserve markers, or remove the first optional marker.
document-end "preserve" "add", "preserve" Whether to add a missing ... document end marker.
prose-wrap "preserve" "preserve", "always", "never" Preferred for new configs: preserve breaks, join and wrap paragraphs, or join without wrapping. See Long lines.
prose [] Array of tables Scoped token boundaries and protected regex spans, active only with prose-wrap = "always". See Expression wrapping.
fold-long-lines false true, false Legacy split-only folding at single spaces; cannot be combined with prose-wrap, even when false.
brace-spacing false true, false Whether to write one space inside non-empty flow mapping braces, { a: 1 }. Empty braces and brackets stay unpadded.
comment-spacing 2 1 to 255 Exact number of spaces between content and an inline comment.
comment-starting-space "add" "add", "preserve" Whether to add a missing space after a comment's #.
max-blank-lines 2 0 to 255 Most blank lines kept in a row between content lines; leading and trailing runs are removed. Scalar content is preserved, including keep-chomping (\|+/>+) tails; clip/strip tails can be trimmed.
indent-sequences true true, false Whether a block sequence under a mapping key is indented past the key; false keeps it flush.
dash-on-own-line false true, false Whether a block mapping in a block sequence starts on the line after its -; false joins them as - name: web.
preview false true, false Opt in to style changes before they become stable. See Preview style.
sequence-style "preserve" "preserve", "block", "flow" Collection style for sequences. See Collection style.
mapping-style "preserve" "preserve", "block", "flow" Collection style for mappings. See Collection style.
sequence-expand "preserve" "preserve", "auto", "always", "never" Line breaks inside flow sequences. See Flow line breaks.
mapping-expand "preserve" "preserve", "auto", "always", "never" Line breaks inside flow mappings. See Flow line breaks.
property-order "preserve" "preserve", "anchor-first", "tag-first" The order of a node's anchor and tag on one line: &a !!seq or !!seq &a.

Comment spacing targets leave ytt #@ directives unchanged, including the gap between an inline directive and its YAML content.

The top-level line-length and indent-width keys are shared with ryl check, where they set the defaults for the line-length and indentation rules (see Quick start). ryl format re-indents every block level to indent-width, and uses both as the fold width and continuation indent under fold-long-lines.

Without indent-width, ryl format targets width 2. Set the top-level indent-width to keep another width. Linting still defaults to spaces = "consistent" when indent-width is unset. If re-indenting would leave inconsistent indentation, ryl format keeps that document's indentation and reports the sites it cannot fix.

The rest of the layout is fixed:

Concern ryl format writes
Own-line comments Aligned with the content they precede
Flow collections No spaces inside [] or empty {}, and inside other {} per brace-spacing; no space before a comma, one after; no trailing comma ([a, b,] becomes [a, b])
Blank lines None at the start or end of the file
Line ends Remove trailing whitespace outside scalar content; add a final newline
After -, ? and : One space, re-indenting a compact collection that hangs on it

Block scalar headers lose trailing spaces and tabs. A header or body at EOF gains a final newline and, with document-end = "add", a ... marker. An indentation-only final line loses its spaces when they are not scalar content. For keep-chomped scalars (|+ or >+), the formatter adds a line break after removing those spaces to preserve the YAML 1.2 reference parser's value. When adding a document end marker, it removes only indentation spaces from a final blank block-scalar line. A root explicit-indent scalar keeps value-bearing spaces; the marker is left unfixed if appending it would change the reference value.

A document that a tab indents, or that re-indenting would parse differently, is left as it is and named on stderr.

Removing an optional document marker

[format]
document-start = "remove"

---\na: 1\n---\nb: 2\n becomes a: 1\n---\nb: 2\n. Only the first optional marker is removed. Directives, empty documents and separators keep required markers. --- | becomes | on the same line; a marker-line comment becomes a standalone comment.

Default profile

With no [format] table, ryl format writes the profile below. It preserves existing document start markers, can remove redundant quotes or switch required double quotes to single, and can indent flush sequences. Migration writes quote-style = "preserve" when quoted-strings is disabled in the source preset.

Default Why
quote-style = "single" yamlfix's default; see Quote style for when it applies
keep-quotes = false Removes unnecessary quotes; retaining them is opt-in
line-ending = "lf" The default of prettier
document-start = "preserve" prettier keeps a file's markers as written
document-end = "preserve" No formatter adds ...; prettier keeps it
prose-wrap = "preserve" Prose keeps its line breaks, as under prettier's proseWrap: "preserve"
brace-spacing = false yamlfix also leaves braces unpadded; prettier pads them
comment-spacing = 2 The default of ruff and yamlfix
comment-starting-space = "add" Adds a space after #
max-blank-lines = 2 Keeps short gaps between content
sequence-style = "preserve" Restyling a collection is opt-in
mapping-style = "preserve" Restyling a collection is opt-in
sequence-expand = "preserve" Rewrapping a flow collection is opt-in
mapping-expand = "preserve" Rewrapping a flow collection is opt-in
property-order = "preserve" Writers split: prettier and the spec's examples put the tag first, eemeli's yaml and libfyaml the anchor
indent-sequences = true prettier also indents them
dash-on-own-line = false prettier writes - name: web
preview = false Preview styles are opt-in, as in ruff
line-length = 80 The default of prettier
indent-width = 2 The default of prettier and yamlfix
Fixed layout above Every formatter probed agrees

Long lines

Use prose-wrap for new configs. fold-long-lines is legacy; never set both, even fold-long-lines = false.

prose-wrap controls paragraphs in plain and quoted values in block context and folded (>) bodies:

  • "preserve" keeps their physical breaks without joining or wrapping.
  • "always" joins each paragraph, then wraps it at line-length (default 80).
  • "never" joins each paragraph without wrapping it to the configured width.

Wrapping and quotes are separate

The default keep-quotes = false removes optional quotes, even with prose-wrap = "preserve". Set keep-quotes = true to keep existing quotes.

# before
message: "hello world"

# after, with prose-wrap = "preserve" and keep-quotes = true
message: 'hello world'

Paragraph breaks and more-indented folded sections keep their newline semantics. The prose setting preserves scalar styles, tags, anchors and comments. Literal (|) bodies, keys and flow-context scalars are excluded. Quote normalization remains independent: retaining optional quoted prose requires keep-quotes = true.

# before, or with prose-wrap = "preserve"
message: >
  hello
  world

# after, with prose-wrap = "always" or "never"
message: >
  hello world

Expression wrapping

Under prose-wrap = "always", TOML-only [[format.prose]] entries select scalars by file and mapping path:

line-length = 60
[format]
prose-wrap = "always"

[[format.prose]]
files = ["*.yaml"]
path = "$.expression"
break-before = ["&&", "||"]
protected-patterns = ['"([^"\\]|\\.)*"', "'([^'\\\\]|\\\\.)*'"]

The first entry matching both files and path wins; entries never merge. files uses file glob matching, including ! exclusions. path uses the same selector subset as custom key ordering: $, .name, ['name'], [*] and .*. Empty file/token lists, empty or whitespace-bearing tokens, invalid globs, selectors and regexes are config errors (exit 2). protected-patterns defaults to an empty list.

Only existing YAML-foldable single spaces before a configured token can break. The last fitting boundary wins; an overlong clause stays whole. Tabs and double spaces never become break points. Short expressions join normally; folded scalars keep their header and chomping mode:

expression: >-
  has(object.spec.securityContext)
  && object.spec.securityContext.runAsNonRoot == true
  && object.spec.securityContext.runAsUser >= 1000

Protected regex matches describe the text forms your expressions use, after YAML quote decoding. Ryl has no embedded-language parser or built-in literal grammar. Raw/triple quotes, comments and malformed literals need additional patterns or suppression; ryl cannot prove your patterns cover every literal. Paragraphs, more-indented content and YAML escapes retain the ordinary prose safety rules. Other prose policies and ryl check --fix ignore the preferences. Without entries, formatting performs no expression selection, regex matching or decoding.

Legacy line folding

When prose-wrap is absent, fold-long-lines defaults to false.

With fold-long-lines = true, ryl format splits scalar lines longer than the top-level line-length (default 80) at single spaces. Folding applies to plain and quoted values in block context, and folded (>) scalar lines at their content indent. For plain and quoted values, the new line takes the indent of the scalar's existing continuation lines, or else sits indent-width past the column of the collection that owns the value:

# before
items:
  - description: This single line is well over eighty characters wide and so the formatter should fold it.
# after, with fold-long-lines = true
items:
  - description: This single line is well over eighty characters wide and so the
      formatter should fold it.

Folded (>) scalars keep their content indent; more-indented lines stay whole. Keys, flow collections, literal (|) scalars, and words with no space to break at stay as they are. Folding ignores the line-length rule's own options, and ryl check --fix never folds.

Collection style

Upgrading from 0.28

With sequence-style = "flow" or mapping-style = "flow", existing long flow collections can now become block. Leave the style at "preserve" to retain existing collection styles, or raise line-length to accommodate longer ones.

With sequence-style or mapping-style set to "block", ryl format rewrites flow collections of that kind in block style, indented by indent-width, copying each entry's text. An inline comment after the collection moves to its key's line:

# before
items: [one, two]  # shopping
metadata: {name: example}
# after, with both set to "block"
items:  # shopping
  - one
  - two
metadata:
  name: example

Empty [] and {} stay flow. A collection that holds a comment, a multi-line entry, a collection or empty key, or an entry some loaders would read differently in block style stays as written, and ryl format says why on stderr. So does a collection followed by a ytt #@ directive on its line, since ytt binds the directive to the last node on the line, and moving it to the key's line rebinds it. If the document cannot be re-indented safely, flow collections in that document stay flow, with a refusal notice. Block-to-flow conversions and conversions in other documents can still proceed.

When a nested block scalar has only blank body lines before content dedents past its header, ryl format leaves the file unchanged and reports a refusal: the YAML reference parser can still read the dedented text as scalar content. A sibling key at the same indent can trigger the same refusal when a sequence dash may move. The same protection applies when indented # text and blank lines form scalar content. ryl check --fix also reports the file, line and reason on stderr and leaves the file unchanged, apart from independently safe key ordering. In Markdown the refusal covers only the embedded YAML region that holds the scalar; other regions are still formatted and fixed. Compact explicit-key sequences with blank scalar lines are refused when spacing the header would change the scalar's content indent. For other block scalars, re-indentation moves value-bearing blank-line spaces with the scalar header.

With "flow", a block collection of scalars and aliases that is not the document root becomes one flow line, such as items: [one, two], when it holds no comment and the line fits line-length. With sequence-expand = "auto" or mapping-expand = "auto", the flow line can fit beside or below its mapping key: at line-length = 5, both a: [b] and a block sequence under a become a: followed by [b]. Block scalars, multi-line or empty entries, and plain scalars holding ,[]{} or starting with : or ? keep it block. A flow collection whose one line would not fit line-length becomes block, and each collection nested in it is then judged the same way at its new position:

# before, with line-length = 30
nested: [[alpha, beta], [delta, epsilon, zeta, eta]]
# after, with both set to "flow"
nested:
  - [alpha, beta]
  - - delta
    - epsilon
    - zeta
    - eta

Collection layout uses the final scalar spellings, indentation and document markers on the first run. Properties on their own line stay there when measuring flow width; a trailing comment on a standalone collection stays with that value.

Flow line breaks

sequence-expand and mapping-expand control line breaks inside flow collections:

Value Layout
"preserve" (default) Keep existing breaks
"never" One line
"always" One entry per line
"auto" First layout below that fits line-length

With sequence-style = "flow" or mapping-style = "flow", width handling can override "preserve": if the expanded placement would overflow but the collection fits inline beside its key, the overflow fallback emits inline flow on the first run.

"auto" tries, in order:

  1. One line where the collection starts.
  2. One line below its mapping key (for either a sequence or a mapping value).
  3. One entry per line.

A spread collection follows prettier: its opening bracket goes on the line after its key, and every entry ends in a comma:

# before, with line-length = 60
items: [first-item-with-long-name, second-item-with-long-name, third, fourth, fifth]
short: [
  a, b,
  ]
# after, with sequence-expand = "auto"
items:
  [
    first-item-with-long-name,
    second-item-with-long-name,
    third,
    fourth,
    fifth,
  ]
short: [a, b]

At the default line-length = 80, the same items collection instead fits alone below the key:

# after, with sequence-expand = "auto" and the default line-length
items:
  [first-item-with-long-name, second-item-with-long-name, third, fourth, fifth]
short: [a, b]

Flow closing brackets and braces must be deeper than the enclosing block. A closer at column zero, as below, is repaired and prints input was YAML the spec rejects; repaired it; --check exits 1:

# before
items: [
  a, b
]
# after, with sequence-expand = "preserve"
items: [
  a, b
 ]

A trailing comma does not keep a collection spread; with either key set, one before a bracket on its own line stays, where ryl format otherwise removes it. Each nested collection is judged at its own line, and one that must spread spreads its parents too. A sequence entry keeps its [ on the - line, re-indented as the indentation rule expects; one after a second - on the line, as in - - [, stays as written rather than spread. A comment after a collection is left out of the width and rules out the move to the next line. A spread collection keeps its [ and the comment on the key line, so the comment keeps its place among the data:

# input and output, sequence-expand = "auto"
key: [  # note
  alpha-package-name,
  beta-package-name,
 ]

A collection that holds a comment stays as written, with a notice on stderr where its target rejects its current form. With *-style = "flow", a collection that fits on one line keeps its *-expand layout, and under "always" a block collection stays block rather than become a spread flow one.

Property order

property-order applies to nodes with both an anchor (&name) and a tag (!!seq). The default "preserve" keeps their order; choose "anchor-first" or "tag-first" to normalize it:

# before
items: !!seq &list [one, two]

# after, with property-order = "anchor-first"
items: &list !!seq [one, two]

Quote style

By default, ryl format quotes a string only where its plain form would load as something else, using quote-style:

# before
a: "x"
b: "123"
c: "it's"
d: "tab\there"
e: 'it''s: x'
f: "say \"hi\": x"
# after, with quote-style = "single"
a: x
b: '123'
c: it's
d: "tab\there"
e: "it's: x"
f: 'say "hi": x'

A string that needs quoting takes whichever quotes avoid an escape: single when it contains ", double when it contains only ', else quote-style. A string that needs escape sequences stays double-quoted. Physical line breaks alone do not require double quotes: conversion to single quotes preserves the continuation lines and blank lines, including their YAML folding. A string that YAML 1.1 loads as a boolean, such as "yes", "NO" or "on", keeps its quotes, so truthy stays clean. So do "y", "Y", "n" and "N", which go-yaml v2, and so Kubernetes, loads as booleans. Mapping keys follow the same rules. A document that declares %YAML 1.2, or any document under the top-level target-version = "1.2", drops those 1.1-only quotes; see YAML version compatibility.

Set keep-quotes = true to retain optional quotes while normalizing their character with the same escape-avoidance rules. Multi-line quoted strings keep their physical line breaks when their quote character changes. With quote-style = "preserve", quoting stays untouched regardless of keep-quotes.

[format]
keep-quotes = true
quote-style = "double"
# before
plain: hello
quoted: 'hello'

# after
plain: hello
quoted: "hello"

Required quotes

When quoted-strings is enabled, formatting adds quotes required by required = true or matching extra-required patterns. Patterns match decoded values. check-keys = true extends those requirements to keys; ordinary key quote normalization always applies. extra-allowed retains matching existing quotes without adding quotes to plain strings. Disabled rules retain the formatter's default quoting policy.

[lint.rules.quoted-strings]
required = false
extra-required = ['\?']
# before
args: [/health?ready=true]
# after
args: [/health?ready=true]

Existing plain flow strings and keys retain their bytes when only extra-required or extra-required-flow would add compatibility quotes. Some readers interpret a leading ? differently after quoting; lint still reports missing quotes for the user to decide. Block strings converted to flow still receive compatibility quotes.

If converting a flow collection to block would require quoting one of those retained plain strings or keys, the collection stays in flow. Other collections still follow the configured style. The same protection applies to width-driven flow-to-block changes, keeping repeated formatting stable.

Only strings under the effective YAML version receive quotes: booleans, numbers, nulls and YAML 1.1 timestamps stay typed. Explicit version directives override target-version. Wrapped plain strings retain continuation and blank lines under prose-wrap = "preserve"; "always" and "never" reflow using the selected quoting. Block scalars stay unchanged.

quote-style = "preserve" freezes all quoting, including missing required quotes; ryl check may still report them. keep-quotes = true wins over required = "only-when-needed" and warns when retained optional quotes conflict. quote-style and escape avoidance choose the quote character; incompatible lint quote-type or escape exceptions warn with the winning setting and a remedy.

Adding quotes to an implicit key is refused if the selected spelling, including escapes and properties, would exceed YAML's 1,024-character simple-key limit. The formatter reports the refusal; shorten the key or use explicit ? syntax. Scalars inside an implicit collection key never gain quotes. Inline suppression and formatter suppression can also leave required quotes missing. With compatible settings and no collection keys, refusals or suppression, quoted-string output passes ryl check under the same config.

Preview style

preview = true opts in to style changes before they become stable. As in ruff, the stable style changes only in a minor release, by promoting a preview style, while a preview style can change in any release. A fix for invalid output, a changed value or a lost comment can ship in any release. No preview styles exist yet, so preview changes nothing today.

YAML in Markdown

ryl format formats YAML front matter and fenced YAML blocks in Markdown files matched by [files].markdown, as described in YAML in Markdown, or every input given --markdown, as with ryl check.

If formatting would create a line that closes a YAML fence, ryl leaves that region unchanged and names the refusal on stderr. Other regions still format. The same guard applies to editor formatting. When formatting would change a region that mixes CRLF and LF line endings, ryl leaves the region unchanged with a notice and --check / --diff exit 1. An already formatted mixed region is quiet.

Suppression

ryl format honours the same inline directives as ryl check: a # ryl disable-file comment leaves the file alone, and # ryl disable rule:quoted-strings or disable-line rule:quoted-strings stops that rule's formatting where it applies. For formatter-only node or region suppression, use format-ignore or format-disable / format-enable. Lint configuration's [[lint.per-line-ignores]] and [lint.per-file-ignores] suppress lint findings and safe check --fix edits, but do not gate ryl format.

Conflicting lint rules

The formatter's layout is also checked by lint rules, and they stay lint rules: ryl check still reports them, and ryl check --fix still fixes the fixable ones. When one of them is enabled with options that reject what ryl format writes, every ryl format run warns on stderr, for example:

warning: the quoted-strings lint rule's options (quote-type = "double", allow-quoted-quotes = false, allow-double-quotes-for-escaping = false) conflict with format.quote-style = "single" and its escape avoidance; format.quote-style wins. Use TOML with lint.rules.quoted-strings.quote-type = "any" and allow-double-quotes-for-escaping = true, or set format.quote-style = "preserve".

--no-warnings silences it. A rule left at its defaults conflicts only where the table says so.

Rule Conflicts with ryl format when
braces forbid is set and [format] mapping-style is not "preserve", min-spaces-inside-empty is above 0, or min-spaces-inside to max-spaces-inside excludes the brace-spacing padding (0, or 1 when true)
brackets forbid is set and [format] sequence-style is not "preserve", or min-spaces-inside or min-spaces-inside-empty is above 0
commas min-spaces-after is above 1, or max-spaces-after is 0
comments min-spaces-from-content is above [format] comment-spacing, or max-spaces-from-content is below it (-1, the default, is unlimited); or ignore-shebangs = false while require-starting-space = true under [format] comment-starting-space = "add", since a shebang keeps its #!
comments-indentation Never
document-start present = false with [format] document-start = "add", or present = true with "remove"
document-end present = false with [format] document-end = "add"
empty-lines max is below [format] max-blank-lines
new-line-at-end-of-file Never
new-lines type resolves to a different ending from [format] line-ending, or line-ending = "auto", which writes either
quoted-strings See below; never under quote-style = "preserve"
trailing-spaces Never
colons max-spaces-after is 0
hyphens max-spaces-after is 0, or dash-on-own-line = true while [format] dash-on-own-line = false
indentation spaces is a number other than indent-width (2 when unset); or indent-sequences is the opposite of [format] indent-sequences
line-length Never; folding is opt-in and leaves lines it cannot break

The table compares formatter settings with lint options; it does not promise every finding can be fixed. A keep-chomped (|+/>+) tail can exceed empty-lines max, and trailing spaces inside a block scalar can remain findings after ryl format and ryl check --fix because removing them would change the scalar value.

quoted-strings accepts the formatter's output for every supported required mode and extra-required pattern when quote-type is either "any" or matches quote-style. A quote-type of "single" or "double" also needs allow-quoted-quotes = true, for strings quoted to avoid an escape. Under required = "only-when-needed", set allow-double-quotes-for-escaping = true to retain optional escaped double quotes, including a literal backslash. A single-quote lint preference also needs the escape exception for necessary escapes. The rule's defaults (required = true) add quotes:

[lint.rules]
quoted-strings = "enable"

These quoted-strings configs accept the formatter's output:

[lint.rules.quoted-strings]
quote-type = "any"
required = "only-when-needed"
allow-double-quotes-for-escaping = true
[lint.rules.quoted-strings]
quote-type = "single"
required = "only-when-needed"
allow-double-quotes-for-escaping = true
allow-quoted-quotes = true
[format]
quote-style = "double"

[lint.rules.quoted-strings]
quote-type = "double"
required = "only-when-needed"
allow-double-quotes-for-escaping = true
allow-quoted-quotes = true

A YAML config cannot set allow-double-quotes-for-escaping. To accept optional escaped quotes there, use quote-type: any and required: false:

rules:
  quoted-strings:
    quote-type: any
    required: false

The other conflicts follow the table:

[format]
document-start = "add"

[lint.rules.document-start]
present = false
[lint.rules.document-start]
present = false
[format]
brace-spacing = true

[lint.rules.braces]
min-spaces-inside = 1
max-spaces-inside = 1
min-spaces-inside-empty = 0
max-spaces-inside-empty = 0
[lint.rules.commas]
max-spaces-after = -1

[lint.rules.comments]
max-spaces-from-content = -1

The other eleven rules check things ryl format never changes, so they never conflict with it: anchors, block-scalar-chomping, empty-values, float-values, key-duplicates, key-ordering, merge-keys, octal-values, tags, truthy and unicode-line-breaks. truthy and key-ordering keep their ryl check --fix fixes.

To lint alongside ryl format, start from the recommended starter config, which enables only rules the formatter never touches and leaves layout to ryl format --check.

Running with ryl check --fix

# ryl format-ignore and formatter regions do not stop ryl check --fix from rewriting protected nodes; lint fixes remain active.

Run ryl check --fix before ryl format, in a pre-commit or prek config as on the command line, so the formatter has the last word on layout; ruff gives the same order for ruff check --fix and ruff format. Re-indenting can still push a line past line-length, which the line-length rule then reports (see Conflicting lint rules), so lint a formatted file rather than relying on the check that ran before formatting.

Exit codes

Code ryl format ryl format --check / --diff
0 Files formatted, or nothing to do No file would change; a symlinked input is refused on stderr but still exits 0
1 Not used At least one file would change, a mixed-newline Markdown region needs formatting, or a ragged Markdown region retains layout findings
2 A usage or config error, an unreadable or unwritable file, a file no [files] glob matches, or a Jinja template A usage or config error, an unreadable file, a file no [files] glob matches, or a Jinja template

A failed write names the file on stderr; formatting continues with the remaining files. A file skipped for a syntax error does not change the exit code.