Skip to content

[Bug]: Key "plugins": Cannot redefine plugin "react" #3765

Closed as not planned
Closed as not planned
@tiavina-mika

Description

@tiavina-mika

Is there an existing issue for this?

  • I have searched the existing issues and my issue is unique
  • My issue appears in the command-line and not only in the text editor

Description Overview

I have this error when runing eslint: Key "plugins": Cannot redefine plugin "react"

here is my eslint.confi.js

import path from 'path';
import { fileURLToPath } from 'url';
import js from "@eslint/js";
import tseslint from 'typescript-eslint';
import react from 'eslint-plugin-react';
import globals from 'globals';
import reactRecommended from 'eslint-plugin-react/configs/recommended.js';


const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
const __dirname = path.dirname(__filename); // get the name of the directory


export default tseslint.config(
  js.configs.recommended,
  reactRecommended,
  {
    files: ["**/*.ts", "**/*.tsx"],
    languageOptions: {
      ecmaVersion: 2022,
      // parser: "@typescript-eslint/parser"
      parser: tseslint.parser,
      parserOptions: {
        sourceType: "module",
        project: true,
        tsconfigRootDir: __dirname,
        ecmaFeatures: {
          jsx: true,
        },
        globals: {
          ...globals.browser,
        },
      },
    },
    plugins: {
      react,
    },
    rules: {},
    ignores: [
      "node_modules/",
    ],
  },
);

Expected Behavior

Should have no errors

eslint-plugin-react version

7.34.2

eslint version

9.4.0

node version

20.22.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions