fix(eslint-plugin-next): respect pageExtensions in no-html-link-for-pages#93853
Open
Eswar809 wants to merge 1 commit into
Open
fix(eslint-plugin-next): respect pageExtensions in no-html-link-for-pages#93853Eswar809 wants to merge 1 commit into
Eswar809 wants to merge 1 commit into
Conversation
…ages Fixes vercel#53473. The no-html-link-for-pages rule used a hardcoded `/(\.(j|t)sx?)$/` regex when scanning the pages and app directories for routes, so projects that configure custom `pageExtensions` (for example `['page.tsx', 'page.ts']`) got false negatives — none of their actual page files were detected as routes. This adds a `settings.next.pageExtensions` shared setting (matching the existing `settings.next.rootDir` convention) and threads it through `parseUrlForPages`, `parseUrlForAppDir`, `getUrlFromPagesDirectories` and `getUrlFromAppDirectory`. The extension regex is built dynamically from the configured list, with regex special characters escaped, and falls back to the previous default of [tsx, ts, jsx, js] when the setting is absent — so existing rule configurations behave identically.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Fixes #53473.
The
no-html-link-for-pagesESLint rule had a hardcoded/(\.(j|t)sx?)$/regex when scanning thepagesandappdirectories, so projects that configure custompageExtensions(e.g.['page.tsx', 'page.ts']) got false negatives — none of their actual page files were detected as routes, and the rule silently skipped them.Why?
This matches the existing
settings.next.rootDirconvention already supported by this plugin. The hardcoded regex was a known limitation flagged by TODO comments inpackages/eslint-plugin-next/src/utils/url.ts:How?
settings.next.pageExtensionsshared setting, read byno-html-link-for-pagesand threaded throughparseUrlForPages,parseUrlForAppDir,getUrlFromPagesDirectories, andgetUrlFromAppDirectory.['tsx', 'ts', 'jsx', 'js']when the setting is absent, so existing rule configurations behave identically.test/unit/eslint-plugin-next/with-page-extensions/) and a test case verifying that<a href="/about">is correctly flagged when the corresponding file ispages/about.page.tsxandpageExtensionsis configured.Test plan
pageExtensionsmatches the previous regex exactly).Closes #53473