Skip to content

trailing commas on dictionaries should be all or none #1540

@docwhat

Description

@docwhat

Introduction

Uneven commas can make terraform code confusing. On dictionaries, they should either be on all or none.

I would expect that tflint would raise an warning on this snippet of code:

locals {
  a_dictionary = {
    "one"  = "fish"
    "two"  = "fish",
    "red"  = "fish"
    "blue" = "fish"
  }
}

I would expect the two line to be flagged as the rest of the lines do not have commas.

Proposal

The rule should take these values:

  • all: All dictionary entries should end in a comma.
  • none: All dictionary entries should not end in a comma.
  • match: All the dictionary entries in a given dictionary should be the same; either all commas or all without commas.

References

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions