Skip to content

new-lines

What this rule does

Checks the first line break against the configured style — Unix (LF), DOS/Windows (CRLF), or whatever the host platform produces. Automatic fixing normalizes every line ending, including later mixed endings that lint does not report.

Why this matters

  • Cross-platform contributors. Mixed CRLF and LF line endings show up in diffs as full-file changes when a contributor's editor normalises them.
  • Tool compatibility. Some YAML consumers and shell utilities behave unexpectedly with the "wrong" line ending for the platform.

Configuration

[lint.rules.new-lines]
level = "error"
type = "unix"
Option Default Description
type "unix" "unix" (LF), "dos" (CRLF), or "platform" to match the host operating system.

Examples

The rule operates on the bytes of the file, so visible examples are limited. With type: "unix":

✅ Allowed

A file whose first line break is \n, even if later endings differ.

❌ Reported

A file whose first line break is \r\n.

🔧 After ryl check --fix

ryl check --fix rewrites the file so every line ends with the configured character sequence.

Bare carriage returns

A bare \r (a carriage return not part of \r\n) is a YAML 1.2 line break, so ryl treats it as a line ending here too. It is never one of the configurable styles (unix/dos/platform), so when the file's first line break is a bare \r the rule reports it as wrong and ryl check --fix rewrites it to the configured ending. This is a deliberate divergence from yamllint, whose line layer cannot see a bare \r and whose type has no mac value; on supported LF/CRLF files the behaviour is identical. See Migrating from yamllint.

Automatic fixing

ryl check --fix rewrites all line endings to match type. Disable with:

[lint]
fixable = ["ALL"]
unfixable = ["new-lines"]

ryl format rewrites line endings to [format] line-ending, lf by default. It conflicts with a type that resolves to a different ending, and with any type under line-ending = "auto"; see Conflicting lint rules.