Fixtures from ESLint rule
Incorporates the fixtures from eslint-plugin-react-hooks using a script, so that we can easily update them in the future. For each fixture we run the compiler with and without hooks validation first so that we know if the fixture is expected to pass — we have some false positives and false negatives that i can work through. For example we accidentally think that `userFetch()` is a hook, oops. Fixtures that should pass but error, or that should error but pass, are marked as `todo.<name>` or `todo.error.<name>`. While i was here i added the ability to have fixtures in subdirectories for grouping purposes.
Joe Savona committed
May 11, 2023 at 13:39 UTC
e649bf6429206a0f5bc865373648861849a6ff0e
66 files changed
+148
-52
compiler/forget/scripts/build-react-hooks-fixures.js
+6
-5
@@ -71,14 +71,15 @@ for (const fixture of fixtures) {
71
let code = fixture.code;
72
let prefix = "";
73
if (error !== null) {
74
- prefix = `todo.`;
74
+ prefix = `todo.bail.`;
75
code = `// @skip\n// Unsupported input\n${code}`;
76
} else if (fixture.valid === false) {
77
- prefix = `error.`;
77
if (passes) {
79
- // oops, passed when we expected an error
80
- prefix = `todo.error.`;
81
- code = `// @skip\n// Passed but should have errored\n${code}`;
78
+ prefix = `todo.error.invalid-`;
79
+ code = `// @skip\n// Passed but should have failed\n${code}`;
80
+ } else {
81
+ prefix = `error.invalid-`;
82
+ code = `// Expected to fail\n${code}`;
83
}
84
} else if (!passes) {
85
// oops, error when it should have passed
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-1b9527f967f3.expect.md
renamed
+5
-3
@@ -2,6 +2,8 @@
2
## Input
3
4
```javascript
5
+// Expected to fail
6
+
7
// Invalid because it's dangerous and might not warn otherwise.
8
// This *must* be invalid.
9
function useHookInLoops() {
@@ -23,13 +25,13 @@ function useHookInLoops() {
25
## Error
26
27
```
26
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (5:5)
27
-
28
[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
29
30
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (10:10)
30
+[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (9:9)
31
32
[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (12:12)
33
+
34
+[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (14:14)
35
```
36
37
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-1b9527f967f3.js
renamed
+2
@@ -1,3 +1,5 @@
1
+// Expected to fail
2
+
3
// Invalid because it's dangerous and might not warn otherwise.
4
// This *must* be invalid.
5
function useHookInLoops() {
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-2aabd222fc6a.expect.md
renamed
+3
-1
@@ -2,6 +2,8 @@
2
## Input
3
4
```javascript
5
+// Expected to fail
6
+
7
// Invalid because it's dangerous and might not warn otherwise.
8
// This *must* be invalid.
9
function ComponentWithConditionalHook() {
@@ -16,7 +18,7 @@ function ComponentWithConditionalHook() {
18
## Error
19
20
```
19
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (5:5)
21
+[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
22
```
23
24
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-2aabd222fc6a.js
renamed
+2
@@ -1,3 +1,5 @@
1
+// Expected to fail
2
+
3
// Invalid because it's dangerous and might not warn otherwise.
4
// This *must* be invalid.
5
function ComponentWithConditionalHook() {
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-49d341e5d68f.expect.md
renamed
+3
-1
@@ -2,6 +2,8 @@
2
## Input
3
4
```javascript
5
+// Expected to fail
6
+
7
// Invalid because it's dangerous and might not warn otherwise.
8
// This *must* be invalid.
9
function useLabeledBlock() {
@@ -17,7 +19,7 @@ function useLabeledBlock() {
19
## Error
20
21
```
20
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (6:6)
22
+[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (8:8)
23
```
24
25
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-49d341e5d68f.js
renamed
+2
@@ -1,3 +1,5 @@
1
+// Expected to fail
2
+
3
// Invalid because it's dangerous and might not warn otherwise.
4
// This *must* be invalid.
5
function useLabeledBlock() {
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-79128a755612.expect.md
renamed
+3
-1
@@ -2,6 +2,8 @@
2
## Input
3
4
```javascript
5
+// Expected to fail
6
+
7
// Invalid because it's dangerous and might not warn otherwise.
8
// This *must* be invalid.
9
function ComponentWithHookInsideLoop() {
@@ -16,7 +18,7 @@ function ComponentWithHookInsideLoop() {
18
## Error
19
20
```
19
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (5:5)
21
+[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
22
```
23
24
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-79128a755612.js
renamed
+2
@@ -1,3 +1,5 @@
1
+// Expected to fail
2
+
3
// Invalid because it's dangerous and might not warn otherwise.
4
// This *must* be invalid.
5
function ComponentWithHookInsideLoop() {
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-9718e30b856c.expect.md
renamed
+3
-1
@@ -2,6 +2,8 @@
2
## Input
3
4
```javascript
5
+// Expected to fail
6
+
7
// Invalid because it's dangerous and might not warn otherwise.
8
// This *must* be invalid.
9
function useHook() {
@@ -20,7 +22,7 @@ function useHook() {
22
## Error
23
24
```
23
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (10:10)
25
+[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (12:12)
26
```
27
28
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-9718e30b856c.js
renamed
+3
-1
@@ -1,11 +1,13 @@
1
+// Expected to fail
2
+
3
// Invalid because it's dangerous and might not warn otherwise.
4
// This *must* be invalid.
5
function useHook() {
6
+ if (a) return;
7
if (b) {
8
console.log("true");
9
} else {
10
console.log("false");
11
}
9
- if (a) return;
12
useState();
13
}
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-9bf17c174134.expect.md
renamed
+4
-2
@@ -2,6 +2,8 @@
2
## Input
3
4
```javascript
5
+// Expected to fail
6
+
7
// Invalid because it's dangerous and might not warn otherwise.
8
// This *must* be invalid.
9
function useHook() {
@@ -15,9 +17,9 @@ function useHook() {
17
## Error
18
19
```
18
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (4:4)
20
+[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (6:6)
21
20
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (5:5)
22
+[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
23
```
24
25
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-9bf17c174134.js
renamed
+2
@@ -1,3 +1,5 @@
1
+// Expected to fail
2
+
3
// Invalid because it's dangerous and might not warn otherwise.
4
// This *must* be invalid.
5
function useHook() {
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-b4dcda3d60ed.expect.md
renamed
+3
-1
@@ -2,6 +2,8 @@
2
## Input
3
4
```javascript
5
+// Expected to fail
6
+
7
// Invalid because it's dangerous and might not warn otherwise.
8
// This *must* be invalid.
9
function ComponentWithTernaryHook() {
@@ -14,7 +16,7 @@ function ComponentWithTernaryHook() {
16
## Error
17
18
```
17
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (4:4)
19
+[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (6:6)
20
```
21
22
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-b4dcda3d60ed.js
renamed
+2
@@ -1,3 +1,5 @@
1
+// Expected to fail
2
+
3
// Invalid because it's dangerous and might not warn otherwise.
4
// This *must* be invalid.
5
function ComponentWithTernaryHook() {
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-c906cace44e9.expect.md
renamed
+3
-1
@@ -2,6 +2,8 @@
2
## Input
3
4
```javascript
5
+// Expected to fail
6
+
7
// Invalid because it's dangerous and might not warn otherwise.
8
// This *must* be invalid.
9
function useHook() {
@@ -15,7 +17,7 @@ function useHook() {
17
## Error
18
19
```
18
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (5:5)
20
+[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
21
```
22
23
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-c906cace44e9.js
renamed
+2
@@ -1,3 +1,5 @@
1
+// Expected to fail
2
+
3
// Invalid because it's dangerous and might not warn otherwise.
4
// This *must* be invalid.
5
function useHook() {
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-d740d54e9c21.expect.md
renamed
+3
-1
@@ -2,6 +2,8 @@
2
## Input
3
4
```javascript
5
+// Expected to fail
6
+
7
// Invalid because it's dangerous and might not warn otherwise.
8
// This *must* be invalid.
9
function normalFunctionWithConditionalHook() {
@@ -16,7 +18,7 @@ function normalFunctionWithConditionalHook() {
18
## Error
19
20
```
19
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (5:5)
21
+[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
22
```
23
24
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-d740d54e9c21.js
renamed
+2
@@ -1,3 +1,5 @@
1
+// Expected to fail
2
+
3
// Invalid because it's dangerous and might not warn otherwise.
4
// This *must* be invalid.
5
function normalFunctionWithConditionalHook() {
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-d85c144bdf40.expect.md
renamed
+4
-2
@@ -2,6 +2,8 @@
2
## Input
3
4
```javascript
5
+// Expected to fail
6
+
7
// Invalid because it's dangerous and might not warn otherwise.
8
// This *must* be invalid.
9
function useHookInLoops() {
@@ -18,9 +20,9 @@ function useHookInLoops() {
20
## Error
21
22
```
21
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (5:5)
22
-
23
[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
24
+
25
+[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (9:9)
26
```
27
28
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-d85c144bdf40.js
renamed
+2
@@ -1,3 +1,5 @@
1
+// Expected to fail
2
+
3
// Invalid because it's dangerous and might not warn otherwise.
4
// This *must* be invalid.
5
function useHookInLoops() {
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-ea7c2fb545a9.expect.md
renamed
+3
-1
@@ -2,6 +2,8 @@
2
## Input
3
4
```javascript
5
+// Expected to fail
6
+
7
// Invalid because it's dangerous and might not warn otherwise.
8
// This *must* be invalid.
9
function useHookWithConditionalHook() {
@@ -16,7 +18,7 @@ function useHookWithConditionalHook() {
18
## Error
19
20
```
19
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (5:5)
21
+[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
22
```
23
24
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-ea7c2fb545a9.js
renamed
+2
@@ -1,3 +1,5 @@
1
+// Expected to fail
2
+
3
// Invalid because it's dangerous and might not warn otherwise.
4
// This *must* be invalid.
5
function useHookWithConditionalHook() {
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-f3d6c5e9c83d.expect.md
renamed
+3
-1
@@ -2,6 +2,8 @@
2
## Input
3
4
```javascript
5
+// Expected to fail
6
+
7
// Invalid because it's dangerous and might not warn otherwise.
8
// This *must* be invalid.
9
function useHook() {
@@ -20,7 +22,7 @@ function useHook() {
22
## Error
23
24
```
23
-[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (10:10)
25
+[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (12:12)
26
```
27
28
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-f3d6c5e9c83d.js
renamed
+3
-1
@@ -1,11 +1,13 @@
1
+// Expected to fail
2
+
3
// Invalid because it's dangerous and might not warn otherwise.
4
// This *must* be invalid.
5
function useHook() {
4
- if (a) return;
6
if (b) {
7
console.log("true");
8
} else {
9
console.log("false");
10
}
11
+ if (a) return;
12
useState();
13
}
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-f69800950ff0.expect.md
new
+28
@@ -0,0 +1,28 @@
1
+
2
+## Input
3
+
4
+```javascript
5
+// Expected to fail
6
+
7
+// Invalid because it's dangerous and might not warn otherwise.
8
+// This *must* be invalid.
9
+function useHook({ bar }) {
10
+ let foo1 = bar && useState();
11
+ let foo2 = bar || useState();
12
+ let foo3 = bar ?? useState();
13
+}
14
+
15
+```
16
+
17
+
18
+## Error
19
+
20
+```
21
+[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (6:6)
22
+
23
+[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (7:7)
24
+
25
+[ReactForget] InvalidInput: Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) (8:8)
26
+```
27
+
28
+
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-f69800950ff0.js
renamed
+1
-2
@@ -1,5 +1,4 @@
1
-// @skip
2
-// Unsupported input
1
+// Expected to fail
2
3
// Invalid because it's dangerous and might not warn otherwise.
4
// This *must* be invalid.
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/rules-of-hooks-c5d1f3143c4c.expect.md
new
+23
@@ -0,0 +1,23 @@
1
+
2
+## Input
3
+
4
+```javascript
5
+// Regression test for incorrectly flagged valid code.
6
+function RegressionTest() {
7
+ const foo = cond ? a : b;
8
+ useState();
9
+}
10
+
11
+```
12
+
13
+## Code
14
+
15
+```javascript
16
+// Regression test for incorrectly flagged valid code.
17
+function RegressionTest() {
18
+ cond ? a : b;
19
+ useState();
20
+}
21
+
22
+```
23
+
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/rules-of-hooks-c5d1f3143c4c.js
renamed
-3
@@ -1,6 +1,3 @@
1
-// @skip
2
-// Unsupported input
3
-
1
// Regression test for incorrectly flagged valid code.
2
function RegressionTest() {
3
const foo = cond ? a : b;
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-279ac76f53af.js
renamed
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-27c18dc8dad2.js
renamed
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-28a78701970c.js
renamed
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-3d692676194b.js
renamed
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-6949b255e7eb.js
renamed
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-69521d94fa03.js
renamed
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-8503ca76d6f8.js
renamed
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-93dc5d5e538a.js
renamed
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-d0935abedc42.js
renamed
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-e0a5db3ae21e.js
renamed
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-e29c874aa913.js
renamed
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-e9f9bac89f8f.js
renamed
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-fadd52c1e460.js
renamed
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-0a1dbff27ba0.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
// Invalid because it's dangerous and might not warn otherwise.
5
// This *must* be invalid.
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-0de1224ce64b.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
// Invalid because it's a common misunderstanding.
5
// We *could* make it valid but the runtime error could be confusing.
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-191029ac48c8.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
// Invalid because it's dangerous.
5
// Normally, this would crash, but not if you use inline requires.
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-206e2811c87c.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
// This is a false positive (it's valid) that unfortunately
5
// we cannot avoid. Prefer to rename it to not start with "use"
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-28a7111f56a7.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
// Technically this is a false positive.
5
// We *could* make it valid (and it used to be).
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-2c51251df67a.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
(class {
5
useHook() {
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-368024110a58.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
// Invalid because it's dangerous and might not warn otherwise.
5
// This *must* be invalid.
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-449a37146a83.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
// Invalid because it's a common misunderstanding.
5
// We *could* make it valid but the runtime error could be confusing.
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-5a7ac9a6e8fa.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
// These are neither functions nor hooks.
5
function _normalFunctionWithHook() {
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-76a74b4666e9.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
// Invalid because it's a common misunderstanding.
5
// We *could* make it valid but the runtime error could be confusing.
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-8303403b8e4c.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
class ClassComponentWithHook extends React.Component {
5
render() {
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-8566f9a360e2.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
// Invalid because it's dangerous and might not warn otherwise.
5
// This *must* be invalid.
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-99b5c750d1d1.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
class ClassComponentWithFeatureFlag extends React.Component {
5
render() {
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-9c79feec4b9b.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
(class {
5
h = () => {
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-a0058f0b446d.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
// Invalid because it's dangerous and might not warn otherwise.
5
// This *must* be invalid.
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-a63fd4f9dcc0.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
// This is invalid because "use"-prefixed functions used in named
5
// functions are assumed to be hooks.
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-acb56658fe7e.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
class C {
5
m() {
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-c59788ef5676.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
// Currently invalid because it violates the convention and removes the "taint"
5
// from a hook. We *could* make it valid to avoid some false positives but let's
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-d842d36db450.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
// Invalid because it's dangerous and might not warn otherwise.
5
// This *must* be invalid.
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-d952b82c2597.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
// Invalid because it's a common misunderstanding.
5
// We *could* make it valid but the runtime error could be confusing.
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-ddeca9708b63.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
(class {
5
i() {
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-e675f0a672d8.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
// Invalid because it's dangerous and might not warn otherwise.
5
// This *must* be invalid.
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-e69ffce323c3.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
(class {
5
useHook = () => {
compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-f6f37b63b2d4.js
renamed
+1
-1
@@ -1,5 +1,5 @@
1
// @skip
2
-// Passed but should have errored
2
+// Passed but should have failed
3
4
Hook.useState();
5
Hook._useState();