Skip to content

fix(eslint): fix no-html-link-for-pages to handle custom pageExtensions - #98115

Open
tahiraltundag wants to merge 1 commit into
vercel:canaryfrom
tahiraltundag:fix/eslint-no-html-link-pageExtensions
Open

fix(eslint): fix no-html-link-for-pages to handle custom pageExtensions#98115
tahiraltundag wants to merge 1 commit into
vercel:canaryfrom
tahiraltundag:fix/eslint-no-html-link-pageExtensions

Conversation

@tahiraltundag

Copy link
Copy Markdown

Fixes #53473

The rule hardcoded js/ts extensions, so custom pageExtensions like "page.tsx" or "mdx" were ignored.

Fixes vercel#53473

The rule previously hardcoded js/ts extensions (/\.(j|t)sx?$/), so it ignored custom pageExtensions like "page.tsx" or "mdx". about.page.tsx was treated as /about.page instead of /about, so <a href="/about"> did not trigger the lint error.

- Change parseUrlForPages and parseUrlForAppDir to handle any extension (\..+$)
- Handles pageExtensions like "page.tsx", "mdx", etc. correctly
- Verified with reproduction https://github.com/nnmax/next-eslint-config-reproduction-app
- Lint now correctly warns for <a href="/about"> when about.page.tsx exists
`${urlprefix}${dirent.name.replace(/^index(\.(j|t)sx?)$/, '')}`
)
// Handle all page extensions (e.g. js, jsx, ts, tsx, mdx, page.tsx, etc.)
// pageExtensions can be like "page.tsx" which contains a dot, so we match any extension

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Broadened extension regex /\..+$/ misclassifies directories whose name contains a dot (e.g. v1.0, 2024.01) as page files, so they are never recursed into and pages beneath them are dropped from the generated URL list.

Fix on Vercel

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

1 participant