Add failing test for eslint-plugin false positive

The eslint rule seems to false positive on this typescript syntax, but
strangely the compiler does not

ghstack-source-id: 19baa24ff7addd83f59e2b03fdb180af169a2794
Pull Request resolved: https://github.com/facebook/react-forget/pull/2913
This commit is contained in:
Lauren Tan
2024-05-06 20:39:49 -04:00
parent b28c53dcf1
commit 7caf071e01
@@ -36,6 +36,22 @@ const tests: CompilerTestCases = {
},
],
invalid: [
{
name: "[FALSE POSITIVE] Repro for hooks as normal values",
filename: "test.tsx",
code: normalizeIndent`
function Button(props) {
const scrollview = React.useRef<ScrollView>(null);
return <Button thing={scrollview} />;
}
`,
errors: [
{
message:
"Hooks may not be referenced as normal values, they must be called. See https://react.dev/reference/rules/react-calls-components-and-hooks#never-pass-around-hooks-as-regular-values",
},
],
},
{
name: "Mutating useState value",
filename: "test.tsx",