Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use hash instead of double slashes for single line comments #309

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

jpenna
Copy link
Contributor

@jpenna jpenna commented Jul 25, 2024

HCL syntax accepts both # and // for line comments, but # is more idiomatic.

This is also mentioned in Terraform documentation:

The # single-line comment style is the default comment style and should be used in most cases. Automatic configuration formatting tools may automatically transform // comments into # comments, since the double-slash style is not idiomatic.

https://developer.hashicorp.com/terraform/language/syntax/configuration#comments

HCL syntax accepts both `#` and `//` for line comments, but `#` is more idiomatic.

This is also mentioned in Terraform documentation:

> The # single-line comment style is the default comment style and should be used in most cases. Automatic configuration formatting tools may automatically transform // comments into # comments, **since the double-slash style is not idiomatic.**

https://developer.hashicorp.com/terraform/language/syntax/configuration#comments
@jpenna jpenna requested a review from a team as a code owner July 25, 2024 20:46
Copy link

hashicorp-cla-app bot commented Jul 25, 2024

CLA assistant check
All committers have signed the CLA.

@jpogran
Copy link
Contributor

jpogran commented Jul 29, 2024

Hey @jpenna, thanks for your contribution!

The purpose of this extension is to provide generic syntax highlighting and limited language support for generic HCL files, not Terraform files. We have the fully featured Terraform Extension with backing Terraform Language Server to handle Terraform files, which does use # as the default line comment character.

The HCL sytanx specification purposely does not choose one comment style over the other. Each application (Boundary, Nomad, etc) is supposed to define what they consider idiomatic. Since this extension is targeted at any other HCL based language than Terraform, we have to conform to the generic HCL sytanx specification.

May I ask what you are using vscode-hcl for that vscode-terraform does not provide? We may be able to address that there instead of making this extension too coarsely purposed for the intended goal.

@jpenna
Copy link
Contributor Author

jpenna commented Jul 29, 2024

Hello @jpogran , this was for settings, like .tflint.hcl. There was another file, but I deleted it, but I remember it was configuring something as well.

I understand what you are saying. Maybe this could be a setting for the vscode extension, since there are two ways of commenting and different projects might prefer one over the other.

Copy link
Member

@dbanck dbanck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for raising this PR!

After some consideration and the discussion in #313, we've decided to make # the default character for line comments.

@dbanck dbanck merged commit e8bd3bd into hashicorp:main Oct 23, 2024
1 check passed
@khaliddermoumi
Copy link

Thanks for the change! I am just using is, is great now! 🥇

@jpenna jpenna deleted the patch-1 branch October 29, 2024 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants