Skip to content

ESLint Configuration Error Fix

DodaTech Updated 2026-06-24 2 min read

In this tutorial, you'll learn about ESLint Configuration Error Fix. We cover key concepts, practical examples, and best practices.

The Problem

You run eslint . and get Error: Failed to load plugin or ESLint configuration is invalid. ESLint configuration errors occur when plugins are missing, config syntax is wrong, or extends chains conflict.

Quick Fix

Step 1: Install missing plugins and parsers

npm install -D eslint-plugin-react @typescript-eslint/parser @typescript-eslint/eslint-plugin

Expected output: The missing plugins and parsers are installed.

Step 2: Validate config file syntax

eslint --print-config .eslintrc.js

Expected output on success:

{
    "env": { ... },
    "rules": { ... },
}

If this fails, the error message points to the exact line causing the problem.

Step 3: Use .eslintrc.js instead of JSON

module.exports = {
    env: {
        browser: true,
        es2021: true,
    },
    extends: [
        'eslint:recommended',
        'plugin:"@typescript"-eslint/recommended',
    ],
    parser: '@typescript-eslint/parser',
    parserOptions: {
        ecmaVersion: 'latest',
        sourceType: 'module',
    },
    rules: {
        'no-unused-vars': 'warn',
        '@typescript-eslint/no-explicit-any': 'error',
    },
};

Expected output: JS format supports comments, trailing commas, and conditional config.

Step 4: Resolve extends chain conflicts

eslint --ext .js,.ts --debug .

Expected output: The --debug flag shows which config files are loaded and their resolution order.

Step 5: Fix parserOptions.project for TypeScript

parserOptions: {
    project: './tsconfig.json',
    tsconfigRootDir: __dirname,
}

Remove parserOptions.project if you do not need type-aware linting:

parserOptions: {
    ecmaVersion: 'latest',
    sourceType: 'module',
}

Expected output: ESLint works without requiring tsconfig for non-type-aware rules.

Step 6: Use flat config for ESLint 9+

// eslint.config.js
import js from '@eslint/js';

export default [
    js.configs.recommended,
    {
        files: ['**/*.js'],
        rules: {
            'no-unused-vars': 'warn',
        },
    },
];

Expected output: Flat config replaces .eslintrc.* and eliminates extends chain confusion.

Prevention

  • Use .eslintrc.js instead of JSON for comments and conditional configs
  • Always run eslint --print-config after editing config
  • Install all extends and plugins as dev dependencies
  • Use either .eslintrc.* or flat config (eslint.config.js), never both

Common Mistakes with config error

  1. Using head and tail instead of pattern matching, causing runtime errors on empty lists
  2. Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks
  3. Using return to exit a function early instead of wrapping a pure value in the monad

These mistakes appear frequently in real-world ESLINT code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### What is the difference between extends and plugins?

plugins add new rules to ESLint. extends sets up a predefined configuration of rules from a plugin or config package. Use plugins to add rule namespaces, and extends to apply recommended rule sets from those plugins.

Why does ESLint work in my editor but fail in CI?

The editor may use a different ESLint version or have global plugins installed. In CI, only devDependencies from package.json are available. Run npm ls eslint in both environments to compare versions.

Can I use both .eslintrc.* and eslint.config.js?

No. ESLint 9 defaults to flat config (eslint.config.js). If both exist, the flat config takes precedence and .eslintrc.* is ignored. Remove .eslintrc.* when migrating to flat config to avoid confusion.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro