vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.52k stars 26.81k forks source link

False positive for @next/next/no-html-link-for-pages with API routes #29483

Open janhoogeveen opened 3 years ago

janhoogeveen commented 3 years ago

What version of Next.js are you using?

canary

What version of Node.js are you using?

14.16.0

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying your application?

Vercel

Describe the Bug

When running the linter, I get the following errors if I link to an API Preview exit route.

71:36 warning Do not use the HTML tag to navigate to /api/exit-preview/. Use Link from 'next/link' instead. See: https://nextjs.org/docs/messages/no-html-link-for-pages @next/next/no-html-link-for-pages

Expected Behavior

I don't believe that a link to an API route should always be tested through the @next/next/no-html-link-for-pages rule as defined in eslint-config-next. Especially when it's following documented behavior from the API previews.

To Reproduce

Example code on GitHub that would fail the linter https://github.com/vercel/next.js/blob/canary/examples/cms-sanity/components/alert.js#L19

MonstraG commented 2 years ago

+1, same error on with-typescript example (and probably many others.

Disabling the rule for now.