pre-commit-hooks
July 8, 2025 ยท View on GitHub
A collection of pre-commit hooks for various languages and tools to ensure code quality, security, and consistency.
Features
- ๐ Multi-language support: Hooks for Python, JavaScript, Go, Rust, Nix, and more
- ๐ก๏ธ Security scanning: Integration with security tools
- ๐ Code quality: Linting, formatting, and style checks
- ๐ CI/CD ready: Works seamlessly with GitHub Actions
- ๐ฆ Multiple installation methods: pre-commit, npm, pip, or direct download
Installation
Using pre-commit (Recommended)
Add this to your .pre-commit-config.yaml:
repos:
- repo: https://github.com/aRustyDev/pre-commit-hooks
rev: v0.1.0 # Use the latest release
hooks:
- id: shellcheck
- id: shfmt
# Add more hooks as needed
Then run:
pre-commit install
pre-commit run --all-files
Using npm
npm install --save-dev @arustydev/pre-commit-hooks
Using pip
pip install arustydev-pre-commit-hooks
Direct Installation
curl -sSL https://github.com/aRustyDev/pre-commit-hooks/releases/latest/download/install.sh | bash
Available Hooks
Shell/Bash
shellcheck- Shell script analysisshfmt- Shell script formatting
Git/Commits
commitizen- Conventional commit messagescommitlint- Commit message lintinggitlint- Git commit message linter
Nix
nix-fmt- Nix code formatternix-lint- Nix linternix-build- Nix build validation
Web Development
eslint- JavaScript lintingjshint- JavaScript code qualityfixmyjs- JavaScript auto-fixingcsslint- CSS lintingscss-lint- SCSS linting
CI/CD
github-action-lint- GitHub Actions workflow linting
Configuration
yamlfmt- YAML formatting
Security
witness- Supply chain security
Usage Examples
Basic Setup
# .pre-commit-config.yaml
repos:
- repo: https://github.com/aRustyDev/pre-commit-hooks
rev: v0.1.0
hooks:
# Shell scripts
- id: shellcheck
args: [-x]
- id: shfmt
args: [-i, '2', -ci]
# JavaScript
- id: eslint
files: \.js$
# Commits
- id: commitlint
stages: [commit-msg]
Advanced Configuration
# .pre-commit-config.yaml
repos:
- repo: https://github.com/aRustyDev/pre-commit-hooks
rev: v0.1.0
hooks:
# Run on specific files
- id: nix-fmt
files: \.nix$
# Custom arguments
- id: shellcheck
args: [--severity=warning]
# Exclude patterns
- id: eslint
exclude: ^vendor/
Development
Prerequisites
- Python 3.6+
- Node.js 14+
- Bash 4+
- pre-commit
Setup
# Clone the repository
git clone https://github.com/aRustyDev/pre-commit-hooks.git
cd pre-commit-hooks
# Install dependencies
npm install
pip install -e .[dev]
pre-commit install
# Run tests
./tests/run_tests.sh
Contributing
See CONTRIBUTING.md for guidelines.
Testing
Tests are written using bats:
# Run all tests
./tests/run_tests.sh
# Run specific test
bats tests/commits/test_gitlint.bats
# Run with coverage
kcov coverage bats tests/
Documentation
Versioning
This project follows Semantic Versioning. See CHANGELOG.md for release history.
License
MIT License - see LICENSE file for details.
Acknowledgments
- Pre-commit framework creators
- All contributors and hook authors
- Open source security tools integrated
Support
- ๐ Report bugs
- ๐ก Request features
- ๐ฌ Discussions
- ๐ Documentation