Skip to content

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

Open
@radeksimko

Description

@radeksimko

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,
    })

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions