Add pre-commit framework
- Install pre-commit - Configure .pre-commit-config.yaml with: - ruff (lint + format) for Python - bandit for Python security - eslint for TypeScript - prettier for TypeScript - shared constants validation - Add Makefile targets: pre-commit, lint
This commit is contained in:
parent
521848217d
commit
d55382d16f
3 changed files with 49 additions and 1 deletions
41
.pre-commit-config.yaml
Normal file
41
.pre-commit-config.yaml
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
|
rev: v0.14.0
|
||||||
|
hooks:
|
||||||
|
- id: ruff
|
||||||
|
args: [--fix]
|
||||||
|
files: ^backend/
|
||||||
|
- id: ruff-format
|
||||||
|
files: ^backend/
|
||||||
|
|
||||||
|
- repo: https://github.com/PyCQA/bandit
|
||||||
|
rev: 1.8.0
|
||||||
|
hooks:
|
||||||
|
- id: bandit
|
||||||
|
args: [-c, backend/pyproject.toml, -r]
|
||||||
|
files: ^backend/
|
||||||
|
exclude: ^backend/(tests|\.venv)/
|
||||||
|
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: eslint
|
||||||
|
name: ESLint
|
||||||
|
entry: npm run lint --prefix frontend
|
||||||
|
language: system
|
||||||
|
files: ^frontend/.*\.(ts|tsx)$
|
||||||
|
pass_filenames: false
|
||||||
|
|
||||||
|
- id: prettier
|
||||||
|
name: Prettier
|
||||||
|
entry: npm run format:check --prefix frontend
|
||||||
|
language: system
|
||||||
|
files: ^frontend/
|
||||||
|
pass_filenames: false
|
||||||
|
|
||||||
|
- id: check-constants
|
||||||
|
name: Check shared constants
|
||||||
|
entry: bash -c 'cd backend && uv run python validate_constants.py'
|
||||||
|
language: system
|
||||||
|
files: shared/constants\.json$
|
||||||
|
pass_filenames: false
|
||||||
|
|
||||||
8
Makefile
8
Makefile
|
|
@ -1,4 +1,4 @@
|
||||||
.PHONY: install-backend install-frontend install setup-hooks backend frontend db db-stop db-ready db-seed dev test test-backend test-frontend test-e2e typecheck generate-types generate-types-standalone check-types-fresh check-constants lint-backend format-backend fix-backend security-backend lint-frontend fix-frontend format-frontend
|
.PHONY: install-backend install-frontend install setup-hooks backend frontend db db-stop db-ready db-seed dev test test-backend test-frontend test-e2e typecheck generate-types generate-types-standalone check-types-fresh check-constants lint-backend format-backend fix-backend security-backend lint-frontend fix-frontend format-frontend pre-commit lint
|
||||||
|
|
||||||
-include .env
|
-include .env
|
||||||
export
|
export
|
||||||
|
|
@ -114,3 +114,9 @@ fix-frontend:
|
||||||
|
|
||||||
format-frontend:
|
format-frontend:
|
||||||
cd frontend && npm run format
|
cd frontend && npm run format
|
||||||
|
|
||||||
|
pre-commit:
|
||||||
|
cd backend && uv run pre-commit run --all-files
|
||||||
|
|
||||||
|
lint: lint-backend lint-frontend security-backend
|
||||||
|
@echo "All linting passed!"
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ dev = [
|
||||||
"ruff>=0.14.10",
|
"ruff>=0.14.10",
|
||||||
"pytest-cov>=7.0.0",
|
"pytest-cov>=7.0.0",
|
||||||
"bandit>=1.9.2",
|
"bandit>=1.9.2",
|
||||||
|
"pre-commit>=4.5.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue