Skip to content

@next/eslint-plugin-next types incorrect #81695

@MattIPv4

Description

@MattIPv4

Link to the code that reproduces this issue

https://github.com/MattIPv4/next-eslint-types

To Reproduce

Incorrect rule types

Run npm run types:

eslint.config.js:11:5 - error TS2322: Type '{ '@next/next/no-html-link-for-pages': string; '@next/next/no-sync-scripts': string; '@next/next/google-font-display': string; '@next/next/google-font-preconnect': string; '@next/next/next-script-for-ga': string; ... 15 more ...; '@next/next/no-script-component-in-head': string; }' is not assignable to type 'Partial<Record<string, RuleEntry>>'.
  Property ''@next/next/no-html-link-for-pages'' is incompatible with index signature.
    Type 'string' is not assignable to type 'RuleEntry'.

11     rules: {
       ~~~~~

Incorrect configs export

Run npm run lint:

Oops! Something went wrong! :(

ESLint: 9.31.0

file:///[snip]/next-eslint-types/eslint.config.js?mtime=1752631838750:3
import nextPlugin, { configs as nextPluginConfigs } from "@next/eslint-plugin-next";
                     ^^^^^^^
SyntaxError: Named export 'configs' not found. The requested module '@next/eslint-plugin-next' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from '@next/eslint-plugin-next';
const { configs: nextPluginConfigs } = pkg;

Current vs. Expected behavior

Incorrect rule types

The rules exported by the plugin have values typed as string. This is not compatible with the RuleEntry type that tseslint expects. The plugin needs to export the actual const strings that the values are (warn etc.) so that they are compatible with RuleEntry (SeverityString).

Incorrect configs export

The plugin currently has typings that declare the plugin exports a named configs export. The plugin is a CommonJS module with no such named ESM export. Either remove these incorrect typings, or distribute the plugin with an ESM version that has the named export.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.5.0: Tue Apr 22 19:53:27 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6041
  Available memory (MB): 24576
  Available CPU cores: 14
Binaries:
  Node: 22.13.1
  npm: 10.9.2
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  next: 15.4.1 // Latest available version is detected (15.4.1).
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: N/A
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Linting

Which stage(s) are affected? (Select all that apply)

Other (Deployed)

Additional context

If it helps give any context, this is the lovely set of workarounds I've had to include in our codebase due to this: alveusgg/alveusgg@32920af

NEXT-4663

Metadata

Metadata

Assignees

No one assigned

    Labels

    LintingRelated to `next lint` or ESLint with Next.js.linear: nextConfirmed issue that is tracked by the Next.js team.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy