<p dir="auto">React version: 16.13.1</p>
<h2 dir="auto">Steps To Reproduce</h2>
<ol dir="auto">
<li>Create a component using a conditional hook</li>
<li>Wrap the component with a HOC, e.g. mobx <a href="https://mobx.js.org/react-integration.html" rel="nofollow">observer</a></li>
</ol>
<h2 dir="auto">Example</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="function HOC&lt;T&gt;(c: T): T { return c; }

const ConditionalHookComp = HOC(
    ({ flag }): JSX.Element =&gt; {
        if (flag) {
            useEffect(() =&gt; console.log(&quot;something&quot;));
        }
        return &lt;&gt;&lt;/&gt;;
    });"><pre class="notranslate"><code class="notranslate">function HOC&lt;T&gt;(c: T): T { return c; }

const ConditionalHookComp = HOC(
    ({ flag }): JSX.Element =&gt; {
        if (flag) {
            useEffect(() =&gt; console.log("something"));
        }
        return &lt;&gt;&lt;/&gt;;
    });
</code></pre></div>
<h2 dir="auto">The current behavior</h2>
<p dir="auto">The linter does not issue a warning/error for the conditional use of hooks, unless you remove the HOC.</p>
<h2 dir="auto">The expected behavior</h2>
<p dir="auto">The linter issues a warning/error for the conditional use of hooks regardless whether the component is wrapped by an HOC or not.</p>
<p dir="auto">React version: 17.0.1</p>
<p dir="auto">my component file is like:</p>
<p dir="auto">`export default function(props) {</p>
<p dir="auto">if (props.data &gt; 1) {<br>
useEffect(function() {</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="})"><pre class="notranslate"><code class="notranslate">})
</code></pre></div>
<p dir="auto">}<br>
return (<br>
</p><div dir="auto"> data</div><br>
)<br>
}`<p dir="auto"></p>
<p dir="auto">my .eslintrc.json file like this:<br>
<code class="notranslate">{ "extends": [], "plugins": [ "react-hooks" ], "rules": { "react-hooks/rules-of-hooks": "error", "react-hooks/exhaustive-deps": "error" }, "parser": "babel-eslint" }</code></p>