Skip to main content
Enforces a newline at the end of non-empty files.
PropertyValue
SeverityStyle
CategoryStyle
DefaultEnabled
Auto-fixYes (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 with cat. 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”)

FROM alpine:3.20
RUN apk --no-cache add ca-certificates
ENTRYPOINT ["/app"]⌁
(where marks the end of file with no trailing newline)

Good (mode: “always”)

FROM alpine:3.20
RUN apk --no-cache add ca-certificates
ENTRYPOINT ["/app"]

Configuration

Default (no config needed):
# Enabled by default with mode = "always"
Disable the rule:
[rules.tally.eol-last]
severity = "off"
Require files to not end with a newline:
[rules.tally.eol-last]
mode = "never"

Options

OptionTypeDefaultDescription
modestring"always""always" requires a final newline; "never" prohibits it

Auto-fix

This rule provides a safe auto-fix:
tally lint --fix Dockerfile
  • In "always" mode, a missing final newline is appended.
  • In "never" mode, the trailing newline is removed.