Skip to content

Commit 91fede0

Browse files
created yaml github actions flow to auto lint
1 parent 00e312a commit 91fede0

File tree

22 files changed

+4141
-142
lines changed

22 files changed

+4141
-142
lines changed

.github/workflows/lint.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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

.husky/pre-commit

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
echo "🔍 Running pre-commit checks..."
5+
6+
# Check if we're in frontend or backend directory
7+
if [[ $PWD == *"/frontend"* ]]; then
8+
echo "📦 Frontend checks..."
9+
npm run lint
10+
npm run type-check
11+
npm run format:check
12+
elif [[ $PWD == *"/backend"* ]]; then
13+
echo "🖥️ Backend checks..."
14+
npm run lint
15+
npm run type-check
16+
npm run format:check
17+
else
18+
echo "🔍 Full project checks..."
19+
20+
# Frontend checks
21+
echo "📦 Checking frontend..."
22+
cd frontend
23+
npm run lint
24+
npm run type-check
25+
npm run format:check
26+
cd ..
27+
28+
# Backend checks
29+
echo "🖥️ Checking backend..."
30+
cd backend
31+
npm run lint
32+
npm run type-check
33+
npm run format:check
34+
cd ..
35+
fi
36+
37+
echo "✅ All checks passed!"

backend/.prettierrc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "es5",
4+
"singleQuote": true,
5+
"printWidth": 100,
6+
"tabWidth": 2,
7+
"useTabs": false,
8+
"bracketSpacing": true,
9+
"arrowParens": "avoid",
10+
"endOfLine": "lf",
11+
"quoteProps": "as-needed",
12+
"bracketSameLine": false,
13+
"overrides": [
14+
{
15+
"files": "*.ts",
16+
"options": {
17+
"parser": "typescript"
18+
}
19+
},
20+
{
21+
"files": "*.prisma",
22+
"options": {
23+
"parser": "prisma-parse"
24+
}
25+
}
26+
]
27+
}

backend/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ app.get('/api/db-test', async (req, res) => {
2626
// API Routes
2727
app.use('/api/analytics', analyticsRoutes);
2828

29-
export default app;
29+
export default app;

backend/config/aws.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ AWS.config.update({
88

99
export const s3 = new AWS.S3();
1010

11-
export default AWS;
11+
export default AWS;

backend/config/database.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ const pool = new Pool({
88
port: parseInt(process.env.DB_PORT || '5432'),
99
});
1010

11-
export default pool;
11+
export default pool;

backend/config/firebase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ if (!admin.apps.length) {
1818
}
1919

2020
export const auth = admin.auth();
21-
export default admin;
21+
export default admin;

backend/config/sendgrid.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ if (!process.env.SENDGRID_API_KEY) {
66

77
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
88

9-
export default sgMail;
9+
export default sgMail;

backend/config/stripe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
88
apiVersion: '2024-06-20',
99
});
1010

11-
export default stripe;
11+
export default stripe;

backend/controllers/controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import { Request, Response } from 'express';
22

3-
// API Controllers Here
3+
// API Controllers Here

0 commit comments

Comments
 (0)