perlpunk / yamltidy

Automatic cleanup of YAML files
https://perlpunk.github.io/yamltidy
Other
6 stars 0 forks source link

Allow to remove quotes where they are unnecessary #10

Open perlpunk opened 4 years ago

perlpunk commented 4 years ago

This is probably simple at least for single-line scalars.

YAML::PP::Schema allows to check to what type a scalar would be loaded.

ingydotnet commented 3 years ago

If yamltidy did this I would constantly promote it.

People constantly use quotes where they are not needed. And they use double quotes where single quotes would be more appropriate.

I would make the behavior:

as much as the specific value allows.

Literal and folded are pretty much always used purposefully so I wouldn't change them.

I would make "less quoting" the default, but provide an option not to.

perlpunk commented 3 years ago

yes, I agree. I would like to use the same or similar options as yamllint (where it is possible/makes sense), see https://yamllint.readthedocs.io/en/stable/rules.html#module-yamllint.rules.quoted_strings

It allows to specify a regex for custom strings that should be quoted.

perlpunk commented 2 years ago

in version 0.003_002 you can try it out. for now it only works on single line scalars. by default single and double quotes are turned to plain if the schema allows it.

it does not yet work in flow style collections.

perlpunk commented 2 years ago

Want to try out https://metacpan.org/release/TINITA/YAML-Tidy-0.006_001 ?