This repository has been archived on 2024-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
ale/test/handler/test_terraform_handler.vader
Keith Maxwell 88fa0b9294 Add a terraform linter
This linter uses the check functionality built into terraform. ALE
already has a fixer using `terraform fmt` but this doesn't provide error
messages. ALE already has a linter using `tflint` but this requires an
extra application to be installed.

For example this linter will give a warning that ! is an illegal
character in the line below:

    variable "example" !{}

This linter runs the buffer through the command below and parses the
output:

    terraform fmt -no-color -check=true -

This commit includes a basic implementation, documentation and tests.
The only option is to control which executable is run.

Tested with:

    $ terraform -version
    Terraform v0.11.13
2019-05-23 15:49:02 +01:00

34 lines
869 B
Text
Executable file

Before:
" Load the file which defines the linter.
runtime ale_linters/terraform/terraform.vim
After:
" Unload all linters again.
call ale#linter#Reset()
Execute(The output should be correct):
AssertEqual
\ [
\ {
\ 'lnum': 1,
\ 'col': 20,
\ 'type': 'E',
\ 'text': 'illegal char',
\ },
\ {
\ 'lnum': 2,
\ 'col': 14,
\ 'type': 'E',
\ 'text': 'literal not terminated',
\ },
\ {
\ 'lnum': 1,
\ 'type': 'E',
\ 'text': 'object expected closing RBRACE got: EOF',
\ },
\ ],
\ ale_linters#terraform#terraform#Handle(bufnr(''), [
\ 'Error running fmt: In <standard input>: At 1:20: illegal char',
\ 'Error running fmt: In <standard input>: At 2:14: literal not terminated',
\ 'Error running fmt: In <standard input>: object expected closing RBRACE got: EOF',
\ ])