Skip to content
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

feat: support multiple spaces before line comments #104

Closed
badouralix opened this issue Apr 1, 2023 · 3 comments · Fixed by #107
Closed

feat: support multiple spaces before line comments #104

badouralix opened this issue Apr 1, 2023 · 3 comments · Fixed by #107
Milestone

Comments

@badouralix
Copy link
Contributor

Currently yamlfmt enforces using a single space before line comments :

# Before yamlfmt
key: "value"  # line comment

# After yamlfmt
key: "value" # line comment

This behavior triggers a warning from yamllint :

$ echo 'key: "value" # line comment' | yamllint -d "{extends: default, rules: {document-start: false}}" -
stdin
  1:14      warning  too few spaces before comment  (comments)

From https://github.com/adrienverge/yamllint/blob/6bfd6756e2414e0a16a256eaf6575e922d7e2ac9/yamllint/rules/comments.py#L86, the default number of spaces before line comments is 2

What do you think about adding an option to format line comments with multiple spaces ?
I am thinking about an option similar to indent: 2 such that users can set a number of spaces before line comments

@braydonk
Copy link
Collaborator

braydonk commented Apr 1, 2023

Interesting setting, I never knew that was the default.

I checked in the yaml library and I think I'll be able to add this without too much trouble. I will do it in the next release.

@braydonk
Copy link
Collaborator

braydonk commented Apr 2, 2023

@badouralix Thanks for the PR! The next step would be to make a PR here that updates braydonk/yaml and adds a setting to the basic formatter config. #103 is a good reference. If you have time to do it that would be great, or I can do it tomorrow before I cut the release.

@braydonk
Copy link
Collaborator

braydonk commented Apr 2, 2023

Thanks for the feature! This will be in the release today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants