1+ name : TypeScript Lint & Format
2+
3+ on :
4+ push :
5+ branches : [ main, develop ]
6+ pull_request :
7+ branches : [ main, develop ]
8+
9+ jobs :
10+ lint :
11+ name : Lint & Format Check
12+ runs-on : ubuntu-latest
13+
14+ steps :
15+ - name : Checkout code
16+ uses : actions/checkout@v4
17+
18+ - name : Setup Node.js
19+ uses : actions/setup-node@v4
20+ with :
21+ node-version : ' 18'
22+ cache : ' npm'
23+ cache-dependency-path : |
24+ frontend/package-lock.json
25+ backend/package-lock.json
26+
27+ # Frontend linting
28+ - name : Install frontend dependencies
29+ working-directory : ./frontend
30+ run : npm ci
31+
32+ - name : Lint frontend TypeScript
33+ working-directory : ./frontend
34+ run : npm run lint
35+
36+ - name : Check frontend TypeScript types
37+ working-directory : ./frontend
38+ run : npm run type-check
39+
40+ - name : Format check frontend
41+ working-directory : ./frontend
42+ run : npm run format:check
43+
44+ # Backend linting
45+ - name : Install backend dependencies
46+ working-directory : ./backend
47+ run : npm ci
48+
49+ - name : Lint backend TypeScript
50+ working-directory : ./backend
51+ run : npm run lint
52+
53+ - name : Check backend TypeScript types
54+ working-directory : ./backend
55+ run : npm run type-check
56+
57+ - name : Format check backend
58+ working-directory : ./backend
59+ run : npm run format:check
60+
61+ auto-fix :
62+ name : Auto-fix & Format
63+ runs-on : ubuntu-latest
64+ if : github.event_name == 'push'
65+
66+ steps :
67+ - name : Checkout code
68+ uses : actions/checkout@v4
69+ with :
70+ token : ${{ secrets.GITHUB_TOKEN }}
71+
72+ - name : Setup Node.js
73+ uses : actions/setup-node@v4
74+ with :
75+ node-version : ' 18'
76+ cache : ' npm'
77+ cache-dependency-path : |
78+ frontend/package-lock.json
79+ backend/package-lock.json
80+
81+ # Auto-fix frontend
82+ - name : Install frontend dependencies
83+ working-directory : ./frontend
84+ run : npm ci
85+
86+ - name : Auto-fix frontend linting issues
87+ working-directory : ./frontend
88+ run : npm run lint:fix
89+
90+ - name : Format frontend code
91+ working-directory : ./frontend
92+ run : npm run format
93+
94+ # Auto-fix backend
95+ - name : Install backend dependencies
96+ working-directory : ./backend
97+ run : npm ci
98+
99+ - name : Auto-fix backend linting issues
100+ working-directory : ./backend
101+ run : npm run lint:fix
102+
103+ - name : Format backend code
104+ working-directory : ./backend
105+ run : npm run format
106+
107+ # Commit fixes if any
108+ - name : Commit auto-fixes
109+ run : |
110+ git config --local user.email "action@github.com"
111+ git config --local user.name "GitHub Action"
112+ git add .
113+ git diff --staged --quiet || git commit -m "🤖 Auto-fix linting and formatting issues"
114+ git push
0 commit comments