HCL autoformat doesn't allow commenting hash values of a list
- Dominant language
- Go
- Stars
- 5.8k
- Forks
- 657
- Avg merge
- 20h 36m
- Merged PRs (30d)
- 6
Description
I have some HCL (specifically, Terraform code) which looks something like this:
```
variable "test" {
default = [
# This is a comment for this list element.
{
key = "value"
},
]
}
```
Running `terraform fmt` changes the formatting of this code to this:
```
variable "test" {
default = [
{
# This is a comment for this list element.
key = "value"
},
]
}
```
This doesn't seem desirable to me because the comment is meant to refer to the entire hash element.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the formatter entry point used by `terraform fmt` and locate tests covering comments on list elements. Reproduce the example from the issue, then update the behavior so a comment for a list element remains attached to that element and add or adjust a regression test.
Written by the indexing model from the issue text.
Assessment
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100