Closed
Description
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
Repro
// eslint.config.js
import eslintReact from 'eslint-plugin-react';
import eslintReactRecommended from 'eslint-plugin-react/configs/recommended.js';
export default [
{
plugins: {
react: eslintReact,
},
},
eslintReactRecommended,
];
npx eslint eslint.config.js
Expected
No errors
Actual
Oops! Something went wrong! :(
ESLint: 8.56.0
Error: Key "plugins": Cannot redefine plugin "react".
More Info
When defining a plugin key in the flat config ESLint enforces that you only ever redefine they key with the same plugin. This check is done by comparing by reference -- i.e. configA.plugin.react === configB.plugin.react
eslint-plugin-react
fails this check because it defines its "plugin" in two locations:
Lines 14 to 31 in 36e791d
eslint-plugin-react/configs/all.js
Lines 23 to 26 in 36e791d
For this to work there needs to be exactly 1 copy of the "plugin" defined by the package.
For example:
const plugin = { ... };
plugin.configs = {
recommended: {
plugins: { react: plugin },
rules: { ... },
},
all: {
plugins: { react: plugin },
rules: { ... },
},
});
eslint-plugin-react version
v7.33.2
eslint version
v8.56.0
node version
v20.11.0