terraform icon indicating copy to clipboard operation
terraform copied to clipboard

Terraform fmt not enforcing convention with respect to dangling commas.

Open sbadakhc opened this issue 4 years ago • 2 comments

Hi,

I have noticed that terraform fmt does not enforce a convention with respect dangling commas. For example:

variable "some_variable" {
  description = "Some description."
  type        = list(string)

  default = [
    "some.string",
    "some.string",   
  ]
}

and

variable "some_variable" {
  description = "Some description."
  type        = list(string)

  default = [
    "some.string",
    "some.string"   
  ]
} 

Are both acceptable.

It would be good to enforce the dangling comma convention in this case.

Terraform Version

Terraform v0.12.26
+ provider.google v3.25.0
+ provider.google-beta v3.25.0
+ provider.null v2.1.2
+ provider.random v2.2.1

References

https://github.com/terraform-google-modules/terraform-google-bootstrap/issues/36 https://medium.com/@nikgraf/why-you-should-enforce-dangling-commas-for-multiline-statements-d034c98e36f8

sbadakhc avatar Jun 14 '20 19:06 sbadakhc

I think this is a bug: back in 2018 the dangling comma being enforced was "decided to be a feature" and it looks like it's no longer working: https://github.com/hashicorp/terraform/issues/13025

christianbundy avatar Nov 25 '20 22:11 christianbundy

bump ..

debuggerpk avatar Jun 20 '21 00:06 debuggerpk