Skip to content

Commit

Permalink
fix: skip add plugin when already imported (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
syi0808 authored Jun 26, 2024
1 parent fac14b8 commit 96f3e01
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/migrate-config/src/migrate-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,11 @@ function createPlugins(plugins, migration) {
bindings: ["fixupPluginRules"],
added: true,
});
} else {
} else if (
!migration.imports
.get("@eslint/compat")
.bindings.includes("fixupPluginRules")
) {
migration.imports
.get("@eslint/compat")
.bindings.push("fixupPluginRules");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
plugins: ["react"],
overrides: [
{
plugins: ["react-hooks"],
}
]
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const react = require("eslint-plugin-react");

const {
fixupPluginRules,
} = require("@eslint/compat");

const reactHooks = require("eslint-plugin-react-hooks");

module.exports = [{
plugins: {
react: fixupPluginRules(react),
},
}, {
plugins: {
"react-hooks": fixupPluginRules(reactHooks),
},
}];
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import react from "eslint-plugin-react";
import { fixupPluginRules } from "@eslint/compat";
import reactHooks from "eslint-plugin-react-hooks";

export default [{
plugins: {
react: fixupPluginRules(react),
},
}, {
plugins: {
"react-hooks": fixupPluginRules(reactHooks),
},
}];
1 change: 1 addition & 0 deletions packages/migrate-config/tests/migrate-config-cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const filePaths = [
"plugins-dedupe/.eslintrc.yml",
"gitignore-simple/.eslintrc.json",
"gitignore-complex/.eslintrc.json",
"import-duplicate/.eslintrc.cjs",
].map(file => `tests/fixtures/${file}`);

//-----------------------------------------------------------------------------
Expand Down

0 comments on commit 96f3e01

Please sign in to comment.