Skip to main content
Disallows multiple consecutive empty lines in Dockerfiles.

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

Good

Configuration

Default (no config needed):
Allow up to 2 consecutive blank lines:
Allow one blank line at beginning and end of file:

Options

Auto-fix

This rule provides a safe auto-fix that removes excess blank lines:
Each group of consecutive excess blank lines is collapsed to the allowed maximum.