chainguard-dev / yam

A sweet little formatter for YAML
Apache License 2.0
20 stars 10 forks source link

Fix comment processing #8

Closed luhring closed 1 year ago

luhring commented 1 year ago

This addresses a few cases where unexpected formatting would happen, either because of the upstream library (https://github.com/go-yaml/yaml) or because of yam itself.

  1. Comments being lost
  2. Comments in lists resulting in malformation

This also makes a change such that, before formatting is applied, all files undergo two "cleaning steps" that are common reasons for surprise structural encodings from https://github.com/go-yaml/yaml.

  1. All lines have any trailing spaces trimmed
  2. Ensures all files end with a final newline character