2

After upgrading my Angular project to version 20, ESLint started throwing the following error when I run linting (using Nx):

[error] (node:20947) ESLintIgnoreWarning: The ".eslintignore" file is no longer supported. Switch to using the "ignores" property in "eslint.config.js".

[error] An unexpected error occurred: Error: Could not find config file. at t assertConfigurationExists (/*/config-loader.js:80:17)
at LegacyConfigLoader.loadConfigArrayForFile (/*/config-loader.js:414:3)

The project is an Nx monorepo with multiple Angular apps and libs. Here’s a simplified version of my setup:

At the root I have: eslint.client.js

// eslint.client.js

module.exports = {
    extends: ['.eslintrc.json'],
    ignorePatterns: ['!**/*'],
    overrides: [{
                parser: '@typescript-eslint/parser',
                parserOptions: {
                    ecmaVersion: 2019,
                    project: join(__dirname, './tsconfig.base.json'),
                    sourceType: 'module',
                },
                files: ['*.ts'],
                extends: ['plugin:@nx/typescript', 'plugin:@nx/angular', 'plugin:@angular-eslint/template/process-inline-templates', ],
                rules: { // custom rules... }, }, ], };

And in each app/lib I have something like:

// .eslintrc.json
{
  "extends": ["../../../eslint.client.js"],
  "ignorePatterns": ["!**/*"]
}

Any idea?

1 Answer 1

0

1. Quick fix

Just add the following line in .vscode/settings.json

"eslint.useFlatConfig": false,

2. Main Solution

Since ESLint v9, .eslintrc.* and .eslintignore are no longer supported.
Nx 20 uses ESLint v9 → your current config is ignored → error appears.

Here is the fix

  1. Remove all .eslintrc.json files

  2. Create a single eslint.config.js at the workspace root

  3. Add a lightweight eslint.config.js inside each app/lib

Example — Root eslint.config.js:

import { join } from 'path';
import nx from '@nx/eslint-plugin';

export default [
  {
    ignores: ['**/dist/**', '**/tmp/**'],
  },
  {
    files: ['**/*.ts'],
    languageOptions: {
      parser: '@typescript-eslint/parser',
      parserOptions: {
        project: join(process.cwd(), 'tsconfig.base.json'),
      },
    },
    plugins: {
      nx,
      '@typescript-eslint': require('@typescript-eslint/eslint-plugin'),
    },
    extends: [
      'plugin:@nx/typescript',
      'plugin:@nx/angular',
      'plugin:@angular-eslint/template/process-inline-templates',
    ],
    rules: {
      // custom rules…
    },
  },
];

Example — App/Lib eslint.config.js:

export default [
  {
    extends: ['../../eslint.config.js'],
  },
];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.