-
Notifications
You must be signed in to change notification settings - Fork 29k
Description
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