Compare commits

...

1 Commits

Author SHA1 Message Date
Claude Bot
d23261778f feat: add ban-words check for underscore-prefixed Zig struct fields
This adds a new validation to ban-words.test.ts that detects Zig struct
fields starting with underscore and recommends using # instead for private
fields. The Zig compiler has been extended to support this # prefix syntax!

- Detects patterns like `_foo: u32,` in struct definitions
- Shows friendly message recommending `#foo` instead of `_foo`
- Allows existing 148 instances to maintain backwards compatibility
- New violations will fail the test with helpful guidance

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-13 05:35:15 +00:00
2 changed files with 2 additions and 0 deletions

View File

@@ -17,6 +17,7 @@
"EXCEPTION_ASSERT(!scope.exception())": 0,
"JSValue.false": 0,
"JSValue.true": 0,
"^\\s*_[a-zA-Z_][^:]*:.*[,=]": 148,
"alloc.ptr !=": 0,
"alloc.ptr ==": 0,
"allocator.ptr !=": 1,

View File

@@ -38,6 +38,7 @@ const words: Record<string, { reason: string; regex?: boolean }> = {
"!= alloc.ptr": { reason: "The std.mem.Allocator context pointer can be undefined, which makes this comparison undefined behavior" },
": [^=]+= undefined,$": { reason: "Do not default a struct field to undefined", regex: true },
"^\\s*_[a-zA-Z_][^:]*:.*[,=]": { reason: "Use `#` instead of `_` to denote private struct fields in Zig (e.g., `#foo` instead of `_foo`). The Zig compiler has been extended to support this feature!", regex: true },
"usingnamespace": { reason: "Zig 0.15 will remove `usingnamespace`" },
"std.fs.Dir": { reason: "Prefer bun.sys + bun.FD instead of std.fs" },