Skip to content

Linter friendly YAML output #591

@abitrolly

Description

@abitrolly

YAML files produced by dump are not linter friendly.
Example dumped.yaml is attached.

require 'psych'

loaded = Psych.load_file('feature_flags.yaml')
#puts loaded

#puts Psych.methods
File.write 'dumped.yaml', Psych.dump(loaded)
$ yamllint dumped.yaml
feature_flags.yaml
  4:3       error    wrong indentation: expected 4 but found 2  (indentation)
  5:81      error    line too long (82 > 80 characters)  (line-length)
  12:81     error    line too long (82 > 80 characters)  (line-length)
  19:81     error    line too long (82 > 80 characters)  (line-length)
  26:81     error    line too long (82 > 80 characters)  (line-length)
  33:81     error    line too long (82 > 80 characters)  (line-length)
  34:23     error    trailing spaces  (trailing-spaces)
  40:81     error    line too long (82 > 80 characters)  (line-length)
  47:81     error    line too long (82 > 80 characters)  (line-length)
  54:81     error    line too long (87 > 80 characters)  (line-length)
...

So how to produce linter friendly YAML with Psych?

yamlrb.tar.gz

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions