How can I use tflint on VSCode with HashiCorp Terraform plugin?

Viewed 7588

I'm trying to use tflint on VSCode, but can't configure it properly.
On my terminal, both terraform and tflint works well.

terraform --version
Terraform v0.12.28

tflint --version
TFLint version 0.17.0

which tflint
/usr/local/bin/tflint

But on VSCode, linting does not work.
I've installed HashiCorp Terraform plugin v2.0.2, and enabled terraform language server. Now I checked my setting.json. Many articles on the Internet says we can configure it on terraform.lintPath fiels, but there isn't any such a field.

{
  "editor.tabSize": 2,
  "editor.formatOnSave": true,
  "terraform.languageServer": {},
}

I tried to add terraform.lintPath inside or outside terraform.languageServer, but it failed. Is there any way to check path that VSCode can refer?

1 Answers

The Terraform plugin for Visual Studio Code no longer supports tflint since v2.

You can see the difference in supported features in the README for each version. The v1.4.0 release shows the following features:

  • Auto-completion support
    1. Terraform high level types (variable, resource, data, module ...) auto completion support.
    2. resource types (aws_dynamodb_table ...) auto completion support for aws, azure, datadog, google, oci and openstack
    3. resource | data | module | output | variable property types auto completion support
    4. resource | data 1-level nested block property types auto completion support
  • Syntax highlighting for .tf and .tfvars files (and .hcl)
  • Automatic formatting using terraform fmt
  • Automatically closes braces and quotes
  • Adds a command for running terraform validate
  • Linting support with the help of tflint
  • Browse document symbols
  • Browse workspace symbols
  • Peek definition
  • Goto definition
  • Find references
  • Completion for variables and outputs
  • Rename variables, resource, and data types and all references
  • Show variable values on hover
  • CodeLens shows if a section is referenced

While the v2 release shows these features:

  • Manages installation and updates of the Terraform Language Server (terraform-ls), exposing its features:
    • Initialized provider completion (resource names, data source names, attribute names)
  • Includes syntax highlighting for .tf and .tfvars files (and .hcl) -- including all syntax changes new to Terraform 0.12
  • Closes braces and quotes
  • Includes for_each and variable syntax shortcuts (fore, vare, varm)

There's an issue tracking re-adding tflint support but there's not been any work done on this just yet.

Related