Skip to content

aRustyDev/pre-commit-hooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

36 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

pre-commit-hooks

CI Security Coverage GitHub release npm version PyPI version License: MIT

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 analysis
  • shfmt - Shell script formatting

Git/Commits

  • commitizen - Conventional commit messages
  • commitlint - Commit message linting
  • gitlint - Git commit message linter

Nix

  • nix-fmt - Nix code formatter
  • nix-lint - Nix linter
  • nix-build - Nix build validation

Web Development

  • eslint - JavaScript linting
  • jshint - JavaScript code quality
  • fixmyjs - JavaScript auto-fixing
  • csslint - CSS linting
  • scss-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

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

About

Pre-commit hooks

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •