TFLint ruleset plugin for Terraform Language with more format check. This ruleset achieves more syntax checking that cannot be detected in 'terraform fmt'.
- TFLint v0.40+
- Go v1.20
Declare a config in .tflint.hcl
as follows:
plugin "formatter" {
enabled = true
version = "0.2.4"
source = "github.com/thaim/tflint-ruleset-formatter"
signing_key = <<-KEY
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQGNBGSpaaYBDAC274I6eRnQ65ZNhvGNm9XOFMuwOQOcvP8dKQ0H4VLPL8ZvJAtu
EJUrsk49x5EpLcbU8cCBFu1D3axUYbF924iNfsRtX6Dljt0YFYxNI//giL98txM7
Zx2p9WHyzCzkUS3eeVt9nK9a97B9XvWFAI3VCGT7pDkEvWHgsmapXll7csTQD6B1
ca1cMh20yUzBAsexqxOadXYL7LADarIWc4B7X67gLrqEL/bcSa7UDQsz27d/LB0I
Vi4tmTUmuJfXEdck8v7lsNTsF03FKx3Jl92wjQZWYVIZ2LFygr1+cEmoSMZ4HhNd
NsCrg2zP+dro6R5rdM+jstVFnBA0hRNy2FagEUTaA2mhNrKlvcwtvw5/IPf3XySU
nOB69p80L5bSJDazNsmTWoUOECA1WZA/VzB8vb5sHHkyqqfgTIN3bVj0RzYhSvjN
VdFmyKJjGzkSJQ3UQoe+gGznXV3zd/SUfmLzNOI2bBZWOIhc+Hv51UW/ikllNkRT
2ni322OCJijqs10AEQEAAbQZdGhhaW0gPHRoYWltMjRAZ21haWwuY29tPokBzgQT
AQoAOBYhBMIh5S+m0Q+iRj45c1+n8Csaj59LBQJkqWmmAhsDBQsJCAcCBhUKCQgL
AgQWAgMBAh4BAheAAAoJEF+n8Csaj59LHn4L/j4ftwC1N93s1iVx9eQpCTfV/16j
0COfXnf4YpYjDyfLoJ8Vbw3YVW48yDl/aWkh7DG2NBy4Bbw0olAIEJrb8ygGmlGi
kbE7urVnFQ6cJuVukkEpAZy2UjI7GIgKcHyTDP5wXMV5+r0EXXsXMC0UzUeoku1w
I6x4nRn6NsFDcnf6pDptbtf1BvqFMrqe4Z5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VgPL4v8E/qY8YLV7xCJ27vW23Kx9+rrTvnwn6xyESe2dYT8
ZYtYluZGxiA01nKHu3B9WZMkQQXuttbK5FIpJ175OtG2dnPd6qw4XAl8C3joWPRg
nMK+aNN36ODOJdIN/r8uPaYU25j1+Lt/WxJVNyKXNiqx6HdniOKes9IgUL6TjV22
iSqJX89qVgAh2f0Atmt0GvtapFJK8KRawPbpXpa7hib29Xr9/DUQQ8zPyRVRPZwk
ChAYYTEtdMhSkBDTaWuHXg5Bg+B6Hm3rli72Vb2N7hc3ej2SZdg9bm7+ZDbSXAqY
Yh81e1KhykujwVteqWduMKAGagOG4r7JIiO5jfJCNsrYFD8jJOvtAWECmZH/QJWd
//0y4Ag=
=opj9
-----END PGP PUBLIC KEY BLOCK-----
KEY
}
You can customize rule specific configurations. See rule docs for more details.
Rule | Description | Severity | Enabled by default |
---|---|---|---|
formatter_blank_line | ensures that there are no extra blank lines | WARNING | ✔ |
formatter_empty_file | ensures that files are not empty | WARNING | ✔ |
formatter_eof | ensures that file end with new line | WARNING | ✔ |
formatter_max_len | ensures the limitation of code line length | WARNING | ✔ |
formatter_trailing_comma | ensures that tuple element always end with comma | WARNING | ✔ |
Clone the repository locally and run the following command:
$ make
You can easily install the built plugin with the following:
$ make install
You can run the built plugin like the following:
$ cat << EOS > .tflint.hcl
plugin "formatter" {
enabled = true
}
EOS
$ tflint
Run command below and answer the options.
$ go run rules/generator/main.go