Skip to content

Conversation

@Thunder-Blaze
Copy link
Contributor

@Thunder-Blaze Thunder-Blaze commented Sep 6, 2025

Description

  • Just switched to Eslint from Next Lint which is soon to be deprecated
  • Fixed Few Lint Errors

Live Demo (if any)

None

Note for Maintainer

None

Checkout

  • I have read all the contributor guidelines for the repo.

Summary by CodeRabbit

  • Bug Fixes

    • Improved error handling in the contributors feature to prevent crashes and display clearer messages when failures occur.
  • Chores

    • Updated linting tooling and configuration to standard ESLint, aligning scripts and dependencies.
    • Reorganized lint settings for consistency without changing ignore patterns or project behavior.

@vercel
Copy link

vercel bot commented Sep 6, 2025

@Thunder-Blaze is attempting to deploy a commit to the mrimmortal09's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Sep 6, 2025

Walkthrough

Reordered ESLint config blocks in eslint.config.mjs to begin and end with ignores around extends. Updated useContributors error handling to use unknown with safe message extraction. Changed lint script from next lint to eslint . and added @eslint/eslintrc to dependencies and devDependencies.

Changes

Cohort / File(s) Summary
ESLint configuration
eslint.config.mjs
Reordered array: added an ignores object at the start and kept an ignores object at the end around ...compat.extends(...); ignore patterns unchanged.
Tooling scripts & deps
package.json
Updated scripts.lint from next lint to eslint .; added @eslint/eslintrc@^3 to both dependencies and devDependencies.
Hook error handling
hooks/useContributors.ts
Catch clause type changed from any to unknown; added instanceof Error check; fallback to String(err) when not an Error.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
hooks/useContributors.ts (1)

48-56: Initial fetch result is never sorted.

The sort effect only runs on sortBy changes. After the first fetch, contributors stays unsorted.

Apply this diff to sort immediately after fetching (and keep the effect for subsequent sortBy changes):

-        const data = await response.json()
-        setContributors(data)
+        const data = (await response.json()) as TypeContributors[]
+        const sorted =
+          sortBy === 'contributions'
+            ? [...data].sort((a, b) => b.contributions - a.contributions)
+            : [...data].sort((a, b) => a.login.localeCompare(b.login))
+        setContributors(sorted)
package.json (1)

57-64: Add missing ESLint peer dependencies
eslint-config-next’s TS setup and React Hooks rules require these devDependencies:

  • @typescript-eslint/parser
  • @typescript-eslint/eslint-plugin
  • eslint-plugin-react-hooks

Install them in package.json and re-run your lint check to confirm resolution.

🧹 Nitpick comments (4)
hooks/useContributors.ts (2)

22-46: Abort in-flight fetch to avoid setting state on unmounted component.

Prevents memory leaks and React warnings during rapid navigation.

Example change:

useEffect(() => {
  const ac = new AbortController();
  const fetchContributors = async () => {
    setIsLoading(true);
    try {
      const response = await fetch(
        `https://api.github.com/repos/${RepoDetails.owner}/${RepoDetails.repo}/contributors`,
        { signal: ac.signal, headers: { Accept: 'application/vnd.github+json' } }
      );
      if (!response.ok) {
        throw new Error(`Failed to fetch contributors: ${response.status} ${response.statusText}`);
      }
      const data = (await response.json()) as TypeContributors[];
      // initial sort here (see previous comment)...
    } catch (err) {
      if (ac.signal.aborted) return;
      setError(err instanceof Error ? err.message : String(err));
    } finally {
      if (!ac.signal.aborted) setIsLoading(false);
    }
  };
  fetchContributors();
  return () => ac.abort();
}, [/* repo details if they can change */]);

29-31: Propagate HTTP context in errors.

Including status/statusText helps users and logs.

Apply this diff:

-        if (!response.ok) {
-          throw new Error('Failed to fetch contributors')
-        }
+        if (!response.ok) {
+          throw new Error(`Failed to fetch contributors: ${response.status} ${response.statusText}`)
+        }
package.json (1)

9-9: Tighten lint script for CI.

Fail on warnings to keep the bar high; add an autofix script.

-    "lint": "eslint .",
+    "lint": "eslint . --max-warnings=0",
+    "lint:fix": "eslint . --fix",
eslint.config.mjs (1)

12-22: Duplicate ignores; simplify config array.

Keep a single ignores block; no need to repeat it at the end.

-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",
-  ],
-}];
+const eslintConfig = [
+  { ignores: ["node_modules/**", ".next/**", "out/**", "build/**", "next-env.d.ts"] },
+  ...compat.extends("next/core-web-vitals", "next/typescript"),
+];
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6aa1691 and 86d88ea.

📒 Files selected for processing (3)
  • eslint.config.mjs (1 hunks)
  • hooks/useContributors.ts (1 hunks)
  • package.json (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
hooks/useContributors.ts (1)
app/contributors/page.tsx (1)
  • useContributors (5-80)
🔇 Additional comments (2)
hooks/useContributors.ts (1)

34-39: Good move to unknown + safe message extraction.

More robust and aligns with TS best practices.

eslint.config.mjs (1)

12-22: Incorrect suggestion: Next v15 lacks a native flat export
eslint-config-next v15 does not ship a built-in “eslint-config-next/flat” export; you must continue using FlatCompat (or a community-maintained flat port) for ESLint v9 flat-config support.

Likely an incorrect or invalid review comment.

@MrImmortal09 MrImmortal09 force-pushed the main branch 2 times, most recently from 0d218de to a1d8e6b Compare December 1, 2025 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants