ziglint Changelog View on GitHub

Z013: Unused import

Detects imports that are never used in the file.

Examples

Bad

// expect: Z013
const std = @import("std");
const unused = @import("unused.zig");

pub fn main() void {
    std.debug.print("hello\n", .{});
}

Good

Remove unused imports:

const std = @import("std");

pub fn main() void {
    std.debug.print("hello\n", .{});
}

Public re-exports are not considered unused:

pub const utils = @import("utils.zig");

Imports used only in tests should be at the top level. If the file only contains tests, the import will be considered used:

const testing = @import("testing.zig");

test "example" {
    testing.check();
}

Rationale

Unused imports add noise to the file and may indicate dead code or incomplete refactoring. Removing them keeps the dependency list accurate and the code clean.