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 #1

Closed
wants to merge 1 commit into from

Conversation

nnmax
Copy link
Owner

@nnmax nnmax commented Aug 3, 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'] },
    ],
  },
}
}

fix vercel#53473

@nnmax nnmax force-pushed the no-html-link-for-pages/pageExtensions branch 2 times, most recently from 48ae09c to 76c8d03 Compare August 3, 2023 13:14
@nnmax nnmax force-pushed the no-html-link-for-pages/pageExtensions branch from 76c8d03 to 13a6c1b Compare August 3, 2023 14:02
@nnmax nnmax closed this Aug 24, 2023
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