Skip to content

fix(eslint-plugin-next): respect pageExtensions in no-html-link-for-pages rule#2

Closed
Jah-yee wants to merge 3 commits into
canaryfrom
fix/no-html-link-for-pages-pageextensions
Closed

fix(eslint-plugin-next): respect pageExtensions in no-html-link-for-pages rule#2
Jah-yee wants to merge 3 commits into
canaryfrom
fix/no-html-link-for-pages-pageextensions

Conversation

@Jah-yee
Copy link
Copy Markdown
Owner

@Jah-yee Jah-yee commented Apr 19, 2026

Fix

The @next/next/no-html-link-for-pages rule was ignoring the pageExtensions configuration from next.config.js, causing false negatives when users configured custom page extensions (e.g., page.tsx, page.ts).

Root Cause

In packages/eslint-plugin-next/src/utils/url.ts, the parseUrlForPages and parseUrlForAppDir functions used hardcoded regex /(\\.(j|t)sx?)$/ to detect page files, instead of using the configured pageExtensions.

Changes

  1. url.ts:

    • parseUrlForPages now accepts a pageExtensions parameter and builds a dynamic regex from it
    • parseUrlForAppDir similarly respects pageExtensions for page.tsx and layout.tsx detection
    • getUrlFromPagesDirectories and getUrlFromAppDirectory now accept and pass pageExtensions
    • Default extensions remain ['jsx', 'js', 'ts', 'tsx'] for backward compatibility
  2. no-html-link-for-pages.ts:

    • Reads pageExtensions from context.settings.next.pageExtensions
    • Passes it to getUrlFromPagesDirectories and getUrlFromAppDirectory

Usage

In your ESLint config:

{
  settings: {
    next: {
      pageExtensions: ['page.tsx', 'page.ts', 'jsx', 'js', 'ts', 'tsx']
    }
  }
}

Closes vercel#53473

nextjs-bot and others added 3 commits April 18, 2026 23:26
…ages rule

The no-html-link-for-pages rule was using hardcoded regex patterns
/(\.(j|t)sx?)$/ to detect page files, ignoring the pageExtensions
configured in next.config.js.

This change:
- Reads pageExtensions from context.settings.next.pageExtensions
- Passes pageExtensions to getUrlFromPagesDirectories and
  getUrlFromAppDirectory
- Updates parseUrlForPages and parseUrlForAppDir to build dynamic
  regex patterns from the configured extensions
- Defaults to ['jsx', 'js', 'ts', 'tsx'] when no pageExtensions is set

Fixes vercel#53473
@Jah-yee
Copy link
Copy Markdown
Owner Author

Jah-yee commented Apr 24, 2026

Closing this internal fork PR to tidy the queue; the upstream PR is the one to track. Happy to reopen here if a fork-only workflow is ever needed.

Upstream: vercel#92980

@Jah-yee Jah-yee closed this Apr 24, 2026
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.

@next/next/no-html-link-for-pages rule does not work with pageExtensions

3 participants