From 7767ebf84511f24b0537a7294d36fd96d49242bb Mon Sep 17 00:00:00 2001 From: Eric Thelin Date: Fri, 5 Jun 2026 11:24:24 +0200 Subject: [PATCH] style(yaml): preserve newlines in folded block scalars From the official documentation of yamlfmt: > Option that will preserve newlines in folded block scalars (blocks > that start with >). Without this option newlines in folded block scalars are always replaced with spaces. This defeats the purpose of using a folded block scalar. Consider this YAML: example_of_folded_block_scalar: > Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. The above is an example of a folded block scalar (as denoted by the `>` syntax). It is a way to break a long string into multiple lines for better readability. The newlines are interpreted as spaces. However, without `scan_folded_as_literal: true` the linter would replace the newlines with spaces and place the whole text on a single line: example_of_folded_block_scalar: > Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. This is counterproductive. If I wanted to put the whole thing on a single line, I would use a regular string and not a folded block scalar. See: https://yaml.cc/tutorial/yaml-multiline-string.html See: https://github.com/google/yamlfmt/blob/main/docs/config-file.md Signed-off-by: Eric Thelin --- linters/config/.yamlfmt | 1 + 1 file changed, 1 insertion(+) diff --git a/linters/config/.yamlfmt b/linters/config/.yamlfmt index a4f85ae..59388e5 100644 --- a/linters/config/.yamlfmt +++ b/linters/config/.yamlfmt @@ -18,3 +18,4 @@ exclude: formatter: type: basic retain_line_breaks_single: true + scan_folded_as_literal: true