-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathsetup-linting.sh
More file actions
executable file
·68 lines (57 loc) · 2 KB
/
Copy pathsetup-linting.sh
File metadata and controls
executable file
·68 lines (57 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# Setup linting and code quality tools for BESS Manager
set -e # Exit on error
echo "=== Setting up code quality tools for BESS Manager ==="
# Check if Python is installed
if ! command -v python3 &> /dev/null; then
echo "Python 3 is required but not found. Please install Python 3 first."
exit 1
fi
# Check if pip is installed
if ! command -v pip3 &> /dev/null; then
echo "pip3 is required but not found. Please install pip3 first."
exit 1
fi
# Check if Node.js is installed (for frontend linting)
if ! command -v node &> /dev/null; then
echo "Node.js is required for frontend linting but not found."
echo "Please install Node.js first if you want to lint frontend code."
echo "Continuing with backend setup only..."
SKIP_FRONTEND=true
else
SKIP_FRONTEND=false
fi
# Install pre-commit
echo "Installing pre-commit..."
pip3 install pre-commit
# Install Python linters
echo "Installing Python linters..."
pip3 install black ruff mypy types-requests types-PyYAML
# Install frontend linters if Node.js is available
if [ "$SKIP_FRONTEND" = false ]; then
echo "Installing frontend linters..."
cd frontend
npm install --save-dev eslint prettier \
eslint-plugin-react \
eslint-config-prettier \
@typescript-eslint/eslint-plugin \
@typescript-eslint/parser
cd ..
fi
# Install pre-commit hooks
echo "Installing pre-commit hooks..."
pre-commit install
echo "Setting up git hook paths..."
git config core.hooksPath .git/hooks
echo ""
echo "=== Setup complete! ==="
echo "Code quality tools are now installed and configured."
echo "Pre-commit hooks will run automatically on git commit."
echo ""
echo "You can also run the checks manually with:"
echo " - pre-commit run --all-files # Run all checks on all files"
echo " - pre-commit run # Run checks only on staged files"
echo ""
echo "For frontend linting, you can also run:"
echo " - cd frontend && npm run lint # Run ESLint"
echo " - cd frontend && npm run format # Run Prettier"