vscode-terraform icon indicating copy to clipboard operation
vscode-terraform copied to clipboard

[tracking issue] tflint

Open FernandoMiguel opened this issue 4 years ago • 28 comments

v2 temporarily dropped tflint support this ticket is meant to track progress on that

FernandoMiguel avatar Jun 05 '20 10:06 FernandoMiguel

I am not that familiar with tflint myself, but we could implement this via the language server as part of https://github.com/hashicorp/terraform-ls/issues/27 which would have the benefit of providing more contextual hints in the code (like highlighting the offending sequence of characters), but I'm not sure if tflint does actually return the warnings/errors with some machine-readable context (in the form of code range).

Alternatively we could just execute tflint from the client and display the output just associated with the file.

The other question is whether the extension should also manage installation/upgrade of tflint. I suppose initially doesn't need to, but long-term should?

radeksimko avatar Jun 05 '20 11:06 radeksimko

@radeksimko not sure who this will work on v2 previously it was used by the old (current?) version by having it installed on the host and formating and testing the code

for clarification here is the project https://github.com/terraform-linters/tflint maybe @wata727 can provide some insight?

FernandoMiguel avatar Jun 05 '20 11:06 FernandoMiguel

TFLint can also run as an LSP server compliant with the Language Server Protocol v3.14.0 so that it can be integrated with any editor. Here is a sample of simple VS Code integration: https://github.com/terraform-linters/vscode-tflint-lsc/blob/764822b9864db5bb96db5592242692b29509a0bd/src/extension.ts

The language server supports textDocumet/publishDiagnostics notifications and can notify you of warnings based on change events.

I'm not sure how it would be preferable to implement it, but it would be a good start to support hooks that can add any language server to this extension. In my opinion, TFLint is not an official HashiCorp project, so I think it's best to provide it as a customization feature and not support installations or upgrades.

wata727 avatar Jun 05 '20 13:06 wata727

TFLint is not an official HashiCorp project, so I think it's best to provide it as a customization feature and not support installations or upgrades.

Agreed, I think if we integrate tflint in some way it would be opt-in, but the "opt-in" could in theory be just having tflint installed and available in $PATH?

As for the integration, I would think the easiest interface to work with would be just plain shell execution with decent machine-readable (JSON) output, similar to terraform validate -json. Is that something tflint can provide?

radeksimko avatar Jun 05 '20 15:06 radeksimko

tflint --format json should work! Reported issues have an associated hcl.Range.

bendrucker avatar Jun 05 '20 17:06 bendrucker

@wata727 @bendrucker happy to have some higher bandwidth chats about tighter integration here, feel free to reach out to me at [email protected] and we can add you to our internal Slack or something.

All that being said, definitely want to add these integration points for additional diagnostic sources and already outputting the ranges seems like it should be a good hook.

paultyng avatar Jun 05 '20 18:06 paultyng

This is to confirm i cannot make tflint working in VSCode even though it is in $PATH and/or hard-coded in settings.json: "terraform.lintPath": "/usr/local/bin/tflint"

Error message: command 'terraform.lint' not found

My setup:

VSCode:
  Version: 1.38.1
  Commit: b37e54c98e1a74ba89e03073e5a3761284e3ffb0
  Date: 2019-09-11T13:30:08.229Z
  Electron: 4.2.10
  Chrome: 69.0.3497.128
  Node.js: 10.11.0
  V8: 6.9.427.31-electron.0
  OS: Linux x64 4.18.0-80.11.2.el8_0.x86_64

HashiCorp Terraform 
  Version: 0.12.9

HashiCorp Terraform for VSCode
  Version: 1.4.1

TFLint
  Version: 0.18.0

luckylittle avatar Jul 27 '20 02:07 luckylittle

tflint --format json should work! Reported issues have an associated hcl.Range.

I'm curious how you use that. I have the vscode terraform plugin installed and flint is installed with brew. If I make typo like var.thisismissing into a .tf file, it will not be detected:

data "aws_s3_bucket" "default" {
  bucket = format("%s-default-%s", var.thisismissing, var.environment)
}

$ tflint --format json
{"issues":[],"errors":[]}

IntelliJ's Terraform plugin will detect the missing variable.

fmunteanu avatar Aug 03 '20 16:08 fmunteanu

Just to clarify this issue is discussing the plan of implementing the integration.

i.e. tflint is not yet integrated with the VSCode extension or the language server.

radeksimko avatar Aug 03 '20 18:08 radeksimko

@radeksimko I think this is a must have. I had to go back to IntelliJ, you cannot write fast efficient TF code without proper linting.

fmunteanu avatar Aug 04 '20 04:08 fmunteanu

