Skip to content

Plugin export is not equal to plugin object on flat configs #3212

@soren121

Description

@soren121

The types added in #3097 do not match with what the plugin currently exports.

The type definitions declare a default export, which this plugin does not have. The ESLint documentation recommends a default export.

Not providing this export, and then declaring that it is provided, can cause user confusion. For instance, I would expect the following to work:

Outdated, see comment # 2 below
import importPlugin from 'eslint-plugin-import';
import { defineConfig } from 'eslint/config';

export default defineConfig(
  {
    plugins: {
      import: importPlugin,
    },
    rules: {
      'import/named': 'error',
    }
  },
  {
    files: ['src/**/*.{ts,tsx}'],
    extends: [importPlugin.flatConfigs.typescript]
  }
);

TypeScript compiles this without any warning, but ESLint will produce this error:

Oops! Something went wrong! :(

ESLint: 9.36.0

ConfigError: Config "UserConfig[1] > import/typescript": Key "plugins": Cannot redefine plugin "import".

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions