Hi all,
I would like to know what do you think about using an opinionated code formatter for our ansible repo ? I think this would help with enforcing a common style and make our yaml files easier to read and maintain.
I have been looking at https://prettier.io/ which support yaml and I ran it on the repo's playbooks directory (see attached patch). Most of the changes are indentation but we could enforce more rules using prettier's configuration options if we wish (vhttps://prettier.io/docs/en/configuration.html).
Prettier looks quite cool but the only down side is that it is a Javascript application and it is currently not packaged in Fedora, I have used a container to run it on my laptop.
Anyway what do you think about it ? Does anybody knows an alternative to prettier ?
I think this is be really nice. It will make our code easy to read and it could help prevent syntax error when bad indentation is used.
mkonecny
On 05/03/19 09:27, Clement Verna wrote:
Hi all,
I would like to know what do you think about using an opinionated code formatter for our ansible repo ? I think this would help with enforcing a common style and make our yaml files easier to read and maintain.
I have been looking at https://prettier.io/ which support yaml and I ran it on the repo's playbooks directory (see attached patch). Most of the changes are indentation but we could enforce more rules using prettier's configuration options if we wish (vhttps://prettier.io/docs/en/configuration.html).
Prettier looks quite cool but the only down side is that it is a Javascript application and it is currently not packaged in Fedora, I have used a container to run it on my laptop.
Anyway what do you think about it ? Does anybody knows an alternative to prettier ?
infrastructure mailing list -- infrastructure@lists.fedoraproject.org To unsubscribe send an email to infrastructure-leave@lists.fedoraproject.org Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/infrastructure@lists.fedorapro...
On 3/5/19 9:27 AM, Clement Verna wrote:
Hi all,
I would like to know what do you think about using an opinionated code formatter for our ansible repo ? I think this would help with enforcing a common style and make our yaml files easier to read and maintain.
I have been looking at https://prettier.io/ which support yaml and I ran it on the repo's playbooks directory (see attached patch). Most of the changes are indentation but we could enforce more rules using prettier's configuration options if we wish (vhttps://prettier.io/docs/en/configuration.html).
Prettier looks quite cool but the only down side is that it is a Javascript application and it is currently not packaged in Fedora, I have used a container to run it on my laptop.
Anyway what do you think about it ? Does anybody knows an alternative to prettier ?
Hi Clement,
The most standrd solution should be yamlint.
It is also packaged in Fedora: yamllint.noarch : A linter for YAML files
It does not autofix the code but it warns you:
-> yamllint stuff.yaml stuff.yaml 196:23 error trailing spaces (trailing-spaces) 278:11 warning too few spaces before comment (comments) 279:11 warning too few spaces before comment (comments) 280:11 warning too few spaces before comment (comments)
I use it with overcommit (https://github.com/brigade/overcommit), toghether they prevents to commit if there are errors.
It is also configurable, of course.
On Tue, 5 Mar 2019 at 09:59, Alessandro Lorenzi alorenzi@alorenzi.eu wrote:
On 3/5/19 9:27 AM, Clement Verna wrote:
Hi all,
I would like to know what do you think about using an opinionated code formatter for our ansible repo ? I think this would help with enforcing a common style and make our yaml files easier to read and maintain.
I have been looking at https://prettier.io/ which support yaml and I ran it on the repo's playbooks directory (see attached patch). Most of the changes are indentation but we could enforce more rules using prettier's configuration options if we wish (vhttps://prettier.io/docs/en/configuration.html).
Prettier looks quite cool but the only down side is that it is a Javascript application and it is currently not packaged in Fedora, I have used a container to run it on my laptop.
Anyway what do you think about it ? Does anybody knows an alternative to prettier ?
Hi Clement,
The most standrd solution should be yamlint.
It is also packaged in Fedora: yamllint.noarch : A linter for YAML files
Ha nice it will be easier to use than prettier and can be used enforce the formatting.
Thanks
It does not autofix the code but it warns you:
-> yamllint stuff.yaml stuff.yaml 196:23 error trailing spaces (trailing-spaces) 278:11 warning too few spaces before comment (comments) 279:11 warning too few spaces before comment (comments) 280:11 warning too few spaces before comment (comments)
I use it with overcommit (https://github.com/brigade/overcommit), toghether they prevents to commit if there are errors.
It is also configurable, of course.
-- Alessandro Lorenzi
On 3/5/19 4:56 AM, Clement Verna wrote:
On Tue, 5 Mar 2019 at 09:59, Alessandro Lorenzi alorenzi@alorenzi.eu wrote:
...snip...
The most standrd solution should be yamlint.
It is also packaged in Fedora: yamllint.noarch : A linter for YAML files
Ha nice it will be easier to use than prettier and can be used enforce the formatting.
I like the idea of doing a mass run to fix things first, then using yamllint to keep it nice.
There is also ansible-lint, but thats more for ansible specific rules...
kevin
we can also start using molecule hat has a lot of this inside already.
Jonathan Lozada De La Matta
Sent with ProtonMail Secure Email.
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Wednesday, March 6, 2019 6:42 PM, Kevin Fenzi kevin@scrye.com wrote:
On 3/5/19 4:56 AM, Clement Verna wrote:
On Tue, 5 Mar 2019 at 09:59, Alessandro Lorenzi alorenzi@alorenzi.eu wrote:
...snip...
The most standrd solution should be yamlint. It is also packaged in Fedora: yamllint.noarch : A linter for YAML files
Ha nice it will be easier to use than prettier and can be used enforce the formatting.
I like the idea of doing a mass run to fix things first, then using yamllint to keep it nice.
There is also ansible-lint, but thats more for ansible specific rules...
kevin
infrastructure mailing list -- infrastructure@lists.fedoraproject.org To unsubscribe send an email to infrastructure-leave@lists.fedoraproject.org Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/infrastructure@lists.fedorapro...
infrastructure@lists.fedoraproject.org