-
Notifications
You must be signed in to change notification settings - Fork 2
chore: bump rspress to v2.0.0-beta.26 #147
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
Conversation
🦋 Changeset detectedLatest commit: 7b02d65 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughPatch release changeset added. package.json dependencies bumped (notably rspress to 2.0.0-beta.26). Several files add ESLint suppression comments. Overview now uses useSidebar() instead of useSidebarData(). Minor code tweaks in PDF export (removed optional chaining) and a config change removing markdown.checkDeadLinks. Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant Overview as Overview Component
participant R as @rspress/core/runtime
U->>Overview: Render
Overview->>R: useSidebar()
R-->>Overview: Sidebar groups array
Overview-->>U: Rendered overview with groups
sequenceDiagram
participant CLI as CLI pdf()
participant DOM as Document
participant P as Printer
CLI->>P: generate PDF
P->>DOM: query title / headings
DOM-->>P: title.textContent, h*.textContent
P->>P: trim() without null checks
P-->>CLI: PDF output or throw on null textContent
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR bumps the rspress framework to version 2.0.0-beta.26, updating dependencies and adapting code to handle deprecation warnings and API changes.
- Updates rspress core dependencies from beta.22 to beta.26
- Replaces deprecated
useSidebarDatawithuseSidebarhook - Adds ESLint disable comments for deprecated
usePageDatausage - Removes unnecessary type assertions and config options
Reviewed Changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Updates rspress and related dependencies to beta.26 versions |
| src/runtime/components/Overview.tsx | Replaces deprecated useSidebarData with useSidebar hook |
| src/runtime/hooks/useIsPrint.ts | Removes unnecessary boolean coercion |
| src/cli/load-config.ts | Removes deprecated checkDeadLinks configuration |
| Multiple component files | Adds ESLint disable comments for deprecated usePageData usage |
| PDF processing files | Removes unnecessary optional chaining with non-null assertions |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
Signed-off-by: JounQin <admin@1stg.me>
commit: |
There was a problem hiding this 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
♻️ Duplicate comments (2)
src/cli/html-export-pdf/core/printer.ts (1)
210-216: Potential runtime error: title.textContent can be nullIf
<title>exists but itstextContentis null,.trim()will throw and unnecessarily abort PDF generation. Use a safe fallback.Apply this diff:
- meta.title = title.textContent.trim() + meta.title = (title.textContent ?? '').trim()Optional: you could also use
document.titlewhich is always a string:meta.title = document.title.trim()src/cli/html-export-pdf/core/outline.ts (1)
109-114: Potential runtime error: tag.textContent can be nullDirectly calling
.trim()ontag.textContentrisks a crash if it’s null, which would break outline extraction for PDFs.Apply this diff:
- title: tag.textContent.trim().replace(/^#|#$/, ''), + title: (tag.textContent ?? '').trim().replace(/^#|#$/, ''),
🧹 Nitpick comments (5)
src/global/SiteOverrides/index.tsx (1)
37-38: Inline no-deprecated suppression is fine given upstream constraintsAcceptable localized suppression until
usePage(or an equivalent) is exported from the runtime. Please track migration to the non-deprecated API when it becomes available.Would you like me to open a follow-up issue to track the migration away from
usePageData()?src/runtime/hooks/useIsPrint.ts (1)
28-30: Redundant boolean coercion removal is correct
mqList.matchesis already boolean; using it directly is cleaner.For consistency, consider aligning the initial state too:
// current const [isPrint, changeIsPrint] = useState(!!printMediaQuery?.matches) // suggested const [isPrint, changeIsPrint] = useState(printMediaQuery?.matches ?? false)src/theme.tsx (1)
95-99: Prefer placing ESLint directive above the statement for consistencyThe inline directive inside the destructuring works, but placing it on the line above the
usePageData()statement matches the pattern used elsewhere in the repo and reads cleaner.Apply this diff to reposition the directive:
export const Layout = () => { - const { - siteData: { lang: siteLang, themeConfig }, - // eslint-disable-next-line @typescript-eslint/no-deprecated -- `usePage` is not exported... - } = usePageData() + // eslint-disable-next-line @typescript-eslint/no-deprecated -- `usePage` is not exported... + const { + siteData: { lang: siteLang, themeConfig }, + } = usePageData()src/runtime/components/Overview.tsx (2)
66-67: Localized eslint suppression is fine; add a TODO to track migrationThis is a pragmatic workaround until a supported replacement is exported. Consider adding a TODO to revisit when
usePage(or equivalent) becomes available.Apply this diff to document the intent:
- // eslint-disable-next-line @typescript-eslint/no-deprecated -- `usePage` is not exported... + // TODO: migrate away from usePageData when a supported `usePage` (or equivalent) is exported upstream. + // eslint-disable-next-line @typescript-eslint/no-deprecated -- `usePage` is not exported...
86-97: Defensive guard when narrowing sidebar by routeIf
findItemByRoutePathreturns an empty array (or a non-array), this reassignment could unintentionally drop the sidebar groups. Add a small guard to keep the original value in that case.Apply this diff:
- overviewSidebarGroups = findItemByRoutePath( - overviewSidebarGroups, - routePath, - ) + const resolved = findItemByRoutePath(overviewSidebarGroups, routePath) + if (Array.isArray(resolved) && resolved.length) { + overviewSidebarGroups = resolved + }If helpful, I can also check the return type of
findItemByRoutePathacross the repo to confirm it always returns an array.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (13)
.changeset/eleven-files-nail.md(1 hunks)package.json(3 hunks)src/cli/html-export-pdf/core/outline.ts(1 hunks)src/cli/html-export-pdf/core/printer.ts(1 hunks)src/cli/load-config.ts(0 hunks)src/global/SiteOverrides/index.tsx(1 hunks)src/global/VersionsNav/index.tsx(1 hunks)src/runtime/components/ExternalSiteLink.tsx(1 hunks)src/runtime/components/OpenAPIPath.tsx(1 hunks)src/runtime/components/OpenAPIRef.tsx(1 hunks)src/runtime/components/Overview.tsx(3 hunks)src/runtime/hooks/useIsPrint.ts(1 hunks)src/theme.tsx(1 hunks)
💤 Files with no reviewable changes (1)
- src/cli/load-config.ts
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-05-26T08:59:41.491Z
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T08:59:41.491Z
Learning: In rspress/core v2.0.0-beta.7, the '/theme' export is available in the package exports field as `"./theme": { "default": "./theme.ts" }`, so imports like `import { Badge, Button } from 'rspress/core/theme'` are valid even if ESLint shows resolution errors.
Applied to files:
src/theme.tsx
📚 Learning: 2025-06-06T07:08:55.881Z
Learnt from: JounQin
PR: alauda/doom#69
File: package.json:101-101
Timestamp: 2025-06-06T07:08:55.881Z
Learning: When a package has peer dependencies that require TypeScript (like `eslint-react/eslint-plugin`), TypeScript should be moved from devDependencies to dependencies to satisfy the peer dependency requirement.
Applied to files:
package.json
🔇 Additional comments (9)
src/runtime/components/OpenAPIPath.tsx (1)
184-185: Local deprecation suppression is fine — centralization optional.I searched the repo: usePageData appears in 9 places (7 runtime code files + 2 docs). All runtime call sites already use a localized
// eslint-disable-next-line @typescript-eslint/no-deprecated comment, so no immediate change is required.Call sites found:
- src/runtime/components/OpenAPIPath.tsx (line ~185)
- src/runtime/components/OpenAPIRef.tsx (line ~168)
- src/runtime/components/ExternalSiteLink.tsx (line ~35)
- src/runtime/components/Overview.tsx (line ~66–67)
- src/global/VersionsNav/index.tsx (line ~49)
- src/global/SiteOverrides/index.tsx (line ~38)
- src/theme.tsx (line ~98)
- docs/en/usage/mdx.mdx (example)
- docs/zh/usage/mdx.mdx (example)
Recommendation — optional:
- Keep the localized suppressions as-is for now.
- If you prefer a single change point for a future migration, add a compat hook that wraps usePageData and centralizes the eslint suppression, export it from your hooks index, and replace runtime usages with it.
Optional diff (if you choose to centralize):
- // eslint-disable-next-line @typescript-eslint/no-deprecated -- `usePage` is not exported... - const { page } = usePageData() + const { page } = usePageCompat()Add compat hook:
// src/runtime/hooks/usePageCompat.ts import { usePageData } from '@rspress/core/runtime' // eslint-disable-next-line @typescript-eslint/no-deprecated -- centralized until `usePage` is exported export const usePageCompat = () => usePageData()Then export/use it from your hooks index or import directly as needed. No fixes required right now — this is an optional cleanup for future ease of migration.
src/global/VersionsNav/index.tsx (1)
48-50: LGTM: targeted lint suppression above usePageData().Keeping the suppression scoped to the exact line minimizes collateral impact and maintains clarity. Consider removing it once
usePage(or an equivalent non-deprecated hook) becomes available from the runtime.src/runtime/components/OpenAPIRef.tsx (1)
167-169: LGTM: localized suppression is appropriate here.This mirrors the pattern elsewhere and keeps the linter happy without changing runtime behavior. When feasible, migrate to a compat hook to avoid repeating suppressions across files.
.changeset/eleven-files-nail.md (1)
1-5: LGTM: patch changeset reads clearly and matches the dependency bump.No further action needed.
src/runtime/components/ExternalSiteLink.tsx (1)
34-36: LGTM: scoped deprecation suppression above usePageData().This is consistent with the approach used elsewhere. The constructed URL remains unaffected, and security headers (
noopener noreferrer) are intact.src/runtime/components/Overview.tsx (2)
10-11: Switch to runtime useSidebar hook looks correct for rspress v2.0.0-beta.26Good move to consume sidebar from runtime. This aligns with the new public API and decouples from theme internals.
12-12: No remaining useSidebarData references found — verification completeSearches across the repo returned no imports/usages/property accesses of
useSidebarData. The codebase uses the new hook:
- src/runtime/components/Overview.tsx — usage:
let overviewSidebarGroups = useSidebar()(around line 86); imports showuseSidebarfrom@rspress/core/runtimeand theme imports at line 12 do not includeuseSidebarData.package.json (2)
70-74: Rspress stack coherently bumped to beta.26All core/shared/plugins are aligned on
2.0.0-beta.26, which reduces cross-version friction. The accompanying code changes (e.g.,useSidebarmigration) reflect this update.
122-124: TS toolchain bumps look consistent
typescriptandtypescript-eslintare bumped together, and TypeScript remains in dependencies (not dev), matching the prior learning about satisfying peer deps. Looks good.
Summary by CodeRabbit