From b043efcaf62d1890c7e87faa912f0283f15367f2 Mon Sep 17 00:00:00 2001 From: devang Date: Sat, 13 Dec 2025 03:39:16 +0530 Subject: [PATCH] feat: Add GitHub Actions workflow for ESLint and Flake8 linting --- .github/workflows/lint.yml | 76 ++++++++++++++++++++++++++++++++++++++ backend/.flake8 | 4 ++ backend/requirements.txt | 1 + frontend/package.json | 2 + 4 files changed, 83 insertions(+) create mode 100644 .github/workflows/lint.yml create mode 100644 backend/.flake8 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..92f9a3ae --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,76 @@ +# File: .github/workflows/lint.yml + +name: Code Quality Checks (Linting) + +# 1. Ensure both workflows run on: pull request and push to main branches +on: + push: + branches: + - main + pull_request: + branches: + - main + # Optional: Allows manual trigger from the GitHub Actions tab + workflow_dispatch: + +jobs: + # ======================================================= + # JOB 1: ESLint (JavaScript/Frontend) + # ======================================================= + eslint-check: + name: 🎨 ESLint (Frontend) + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + # Use a modern LTS version + node-version: '20' + # Use cache for faster dependency installation + cache: 'npm' + # Tell the action where the lock file is located + cache-dependency-path: frontend/package-lock.json + + - name: Install Frontend Dependencies + # Run inside the frontend directory + run: npm install + working-directory: frontend + + - name: Run ESLint + # This executes the "lint" script defined in frontend/package.json + run: npm run lint + working-directory: frontend + + # ======================================================= + # JOB 2: Flake8 (Python/Backend) + # ======================================================= + flake8-check: + name: 🐍 Flake8 (Backend) + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + # Choose a compatible Python version + python-version: '3.10' + + - name: Install Flake8 and Backend Dependencies + # Assuming you use a requirements.txt in the backend/ directory or root + run: | + pip install flake8 + if [ -f backend/requirements.txt ]; then + pip install -r backend/requirements.txt + fi + # Or if requirements is at the root: pip install -r requirements.txt + + - name: Run Flake8 on Backend Code + # Run Flake8 against the 'backend' directory. + # It will use the configuration from the .flake8 file if present. + run: flake8 backend/ + diff --git a/backend/.flake8 b/backend/.flake8 new file mode 100644 index 00000000..9b4463a9 --- /dev/null +++ b/backend/.flake8 @@ -0,0 +1,4 @@ +[flake8] +max-line-length = 120 +exclude = .git,__pycache__,venv,env,ENV,.venv,sessions,data + diff --git a/backend/requirements.txt b/backend/requirements.txt index a35dcb1e..b23cbbf1 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -3,4 +3,5 @@ flask-cors==4.0.0 flask-session==0.5.0 Werkzeug==3.0.1 python-dotenv==1.0.0 +flake8==7.3.0 diff --git a/frontend/package.json b/frontend/package.json index d28b3bdb..7b917e14 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -22,12 +22,14 @@ "three": "^0.181.2" }, "devDependencies": { + "@babel/eslint-parser": "^7.28.5", "@eslint/js": "^9.39.1", "@types/react": "^19.2.5", "@types/react-dom": "^19.2.3", "@vitejs/plugin-react": "^5.1.1", "autoprefixer": "^10.4.22", "eslint": "^9.39.1", + "eslint-plugin-react": "^7.37.5", "eslint-plugin-react-hooks": "^7.0.1", "eslint-plugin-react-refresh": "^0.4.24", "globals": "^16.5.0",