hashicorp / hashicorp/hcl

HCL autoformat wants multi-lined array to be grouped by themselves

Open
#222 0 comments 0 reactions 0 assignees View on GitHub
v1
Dominant language
Go
Stars
5.8k
Forks
657
Avg merge
20h 36m
Merged PRs (30d)
6

Description

Perhaps this is intentional. but it seems that HCL autoformatting (i.e. the `terraform fmt` command) wants to group multi-lined arrays in separate blocks. For example, consider the following HCL:

```
data "aws_iam_policy_document" "test" {
statement {
actions = [
"s3:GetObject",
"s3:ListBucket",
]
resources = ["*"]
}
}
```

`terraform fmt` wants to change this to:

```
data "aws_iam_policy_document" "test" {
statement {
actions = [
"s3:GetObject",
"s3:ListBucket",
]

resources = ["*"]
}
}
```

Would it be possible to disable this behavior? If this behavior is intentional then I guess I can live with it.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the formatting change with the HCL example and the `terraform fmt` behavior described in the issue. Trace the formatter entry point that handles multi-line arrays and determine whether the grouping can be made configurable. Done means the requested behavior is either disableable or the issue is clearly documented as intentional, with coverage for the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.