From bdc272627ba9f7c2eaad4dd56c4a4f62b884d8d9 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Wed, 30 Sep 2026 10:17:34 +0200 Subject: [PATCH] Skip @type inside docblock description in blink TypeToVarTag Port TypeToVarTagFixer #81 to blink: only rewrite @type to @var at the start of a doc line (after an optional /**, /* or *), never inside a description. This was the last --blink divergence from ECS on this repository. --- blink/internal/fixer/rules/symplify_docblock.go | 6 ++++-- blink/internal/fixer/rules/symplify_docblock_test.go | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/blink/internal/fixer/rules/symplify_docblock.go b/blink/internal/fixer/rules/symplify_docblock.go index 8980782c48..fed20bea60 100644 --- a/blink/internal/fixer/rules/symplify_docblock.go +++ b/blink/internal/fixer/rules/symplify_docblock.go @@ -133,7 +133,9 @@ func (FixTagTypo) Fix(s *tokens.Stream) bool { type TypeToVarTag struct{} var ( - typeTagRe = regexp.MustCompile(`@type\b`) + // only "@type" at the start of a doc line (after an optional /**, /* or *), + // never inside a description - mirrors TypeToVarTagFixer #81 + typeTagRe = regexp.MustCompile(`(?m)^(\s*(?:/\*{1,2}|\*)?\s*)@type\b`) typeToVarSingleAsteriskRe = regexp.MustCompile(`^/\*(\n?\s+@var)`) ) @@ -155,7 +157,7 @@ func (TypeToVarTag) Fix(s *tokens.Stream) bool { if !typeTagRe.MatchString(t.Value) { continue } - nc := typeTagRe.ReplaceAllString(t.Value, "@var") + nc := typeTagRe.ReplaceAllString(t.Value, "${1}@var") nc = typeToVarSingleAsteriskRe.ReplaceAllString(nc, "/**$1") s.Set(i, token.Token{Kind: token.DocComment, Value: nc}) changed = true diff --git a/blink/internal/fixer/rules/symplify_docblock_test.go b/blink/internal/fixer/rules/symplify_docblock_test.go index 561dbac0e4..b2ebe0fa21 100644 --- a/blink/internal/fixer/rules/symplify_docblock_test.go +++ b/blink/internal/fixer/rules/symplify_docblock_test.go @@ -37,6 +37,15 @@ func TestTypeToVarTag(t *testing.T) { idempotent(t, TypeToVarTag{}, got) } +// TestTypeToVarTagSkipsDescription leaves "@type" inside a description untouched, +// only rewriting it at the start of a doc line (mirrors #81). +func TestTypeToVarTagSkipsDescription(t *testing.T) { + src := "