Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate tflint with focus on a generalized linter/validator interface #334

Open
radeksimko opened this issue Dec 8, 2020 · 1 comment
Labels
enhancement New feature or request linting Functionality related to linting and external linters textDocument/codeAction textDocument/publishDiagnostics

Comments

@radeksimko
Copy link
Member

radeksimko commented Dec 8, 2020

This is part of hashicorp/vscode-terraform#635

Use-cases

(Follow up on #27)
The user can run terraform validate since 0.11 as a command (if dedicated clients such as VS Code extension choose to integrate) and can also run this on didSave automatically.

The integration of linters requires similar work and could be implemented as a command, which can be executed on didSave as well.

Proposal

  1. Start with the integration of a single linter tflint
  2. Make use of the settings introduced in Add linter configuration to initialization options #855
  3. Implement tflint as an executable command, which calls the tflint binary, similar to validate
    progress.Begin(ctx, "Validating")
    defer func() {
    progress.End(ctx, "Finished")
    }()
    progress.Report(ctx, "Running terraform validate ...")
    jsonDiags, err := tfExec.Validate(ctx)
    if err != nil {
    return nil, err
    }
  4. Inspect the output tflint --json and how to store it in the diagnostics memdb table introduced in Store diagnostics in memdb table #856
  5. Add tflint to the didSave handler, similar to validate
    if !expFeatures.ValidateOnSave {
    return nil
    }
    dh := ilsp.HandleFromDocumentURI(params.TextDocument.URI)
    cmdHandler := &command.CmdHandler{
    StateStore: svc.stateStore,
    }
    _, err = cmdHandler.TerraformValidateHandler(ctx, cmd.CommandArgs{
    "uri": dh.Dir.URI,
    })
@radeksimko radeksimko added the enhancement New feature or request label Dec 8, 2020
@dbanck dbanck changed the title Integrate tflint & generalize linter/validator interface Integrate tflint with focus on a generalized linter/validator interface Apr 14, 2022
@xiehan xiehan added the linting Functionality related to linting and external linters label Apr 21, 2023
@wata727
Copy link

wata727 commented Jun 15, 2024

@dbanck I'm currently interested in working on this, here is the PoC:

As I understand it, #856 has already been resolved, so there are no related fixes in the PoC.

If you are able to move this forward I would be happy to submit a PR, which can be split into separate PRs for each step outlined here, or combined. Please let me know if we need to discuss the overall design before we move forward.

Also, since the architecture will change significantly in #1667, it would be fine to implement it after that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request linting Functionality related to linting and external linters textDocument/codeAction textDocument/publishDiagnostics
Projects
None yet
Development

No branches or pull requests

3 participants