Any news about this? I'm using tflint for cloud specific linting/rule check, for example to lint Azure VM sizes and naming conventions. Is such functionality possible with native tools?

Satak avatar Mar 18 '21 04:03 Satak

hi any update on this request. I miss terraform-lsp, please add support for tflint in to terraform-ls which is used. by vscode-terraform. https://github.com/hashicorp/terraform-ls#terraform-ls-vs-terraform-lsp

deepak-kosaraju avatar Sep 16 '21 21:09 deepak-kosaraju

Hi everyone! Thank you for your interest in our extension, and this request especially. We don't have this planned at the moment, we have a couple other features in flight, but it is on our radar to investigate how to best integrate with it.

If you are interested in what we are working on, we do our work in the open in GitHub. You can see what we are working on, what we're planning to do, and what we've accomplished at https://github.com/orgs/hashicorp/projects/83

jpogran avatar Sep 22 '21 13:09 jpogran

Any updates on when this feature might be completed?

johnkoehn avatar Aug 10 '22 18:08 johnkoehn

Hi @johnkoehn! Most of the research and planning for this issue have been done. We're tracking the work and the individual tickets in https://github.com/hashicorp/vscode-terraform/issues/635.

While it is on our roadmap for the next couple of months, we can't provide a detailed timeline yet. This is because there are a couple of other issues we need to tackle first. Thanks for your understanding.

dbanck avatar Aug 12 '22 09:08 dbanck

Hello Team, Any update when this feature be available for use? we badly need to implement language server protocol with vscode for proper linting

bhushan1988-007 avatar Sep 21 '22 05:09 bhushan1988-007

Hi @bhushan1988-007, I'm sorry, but there hasn't been much progress. We're still working on other table stakes features. Thank you for being so patient.

dbanck avatar Oct 04 '22 18:10 dbanck

Hi, any update on this? ;)

luciosis avatar Nov 30 '22 12:11 luciosis

Hi @luciosis,

I'm sorry, but there hasn't been much progress. It's still on our roadmap for the next quarter (starting in February), but that's all I can say for now. Thank you for being so patient.

dbanck avatar Nov 30 '22 13:11 dbanck

any updates?

sansmoraxz avatar Apr 05 '23 07:04 sansmoraxz

Hi @sansmoraxz,

I'm sorry, but there hasn't been much progress. We acknowledge that this is our most requested community issue and is still on our roadmap, but that's all I can say for now. Thank you for being so patient.

dbanck avatar Apr 06 '23 08:04 dbanck

So...it´s been 3 years now. Should we fork?

mroedder-d7 avatar Jun 01 '23 08:06 mroedder-d7

Hi @mroedder-d7,

We understand your concerns and always welcome input on how we can improve. However, before considering a fork, we'd appreciate it if you would contribute directly. The project is actively maintained and has no open community PRs waiting to be merged.

Feel free to create an issue outlining your plans for integrating with tflint. We'd love to hear more about your ideas!

dbanck avatar Jun 01 '23 12:06 dbanck

Any updates on this?

Poltergeisen avatar Oct 05 '23 14:10 Poltergeisen

Hi @sansmoraxz,

I'm sorry, but there hasn't been much progress. We acknowledge that this is our most requested community issue and is still on our roadmap, but that's all I can say for now. Thank you for being so patient.

bump @dbanck

wico-bienias avatar Feb 19 '24 07:02 wico-bienias

Pretty much all tools i have use linters, sad to see that this was removed at some point. Then you see a ticket 'to get it back in' and it is 3 years later. Wasn't the old code re-usable you would say? Feels like that guy that is in the 'friends' zone :)

riemers avatar Feb 20 '24 08:02 riemers

Hi @mroedder-d7,

We understand your concerns and always welcome input on how we can improve. However, before considering a fork, we'd appreciate it if you would contribute directly. The project is actively maintained and has no open community PRs waiting to be merged.

Feel free to create an issue outlining your plans for integrating with tflint. We'd love to hear more about your ideas!

Can you tell us what is higher priority than this for the vscode addon? Or direct me somewhere to view it?

Poltergeisen avatar Feb 20 '24 15:02 Poltergeisen

Thanks for your question and the continued interest in this feature. There has been and continues to be strong support for this feature on the development team, however it has taken a back seat to features such as enhanced editor experience (see: https://www.hashicorp.com/blog/new-terraform-testing-and-ux-features-reduce-toil-errors-and-costs).

We are continuously reconsidering prioritization and we are aware that this is currently the highest user-requested feature. At this time, we would also welcome a user-contributed pull request for this functionality. Thanks again for your interest, we are aware and will do our best to prioritize this.

dbanck avatar Feb 23 '24 12:02 dbanck