vercel/next.js

`next lint` creates .eslintrc.json instead of eslint.config.mjs after deleting initial ESLint config

uwoobeat opened this issue · 0 comments

Link to the code that reproduces this issue

https://github.com/uwoobeat/nextjs-eslint-config-bug

To Reproduce

  1. Clone the repository (created via npx create-next-app@canary)
  2. Install dependencies: npm install
  3. Delete eslint.config.mjs
  4. Run npm run lint (or pnpm lint)
  5. Observe that .eslintrc.json is created instead of regenerating eslint.config.mjs

Current vs. Expected behavior

Current behavior:

  • After deleting eslint.config.mjs, running next lint creates a new .eslintrc.json file with legacy ESLint configuration format, even though the project was initially set up with ESLint v9's config

Expected behavior:

  • When running next lint after deleting the config file, it should regenerate the same type of configuration file that was initially created (eslint.config.mjs), maintaining consistency with the project's initial ESLint setup

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.2.0: Fri Dec  6 18:40:14 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T8103
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 23.4.0
  npm: 10.9.2
  Yarn: 1.22.22
  pnpm: 9.15.0
Relevant Packages:
  next: 15.1.1-canary.13 // Latest available version is detected (15.1.1-canary.13).
  eslint-config-next: 15.1.1-canary.13
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.7.2
Next.js Config:
  output: N/A

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

create-next-app, Linting

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

next dev (local)

Additional context

While #71218 added support for ESLint v9, examining runLintCheck and writeDefaultConfig shows that Next.js still creates .eslintrc.json when regenerating config files. It's unclear whether this is intentional or if the flat config support was meant to be implemented for config regeneration as well.

I noticed that while Next.js detects and properly uses flat config files (eslint.config.*) during linting process, the default config generation still creates legacy format files. Would like to know if this behavior is intended or if it needs to be updated to maintain consistency with the initial flat config setup from create-next-app.