vscode-terraform
vscode-terraform copied to clipboard
[tracking issue] tflint
v2 temporarily dropped tflint support this ticket is meant to track progress on that
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 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?
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.
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?
tflint --format json
should work! Reported issues have an associated hcl.Range
.
@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.
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
tflint --format json
should work! Reported issues have an associatedhcl.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.
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 I think this is a must have. I had to go back to IntelliJ, you cannot write fast efficient TF code without proper linting.
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?
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
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
Any updates on when this feature might be completed?
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.
Hello Team, Any update when this feature be available for use? we badly need to implement language server protocol with vscode for proper linting
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.
Hi, any update on this? ;)
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.
any updates?
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.
So...it´s been 3 years now. Should we fork?
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!
Any updates on this?
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
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 :)
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?
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.