Skip to content

Commit 469695f

Browse files
authored
Allow commas with spaces in annotations (#1834)
1 parent eb0b7ff commit 469695f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

tflint/annotation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"golang.org/x/exp/slices"
1111
)
1212

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

1515
// Annotation represents comments with special meaning in TFLint
1616
type Annotation struct {

tflint/annotation_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import (
1212
func Test_NewAnnotations(t *testing.T) {
1313
src := `
1414
resource "aws_instance" "foo" {
15-
/* tflint-ignore: aws_instance_invalid_type */
15+
/* tflint-ignore: aws_instance_invalid_type, terraform_deprecated_syntax */
1616
instance_type = "t2.micro" // tflint-ignore: aws_instance_invalid_type
17-
# tflint-ignore: aws_instance_invalid_type This is also comment
17+
# tflint-ignore: aws_instance_invalid_type
1818
iam_instance_profile = "foo" # This is also comment
1919
// This is also comment
2020
}`
@@ -30,14 +30,14 @@ resource "aws_instance" "foo" {
3030

3131
expected := Annotations{
3232
{
33-
Content: "aws_instance_invalid_type",
33+
Content: "aws_instance_invalid_type, terraform_deprecated_syntax ",
3434
Token: hclsyntax.Token{
3535
Type: hclsyntax.TokenComment,
36-
Bytes: []byte("/* tflint-ignore: aws_instance_invalid_type */"),
36+
Bytes: []byte("/* tflint-ignore: aws_instance_invalid_type, terraform_deprecated_syntax */"),
3737
Range: hcl.Range{
3838
Filename: "resource.tf",
3939
Start: hcl.Pos{Line: 3, Column: 3},
40-
End: hcl.Pos{Line: 3, Column: 49},
40+
End: hcl.Pos{Line: 3, Column: 78},
4141
},
4242
},
4343
},
@@ -57,7 +57,7 @@ resource "aws_instance" "foo" {
5757
Content: "aws_instance_invalid_type",
5858
Token: hclsyntax.Token{
5959
Type: hclsyntax.TokenComment,
60-
Bytes: []byte("# tflint-ignore: aws_instance_invalid_type This is also comment\n"),
60+
Bytes: []byte("# tflint-ignore: aws_instance_invalid_type\n"),
6161
Range: hcl.Range{
6262
Filename: "resource.tf",
6363
Start: hcl.Pos{Line: 5, Column: 3},

0 commit comments

Comments
 (0)