Skip to content

docs(repo): Fix broken typedoc links#8420

Open
SarahSoutoul wants to merge 1 commit intomainfrom
ss/fix-typedoc-links
Open

docs(repo): Fix broken typedoc links#8420
SarahSoutoul wants to merge 1 commit intomainfrom
ss/fix-typedoc-links

Conversation

@SarahSoutoul
Copy link
Copy Markdown
Contributor

Description

This PR fixes typedoc links to be used in docs.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@SarahSoutoul SarahSoutoul self-assigned this Apr 29, 2026
@SarahSoutoul SarahSoutoul requested a review from wobsoriano April 29, 2026 21:36
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Apr 29, 2026 9:36pm

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 29, 2026

⚠️ No Changeset found

Latest commit: 3862243

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@SarahSoutoul SarahSoutoul requested a review from NWylynko April 29, 2026 21:36
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 29, 2026

📝 Walkthrough

Walkthrough

The TypeDoc MDX link-rewriting plugin configuration is extended with seven new mappings. These additions enable the plugin to rewrite relative or embedded links targeting various enterprise and billing entities (enterprise-account, enterprise-account-connection, billing-plan-unit-price, billing-plan-unit-price-tier, billing-per-unit-total, billing-per-unit-total-tier, and billing-subscription-item-seats) to their corresponding absolute documentation URLs.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'docs(repo): Fix broken typedoc links' directly describes the main change, which involves fixing TypeDoc MDX link-rewriting configurations.
Description check ✅ Passed The description states the PR fixes typedoc links to be used in docs, which is directly related to the changeset that extends TypeDoc link-rewriting configurations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

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

Copy link
Copy Markdown
Contributor

@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.

Caution

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

⚠️ Outside diff range comments (1)
.typedoc/custom-plugin.mjs (1)

77-99: ⚠️ Potential issue | 🟡 Minor

The new mappings follow established patterns, but the unescaped fileName in the RegExp is brittle—consider escaping it or validating at build time.

