hashicorp / vscode-terraform

HashiCorp Terraform VSCode extension
https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform
Mozilla Public License 2.0
926 stars 179 forks source link

[tracking issue] tflint #337

Open FernandoMiguel opened 4 years ago

FernandoMiguel commented 4 years ago

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

radeksimko commented 4 years ago

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?

FernandoMiguel commented 4 years ago

@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?

wata727 commented 4 years ago

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.

radeksimko commented 4 years ago

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?

bendrucker commented 4 years ago

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

paultyng commented 4 years ago

@wata727 @bendrucker happy to have some higher bandwidth chats about tighter integration here, feel free to reach out to me at ptyng@hashicorp.com 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.

luckylittle commented 4 years ago

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
fmunteanu commented 4 years ago

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.

radeksimko commented 4 years ago

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.

fmunteanu commented 4 years ago

@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.

Satak commented 3 years ago

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?

deepak-kosaraju commented 3 years ago

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

jpogran commented 3 years ago

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

johnkoehn commented 2 years ago

Any updates on when this feature might be completed?

dbanck commented 2 years ago

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.

bhushan1988-007 commented 2 years ago

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

dbanck commented 2 years ago

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.

luciosis commented 1 year ago

Hi, any update on this? ;)

dbanck commented 1 year ago

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.

sansmoraxz commented 1 year ago

any updates?

dbanck commented 1 year ago

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.

mroedder-d7 commented 1 year ago

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

dbanck commented 1 year ago

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!

Poltergeisen commented 1 year ago

Any updates on this?

wico-bienias commented 8 months ago

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

riemers commented 8 months ago

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 :)

Poltergeisen commented 8 months ago

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?

dbanck commented 8 months ago

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.

DevoFalcon commented 2 months ago

Commenting for another check-in on this. Thanks for your continued transparency on the roadmap