| Property | Value |
|---|---|
| Severity | Style |
| Category | Style |
| Default | Enabled |
| Auto-fix | Yes (safe) |
Description
POSIX defines a line as a sequence of characters ending with a newline. Files that lack a trailing newline can cause issues with file concatenation, produce messy diffs in version control, and interfere with shell prompts when printed withcat. This rule enforces (or prohibits) a final newline in
Dockerfiles, mirroring ESLint’s eol-last rule.
In the default "always" mode, the rule reports a violation when a non-empty file does not end with \n. In "never" mode, it reports when a file
does end with \n.
Empty files (zero bytes) are always ignored.
Examples
Bad (mode: “always”)
⌁ marks the end of file with no trailing newline)
Good (mode: “always”)
Configuration
Default (no config needed):Options
| Option | Type | Default | Description |
|---|---|---|---|
mode | string | "always" | "always" requires a final newline; "never" prohibits it |
Auto-fix
This rule provides a safe auto-fix:- In
"always"mode, a missing final newline is appended. - In
"never"mode, the trailing newline is removed.
Related Rules
tally/no-multiple-empty-lines— controls excess blank lines at the end (and beginning) of filestally/no-trailing-spaces— removes trailing whitespace on individual lines