diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 61f65df..99e9561 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,13 +1,12 @@ -name: Enforce Maintainer Approvals + +name: PR Checks and Maintainer Approvals + on: pull_request: - types: - - opened - - synchronize - - reopened - - review_requested - - review_submitted + types: [opened, synchronize, reopened, ready_for_review] + branches: + - main jobs: require-approvals: @@ -24,15 +23,15 @@ jobs: pull_number: context.payload.pull_request.number, }); - const maintainers = ["MrImmortal09", "whilstsomebody", "0PrashantYadav0", "shuklamaneesh23", " gauravghodinde", "Robinaditya1045"]; + const maintainers = ["MrImmortal09", "whilstsomebody", "0PrashantYadav0", "shuklamaneesh23", "gauravghodinde", "Robinaditya1045"]; let approvals = new Set(); reviews.forEach(review => { - if (review.state === "APPROVED" && maintainers.includes(review.user.login)) { - approvals.add(review.user.login); + if (review.state === "APPROVED" && maintainers.includes(review.user.login.trim())) { + approvals.add(review.user.login.trim()); } }); if (approvals.size < 1) { - core.setFailed(`At least 1 maintainer approvals are required. Currently approved by: ${Array.from(approvals).join(', ')}`); + core.setFailed(`At least 1 maintainer approval is required. Currently approved by: ${Array.from(approvals).join(', ') || 'none'}`); } diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 5dfc101..ec58038 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -20,13 +20,16 @@ jobs: uses: actions/setup-node@v4 with: node-version: 18 - cache: 'npm' + cache: 'pnpm' + + - name: Install pnpm + run: npm install -g pnpm - name: Install dependencies - run: npm ci + run: pnpm install - name: Run ESLint - run: npm run lint + run: pnpm lint build: runs-on: ubuntu-latest @@ -41,10 +44,13 @@ jobs: uses: actions/setup-node@v4 with: node-version: 18 - cache: 'npm' + cache: 'pnpm' + + - name: Install pnpm + run: npm install -g pnpm - name: Install dependencies - run: npm ci + run: pnpm install - name: Build - run: npm run build + run: pnpm build diff --git a/eslint.config.mjs b/eslint.config.mjs index 719cea2..1455289 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -9,17 +9,16 @@ const compat = new FlatCompat({ baseDirectory: __dirname, }); -const eslintConfig = [ - ...compat.extends("next/core-web-vitals", "next/typescript"), - { - ignores: [ - "node_modules/**", - ".next/**", - "out/**", - "build/**", - "next-env.d.ts", - ], - }, -]; +const eslintConfig = [{ + ignores: ["node_modules/**", ".next/**", "out/**", "build/**", "next-env.d.ts"] +}, ...compat.extends("next/core-web-vitals", "next/typescript"), { + ignores: [ + "node_modules/**", + ".next/**", + "out/**", + "build/**", + "next-env.d.ts", + ], +}]; export default eslintConfig; diff --git a/hooks/useContributors.ts b/hooks/useContributors.ts index a1716c9..8ba3243 100644 --- a/hooks/useContributors.ts +++ b/hooks/useContributors.ts @@ -31,8 +31,12 @@ export default function useContributors() { } const data = await response.json() setContributors(data) - } catch (err: any) { - setError(err.message) + } catch (err: unknown) { + if (err instanceof Error) { + setError(err.message) + } else { + setError(String(err)) + } } finally { setIsLoading(false) } diff --git a/package.json b/package.json index f90432e..5e96b24 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "dev": "next dev --turbopack", "build": "next build", "start": "next start", - "lint": "next lint", + "lint": "eslint .", "format": "prettier --write ." }, "dependencies": { @@ -59,7 +59,8 @@ "prettier": "^3.6.2", "tailwindcss": "^4.1.13", "tailwindcss-animate": "^1.0.7", - "typescript": "^5.9.2" + "typescript": "^5.9.2", + "@eslint/eslintrc": "^3" }, "trustedDependencies": [ "@tailwindcss/oxide",