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
Lauren Tan committed
May 6, 2024 at 20:39 UTC
7caf071e01afcc6a3ccb9c3f3a5c41fbcb3d6152
1 file changed
+16
compiler/packages/eslint-plugin-react-compiler/__tests__/ReactCompilerRuleTypescript-test.ts
+16
@@ -36,6 +36,22 @@ const tests: CompilerTestCases = {
36
},
37
],
38
invalid: [
39
+ {
40
+ name: "[FALSE POSITIVE] Repro for hooks as normal values",
41
+ filename: "test.tsx",
42
+ code: normalizeIndent`
43
+ function Button(props) {
44
+ const scrollview = React.useRef<ScrollView>(null);
45
+ return <Button thing={scrollview} />;
46
+ }
47
+ `,
48
+ errors: [
49
+ {
50
+ message:
51
+ "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",
52
+ },
53
+ ],
54
+ },
55
{
56
name: "Mutating useState value",
57
filename: "test.tsx",