Skip to content

fix(eslint-plugin): exempt /api paths from no-raw-hrefs - #73

Merged
JasonPaff merged 2 commits into
mainfrom
jasonpaff/par-117-no-raw-hrefs-flags-links-to-route-handlers-which-href-cannot
Oct 2, 2026
Merged

JasonPaff merged 2 commits into
mainfrom
jasonpaff/par-117-no-raw-hrefs-flags-links-to-route-handlers-which-href-cannot

Conversation

@JasonPaff

Copy link
Copy Markdown
Owner

In the Cadence rc trial (PAR-3), the recommended preset's only paramour warning was no-raw-hrefs on <Link href='/api/auth/auto-signin' />. That path is a route handler. The registry lists only pages, so the route can't be defined and href() can't build the link. The only way to clear the warning was ignorePaths, which the docs present as a migration escape hatch.

Change

  • Paths under /api are always exempt. The match uses the same segment-bounded logic as ignorePaths: /api, /api/…, /api?… and /api#… are exempt, /apiary and /apis/… are not. The exemption stacks with configured ignorePaths.
  • /api is the Pages Router's reserved API directory and the App Router convention for route handlers. The accepted cost is that a real page under /api isn't checked. The docs say so.
  • The "What is exempt" section of the rule reference, the package README and a changeset are updated.

Reporting fewer warnings isn't a breaking change.

Verification

  • New no-raw-hrefs.test.ts cases cover /api paths across Link, the UrlObject pathname, router.push and NextResponse.redirect with no options; stacking with ignorePaths; and /apiary and /apis/v2 still being reported. The six valid cases fail without the fix.
  • pnpm test packages/eslint-plugin: 227 passed. Typecheck and lint are clean.

Fixes PAR-117

🤖 Generated with Claude Code

Links to route handlers can't be built with href(), because the route
registry lists only pages, so no-raw-hrefs reported a warning with no fix.
The Cadence rc trial hit this on <Link href="/api/auth/auto-signin" />.
Paths under /api are now always exempt, segment-bounded like ignorePaths.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
paramour-docs Ready Ready Preview Oct 2, 2026 10:04pm UTC

@JasonPaff
JasonPaff merged commit 3b9d326 into main Oct 2, 2026
13 checks passed
@JasonPaff
JasonPaff deleted the jasonpaff/par-117-no-raw-hrefs-flags-links-to-route-handlers-which-href-cannot branch October 2, 2026 22:11

This branch was successfully deployed

1 active deployment
Preview — c388d492 Deployed Oct 2, 2026 by vercel[bot]
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.

1 participant