> ## 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/no-multiple-empty-lines

> Disallows multiple consecutive empty lines in Dockerfiles.

Disallows multiple consecutive empty lines in Dockerfiles.

| Property | Value |
| - | - |
| Severity | Style |
| Category | Style |
| Default | Enabled |
| Auto-fix | Yes (safe) |

## Description

Multiple consecutive blank lines add visual noise and waste vertical space. This rule limits the number of consecutive empty lines allowed anywhere in
a Dockerfile, as well as at the beginning and end of the file. It mirrors ESLint's
[`no-multiple-empty-lines`](https://eslint.style/rules/no-multiple-empty-lines) rule.

A line is considered empty if it contains only whitespace characters (spaces, tabs).

### Heredoc handling

* **RUN heredocs** with a parseable shell (bash, sh, mksh): blank lines are flagged and fixable.
* **RUN heredocs** with an unknown shebang (e.g., `#!/usr/bin/env python3`): skipped entirely.
* **COPY heredocs**: skipped entirely (opaque file content).

## Examples

### Bad

```dockerfile theme={null}
FROM alpine:3.20


RUN apk add --no-cache curl



COPY . /app
```

### Good

```dockerfile theme={null}
FROM alpine:3.20

RUN apk add --no-cache curl

COPY . /app
```

## Configuration

Default (no config needed):

```toml theme={null}
# Enabled by default: max=1, max-bof=0, max-eof=0
```

Allow up to 2 consecutive blank lines:

```toml theme={null}
[rules.tally.no-multiple-empty-lines]
max = 2
```

Allow one blank line at beginning and end of file:

```toml theme={null}
[rules.tally.no-multiple-empty-lines]
max-bof = 1
max-eof = 1
```

## Options

| Option | Type | Default | Description |
| - | - | - | - |
| `max` | integer | `1` | Maximum consecutive empty lines allowed anywhere in the file |
| `max-bof` | integer | `0` | Maximum consecutive empty lines at the beginning of the file |
| `max-eof` | integer | `0` | Maximum consecutive empty lines at the end of the file |

## Auto-fix

This rule provides a safe auto-fix that removes excess blank lines:

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

Each group of consecutive excess blank lines is collapsed to the allowed maximum.


## Related topics

- [tally/eol-last](/rules/tally/eol-last.md)
- [powershell/PSPlaceCloseBrace](/rules/powershell/PSPlaceCloseBrace.md)
- [buildkit/NoEmptyContinuation](/rules/buildkit/NoEmptyContinuation.md)
- [tally/no-multi-spaces](/rules/tally/no-multi-spaces.md)
- [BuildKit rules](/rules/buildkit/overview.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.