Skip to content

Commit f181da8

Browse files
committed
chore: find any values in interface fields
1 parent 8cb1c4e commit f181da8

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

config/mutations.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,30 @@ func (r *anyLintIgnore) Visit(node bindings.Node) (w walk.Visitor) {
185185
node.Comments = append(node.Comments, "biome-ignore lint lint/complexity/noUselessTypeConstraint: golang does 'any' for generics, typescript does not like it")
186186
}
187187

188+
for _, field := range node.Fields {
189+
h := &hasAnyVisitor{}
190+
walk.Walk(h, field.Type)
191+
if h.hasAnyValue {
192+
field.FieldComments = append(field.FieldComments, "biome-ignore lint lint/complexity/noUselessTypeConstraint: ignore linter")
193+
}
194+
}
195+
188196
return nil
189197
}
190198

191199
return r
192200
}
201+
202+
type hasAnyVisitor struct {
203+
hasAnyValue bool
204+
}
205+
206+
func (h *hasAnyVisitor) Visit(node bindings.Node) walk.Visitor {
207+
if isLiteral, ok := node.(*bindings.LiteralKeyword); ok {
208+
if *isLiteral == bindings.KeywordAny {
209+
h.hasAnyValue = true
210+
return nil // stop here, the comment works for the whole field
211+
}
212+
}
213+
return h
214+
}

0 commit comments

Comments
 (0)