Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update nextjs v15, react v19 and eslint v9 #420

Merged
merged 8 commits into from
Nov 14, 2024

Conversation

thucpn
Copy link
Collaborator

@thucpn thucpn commented Nov 11, 2024

Summary by CodeRabbit

  • New Features

    • Updated project dependencies to the latest versions, improving performance and compatibility.
    • Added a new TypeScript configuration option to target ECMAScript 2017.
    • Introduced a new ESLint configuration for TypeScript projects to enhance code quality.
  • Bug Fixes

    • Simplified configuration by removing unnecessary wrappers in the project settings.
    • Enhanced CORS handling based on the environment for better security.
  • Chores

    • Updated various development tools and libraries, including ESLint and Next.js, to enhance code quality and maintainability.
    • Added a new script for linting the project.

Copy link

changeset-bot bot commented Nov 11, 2024

🦋 Changeset detected

Latest commit: 6e7792f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
create-llama Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

coderabbitai bot commented Nov 11, 2024

Walkthrough

This pull request introduces a patch named "create-llama" that updates multiple dependencies across several configuration files. Key updates include upgrading ESLint to version 9, Next.js to version 15, and React to version 19. Additionally, the next.config.json file is simplified by removing the "experimental" key, and a new target property is added to the TypeScript configuration to specify ECMAScript version 2017.

Changes

File Path Change Summary
.changeset/swift-donuts-own.md Introduces patch "create-llama" and updates ESLint, Next.js, and React versions.
templates/types/streaming/express/package.json Adds "lint": "eslint ." script, updates ESLint from ^8.54.0 to ^9.14.0, and adds "typescript-eslint": "^8.14.0" in devDependencies.
templates/types/streaming/nextjs/next.config.json Removes "experimental" key, retaining outputFileTracingIncludes and outputFileTracingExcludes.
templates/types/streaming/nextjs/package.json Updates dependencies: next to ^15.0.3, react and react-dom to 19.0.0-rc-5c56b873-20241107, and various ESLint packages.
templates/types/streaming/nextjs/tsconfig.json Adds target: "ES2017" to compilerOptions.
templates/types/streaming/express/eslint.config.mjs Introduces a new ESLint configuration file for TypeScript, setting up compatibility with recommended configurations.
templates/types/streaming/express/eslintrc.json Removes the existing ESLint configuration file, eliminating previous linting rules.
templates/types/streaming/express/index.ts Modifies CORS configuration based on environment variables and streamlines Express server initialization.
helpers/typescript.ts Updates installTSTemplate function to change handling of Next.js configuration for server components.
templates/types/streaming/nextjs/app/api/files/[...slug]/route.ts Updates GET function to change params argument type from synchronous to a promise.

Possibly related PRs

Suggested reviewers

  • marcusschiesser

🐰 In the meadow, changes bloom,
Dependencies rise, banishing gloom.
ESLint and React, a fresh new start,
With Next.js shining, a work of art.
Let's hop along, with joy we sing,
For every update, new features bring! 🌼

Warning

Rate limit exceeded

@thucpn has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 17 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between a3ab617 and 6e7792f.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@thucpn thucpn marked this pull request as ready for review November 13, 2024 03:39
@thucpn thucpn changed the title chore: update eslint and nextjs v15 chore: update nextjs v15, react v19 and eslint v9 Nov 13, 2024
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: 1

🧹 Outside diff range and nitpick comments (1)
templates/types/streaming/nextjs/next.config.json (1)

1-13: Consider adding Next.js 15 specific optimizations

The configuration could benefit from new Next.js 15 features and optimizations.

Consider adding these Next.js 15 specific configurations:

{
  "outputFileTracingIncludes": {
    "/*": ["./cache/**/*"]
  },
  "outputFileTracingExcludes": {
    "/api/files/*": [
      ".next/**/*",
      "node_modules/**/*",
      "public/**/*",
      "app/**/*"
    ]
  },
-  "transpilePackages": ["highlight.js"]
+  "transpilePackages": ["highlight.js"],
+  "logging": {
+    "fetches": {
+      "fullUrl": true
+    }
+  },
+  "typedRoutes": true
}

These additions will:

  • Enable better debugging with full URL logging for fetch requests
  • Enable type safety for routes (new in Next.js 15)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2b712ce and ffca1dd.

