-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding YAML formatter #141
base: main
Are you sure you want to change the base?
Conversation
@mikealfare I listed what I found on each of the options for linters and formatters above and why I picked these 2. I didn't see too many other options that looked any different out there. Let me know if this is what you were hoping the for linter and formatter to achieve. I know you mentioned kebab casing, capitalization, etc. standardizing as well but none of the formatters are enforcing things like that so we would have to look at some more extensive tooling if you want that kind of standard enforced. |
- unlabeled | ||
- synchronize | ||
pull_request: | ||
types: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know why this list gets indented whereas lists in other files, e.g. pre-commit-config.yaml
align the bullets with the parent node?
rev: v2.14.0 | ||
hooks: | ||
- id: pretty-format-yaml | ||
args: [--autofix, --indent, '2', --offset, '2', --preserve-quotes] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should either make this a long form list (like black
's args
) or make other lists short form. I think one of the formatters also had an option for enforcing that automatically.
Thanks for the PR @leahwicz! I agree with your assessment above. I left two comments. Let me know your thoughts. |
resolves #137
Problem
Have a linter and formatter for GitHub workflows
Solution
This is one possible solution after looking at a few possibilities here is a summary of my findings
Linter Options
check-yaml
@ https://github.com/pre-commit/pre-commit-hooks - we actually are already using this so unless we are looking for more from a linter, we have this coveredyamllint
@ https://github.com/adrienverge/yamllint - this is extremely configurable which is nice but it doesn't autofix the files for you and instead you have to manually do it which is a painFormatter Options
pretty-format-yaml
@ https://github.com/macisamuele/language-formatters-pre-commit-hooks - does the job for indentation and line width if that's the prime focus. Will autofix for the developer. Actually is nice with keeping quotations persistent if we want to enable that.yamlfmt
@ https://github.com/jumanjihouse/pre-commit-hook-yamlfmt - forces each file to start with---
which isn't really the style that we are currently abiding by unless we want to changeyamlfmt
@ https://github.com/google/yamlfmt (requires Go) - the Go setup seems overkill for nothing extraThis PR shows the top vote options enabled and their changes.
I have it only enabled for GitHub workflow files at the moment. I also had it format the
.pre-commit-config.yaml
file as well since it was all over the place. If we enable it for all YAML files then a bunch of the changie files will change which I'm not sure how that would impact changie at the moment.Checklist