Skip to content

new-line-at-end-of-file

What this rule does

Requires the file to end with a trailing newline character.

Why this matters

  • POSIX text files are defined as a sequence of zero or more lines, each terminated by a newline. Many tools (concat, cat, version control diff renderers) behave unexpectedly without the trailing newline.
  • Editor friendliness. Most editors silently add or strip a trailing newline on save; pinning the rule keeps diffs from oscillating between contributors.

Configuration

[lint.rules.new-line-at-end-of-file]
level = "error"

This rule has no options beyond level.

Examples

✅ Allowed

---
key: value

(File ends with a single \n after the last line.)

❌ Reported

A file whose final byte is not a newline character. (Trailing blank lines are not this rule's concern; see empty-lines.)

🔧 After ryl check --fix

ryl appends a single newline when the file does not already end with one.

Automatic fixing

ryl check --fix appends a trailing newline when one is missing, including after a block scalar header or body. A spaces-only final block-scalar line keeps its spaces when only this rule runs; document-end can remove indentation spaces before adding .... Disable with:

[lint]
fixable = ["ALL"]
unfixable = ["new-line-at-end-of-file"]

ryl format applies the same fix, ending the file with the [format] line-ending, and no option of this rule conflicts with it.

  • empty-lines — controls multiple empty lines at the end of file (distinct from the trailing newline).
  • new-lines — controls which line ending character is used.