VladRassokhin / intellij-hcl

HCL language support for IntelliJ platform based IDEs
Apache License 2.0
244 stars 47 forks source link

Omit Quotes In Terraform Resource Type And Name #285

Closed Tensho closed 3 years ago

Tensho commented 4 years ago

Feature Request

Terraform 0.12+ allows to omit redundant quotes around resource type and name. Please could you make it configurable in "Editor –> Code Style –> Terraform Config"?

Terraform Configuration Example

resource aws_sns_topic opsgenie_service_health {
  name = "opsgenie-service-health"
}
Tensho commented 4 years ago

Does it make sense?

VladRassokhin commented 4 years ago

Makes sense, yes, will try to implement in further versions

Tensho commented 3 years ago

@VladRassokhin Is it still on the roadmap? πŸ˜…

Tensho commented 3 years ago

This is not more relevant. Here is a comment from HashiCorp representative:

For the real reasoning, I think it has to do with whether or not the token represents a configuration language keyword or expression, which in this case it doesn’t since it is intended as a label (and can potentially have characters outside that of an expression). I believe the allowance of non-quotes there was incidental more than intentional and the quotes being idiomatic is there for the consistency of those labels which might require the quotes. In the future, the SDK may support block syntax like this:

resource "example_thing" "example" {
  some_block "label1" {
    # nested attributes
  }
  some_block "label2" {
    # nested attributes
  }
}

Which will likely have the quoting requirement for "label1" and "label2" for similar reasons.

and further MR making formatter not happy with unquoted labels.

References

Tensho commented 3 years ago

@VladRassokhin Thank you for the patience πŸ™‡

VladRassokhin commented 3 years ago

@Tensho Thank you for investigation and follow-up!