Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eslint-plugin-next): add pageExtensions option #54474

Open
wants to merge 1 commit into
base: canary
Choose a base branch
from

Conversation

nnmax
Copy link
Contributor

@nnmax nnmax commented Aug 24, 2023

For Contributors

Improving Documentation

Adding or Updating Examples

Adding a feature

For Maintainers

  • Minimal description (aim for explaining to someone not on the team to understand the PR)
  • When linking to a Slack thread, you might want to share details of the conclusion
  • Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
  • Add review comments if necessary to explain to the reviewer the logic behind a change

What?

This PR is to fix a problem where @next/next/no-html-link-for-pages doesn't work when pageExtensions are configured.

As to why a new option should be provided, see the commend.

How?

An ESLint option called pageExtensions is provided.

Options Type

The rule accepts the following options:

type NoHTMLLinkForPagesOptions =
  | string
  | string[]
  | {
      pagesDir?: string | string[]
      pageExtensions?: string | string[]
    }

The values can be:

  • string - It's equivalent to the pagesDir argument.
  • string[] - It's equivalent to the pagesDir argument.
  • An object with the following properties:
    • pagesDir - a path to a directory or an array of paths to directories
    • pageExtensions - a string or an array of strings representing the extensions of the page files

Usage

If you set the pageExtensions config, this rule will not work and the pageExtensions option must be set for it to work.

// next.config.js
/** @type {import('next').NextConfig} */
module.exports = {
  pageExtensions: ['page.tsx', 'mdx'],
}
// .eslintrc.js
module.exports = {
  rules: {
    '@next/next/no-html-link-for-pages': [
      'error',
      { pageExtensions: ['page.tsx', 'mdx'] },
    ],
  },
}
}

Fixes #53473

Copy link

@orca-security-us orca-security-us bot left a comment

Choose a reason for hiding this comment

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

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca

@balazsorban44 balazsorban44 added Documentation Related to Next.js' official documentation. and removed area: documentation labels Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Related to Next.js' official documentation. tests type: next
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