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

Spaces before comments #208

Open
kimllee opened this issue Sep 16, 2024 · 2 comments
Open

Spaces before comments #208

kimllee opened this issue Sep 16, 2024 · 2 comments

Comments

@kimllee
Copy link

kimllee commented Sep 16, 2024

Hello,

yamllint 1.35.1 output
image

yamlfmt 0.13.0 doesn't add the required spaces asked by yamllint

.yamlfmt file

formatter:
    type: basic
    include_document_start: true
    pad_line_comments: 2

It happens when there's a comment in a like starting by the dash character like this :

...
    rules:
      - # Ingress host
        host: "xxxx.xxx.xxx"
        # Paths for the host
        paths:
          - path: /auth/admin/
            pathType: Prefix
    # Console TLS configuration
    tls:

Am I missing something please ?

Thank you.

@braydonk
Copy link
Collaborator

Hi @kimllee,

The underlying yaml parser has a concept of Head, Line, and Foot comments. These are to determine where to place the comments when rendering. A Head comment is a comment above the given yaml node, a line comment is on the same line, and a foot comment is below. pad_line_comments is a config value for adding space padding to line comments (where the default and minimum is 1).

The problem here is that the yaml parser interprets the # Ingress host comment to be a Head Comment to the host: "x" node rather than a Line Comment to the block sequence starting node -.

I'm not confident I could make the yaml parser do what yamllint wants here without potentially breaking other parsing code.

@kimllee
Copy link
Author

kimllee commented Nov 29, 2024

Hello,
I can understand.

Thank you for your answer

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

No branches or pull requests

2 participants