Skip to content

fix(scripts): make the docs link check work on Windows - #11181

Open
yogesh968 wants to merge 1 commit into
TanStack:mainfrom
yogesh968:fix/verify-links-windows-paths
Open

fix(scripts): make the docs link check work on Windows#11181
yogesh968 wants to merge 1 commit into
TanStack:mainfrom
yogesh968:fix/verify-links-windows-paths

Conversation

@yogesh968

@yogesh968 yogesh968 commented Aug 13, 2026

Copy link
Copy Markdown

Fixes #11177

The problem

relativeLinkExists builds the target path with path.resolve, which uses the platform separator, and then matches that path against patterns written with forward slashes:

const isExample = absPath.includes('/examples/')

if (isExample) {
  absPath = absPath.replace(
    /\/docs\/framework\/([^/]+)\/examples\//,
    '/examples/$1/',
  )
  exists = existsSync(absPath) && statSync(absPath).isDirectory()
}

On Windows the resolved path uses backslashes, so neither pattern matches. Every documentation link pointing at an example skips the rewrite and gets looked up as a markdown file under docs/framework/<name>/examples/ instead of a directory under examples/<name>/.

pnpm test:docs then reports 27 broken links that are all fine. CI does not catch it because it runs on Linux, and the reported resolved: path shows the problem directly.

The change

Normalize the separators once, before the two comparisons. Node accepts forward slashes on Windows, so the path stays usable for existsSync and statSync, and the value printed in the error report stays readable.

The docsRoot containment check above it still runs on the platform native path, so it is unaffected.

Tests

node scripts/verify-links.ts on Windows goes from 27 reported broken links to "No broken links found". Behaviour on Linux is unchanged, since split(sep).join('/') is a no-op there.

No changeset, this is repository tooling.

Summary by CodeRabbit

  • Bug Fixes
    • Improved link verification consistency across operating systems.
    • Ensured example paths are detected reliably regardless of platform-specific path separators.

'relativeLinkExists' builds the target path with 'path.resolve', which
uses the platform separator, but then matches it against '/examples/'
and rewrites it with a regex written in forward slashes.

On Windows the resolved path uses backslashes, so neither pattern
matches. Every documentation link that points at an example is looked up
as a markdown file under 'docs/framework/<name>/examples/' instead of a
directory under 'examples/<name>/', and 'pnpm test:docs' reports 27
broken links that are fine on CI.

Normalize the separators before the two comparisons. Node accepts
forward slashes on Windows, so the resolved path stays usable.
@yogesh968
yogesh968 requested a review from a team as a code owner August 13, 2026 05:48
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5f3a04c7-f0cb-4c63-bc7f-062d48fe6591

📥 Commits

Reviewing files that changed from the base of the PR and between 159982c and 9fc856b.

📒 Files selected for processing (1)
  • scripts/verify-links.ts

📝 Walkthrough

Walkthrough

The link verification script now normalizes platform-specific path separators before detecting and transforming example paths.

Changes

Link verification

Layer / File(s) Summary
Normalize resolved link paths
scripts/verify-links.ts
The script imports sep and converts resolved paths to forward-slash format before example-path matching and transformation.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Mergeability Score: ⚪ Minimal · up to 9fc85

This localized documentation-link checker fix changes path normalization for Windows without introducing a merge-blocking risk; it is merge-ready after normal checks and review.

Suggested reviewers: alemtuzlak

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: fixing the documentation link checker on Windows.
Description check ✅ Passed The description explains the Windows bug, implementation, testing, and no-release impact, with only checklist formatting omitted.
Linked Issues check ✅ Passed The separator normalization directly addresses the false-positive example-link failures described in issue #11177.
Out of Scope Changes check ✅ Passed The changes are limited to verify-links.ts and support the linked Windows compatibility fix.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with 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.

❤️ Share

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

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.

pnpm test:docs reports 27 broken links on Windows because verify-links.ts assumes forward slashes

2 participants