📒 Files selected for processing (5)
  • .changeset/swift-donuts-own.md (1 hunks)
  • templates/types/streaming/express/package.json (1 hunks)
  • templates/types/streaming/nextjs/next.config.json (1 hunks)
  • templates/types/streaming/nextjs/package.json (2 hunks)
  • templates/types/streaming/nextjs/tsconfig.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • templates/types/streaming/express/package.json
🧰 Additional context used
📓 Path-based instructions (3)
templates/types/streaming/nextjs/next.config.json (1)

Pattern templates/**: For files under the templates folder, do not report 'Missing Dependencies Detected' errors.

templates/types/streaming/nextjs/package.json (1)

Pattern templates/**: For files under the templates folder, do not report 'Missing Dependencies Detected' errors.

templates/types/streaming/nextjs/tsconfig.json (1)

Pattern templates/**: For files under the templates folder, do not report 'Missing Dependencies Detected' errors.

🪛 LanguageTool
.changeset/swift-donuts-own.md

[uncategorized] ~5-~5: The official spelling of this programming framework is “Next.js”.
Context: ...ma": patch --- chore: update eslint 9, nextjs 15, react 19

(NODE_JS)

🔇 Additional comments (4)
templates/types/streaming/nextjs/next.config.json (1)

2-11: Verify file tracing paths for Next.js 15 compatibility

The file tracing configuration has been moved out of the "experimental" key, which is correct as these features are now stable in Next.js 15. However, we should verify that all the excluded paths are still necessary and working as expected with the new version.

Let's verify the existence and usage of these paths:

templates/types/streaming/nextjs/package.json (3)

31-31: Verify compatibility between Next.js 15 and ESLint 9

The major version upgrades of both Next.js (15.0.3) and ESLint (9.14.0) require careful verification of compatibility, especially with eslint-config-next.

Run this verification:

#!/bin/bash
# Check for any Next.js 15 specific lint rules or breaking changes
rg -l "next/core-web-vitals|next/babel|next/recommended" 

# Look for any .eslintrc files that might need updates
fd -e json -e js -e yml -e yaml '.eslintrc'

Also applies to: 50-50


49-51: ESLint Configuration Updates Required

Major version upgrades in ESLint and its configs might introduce breaking changes in linting rules.

Run this verification:

Consider documenting any required updates to ESLint configuration in the migration guide.


32-33: ⚠️ Potential issue

Caution: Using React Release Candidate in Production

The update includes a specific React RC build (19.0.0-rc-5c56b873-20241107). While this allows early access to React 19 features, using RC versions in production templates could lead to stability issues.

Consider either:

  1. Staying on stable React 18 until React 19 is officially released
  2. Adding a warning in the template documentation about the experimental nature of React 19 RC
✅ Verification successful

Verified: No Production Code Uses React 19-specific Features

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if any production code relies on React 19-specific features
rg -l "use(Optimizer|Cache|FormStatus|FormState)" 

Length of output: 149

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: 2

🧹 Outside diff range and nitpick comments (2)
templates/types/streaming/express/eslint.config.mjs (2)

26-28: Consider documenting disabled TypeScript rules

While disabling these TypeScript rules might be necessary for your use case, it's recommended to document why these rules are disabled to help maintain the codebase in the future.

   rules: {
-    "@typescript-eslint/no-explicit-any": "off",
-    "@typescript-eslint/ban-ts-comment": "off",
-    "@typescript-eslint/no-unused-vars": "off",
+    // Disabled to allow flexibility in template code
+    "@typescript-eslint/no-explicit-any": "off",
+    // Disabled to allow necessary type assertions in template code
+    "@typescript-eslint/ban-ts-comment": "off",
+    // Disabled as template code might contain example variables
+    "@typescript-eslint/no-unused-vars": "off",

24-24: Consider increasing the max-params limit

A limit of 4 parameters might be too restrictive for some use cases. Consider increasing this limit or using object parameters for functions that need more parameters.

-    "max-params": ["error", 4],
+    "max-params": ["error", 5],
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ffca1dd and 8bf3236.

📒 Files selected for processing (4)
  • templates/types/streaming/express/eslint.config.mjs (1 hunks)
  • templates/types/streaming/express/eslintrc.json (0 hunks)
  • templates/types/streaming/express/index.ts (0 hunks)
  • templates/types/streaming/express/package.json (2 hunks)
💤 Files with no reviewable changes (2)
  • templates/types/streaming/express/eslintrc.json
  • templates/types/streaming/express/index.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • templates/types/streaming/express/package.json
🧰 Additional context used
📓 Path-based instructions (1)
templates/types/streaming/express/eslint.config.mjs (1)

Pattern templates/**: For files under the templates folder, do not report 'Missing Dependencies Detected' errors.

🔇 Additional comments (3)
templates/types/streaming/express/eslint.config.mjs (3)

1-5: LGTM! Proper usage of ESLint v9's flat config system

The imports are correctly structured using ESLint v9's new flat configuration format, with proper usage of the node: prefix for built-in modules.


7-8: LGTM! Correct ES module path handling

The code properly sets up __filename and __dirname for ES modules, which is necessary since these variables aren't available by default in ESM.


9-13: LGTM! Proper FlatCompat initialization

The FlatCompat initialization is correctly configured with the necessary base directory and recommended configurations for ESLint v9.

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

🧹 Outside diff range and nitpick comments (1)
templates/types/streaming/nextjs/app/api/files/[...slug]/route.ts (1)

24-24: Consider adding type safety for array destructuring

While the destructuring works correctly, consider adding runtime validation for the expected array structure to prevent potential undefined values.

-  const [folder, ...pathTofile] = slug; // data, file.pdf
+  if (slug.length === 0) {
+    return NextResponse.json({ detail: "Invalid file path format" }, { status: 400 });
+  }
+  const [folder, ...pathTofile] = slug; // data, file.pdf
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a3ab617 and 6e7792f.

📒 Files selected for processing (4)
  • helpers/typescript.ts (1 hunks)
  • templates/types/streaming/express/package.json (2 hunks)
  • templates/types/streaming/nextjs/app/api/files/[...slug]/route.ts (2 hunks)
  • templates/types/streaming/nextjs/package.json (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • helpers/typescript.ts
  • templates/types/streaming/express/package.json
  • templates/types/streaming/nextjs/package.json
🧰 Additional context used
📓 Path-based instructions (1)
templates/types/streaming/nextjs/app/api/files/[...slug]/route.ts (1)

Pattern templates/**: For files under the templates folder, do not report 'Missing Dependencies Detected' errors.

🔇 Additional comments (1)
templates/types/streaming/nextjs/app/api/files/[...slug]/route.ts (1)

12-14: Verify Next.js 15 route handler changes

The change to make params a Promise type aligns with Next.js 15's API changes for dynamic route parameters. The implementation correctly awaits the params before accessing the slug.

Let's verify other route handlers for consistency:

✅ Verification successful

Let me gather more information to verify if there are any other route handlers that might need updates.


Based on the search results, I can now generate the final response:

Next.js 15 route handler implementation is correct

The implementation in [...slug]/route.ts is the only dynamic route handler in the codebase that requires the Promise-based params type. The change correctly handles the Next.js 15 API requirements by:

  • Using the correct Promise type annotation for params
  • Properly awaiting the params before accessing the slug property
  • Maintaining consistent error handling and response patterns
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if all route handlers are updated for Next.js 15
# Expected: All dynamic route handlers should use Promise<{ params }> type

# Search for other route handlers with dynamic parameters
ast-grep --pattern 'export async function $_(
  $_: NextRequest,
  { params }: { params: { $$$} }
)'

# Search for potential missed updates
rg -l "params.*slug.*string\[\]" --type ts

Length of output: 213


Script:

#!/bin/bash
# Search for all route handlers in the codebase
ast-grep --pattern 'export async function $_(
  $_,
  { params }: $_
) {
  $$$
}'

# Also search for any other files that might be using params
rg -l "export.*function.*params.*:" --type ts

Length of output: 4760

@marcusschiesser marcusschiesser merged commit 44b34fb into main Nov 14, 2024
46 checks passed
@marcusschiesser marcusschiesser deleted the feat/upgrade-latest-nextjs-and-eslint branch November 14, 2024 02:47
@coderabbitai coderabbitai bot mentioned this pull request Dec 27, 2024
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