Skip to content

fix(eslint-plugin-next): support custom pageExtensions in no-html-link-for-pages rule#3

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

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

Conversation

@Jah-yee
Copy link
Copy Markdown
Owner

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

Good day,

Problem

The @next/next/no-html-link-for-pages ESLint rule was not working when users configured custom pageExtensions in their next.config.js. The rule was hardcoded to only detect standard JS/TS extensions.

Solution

This fix reads pageExtensions from context.settings.next.pageExtensions in the ESLint config and passes it to the parseUrlForPages function. It falls back to default extensions ['tsx','ts','jsx','js'] when not configured.

Changes

  • get-root-dirs.ts: Added getPageExtensions function to extract pageExtensions from ESLint settings
  • url.ts: Updated parseUrlForPages and getUrlFromPagesDirectories to accept and use pageExtensions parameter
  • no-html-link-for-pages.ts: Import and use getPageExtensions, pass pageExtensions to cachedGetUrlFromPagesDirectories

Usage

Users can now configure pageExtensions in their ESLint config:

module.exports = {
  settings: {
    next: {
      pageExtensions: ['tsx', 'ts', 'jsx', 'js', 'mdx']
    }
  },
  rules: {
    '@next/next/no-html-link-for-pages': 'error'
  }
}

Thank you for your attention. If there are any issues or suggestions, please leave a comment and I will address them promptly.

Warmly,
Jah-yee

@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.

1 participant