Skip to content

Bug: A config object has a "plugins" key defined as an array of strings. #291

@aladdin-add

Description

@aladdin-add

Which packages are affected?

  • @eslint/compat
  • @eslint/config-array
  • @eslint/config-helpers
  • @eslint/core
  • @eslint/mcp
  • @eslint/migrate-config
  • @eslint/object-schema
  • @eslint/plugin-kit

Environment

Node version: v24.7.0
npm version: v10.2.5
Local ESLint version: v9.35.0 (Currently used)
Global ESLint version: Not found
Operating System: win32 10.0.26100

What did you do?

eslint.config.js

import {defineConfig} from "eslint/config";

const pluginX = {
    configs: {
        "recommended": {plugins: ["plugin-x"]},
    }
};

pluginX.configs["flat/recommended"] = {plugins: {"plugins-x": pluginX}};

export default defineConfig([
    {
        files: ["**/*.js"],
        plugins: {"plugin-x": pluginX},
        extends: ["plugin-x/recommended"]
    }
]);

What did you expect to happen?

load the config successfully.

What actually happened?

Oops! Something went wrong! :(

ESLint: 9.35.0


A config object has a "plugins" key defined as an array of strings. It looks something like this:

    {
        "plugins": ["plugin-x"]
    }

Flat config requires "plugins" to be an object, like this:

    {
        plugins: {
            plugin-x: pluginObject
        }
    }

Please see the following page for information on how to convert your config object into the correct format:
https://eslint.org/docs/latest/use/configure/migration-guide#importing-plugins-and-custom-parsers

If you're using a shareable config that you cannot rewrite in flat config format, then use the compatibility utility:
https://eslint.org/docs/latest/use/configure/migration-guide#using-eslintrc-configs-in-flat-config

Link to Minimal Reproducible Example

https://stackblitz.com/edit/stackblitz-starters-scc3kvqs?file=eslint.config.js

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

it was firstly reported in eslint/generator-eslint#228 (comment).

Metadata

Metadata

Assignees

Labels

acceptedbugSomething isn't workingrepro:yesIssues with a reproducible example

Type

No type

Projects

Status

Implementing

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions