KEMBAR78
Using flat config from eslint-plugin-next causes errors in eslint.config.mjs · Issue #82967 · vercel/next.js · GitHub
Skip to content

Using flat config from eslint-plugin-next causes errors in eslint.config.mjs #82967

@TrevorBurnham

Description

@TrevorBurnham

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/peaceful-snow-forked-4gz2ym

To Reproduce

I've spun this issue off from #82187. There are several problems around the build and types for eslint-plugin-next, and I want to be clear about this specific problem: There's currently no possible way to import eslint-plugin-next in an eslint.config.mjs that both 1) correctly imports the recommended flat config and 2) does not raise TypeScript errors if the config is type checked.

A secondary issue is that the docs for the plugin are out of date, using FlatCompat rather than importing the flat configuration added by #73873 directly.

All I've done to set up the sandbox project is:

  1. Followed the official typescript-eslint start guide to create an initial eslint.config.mjs
  2. Installed @next/eslint-plugin-next@15.4.5

Current vs. Expected behavior

Any attempt to use the flatConfig.recommended configuration added by #73873 will trigger an ESLint error, a TypeScript error, or both:

Default import

import eslintPluginNext from "@next/eslint-plugin-next";
...
eslintPluginNext.flatConfig.recommended // TypeScript error

Named import

import { flatConfig } from "@next/eslint-plugin-next";
...
flatConfig.recommended // ESLint error and TypeScript error

Namespace import

import * as eslintPluginNext from "@next/eslint-plugin-next";
...
eslintPluginNext.flatConfig.recommended // ESLint error and TypeScript error

The expected behavior is that there should be an approach to importing flat configurations that both works and satisfies the type checker.

Provide environment information

Relevant packages:
  eslint-plugin-next: 15.4.5

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

Linting

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

next dev (local), next build (local)

Additional context

With the deprecation of next lint in Next 15.5, this issue is likely to affect more users in the near future, as many will be migrating to maintaining their own eslint.config.mjs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    LintingRelated to `next lint` or ESLint with Next.js.locked

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions