Course contentsShow
← JavaScript
Lesson 2574 of 2,72352. Linting and FormattingFree lesson

Plugin Compatibility with Flat Config

Learn how plugins work differently in flat config and how to adapt plugin usage for the new format.

Plugin Compatibility with Flat Config

You'll learn how ESLint plugins adapt to the new flat config format and what changes you need to make when using them.

The Plugin Format Change

In legacy .eslintrc, plugins were referenced as strings and their rules accessed with prefixes. Flat config changes this fundamentally: plugins are now JavaScript objects that you import directly and assign to a configuration object. This means you interact with the actual plugin code, not just its name.

How Plugins Work in Flat Config

Instead of writing plugins: ['react'] and then react/jsx-uses-react, you now import the plugin and reference it directly:

// eslint.config.js
import reactPlugin from 'eslint-plugin-react';

export default [
  {
    plugins: {
      react: reactPlugin
    },
    rules: {
      'react/jsx-uses-react': 'error'
    }
  }
];

The key difference: plugins is now an object where keys are your chosen prefixes and values are the imported plugin modules.

Adapting Plugin Usage

When a plugin provides a shareable config, you spread it into your array rather than using extends:

import reactPlugin from 'eslint-plugin-react';

export default [
  reactPlugin.configs.recommended,
  {
    // Your overrides
  }
];

Some older plugins may not yet export flat config-compatible structures. In those cases, you might need to manually structure the plugin object or wait for updates.

Plugin Naming Flexibility

You control the prefix in flat config. If you import as { react: myReactPlugin }, rules become react/rule-name. This gives you flexibility to avoid naming conflicts.

Key Takeaway: Flat config treats plugins as imported JavaScript objects rather than string references, giving you direct control over how they're named and configured in your linting setup.