feat: add unified linting scripts and git hooks for code quality enforcement
- Introduced `lint` and `lint-fix` applications in `flake.nix` for unified linting of backend (Python) and frontend (TypeScript/Svelte) code. - Added `scripts/lint.sh` for manual linting execution. - Created `scripts/install-hooks.sh` to set up git hooks for automatic linting before commits and optional tests before pushes. - Updated `README.md` with instructions for using the new linting features and git hooks.
This commit is contained in:
61
flake.nix
61
flake.nix
@@ -96,6 +96,67 @@
|
||||
'';
|
||||
};
|
||||
|
||||
# Apps - Scripts that can be run with `nix run`
|
||||
apps = {
|
||||
# Unified linting for all code
|
||||
lint = {
|
||||
type = "app";
|
||||
program = "${pkgs.writeShellScript "lint" ''
|
||||
set -e
|
||||
cd ${self}
|
||||
|
||||
# Backend Python linting
|
||||
echo "🔍 Linting backend Python code..."
|
||||
cd backend
|
||||
${pkgs.ruff}/bin/ruff check --no-cache app/
|
||||
${pkgs.ruff}/bin/ruff format --check app/
|
||||
cd ..
|
||||
|
||||
# Frontend linting (if node_modules exists)
|
||||
if [ -d "frontend/node_modules" ]; then
|
||||
echo ""
|
||||
echo "🔍 Linting frontend TypeScript/Svelte code..."
|
||||
cd frontend
|
||||
npm run lint
|
||||
npx prettier --check src/
|
||||
npm run check
|
||||
cd ..
|
||||
else
|
||||
echo "⚠ Frontend node_modules not found, run 'npm install' first"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "✅ All linting checks passed!"
|
||||
''}";
|
||||
};
|
||||
|
||||
# Auto-fix linting issues
|
||||
lint-fix = {
|
||||
type = "app";
|
||||
program = "${pkgs.writeShellScript "lint-fix" ''
|
||||
set -e
|
||||
cd ${self}
|
||||
|
||||
echo "🔧 Auto-fixing backend Python code..."
|
||||
cd backend
|
||||
${pkgs.ruff}/bin/ruff check --fix --no-cache app/
|
||||
${pkgs.ruff}/bin/ruff format app/
|
||||
cd ..
|
||||
|
||||
if [ -d "frontend/node_modules" ]; then
|
||||
echo ""
|
||||
echo "🔧 Auto-fixing frontend code..."
|
||||
cd frontend
|
||||
npx prettier --write src/
|
||||
cd ..
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "✅ Auto-fix complete!"
|
||||
''}";
|
||||
};
|
||||
};
|
||||
|
||||
# Package definitions (for production deployment)
|
||||
packages = {
|
||||
# Backend package
|
||||
|
||||
Reference in New Issue
Block a user