Skip to content

Commit

Permalink
mandatory-UseEvent does not warn on effect stores
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkamyshev committed Jun 10, 2022
1 parent 33f8718 commit 5f94ae2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from "react";
import { useEvent, useStore } from "effector-react";

import { fetchFx } from "./model";

const Button: React.FC = () => {
const loading = useStore(fetchFx.pending);

if (loading) {
return null;
}

return <button>click</button>;
};

export { Button };
6 changes: 3 additions & 3 deletions rules/mandatory-useEvent/mandatory-useEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = {
return;
}

if (isInsideUseEventCall({ node, context })) {
if (isInsideEffectorHook({ node, context })) {
return;
}

Expand All @@ -61,14 +61,14 @@ module.exports = {
},
};

function isInsideUseEventCall({ node, context }) {
function isInsideEffectorHook({ node, context }) {
const calleeParentNode = traverseParentByType(node.parent, "CallExpression");

if (!calleeParentNode?.callee) return false;

return nodeTypeIs.effectorReactHook({
node: calleeParentNode.callee,
context,
hook: ["useEvent", "useUnit"],
hook: ["useEvent", "useUnit", "useStore"],
});
}

0 comments on commit 5f94ae2

Please sign in to comment.