The plugin constructs RegExp patterns by directly interpolating fileName on line 128 without escaping. While current mapping names (hyphenated slugs) are safe, future entries containing regex metacharacters will silently fail to match. Consider either:

  • Escaping fileName with a helper function (e.g., fileName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
  • Adding a build-time validation that confirms each mapping's source file actually exists in the generated typedoc output

Additionally, these mappings cannot be verified in the source repository (typedoc generates the .mdx files at build time). After running the docs build, spot-check one of these new type links in the rendered output to ensure the rewritten absolute paths are correct.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.typedoc/custom-plugin.mjs around lines 77 - 99, The RegExp built from the
unescaped fileName (used where the plugin constructs a RegExp around fileName)
is brittle; fix it by escaping fileName before interpolation (use a helper that
escapes regex metacharacters) or add a build-time validation step that verifies
each mapping's source file exists in the generated typedoc output; update the
code path that creates the RegExp (the spot referencing fileName / new
RegExp(...) in the plugin) to call the escape helper, and/or add a validation
routine that iterates the mapping array and checks the generated .mdx files to
fail early if a mapping doesn't resolve.
🧹 Nitpick comments (2)
.typedoc/custom-plugin.mjs (2)

124-133: Escape fileName before embedding it into RegExp (brittleness/security hardening).

getRelativeLinkReplacements() builds new RegExp(... ${fileName}\\.mdx ...) without escaping fileName. Your current slugs (hyphens) are regex-safe, but this is brittle for future mappings—any fileName containing regex metacharacters (e.g. +, ., (, )) would break the pattern or match unexpectedly.

Consider a small escapeRegExp() helper and use it when building the regex.

Patch suggestion
 function getRelativeLinkReplacements() {
   return LINK_REPLACEMENTS.map(([fileName, newPath]) => {
+    const escapeRegExp = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
     return {
       // Match both path and optional anchor
-      pattern: new RegExp(`\\((?:(?:\\.{1,2}\\/)+[^()]*?|)${fileName}\\.mdx(#[^)]+)?\\)`, 'g'),
+      pattern: new RegExp(
+        `\\((?:(?:\\.{1,2}\\/)+[^()]*?|)${escapeRegExp(fileName)}\\.mdx(#[^)]+)?\\)`,
+        'g'
+      ),
       // Preserve the anchor in replacement if it exists
       replace: (/** `@type` {string} */ _match, anchor = '') => `(${newPath}${anchor})`,
     };
   });
 }

You can validate this locally with a small Node snippet that demonstrates the regex still matches the same inputs for the current slugs.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.typedoc/custom-plugin.mjs around lines 124 - 133,
getRelativeLinkReplacements currently interpolates raw fileName into a RegExp
which is brittle and can break if fileName contains regex metacharacters; add an
escapeRegExp helper (e.g., escapeRegExp(name): string) and use it to sanitize
the fileName from LINK_REPLACEMENTS before building the RegExp in
getRelativeLinkReplacements so the pattern uses escapedFileName instead of
fileName; update the pattern construction and verify replace behavior remains
the same.

264-273: Avoid recomputing getRelativeLinkReplacements() for every page (minor perf).

load(app) calls getRelativeLinkReplacements() inside the MarkdownPageEvent.END handler, meaning you rebuild the replacement regex list once per page. Docs generation can involve many pages; this is minor, but easy to improve by precomputing once outside the event callback.

Precompute const linkReplacements = getRelativeLinkReplacements() once at module scope (or once per load(app) call) and reuse it.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.typedoc/custom-plugin.mjs around lines 264 - 273, The code currently calls
getRelativeLinkReplacements() inside the MarkdownPageEvent.END handler, causing
the replacement list to be rebuilt for every page; move the call to compute
linkReplacements once (either at module scope or at the start of load(app)) and
reuse that const inside the app.renderer.on(MarkdownPageEvent.END, ...) callback
so you iterate over the precomputed linkReplacements and update output.contents
(and still use output.url as before) without recomputing the regex list per
page.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In @.typedoc/custom-plugin.mjs:
- Around line 77-99: The RegExp built from the unescaped fileName (used where
the plugin constructs a RegExp around fileName) is brittle; fix it by escaping
fileName before interpolation (use a helper that escapes regex metacharacters)
or add a build-time validation step that verifies each mapping's source file
exists in the generated typedoc output; update the code path that creates the
RegExp (the spot referencing fileName / new RegExp(...) in the plugin) to call
the escape helper, and/or add a validation routine that iterates the mapping
array and checks the generated .mdx files to fail early if a mapping doesn't
resolve.

---

Nitpick comments:
In @.typedoc/custom-plugin.mjs:
- Around line 124-133: getRelativeLinkReplacements currently interpolates raw
fileName into a RegExp which is brittle and can break if fileName contains regex
metacharacters; add an escapeRegExp helper (e.g., escapeRegExp(name): string)
and use it to sanitize the fileName from LINK_REPLACEMENTS before building the
RegExp in getRelativeLinkReplacements so the pattern uses escapedFileName
instead of fileName; update the pattern construction and verify replace behavior
remains the same.
- Around line 264-273: The code currently calls getRelativeLinkReplacements()
inside the MarkdownPageEvent.END handler, causing the replacement list to be
rebuilt for every page; move the call to compute linkReplacements once (either
at module scope or at the start of load(app)) and reuse that const inside the
app.renderer.on(MarkdownPageEvent.END, ...) callback so you iterate over the
precomputed linkReplacements and update output.contents (and still use
output.url as before) without recomputing the regex list per page.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: b590224d-631a-4d17-88b3-5b5567cbb502

📥 Commits

Reviewing files that changed from the base of the PR and between 61e0a78 and 3862243.

📒 Files selected for processing (1)
  • .typedoc/custom-plugin.mjs

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 29, 2026

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@8420

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@8420

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@8420

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@8420

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@8420

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@8420

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@8420

@clerk/express

npm i https://pkg.pr.new/@clerk/express@8420

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@8420

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8420

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@8420

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@8420

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@8420

@clerk/react

npm i https://pkg.pr.new/@clerk/react@8420

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@8420

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@8420

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@8420

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@8420

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8420

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@8420

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@8420

commit: 3862243

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