Skip to content

Commit 76688dd

Browse files
authored
Added check to test if list is empty (#5)
Signed-off-by: Lasse Gaardsholt <[email protected]>
1 parent 74e1aeb commit 76688dd

File tree

3 files changed

+5
-16
lines changed

3 files changed

+5
-16
lines changed

.github/workflows/release-drafter.yml

-7
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ on:
55
# branches to consider in the event; optional, defaults to all
66
branches:
77
- main
8-
# pull_request event is required only for autolabeler
9-
pull_request:
10-
# Only following types are handled by the action, but one can default to all as well
11-
types: [opened, reopened, synchronize]
12-
# pull_request_target event is required for autolabeler to support PRs from forks
13-
# pull_request_target:
14-
# types: [opened, reopened, synchronize]
158

169
permissions:
1710
# write permission is required to create a github release

README.md

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
1-
# TFLint Ruleset Template
2-
[![Build Status](https://github.com/terraform-linters/tflint-ruleset-template/workflows/build/badge.svg?branch=main)](https://github.com/terraform-linters/tflint-ruleset-template/actions)
3-
4-
This is a template repository for building a custom ruleset. You can create a plugin repository from "Use this template". See also [Writing Plugins](https://github.com/terraform-linters/tflint/blob/master/docs/developer-guide/plugins.md).
1+
# TFLint Ruleset trailing-comma
52

63
## Requirements
74

85
- TFLint v0.42+
9-
- Go v1.22
6+
- Go v1.22 or newer
107

118
## Installation
129

13-
TODO: This template repository does not contain release binaries, so this installation will not work. Please rewrite for your repository. See the "Building the plugin" section to get this template ruleset working.
14-
1510
You can install the plugin with `tflint --init`. Declare a config in `.tflint.hcl` as follows:
1611

1712
```hcl
18-
plugin "template" {
13+
plugin "trailing-comma" {
1914
enabled = true
2015
2116
version = "0.1.0"

rules/terraform_lists_trailing_comma.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ func (r *TerraformListsTrailingCommaRule) Check(runner tflint.Runner) error {
4848
file := files[filename]
4949

5050
list, ok := e.(*hclsyntax.TupleConsExpr)
51-
if !ok {
51+
if !ok || len(list.Exprs) <= 0 {
5252
return nil
5353
}
54+
5455
listRange := list.Range()
5556
lastItem := list.Exprs[len(list.Exprs)-1]
5657
lastItemRange := lastItem.Range()

0 commit comments

Comments
 (0)