https://github.com/a-kenji/sizelint
Lint your file tree based on file sizes
https://github.com/a-kenji/sizelint
ci-cd cli code-quality developer-tools file-size formatter linter pre-commit
Last synced: 4 months ago
JSON representation
Lint your file tree based on file sizes
- Host: GitHub
- URL: https://github.com/a-kenji/sizelint
- Owner: a-kenji
- License: mit
- Created: 2025-07-16T21:39:17.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-08-01T15:16:36.000Z (11 months ago)
- Last Synced: 2025-08-02T19:34:26.231Z (11 months ago)
- Topics: ci-cd, cli, code-quality, developer-tools, file-size, formatter, linter, pre-commit
- Language: Rust
- Homepage:
- Size: 93.8 KB
- Stars: 11
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-starred - a-kenji/sizelint - Lint your file tree based on file sizes (Rust)
README
# `$ sizelint` - lint your working tree based on file sizes
[](https://builtwithnix.org)
[](https://crates.io/crates/sizelint)
`sizelint` is a fast, configurable file size linter that helps prevent large files from entering your Git repository.
It can be used as a standalone tool, pre-commit hook, or as part of your CI/CD pipeline.
## Overview
- [`$ sizelint` - lint your working tree based on file sizes](#sizelint-lint-your-working-tree-based-on-file-sizes)
- [`$ sizelint` - usage](#-sizelint---usage)
- [`$ sizelint check`](#-sizelint-check)
- [`$ sizelint rules`](#-sizelint-rules)
- [`$ sizelint init`](#-sizelint-init)
- [Configuration](#configuration)
- [Documentation](#documentation)
- [Development](#development)
- [License](#license)
## `$ sizelint` - usage
```
Lint your working tree based on file size
Usage: sizelint [OPTIONS]
Commands:
check Check files for size violations
init Initialize sizelint configuration
rules Rule management
completions Generate shell completions
help Print this message or the help of the given subcommand(s)
Options:
-c, --config
Configuration file path
-v, --verbose
Verbose output
--log-level
Log level
Possible values:
- trace: Trace level logging
- debug: Debug level logging
- info: Info level logging
- warn: Warning level logging
- error: Error level logging
[default: info]
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
```
## `$ sizelint check`
```
Check files for size violations
Usage: sizelint check [OPTIONS] [PATHS]...
Arguments:
[PATHS]...
Paths to check
Options:
-c, --config
Configuration file path
-f, --format
Output format
Possible values:
- human: Human-readable output
- json: JSON output
[default: human]
--staged
Check only staged files (git diff --staged)
--working-tree
Check working tree files
--git
Check files changed in a git revision range (e.g. "main", "main..HEAD", "main...feature")
--no-history
Skip git history scanning for deleted blobs (only check files at HEAD)
-q, --quiet
Quiet mode (only show violations)
--fail-on-warn
Treat warnings as errors
-h, --help
Print help (see a summary with '-h')
```
## `$ sizelint rules`
```
Rule management
Usage: sizelint rules
Commands:
list List available rules
describe Show rule documentation
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
```
## `$ sizelint init`
```
Initialize sizelint configuration
Usage: sizelint init [OPTIONS]
Options:
-f, --force Force overwrite existing configuration
--stdout Print the default configuration to stdout
--edit Open configuration file in editor after creation
-h, --help Print help
```
## Quick Start
### Installation
```bash
cargo install sizelint --locked
```
### Basic Usage
```bash
# Initialize configuration
sizelint init
# Check all files
sizelint check
# Check specific files
sizelint check src/main.rs README.md
```
## Configuration
`sizelint` uses TOML configuration files.
Run `sizelint init` to create a default configuration:
```
max_file_size = "10MB"
warn_file_size = "5MB"
excludes = []
check_staged = false
check_working_tree = false
respect_gitignore = true
fail_on_warn = false
[rules.medium_files]
enabled = true
description = "Base rule that fits many normal repos"
priority = 50
max_size = "5MB"
warn_size = "2MB"
includes = []
excludes = []
[rules.no_images]
enabled = false
description = "Warn about image files that might be better handled with LFS"
priority = 80
includes = ["*.png", "*.jpg", "*.jpeg", "*.gif", "*.bmp"]
excludes = []
warn_on_match = true
```
## Documentation
- [Manual Page](docs/sizelint.1.scd) - Reference in scdoc format
## Development
### Development Shell
```bash
nix develop
```
### Building
```bash
cargo build --release
```
### Testing
```bash
cargo test
cargo clippy
```
## License
MIT License - see [LICENSE](LICENSE) file for details.