| Crates.io | yamllint-rs |
| lib.rs | yamllint-rs |
| version | 0.1.4 |
| created_at | 2025-11-05 18:10:58.841834+00 |
| updated_at | 2025-11-07 22:14:06.40656+00 |
| description | A YAML linter written in Rust |
| homepage | |
| repository | https://github.com/AvnerCohen/yamllint-rs |
| max_upload_size | |
| id | 1918382 |
| size | 559,627 |
A YAML linter written in Rust, inspired by the Python yamllint package.
This project is a Rust implementation of yamllint by Adrien Vergé. The original yamllint serves as the reference implementation for all rules, configurations, and behavior. This Rust version aims to provide the same functionality with improved performance through parallel processing and native compilation.
--fix flag.yamllint files.gitignore filesgit clone https://github.com/AvnerCohen/yamllint-rs
cd yamllint-rs
cargo build --release
cargo install yamllint-rs
yamllint-rs is available as a Docker image on Docker Hub. No installation required - just run it directly:
# Lint a single file
docker run --rm -v $(pwd):/work -w /work yamllint-rs:latest file.yaml
# Lint multiple files
docker run --rm -v $(pwd):/work -w /work yamllint-rs:latest file1.yaml file2.yaml
# Recursive directory processing
docker run --rm -v $(pwd):/work -w /work yamllint-rs:latest --recursive .
# Verbose output
docker run --rm -v $(pwd):/work -w /work yamllint-rs:latest --verbose file.yaml
# Use custom config file
docker run --rm -v $(pwd):/work -w /work yamllint-rs:latest --config .yamllint.yaml file.yaml
# Automatically fix fixable issues
docker run --rm -v $(pwd):/work -w /work yamllint-rs:latest --fix file.yaml
# Use specific version
docker run --rm -v $(pwd):/work -w /work yamllint-rs:v0.1.1 file.yaml
Note: Replace yamllint-rs with your Docker Hub username/organization if the image is published under a different namespace (e.g., yourusername/yamllint-rs:latest).
# Lint a single file
yamllint-rs file.yaml
# Lint multiple files (processed in parallel)
yamllint-rs file1.yaml file2.yaml file3.yaml
# Recursive directory processing
yamllint-rs --recursive directory/
# Verbose output
yamllint-rs --verbose file.yaml
# Use custom config file
yamllint-rs --config .yamllint.yaml file.yaml
# Automatically fix fixable issues
yamllint-rs --fix file.yaml
# Set output format (standard, colored, or auto)
yamllint-rs --format colored file.yaml
# Disable progress updates
yamllint-rs --no-progress --recursive directory/
# Combine options
yamllint-rs -r --verbose --fix directory/
files - YAML file(s) to lint (positional arguments)-r, --recursive - Process directories recursively-v, --verbose - Enable verbose output-c, --config <path> - Path to configuration file--fix - Automatically fix fixable issues-f, --format <format> - Output format: standard, colored, or auto (default: auto)--no-progress - Disable progress updates during processingyamllint-rs automatically discovers configuration files by searching for .yamllint in the current directory and parent directories. You can also specify a custom path with --config.
# Automatic discovery (searches for .yamllint in current and parent dirs)
yamllint-rs file.yaml
# Explicit config file
yamllint-rs --config custom-config.yaml file.yaml
The tool supports both the original yamllint configuration format and the native format. See the Rules.md file for detailed rule documentation.
Example .yamllint configuration:
rules:
line-length:
max: 120
indentation:
spaces: 4
ignore: |
*.template.yaml
generated/
truthy:
allowed-values: ['true', 'false', 'yes', 'no']
use yamllint_rs::{FileProcessor, ProcessingOptions, OutputFormat};
// Process a single file
let options = ProcessingOptions {
recursive: false,
verbose: false,
output_format: OutputFormat::Colored,
show_progress: true,
};
let processor = FileProcessor::with_default_rules(options);
let result = processor.process_file("path/to/file.yaml")?;
for (issue, rule_name) in result.issues {
println!("{}:{} - {} ({})",
issue.line,
issue.column,
issue.message,
rule_name
);
}
// Process directory recursively
let processor = FileProcessor::with_default_rules(options);
let issue_count = processor.process_directory("directory/")?;
// Use custom configuration
use yamllint_rs::{load_config, discover_config_file};
if let Some(config_path) = discover_config_file() {
let config = load_config(config_path)?;
let processor = FileProcessor::with_config(options, config);
processor.process_file("file.yaml")?;
}
// Fix mode
let processor = FileProcessor::with_fix_mode(options);
processor.process_file("file.yaml")?;
# Build the project
cargo build
# Build optimized release binary
cargo build --release
# Run tests
cargo test
# Run with debug output
cargo run -- --verbose file.yaml
# Format code
cargo fmt
# Run clippy linter
cargo clippy
# Run benchmarks
cargo bench
yamllint-rs processes multiple files in parallel for better performance. Files are automatically processed in parallel when:
Many rules support automatic fixes. When using --fix, the tool will:
When processing directories recursively, yamllint-rs respects .gitignore files using the ignore crate, automatically skipping files that would be ignored by Git.
yamllint-rs supports all 23 rules from the original yamllint. See Rules.md for complete documentation.
MIT