Skip to content

YAML formatting strips document begin #5013

@pbrisbin

Description

@pbrisbin

One thing I've noticed with the new YAML formatting (which is awesome btw!) is that it will strip a standalone (not part of frontmatter) document-separator (---). For example, you can see it happen in this PR diff (a commit made by Restyled, which runs prettier).

I don't have a definitive reference that it's good style to include these document delimiters when they're not strictly necessary, but I tend to include them because:

  1. yamllint has a rule (by default) that requires them, and

  2. I saw a tweet with this justification (paraphrased):

    If you concatenate multiple YAML documents into some process, e.g.

    cat one.yaml two.yaml | some-process

    Having document-separators in the files will ensure they get processed correctly (as multiple documents). Without the separators, you may silently get something unexpected (smashing of objects) or it might just error.

Because of point (1), it's particularly annoying when ALE runs prettier as an auto-fixer, which strips the ---, then it runs yamllint as a linter, which complains about its omission...

So, is it intentional to strip it? If so, can an option be added to preserve it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:yamlIssues affecting YAMLlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.status:has prIssues with an accompanying pull request. These issues will probably be fixed soon!

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions