-
Notifications
You must be signed in to change notification settings - Fork 280
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
automatic format #62
Comments
No sorry, it doesn't. yamllint is only a linter: it reports potential problems but doesn't fix them (mainly because there could be ambiguities in fixing). |
This would be really great. If the warning is that there is a trailing newline missing, it would be really easy to fix ;-) |
Tools like ESlint also only provide auto fixing for a subset or rules... |
|
Building a new auto-fixing tool around yamllint would be a good approach for anyone wanting this. e.g. autoflake wraps pyflakes, and autopep8 wraps pycodestyle. Where the linter doesnt expose enough information to aide fixing, that is a valid problem with the linter. |
It is probably worthwhile adding a note to the readme that reformatting is out of scope. Maybe include some recommendations on existing Python yaml reformatters , and non-Python ones (jq?), which support the yamllint default style. The jq wrappers for python are probably the best options IMO , but yq has a problem with indentation kislyuk/yq#52 . At https://stackoverflow.com/questions/30642317/how-to-automatically-re-indent-a-yaml-file , @ruamel recommends his https://github.com/dbohdan/remarshal is popular, and could be used to convert yaml2toml , and then toml2yaml , however note indentation is an issue there too remarshal-project/remarshal#13 . And another issue mmlb/yamlfmt#10 Hmm.. |
https://github.com/mk-fg/pretty-yaml works for several files I've tried, and has very basic cli, but it does discard comments.
|
@ruamel fixed and released a new version of https://pypi.org/project/ruamel.yaml.cmd/ , and I've packaged it for openSUSE https://build.opensuse.org/project/show/home:jayvdb:ruamel It prefers single quotes over double quotes, and likes |
I've been breaking my head over finding a formatter that would provide more or less the same features as yamllint via cli or via VSS, i've already tried all of the suggestions mentioned here. Can someone suggest a tool that would provide formatting similar to the following rules in yamllint:
Thanks! |
@adrienverge can the issue be reconsidered? Most of linters supports auto fixing today, for example:
Not to mention prettier and go fmt that are more code formatters. I don't want to find an alternative to yamllint, because I find it awesome.. but the lack of autofixing feature will make us find another tool or fork.. I'm using yamllint at an enterprise scale and it's very painful to ask developers manually fixing problems that can "easily" be automated 😓
@adrienverge if you main concern is "mainly because there could be ambiguities in fixing" we can do like ESLint and styleling and ONLY fix errors that are fixable without ambiguities 🤷 This should be more than enough |
Hey @yvele, I agree such a feature would be great. It could be in a separated command like Would you want to implement and maintain this? Here are the 4 main issues I see:
|
My solution was to use |
FYI another fixer with a different approach : https://github.com/opt-nc/yamlfixer |
Not every rule can be fixed, but some can be trivially fixed without ambiguities for example |
Why not combine efforts with one of the yamlfix projects to provide both checking and fixing functionality? |
Tested, works perfectly. Thanks a bunch! |
Man, this example: 'foo #bar' to example: 'foo # bar' I just can't use it :/ |
@socherbyc - wrong repo, old closed issue. This is yamllint, not yamlfix. |
Hope this tool can format the code automatic, just like
yapf -i
for Python.The text was updated successfully, but these errors were encountered: