fix(eslint-plugin): support pageExtensions in no-html-link-for-pages rule#94092
Open
AliMahmoudDev wants to merge 3 commits into
Open
fix(eslint-plugin): support pageExtensions in no-html-link-for-pages rule#94092AliMahmoudDev wants to merge 3 commits into
AliMahmoudDev wants to merge 3 commits into
Conversation
…rule Fixes vercel#53473 The no-html-link-for-pages rule was hardcoded to only match .js, .jsx, .ts, .tsx file extensions. When users configure custom pageExtensions in next.config.js (e.g. ['page.tsx', 'page.ts']), the rule would produce false positives/negatives. Changes: - Added pageExtensions support via eslint settings.next.pageExtensions - Modified parseUrlForPages and parseUrlForAppDir to accept custom extension regex patterns - Updated getUrlFromPagesDirectories and getUrlFromAppDirectory signatures to pass through extension regexes - Removed hardcoded TODO comments about page extensions support Usage in .eslintrc: settings: { next: { pageExtensions: ['page.tsx', 'page.ts'] } }
…y safety
- Pass extPattern string instead of RegExp objects to memoized functions,
fixing cache key collision (JSON.stringify(regex) returns '{}' for all)
- Properly escape regex special characters in extension patterns to prevent
false-positive file matches
…ttern - Split extPattern by '|' and escape each extension individually before rejoining, so that regex special characters in extensions (e.g. dots in 'custom.ext') are properly escaped as literals - Previously, escapeRegExp was applied to the entire pipe-joined pattern, which also escaped the '|' alternation operators, causing the regex to never match any file extensions
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.
Fixes #53473
The @next/next/no-html-link-for-pages ESLint rule was hardcoded to only recognize .js, .jsx, .ts, .tsx file extensions. When users configure custom pageExtensions in next.config.js, the rule produces false positives and false negatives.
Changes: