Skip to content

Commit

Permalink
refactor(eslint-plugin): refactor 'react' config (#3396)
Browse files Browse the repository at this point in the history
  • Loading branch information
tido64 authored Oct 17, 2024
1 parent 57013d2 commit 8502d48
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .changeset/great-ways-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
11 changes: 11 additions & 0 deletions packages/eslint-plugin/src/configs/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,15 @@ const compat = new FlatCompat({
module.exports = [
...compat.extends("plugin:react-hooks/recommended"),
react.configs.flat.recommended,
{
name: "rnx-kit/react",
rules: {
"react/prop-types": "off",
},
settings: {
react: {
version: "detect",
},
},
},
];
10 changes: 2 additions & 8 deletions packages/eslint-plugin/src/configs/recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ function isInstalled(spec) {
}
}

const usesReact = isInstalled("react");
const reactConfigs = usesReact ? require("./react") : [];
const reactConfigs = isInstalled("react") ? require("./react") : [];

module.exports = [
eslint.configs.recommended,
...tseslint.configs.recommended,
...reactConfigs,
{
name: "rnx-kit/recommended",
plugins: {
// @ts-expect-error No declaration file for module
"@react-native": require("@react-native/eslint-plugin"),
Expand Down Expand Up @@ -53,12 +53,6 @@ module.exports = [
],
"@typescript-eslint/no-var-requires": "off",
"no-undef": "off",
...(usesReact ? { "react/prop-types": "off" } : {}),
},
settings: {
react: {
version: "detect",
},
},
},
];

0 comments on commit 8502d48

Please sign in to comment.