aspect-build / rules_lint

Run static analysis tools with Bazel
Apache License 2.0
88 stars 46 forks source link

[Bug]: Restore HCL language #155

Open alexeagle opened 9 months ago

alexeagle commented 9 months ago

What happened?

Switched from hcl to terraform because terraform-fmt doesn't cover everything

See comment: https://github.com/aspect-build/rules_lint/blob/a9d300ff881c5274319720a46917459e012c321a/format/private/format.sh#L58-L63

alexeagle commented 9 months ago

Some research:

I was wrong about https://terragrunt.gruntwork.io/docs/reference/cli-options/#hclfmt - it only wants to format "terragrunt" files, none of the HCL files in Silo were affected by it. Dead end.

The official HCL language does provide a formatter, however they don't ship any binary distribution. https://github.com/hashicorp/hcl/blob/main/cmd/hclfmt/main.go

According to one of the HCL2 authors, each product that uses HCL actually ships its own fmt command intentionally because the domain-specifics may be formatted beyond what the language syntax understands: https://github.com/hashicorp/vscode-hcl/issues/98#issuecomment-1137569350

So that means users of rules_lint might expect their vault files to be vault fmt, packer files to be packer fmt, terraform to be terraform fmt, etc. This strikes me as a lot of burden for a little repo like this to take on.

Or, we can eschew these domain-specifics and just run the generic hclfmt, providing less value than those users expect, as they might take a file that's already "correctly formatted" according to rules_lint, run terraform fmt on it, and then be surprised that it makes modifications. In this case we'd also want to provide a precompiled binary to make things easier for users.

alexeagle commented 7 months ago

Slipping this from 1.0, it looks too underspecified