Skip to content

Commit 5d5581f

Browse files
authored
Merge pull request #16 from Tensho/tflint
Add "tflint" Hook
2 parents db47313 + 6808ede commit 5d5581f

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

.pre-commit-hooks.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@
1818
exclude: \.+.terraform\/.*$
1919
require_serial: true
2020

21+
- id: tflint
22+
name: tflint
23+
description: Linter for Terraform source code
24+
entry: hooks/tflint.sh
25+
language: script
26+
files: \.tf$
27+
exclude: \.+.terraform\/.*$
28+
2129
- id: shellcheck
2230
name: Shellcheck Bash Linter
2331
description: Performs linting on bash scripts

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ supported hooks are:
77

88
* **terraform-fmt**: Automatically run `terraform fmt` on all Terraform code (`*.tf` files).
99
* **terraform-validate**: Automatically run `terraform validate` on all Terraform code (`*.tf` files).
10+
* **tflint**: Automatically run [`tflint`](https://github.com/terraform-linters/tflint) on all Terraform code (`*.tf` files).
1011
* **shellcheck**: Run [`shellcheck`](https://www.shellcheck.net/) to lint files that contain a bash [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix))
1112
* **gofmt**: Automatically run `gofmt` on all Golang code (`*.go` files).
1213
* **golint**: Automatically run `golint` on all Golang code (`*.go` files)
@@ -28,6 +29,7 @@ repos:
2829
hooks:
2930
- id: terraform-fmt
3031
- id: terraform-validate
32+
- id: tflint
3133
- id: shellcheck
3234
- id: gofmt
3335
- id: golint

hooks/tflint.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# OSX GUI apps do not pick up environment variables the same way as Terminal apps and there are no easy solutions,
6+
# especially as Apple changes the GUI app behavior every release (see https://stackoverflow.com/q/135688/483528). As a
7+
# workaround to allow GitHub Desktop to work, add this (hopefully harmless) setting here.
8+
export PATH=$PATH:/usr/local/bin
9+
10+
for file in "$@"; do
11+
tflint $file
12+
done

0 commit comments

Comments
 (0)