> ## Documentation Index
> Fetch the complete documentation index at: https://tally.wharflab.com/llms.txt
> Use this file to discover all available pages before exploring further.

# tally/eol-last

> Enforces a newline at the end of non-empty files.

Enforces a newline at the end of non-empty files.

| 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 with `cat`. This rule enforces (or prohibits) a final newline in
Dockerfiles, mirroring ESLint's [`eol-last`](https://eslint.style/rules/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.

## Companion editor configuration

Use [EditorConfig integration](/integrations/editorconfig) to configure IDEs and editors to insert the final newline before tally reports it.

## Examples

### Bad (mode: "always")

```dockerfile theme={null}
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")

```dockerfile theme={null}
FROM alpine:3.20
RUN apk --no-cache add ca-certificates
ENTRYPOINT ["/app"]
```

## Configuration

Default (no config needed):

```toml theme={null}
# Enabled by default with mode = "always"
```

Disable the rule:

```toml theme={null}
[rules.tally.eol-last]
severity = "off"
```

Require files to **not** end with a newline:

```toml theme={null}
[rules.tally.eol-last]
mode = "never"
```

## 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:

```bash theme={null}
tally lint --fix Dockerfile
```

* In `"always"` mode, a missing final newline is appended.
* In `"never"` mode, the trailing newline is removed.

## Related Rules

* [`tally/no-multiple-empty-lines`](./no-multiple-empty-lines) — controls excess blank lines at the end (and beginning) of files
* [`tally/no-trailing-spaces`](./no-trailing-spaces) — removes trailing whitespace on individual lines
