[Feat] Introduce linting in frontend project #2
Workflow file for this run
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | name: Frontend Checks | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'frontend/**' | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - 'frontend/**' | |
| permissions: | |
| contents: read | |
| jobs: | |
| frontend-lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'yarn' | |
| cache-dependency-path: 'frontend/yarn.lock' | |
| - name: Install dependencies | |
| working-directory: frontend | |
| run: yarn install --frozen-lockfile | |
| - name: Run ESLint (must have 0 errors) | |
| working-directory: frontend | |
| run: | | |
| echo "🧹 Running ESLint - checking for 0 errors..." | |
| # Run lint and capture output | |
| LINT_OUTPUT=$(yarn lint 2>&1) | |
| LINT_EXIT_CODE=$? | |
| echo "$LINT_OUTPUT" | |
| # Parse the output to check for errors (but not warnings) | |
| if echo "$LINT_OUTPUT" | grep -q "([1-9][0-9]* errors\?"; then | |
| ERROR_COUNT=$(echo "$LINT_OUTPUT" | grep -o '([1-9][0-9]* error' | head -1 | grep -o '[0-9]\+' || echo "unknown") | |
| echo "" | |
| echo "❌ ESLint found $ERROR_COUNT errors. All errors must be fixed before merging." | |
| echo "💡 Run 'cd frontend && yarn lint:fix' to automatically fix some issues." | |
| echo "💡 Or fix them manually and commit the changes." | |
| exit 1 | |
| elif [ $LINT_EXIT_CODE -ne 0 ]; then | |
| echo "❌ ESLint failed with exit code $LINT_EXIT_CODE" | |
| exit 1 | |
| else | |
| echo "✅ ESLint passed with 0 errors!" | |
| fi | |
| - name: Run TypeScript check | |
| working-directory: frontend | |
| run: | | |
| echo "🔍 Running TypeScript check..." | |
| yarn typecheck | |
| if [ $? -eq 0 ]; then | |
| echo "✅ TypeScript check passed!" | |
| else | |
| echo "❌ TypeScript check failed" | |
| exit 1 | |
| fi |