mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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:
+16
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user