This repository uses pre-commit hooks to automatically format code on every commit.
- Ruff: Fast Python linter and formatter (replaces Black, isort, and flake8)
- Prettier: Code formatter for JavaScript, TypeScript, JSON, YAML, and Markdown
-
Install dependencies (if not already installed):
pip install -r requirements-dev.txt
Or install individually:
pip install pre-commit ruff
-
Install pre-commit hooks:
pre-commit install
This will set up the git hooks to run automatically on every commit.
-
Optional: Run on all files (to format existing code):
pre-commit run --all-files
Once installed, pre-commit will automatically:
- Format Python code with Ruff before each commit
- Format JavaScript/TypeScript/JSON/YAML/Markdown files with Prettier
- Check for trailing whitespace, end-of-file issues, and other common problems
- Prevent committing if there are formatting issues
You can also run the formatters manually:
# Run all hooks on staged files
pre-commit run
# Run all hooks on all files
pre-commit run --all-files
# Run a specific hook
pre-commit run ruff --all-files
pre-commit run prettier --all-files.pre-commit-config.yaml: Pre-commit hooks configurationpyproject.toml: Ruff configuration (Python formatting and linting).prettierrc: Prettier configuration (JavaScript/TypeScript formatting).prettierignore: Files to exclude from Prettier formatting
To update pre-commit hooks to their latest versions:
pre-commit autoupdateIf hooks fail, you can:
-
Skip hooks for a specific commit (not recommended):
git commit --no-verify
-
Update hook versions:
pre-commit autoupdate
-
Clear pre-commit cache:
pre-commit clean