Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tusharsadhwani/zigimports
Automatically remove unused imports and globals from Zig files.
https://github.com/tusharsadhwani/zigimports
imports zig
Last synced: about 1 month ago
JSON representation
Automatically remove unused imports and globals from Zig files.
- Host: GitHub
- URL: https://github.com/tusharsadhwani/zigimports
- Owner: tusharsadhwani
- License: mit
- Created: 2024-09-02T20:25:33.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-09-08T12:17:11.000Z (2 months ago)
- Last Synced: 2024-10-01T03:20:16.535Z (about 2 months ago)
- Topics: imports, zig
- Language: Zig
- Homepage:
- Size: 37.1 KB
- Stars: 29
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# zigimports
Automatically remove unused imports and global variables from Zig files.
Zig currently entirely ignores unused globals, which means unused imports aren't errors.
They aren't even warnings.In fact, you can have an import importing a module/file that *doesn't even exist*, and
the Zig compiler will simply ignore it.`zigimports` helps you avoid that by cleaning up unused imports.
> [!NOTE]
> Zig plans to eventually address this issue in the compiler directly:
> https://github.com/ziglang/zig/issues/335## Installation
Requires Zig 0.13.0 or newer:
```bash
zig build --release=safe
```You should have the `./zig-out/bin/zigimports` binary now.
## Usage
Basic usage:
```console
$ zigimports path/to/file.zig
path/to/file.zig:1:0: std is unused
path/to/file.zig:2:0: otherfile is unused
path/to/file.zig:9:0: MyStruct is unused$ zigimports path/to/file.zig --fix
path/to/file.zig - Removed 3 unused imports
```To tidy up your entire codebase, use:
```bash
zigimports --fix .
```