ziglint Changelog View on GitHub

Z006: Variable names should be snake_case

Variable and constant names should use snake_case, unless they are type aliases.

Examples

Bad

// expect: Z006
const myValue = 42;
// expect: Z006
var currentIndex = 0;

Good

const my_value = 42;
var current_index = 0;

Type aliases built with builtin type constructors are PascalCase:

const chunk_bytes = 32;
const Chunk = @Vector(chunk_bytes, u8);

The 0.16 constructor builtins are recognized the same way: @Int, @Pointer, @Struct, @Enum, @Union, @Tuple, @Fn, @FieldType, plus @This, @TypeOf, @Frame, and @EnumLiteral:

const vector_chunk_len = 32;
const VectorMask = @Int(.unsigned, vector_chunk_len);

@typeInfo is not a type constructor. It returns a std.builtin.Type value, so a PascalCase name for its result is a misnamed variable, not a type alias:

// expect: Z006
const Info = @typeInfo(u32);

When ziglint runs over a directory (module graph mode), aliases produced by camelCase type-functions are also recognized — const ConnLog = log.withContext(Ctx, .conn) is a type alias even though withContext keeps a std.log-style name. Single-file mode falls back to name-shape heuristics and cannot see these.

Type aliases are allowed to be PascalCase:

const MyType = struct { value: u32 };
const Allocator = std.mem.Allocator;

Function aliases are allowed to be camelCase:

fn fooBar() void {}
const myAlias = fooBar;
const myFunc = std.someModule.someFunc;

Single letters are allowed:

fn example() void {
    const x = 10;
    _ = x;
}

Rationale

Zig uses different cases to distinguish different kinds of identifiers:

This rule enforces snake_case for variables while allowing PascalCase for type aliases, which are detected by analyzing the assigned value.