LineGuard
A fast and reliable file linter that ensures proper line endings and clean formatting.
Features
- ✅ Newline Ending Check: Ensures files end with exactly one newline character
- ✅ Trailing Space Detection: Identifies and reports trailing whitespace at line ends
- 🚀 High Performance: Parallel file processing with progress indicators
- 🎨 Multiple Output Formats: Human-readable (with colors), JSON, and GitHub Actions formats
- 🔧 Configurable: Flexible configuration via CLI flags or
.lineguardrcfiles - 🔄 Auto-fix: Automatically fix issues with
--fixflag - 📁 Smart File Discovery: Glob patterns, recursive directory scanning, stdin support
- 🎯 Selective Checks: Disable specific checks via CLI flags
- 💾 Memory Efficient: Streaming support for large files (>10MB)
- 🛡️ Robust Error Handling: Graceful handling of permission errors
- 🔍 Binary File Detection: Automatically skips binary files
- 🚫 Ignore Patterns: Skip files/directories with glob patterns
- 📝 File Extension Filtering: Check only specific file types
- 🔀 Git Integration: Check only files changed between commits
Installation
From Crates.io
From GitHub Releases
Download pre-built binaries from the latest release:
# Linux/macOS
|
# Windows
# Download the .zip file and extract lineguard.exe to a directory in your PATH
From Source
Usage
Basic Usage
# Check a single file
# Check multiple files
# Check with glob pattern
# Check all files in directory
Command-Line Options
)
)
)
)
Advanced Usage
# Fix issues automatically
# Preview fixes without applying
# Ignore specific patterns
# Check only specific file types
# Use custom config file
# Disable specific checks
# Pipe files from other commands
|
# Check files changed in the last commit
# Check files changed between specific commits
# Check files changed since a tag
# Combine with other options
Output Examples
Human-Readable Format (Default)
✗ src/main.rs
- Missing newline at end of file
- Line 45: Trailing spaces found
✓ src/lib.rs
Summary: 1 file with issues, 2 total issues found
JSON Format
GitHub Actions Format
Configuration File
LineGuard supports configuration files to customize its behavior. Create a .lineguardrc file in your project root:
# .lineguardrc
[]
= true # Check for proper newline at end of file
= true # Check for trailing spaces
# Ignore patterns (glob format)
= [
"**/target/**",
"**/.git/**",
"**/node_modules/**",
"*.generated.*",
]
# File extensions to check (default: all text files)
= [
"rs", "toml", "md", "txt",
"js", "ts", "jsx", "tsx",
"py", "go", "java", "c", "cpp", "h", "hpp",
"yml", "yaml", "json", "xml",
]
Configuration files are searched in the following order:
- Path specified with
--configflag .lineguardrcin the current directory.lineguardrcin parent directories (up to the root)
CLI flags always override configuration file settings.
Exit Codes
0- Success, no issues found1- Issues found in checked files2- Error in command-line arguments3- File access or I/O error4- Configuration error
Development
This project follows strict Test-Driven Development (TDD) practices. See IMPLEMENTATION_PLAN.md for development guidelines.
Building
Testing
Code Quality
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.