ziglint Changelog View on GitHub

Z009: Files with top-level fields should be PascalCase

When a file defines top-level fields (making it a "file struct"), the filename should be PascalCase to indicate it represents a type.

Examples

Bad

A file named config.zig with top-level fields:

// expect: Z009
value: u32,
name: []const u8,

Good

Option 1: Rename the file to Config.zig (PascalCase).

Option 2: Use a regular struct without top-level fields:

pub const Config = struct {
    value: u32,
    name: []const u8,
};

Rationale

In Zig, a file with top-level fields is itself a struct type. Following the convention that types are PascalCase, such files should have PascalCase names. This makes it clear when importing that Config is a type, not a namespace.