Skip to content

Commit

Permalink
Allow commas with spaces in annotations (#1834)
Browse files Browse the repository at this point in the history
  • Loading branch information
wata727 authored Sep 3, 2023
1 parent eb0b7ff commit 469695f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tflint/annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"golang.org/x/exp/slices"
)

var annotationPattern = regexp.MustCompile(`tflint-ignore: (\S+)`)
var annotationPattern = regexp.MustCompile(`tflint-ignore: ([^\n*/]+)`)

// Annotation represents comments with special meaning in TFLint
type Annotation struct {
Expand Down
12 changes: 6 additions & 6 deletions tflint/annotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
func Test_NewAnnotations(t *testing.T) {
src := `
resource "aws_instance" "foo" {
/* tflint-ignore: aws_instance_invalid_type */
/* tflint-ignore: aws_instance_invalid_type, terraform_deprecated_syntax */
instance_type = "t2.micro" // tflint-ignore: aws_instance_invalid_type
# tflint-ignore: aws_instance_invalid_type This is also comment
# tflint-ignore: aws_instance_invalid_type
iam_instance_profile = "foo" # This is also comment
// This is also comment
}`
Expand All @@ -30,14 +30,14 @@ resource "aws_instance" "foo" {

expected := Annotations{
{
Content: "aws_instance_invalid_type",
Content: "aws_instance_invalid_type, terraform_deprecated_syntax ",
Token: hclsyntax.Token{
Type: hclsyntax.TokenComment,
Bytes: []byte("/* tflint-ignore: aws_instance_invalid_type */"),
Bytes: []byte("/* tflint-ignore: aws_instance_invalid_type, terraform_deprecated_syntax */"),
Range: hcl.Range{
Filename: "resource.tf",
Start: hcl.Pos{Line: 3, Column: 3},
End: hcl.Pos{Line: 3, Column: 49},
End: hcl.Pos{Line: 3, Column: 78},
},
},
},
Expand All @@ -57,7 +57,7 @@ resource "aws_instance" "foo" {
Content: "aws_instance_invalid_type",
Token: hclsyntax.Token{
Type: hclsyntax.TokenComment,
Bytes: []byte("# tflint-ignore: aws_instance_invalid_type This is also comment\n"),
Bytes: []byte("# tflint-ignore: aws_instance_invalid_type\n"),
Range: hcl.Range{
Filename: "resource.tf",
Start: hcl.Pos{Line: 5, Column: 3},
Expand Down

0 comments on commit 469695f

Please sign in to comment.