Skip to content

Fix: allow pageExtensions to be configured in no-html-link-for-pages (#53473)#95321

Open
abhijeetnardele24-hash wants to merge 2 commits into
vercel:canaryfrom
abhijeetnardele24-hash:fix-issue-53473
Open

Fix: allow pageExtensions to be configured in no-html-link-for-pages (#53473)#95321
abhijeetnardele24-hash wants to merge 2 commits into
vercel:canaryfrom
abhijeetnardele24-hash:fix-issue-53473

Conversation

@abhijeetnardele24-hash

@abhijeetnardele24-hash abhijeetnardele24-hash commented Jun 30, 2026

Copy link
Copy Markdown

What?\


This updates the @next/next/no-html-link-for-pages\ ESLint rule so that it correctly respects the \pageExtensions\ array instead of strictly defaulting to .js, .jsx, .ts, .tsx.
\

Why?\


Currently, developers using custom page extensions (e.g., \pageExtensions: ['page.tsx']\ in Next.js) experience false positives from the ESLint plugin when linking to their pages. The plugin was hardcoded to only recognize standard extensions. This resulted in legitimate <Link>\ components to custom-extension pages not being validated, and legitimate uses of <a>\ tags falling through or triggering errors improperly.

By propagating the custom \pageExtensions\ from \settings.next.pageExtensions\ in .eslintrc, the linter behaves identically to Next.js routing.
\

How?\

\

  • Modified \parseUrlForPages\ and \parseUrlForAppDir\ in \packages/eslint-plugin-next/src/utils/url.ts\ to accept \pageExtensions\ and dynamically build the regex matcher.\
  • Updated
    o-html-link-for-pages.ts\ to retrieve \context.settings.next.pageExtensions. If omitted, it falls back to the default ['tsx', 'ts', 'jsx', 'js'].\
  • Added a unit test in \ est/unit/eslint-plugin-next/no-html-link-for-pages.test.ts\ to verify the rule operates correctly on custom extensions.

    Fixes @next/next/no-html-link-for-pages rule does not work with pageExtensions #53473
Comment thread test/unit/eslint-plugin-next/no-html-link-for-pages.test.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant