Skip to main content

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.

Pretty-prints COPY and ADD heredoc bodies when the destination filename has a supported structured-data extension.
PropertyValue
SeverityStyle
CategoryStyle
DefaultEnabled
Auto-fixYes (safe)

Description

This rule formats heredoc payloads that are copied into JSON, YAML, TOML, XML, or INI files. It detects the file type from the heredoc destination path extension and uses the repository’s .editorconfig settings for indentation. YAML heredocs can also use max_line_length as a preferred scalar wrapping width. For EditorConfig lookup, tally resolves a virtual filename next to the Dockerfile using the destination basename. For example, a heredoc in services/api/Dockerfile targeting /etc/app/config.yaml is matched as services/api/config.yaml, so selectors such as *.yaml and config.yaml apply naturally. The formatter also runs as a final auto-fix pass. This means heredocs emitted by other rules, such as tally/prefer-copy-heredoc, are formatted in the same --fix run when this rule is enabled.

Examples

Bad

FROM alpine:3.20
COPY <<EOF /etc/app/config.json
{"b":2,"a":1}
EOF

Good

FROM alpine:3.20
COPY <<EOF /etc/app/config.json
{
  "b": 2,
  "a": 1
}
EOF

Supported Types

ExtensionFormat
.jsonJSON
.yaml, .ymlYAML
.tomlTOML
.xml, .config, .xsd, .wsdl, .xsl, .xsltXML
.iniINI

Configuration

Default (no config needed):
# Enabled by default with no rule-specific options
This rule intentionally has no formatter-specific options. Use .editorconfig for indentation style and width, and for YAML scalar wrapping width. See EditorConfig integration for recommended Dockerfile settings and path resolution details. The rule reads indent_style, indent_size, tab_width, and YAML-only max_line_length. max_line_length is treated as a preferred wrapping width, not a hard maximum. It does not currently interpret insert_final_newline, end_of_line, charset, or trim_trailing_whitespace for the virtual payload file. Formatted heredoc bodies always end with exactly one newline before the heredoc terminator, and line endings follow the parent Dockerfile/fix application rather than a separate payload setting. The current structured serializers do not emit incidental trailing whitespace, but tally does not run a separate trailing-whitespace trim pass because whitespace can be payload data.

Auto-fix

Run:
tally lint --fix Dockerfile
To format heredocs produced by another selected rule, select both rules:
tally lint --fix --fix-unsafe \
  --select tally/prefer-copy-heredoc \
  --select tally/prefer-formatted-heredocs \
  Dockerfile