Ale: Add support for tflint and `terraform fmt`

Created on 12 Jul 2018  路  11Comments  路  Source: dense-analysis/ale

Name: HCL
URL: https://github.com/hashicorp/hcl


Hashicorp uses Hashicorp Configuration Language (HCL) for most, if not all, of their products (e.g. Terraform, Vault, Consul ...etc).

Terraform itself is a form of HCL with special keywords and Terraform files end with .tf extension, so tflint is the appropriate linter/fixer for it.

However, for Vault and other tools that require some config.hcl file, I suggest and recommend hclfmt as a linter/fixer.

Thank you.

new tool

All 11 comments

@petermbenjamin Why not use the built-in defacto formatter that comes with terraform? (i.e. terraform fmt).

I don't usually work with terraform templates, so I don't have terraform cli installed. I usually work with consul and vault configs (and vault policy files, which are based on HCL as well).

Got it.

I suppose a separate fixer can be added for terraform then. No harm, no foul.

Few questions:

  1. Do you know if terraform fmt works on consul/vault configs (e.g. .hcl files) in addition to .tf files?
  2. Do you know if hclfmt does not work on terraform .tf files?

Just seeing your question now @petermbenjamin, sorry for the delay:

  1. (I just checked to make sure, because I didn't know the answer to this off the top of my head) -- terraform fmt works on .hcl files ONLY if the files are passed to fmt explicitly. This should work fine for the case of this fixer.
  2. I've never heard of hclfmt until seeing this issue, so I'm not totally sure.

Thanks for the information, @dsifford .
Considering Fatih (author/maintainer) of hclfmt has recently archived the project with no plans to maintain it, and considering terraform fmt works on .hcl as well as .tf files, we should just integrate vim-terraform as a fixer for HCL and TF files.

It's best to not rely on other plugins. terraform fmt can easily be integrated as a fixer of its own.

Agree with @RyanSquared --- I can PR the fixer for that if needed. Just let me know.

@dsifford sounds good, if you could get a PR set up that would be helpful. Otherwise I can look into it, might be useful as I use .tf files at work.

All set in #2015

Done now, thanks to @dsifford. :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

trevordmiller picture trevordmiller  路  3Comments

aressler38 picture aressler38  路  3Comments

trevordmiller picture trevordmiller  路  4Comments

catbaron0 picture catbaron0  路  3Comments

kronos29296 picture kronos29296  路  4Comments