redhat-developer / redhat-developer/vscode-yaml
YAML formatting not compliant with yamllint "spaces before comments" requirement
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 829
- Forks
- 260
- Avg merge
- 5h 43m
- Merged PRs (30d)
- 1
Description
Describe the bug
yamllint, a linter used by many projects and companies, has a different requirement on the number of spaces before comments than what the YAML formatter in this plugin provides:
What yamllint requires is two spaces before the comment #:
timeout: 1800 # value in seconds ~ 30m
Formatting of this plugin results in a single space:
timeout: 1800 # value in seconds ~ 30m
Thus, YAML files saved (with Format on Save activated) with VS Code and this plugin enabled results in YAML files that are rejected by systems using yamllint to check for compliance (e.g. CI systems).
Expected Behavior
Files are formatted according to the yamllint requirements, e.g. double space before comments.
OR
Option to specify formatting requirements is given.
Current Behavior
Files are not formatted according to yamllint requirements, e.g. single space before comments.
Steps to Reproduce
- Create file
test.yamlwith contents:
- job:
name: some-job
timeout: 1800 # value in seconds ~ 30m
- Run
yamllint test.yaml--> pass - Apply formatting in VS Code which will reduce double-space to single-space
- Run
yamllint test.yaml--> fail
Environment
- Windows
- Mac
- Linux
- other (please specify)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the test.yaml reproducer and run yamllint before and after applying the VS Code formatter. Trace the formatter behavior that changes two spaces before a comment to one, then verify that formatted output retains yamllint-compliant spacing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- yaml
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100