Skip to content

a-kenji/sizelint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

172 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

$ sizelint - lint your working tree based on file sizes

Built with Nix Crates

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 - usage

Lint your working tree based on file size

Usage: sizelint [OPTIONS] <COMMAND>

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 <FILE>  Configuration file path
      --debug          Enable debug output (or set SIZELINT_LOG for fine-grained control)
  -h, --help           Print help
  -V, --version        Print version

$ sizelint check

Check files for size violations

Usage: sizelint check [OPTIONS] [PATHS]...

Arguments:
  [PATHS]...
          Paths to check

Options:
  -c, --config <FILE>
          Configuration file path

  -f, --format <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 <RANGE>
          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 <COMMAND>

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

cargo install sizelint --locked

Basic Usage

# Initialize configuration
sizelint init

# Check all files
sizelint check

# Check specific files
sizelint check src/main.rs README.md

Git Integration

# Check files changed since diverging from main
sizelint check --git main

# Scan the entire history of a branch for oversized blobs
sizelint check --git "$(git hash-object -t tree /dev/null)..master"

Configuration

sizelint uses TOML configuration files.

Run sizelint init to create a default configuration:

max_file_size = "2MB"
warn_file_size = "1MB"
excludes = []
check_staged = false
check_working_tree = false
respect_gitignore = true
fail_on_warn = false

[rules.default]
enabled = true
description = "Default file size check"
suggestion = "Add the file to 'excludes' or adjust 'max_file_size' in sizelint.toml"

[rules.medium_files]
enabled = false
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
suggestion = "Consider using Git LFS: git lfs track '*.png'"

Documentation

Development

Development Shell

nix develop

Building

cargo build --release

Testing

cargo test
cargo clippy

License

MIT License - see LICENSE file for details.