This repository uses pre-commit hooks to automatically lint and format code before commits.
- Code formatting (black, ruff-format)
- Linting issues (ruff)
- Import sorting (isort via ruff)
- ESLint (with TypeScript support)
- Prettier formatting
- Trailing whitespace
- End-of-file fixers
- Large file detection
- Merge conflicts
- Debug statements
pip install pre-commitOr with homebrew:
brew install pre-commitIf you previously had Husky installed:
git config --unset-all core.hooksPathFrom the repository root:
pre-commit installThat's it. The hooks will now run automatically on every commit.
When you commit, pre-commit will automatically run:
git commit -m "your message"If hooks fail:
- Most issues are auto-fixed (formatting, trailing whitespace, etc.)
- Review the changes:
git diff - Stage the fixes:
git add . - Commit again:
git commit -m "your message"
Only when absolutely necessary:
git commit -m "your message" --no-verifyTest hooks on all files without committing:
pre-commit run --all-filesRun on specific files:
pre-commit run --files path/to/file.pyEach project has its own ruff configuration in pyproject.toml:
projects/web-backend/pyproject.toml- Django project (Python 3.10+)projects/mission-planner/pyproject.toml- Flask project (Python 3.9+)projects/integration-tests/pyproject.toml- Test suite (Python 3.10+)
Ruff will automatically use the appropriate config based on file location.
ESLint and Prettier use the existing configuration in:
projects/web-frontend/.eslintrc.cjsor eslint config inpackage.jsonprojects/web-frontend/.prettierrcor prettier config inpackage.json
After migrating to pre-commit, you can optionally remove Husky:
-
Remove the prepare script from
projects/web-frontend/package.json:- "prepare": "cd ../.. && husky install projects/web-frontend/.husky", -
Uninstall Husky and lint-staged:
cd projects/web-frontend npm uninstall husky lint-staged -
Remove the
.huskydirectory:rm -rf projects/web-frontend/.husky
-
Remove lint-staged config from
package.json(thelint-stagedsection)
pre-commit installpre-commit autoupdatepre-commit clean
pre-commit run --all-files