From 64b513e3de042e544c934c8d9c2f8e675d15c8be Mon Sep 17 00:00:00 2001 From: Evan Reichard Date: Thu, 29 Jan 2026 20:34:28 -0500 Subject: [PATCH] style(tsconvert): enforce two-space indentation for TypeScript interfaces - Add two spaces before each field in generated interfaces - Use newlines between fields and closing brace for proper formatting - Update test to validate proper indentation - Document test requirements in AGENTS.md --- AGENTS.md | 8 ++++++++ internal/functions/typescript_test.go | 2 +- internal/tsconvert/convert.go | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 1231393..ecb59fb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -100,6 +100,14 @@ functions.RegisterAsyncFunction[FetchArgs, *FetchResult]("fetch", Fetch) - **Linting**: `golangci-lint run` - must pass before committing - **Test organization**: Test files use `_test.go` suffix, test functions prefixed with `Test` - **TypeScript test files**: Tests that require TypeScript files should create them inline using `os.CreateTemp()` instead of relying on external test files +- **CRITICAL**: You must run `go test ./...` after any code change to validate that tests pass before committing + +## Test Requirements + +Before any commit, ensure: +1. All tests pass: `go test ./...` +2. All linting passes: `golangci-lint run` +3. Type declarations are properly formatted (two spaces indentation) ## Dependencies diff --git a/internal/functions/typescript_test.go b/internal/functions/typescript_test.go index 491e47c..5156015 100644 --- a/internal/functions/typescript_test.go +++ b/internal/functions/typescript_test.go @@ -133,7 +133,7 @@ func TestResultStruct(t *testing.T) { // Verify Declarations defs := GetFunctionDeclarations() assert.Contains(t, defs, "declare function result(input: string): TestResult;") - assert.Contains(t, defs, "interface TestResult {id: number; data: number[]}") + assert.Contains(t, defs, "interface TestResult {\n id: number\n data: number[]\n}") } type TestAsyncArgs struct { diff --git a/internal/tsconvert/convert.go b/internal/tsconvert/convert.go index 423fcd1..47bb45e 100644 --- a/internal/tsconvert/convert.go +++ b/internal/tsconvert/convert.go @@ -155,14 +155,14 @@ func collectStructTypes(t reflect.Type, ts *TypeSet) { fieldName += "?" } - fields = append(fields, fmt.Sprintf("%s: %s", fieldName, tsType)) + fields = append(fields, fmt.Sprintf(" %s: %s", fieldName, tsType)) // Recursively Collect Nested Types collectType(field.Type, ts) } // Add Type Definition - definition := fmt.Sprintf("interface %s {%s}", name, strings.Join(fields, "; ")) + definition := fmt.Sprintf("interface %s {\n%s\n}", name, strings.Join(fields, "\n")) _ = ts.Add(name, definition) }