From e649bf6429206a0f5bc865373648861849a6ff0e Mon Sep 17 00:00:00 2001 From: Joe Savona Date: Thu, 11 May 2023 13:39:58 -0600 Subject: [PATCH] Fixtures from ESLint rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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.` or `todo.error.`. While i was here i added the ability to have fixtures in subdirectories for grouping purposes. --- .../scripts/build-react-hooks-fixures.js | 11 ++++---- ...lid-rules-of-hooks-1b9527f967f3.expect.md} | 8 ++++-- ...or.invalid-rules-of-hooks-1b9527f967f3.js} | 2 ++ ...lid-rules-of-hooks-2aabd222fc6a.expect.md} | 4 ++- ...or.invalid-rules-of-hooks-2aabd222fc6a.js} | 2 ++ ...lid-rules-of-hooks-49d341e5d68f.expect.md} | 4 ++- ...or.invalid-rules-of-hooks-49d341e5d68f.js} | 2 ++ ...lid-rules-of-hooks-79128a755612.expect.md} | 4 ++- ...or.invalid-rules-of-hooks-79128a755612.js} | 2 ++ ...lid-rules-of-hooks-9718e30b856c.expect.md} | 4 ++- ...or.invalid-rules-of-hooks-9718e30b856c.js} | 4 ++- ...lid-rules-of-hooks-9bf17c174134.expect.md} | 6 ++-- ...or.invalid-rules-of-hooks-9bf17c174134.js} | 2 ++ ...lid-rules-of-hooks-b4dcda3d60ed.expect.md} | 4 ++- ...or.invalid-rules-of-hooks-b4dcda3d60ed.js} | 2 ++ ...lid-rules-of-hooks-c906cace44e9.expect.md} | 4 ++- ...or.invalid-rules-of-hooks-c906cace44e9.js} | 2 ++ ...lid-rules-of-hooks-d740d54e9c21.expect.md} | 4 ++- ...or.invalid-rules-of-hooks-d740d54e9c21.js} | 2 ++ ...lid-rules-of-hooks-d85c144bdf40.expect.md} | 6 ++-- ...or.invalid-rules-of-hooks-d85c144bdf40.js} | 2 ++ ...lid-rules-of-hooks-ea7c2fb545a9.expect.md} | 4 ++- ...or.invalid-rules-of-hooks-ea7c2fb545a9.js} | 2 ++ ...lid-rules-of-hooks-f3d6c5e9c83d.expect.md} | 4 ++- ...or.invalid-rules-of-hooks-f3d6c5e9c83d.js} | 4 ++- ...alid-rules-of-hooks-f69800950ff0.expect.md | 28 +++++++++++++++++++ ...or.invalid-rules-of-hooks-f69800950ff0.js} | 3 +- .../rules-of-hooks-c5d1f3143c4c.expect.md | 23 +++++++++++++++ ...99ca.js => rules-of-hooks-c5d1f3143c4c.js} | 3 -- ... todo.bail.rules-of-hooks-279ac76f53af.js} | 0 ... todo.bail.rules-of-hooks-27c18dc8dad2.js} | 0 ... todo.bail.rules-of-hooks-28a78701970c.js} | 0 ... todo.bail.rules-of-hooks-3d692676194b.js} | 0 ... todo.bail.rules-of-hooks-6949b255e7eb.js} | 0 ... todo.bail.rules-of-hooks-69521d94fa03.js} | 0 ... todo.bail.rules-of-hooks-8503ca76d6f8.js} | 0 ... todo.bail.rules-of-hooks-93dc5d5e538a.js} | 0 ... todo.bail.rules-of-hooks-d0935abedc42.js} | 0 ... todo.bail.rules-of-hooks-e0a5db3ae21e.js} | 0 ... todo.bail.rules-of-hooks-e29c874aa913.js} | 0 ... todo.bail.rules-of-hooks-e9f9bac89f8f.js} | 0 ... todo.bail.rules-of-hooks-fadd52c1e460.js} | 0 ...or.invalid-rules-of-hooks-0a1dbff27ba0.js} | 2 +- ...or.invalid-rules-of-hooks-0de1224ce64b.js} | 2 +- ...or.invalid-rules-of-hooks-191029ac48c8.js} | 2 +- ...or.invalid-rules-of-hooks-206e2811c87c.js} | 2 +- ...or.invalid-rules-of-hooks-28a7111f56a7.js} | 2 +- ...or.invalid-rules-of-hooks-2c51251df67a.js} | 2 +- ...or.invalid-rules-of-hooks-368024110a58.js} | 2 +- ...or.invalid-rules-of-hooks-449a37146a83.js} | 2 +- ...or.invalid-rules-of-hooks-5a7ac9a6e8fa.js} | 2 +- ...or.invalid-rules-of-hooks-76a74b4666e9.js} | 2 +- ...or.invalid-rules-of-hooks-8303403b8e4c.js} | 2 +- ...or.invalid-rules-of-hooks-8566f9a360e2.js} | 2 +- ...or.invalid-rules-of-hooks-99b5c750d1d1.js} | 2 +- ...or.invalid-rules-of-hooks-9c79feec4b9b.js} | 2 +- ...or.invalid-rules-of-hooks-a0058f0b446d.js} | 2 +- ...or.invalid-rules-of-hooks-a63fd4f9dcc0.js} | 2 +- ...or.invalid-rules-of-hooks-acb56658fe7e.js} | 2 +- ...or.invalid-rules-of-hooks-c59788ef5676.js} | 2 +- ...or.invalid-rules-of-hooks-d842d36db450.js} | 2 +- ...or.invalid-rules-of-hooks-d952b82c2597.js} | 2 +- ...or.invalid-rules-of-hooks-ddeca9708b63.js} | 2 +- ...or.invalid-rules-of-hooks-e675f0a672d8.js} | 2 +- ...or.invalid-rules-of-hooks-e69ffce323c3.js} | 2 +- ...or.invalid-rules-of-hooks-f6f37b63b2d4.js} | 2 +- 66 files changed, 148 insertions(+), 52 deletions(-) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-1dd104f3e579.expect.md => error.invalid-rules-of-hooks-1b9527f967f3.expect.md} (96%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-1dd104f3e579.js => error.invalid-rules-of-hooks-1b9527f967f3.js} (92%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-70d37bc6dabc.expect.md => error.invalid-rules-of-hooks-2aabd222fc6a.expect.md} (93%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-70d37bc6dabc.js => error.invalid-rules-of-hooks-2aabd222fc6a.js} (89%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-3d95dc7a5f98.expect.md => error.invalid-rules-of-hooks-49d341e5d68f.expect.md} (93%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-3d95dc7a5f98.js => error.invalid-rules-of-hooks-49d341e5d68f.js} (89%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-bfa72d1b8135.expect.md => error.invalid-rules-of-hooks-79128a755612.expect.md} (93%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-bfa72d1b8135.js => error.invalid-rules-of-hooks-79128a755612.js} (89%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-ec94ef9d80df.expect.md => error.invalid-rules-of-hooks-9718e30b856c.expect.md} (93%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-92708a08b920.js => error.invalid-rules-of-hooks-9718e30b856c.js} (91%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-99ca80f8b0b6.expect.md => error.invalid-rules-of-hooks-9bf17c174134.expect.md} (94%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-99ca80f8b0b6.js => error.invalid-rules-of-hooks-9bf17c174134.js} (87%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-62bded832974.expect.md => error.invalid-rules-of-hooks-b4dcda3d60ed.expect.md} (93%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-62bded832974.js => error.invalid-rules-of-hooks-b4dcda3d60ed.js} (88%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-fc7007852fe0.expect.md => error.invalid-rules-of-hooks-c906cace44e9.expect.md} (93%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-fc7007852fe0.js => error.invalid-rules-of-hooks-c906cace44e9.js} (87%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-baf61a179e4c.expect.md => error.invalid-rules-of-hooks-d740d54e9c21.expect.md} (93%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-baf61a179e4c.js => error.invalid-rules-of-hooks-d740d54e9c21.js} (90%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-2e9963324591.expect.md => error.invalid-rules-of-hooks-d85c144bdf40.expect.md} (95%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-2e9963324591.js => error.invalid-rules-of-hooks-d85c144bdf40.js} (90%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-e70a6f5d6d4b.expect.md => error.invalid-rules-of-hooks-ea7c2fb545a9.expect.md} (93%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-e70a6f5d6d4b.js => error.invalid-rules-of-hooks-ea7c2fb545a9.js} (89%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-92708a08b920.expect.md => error.invalid-rules-of-hooks-f3d6c5e9c83d.expect.md} (93%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{error.rules-of-hooks-ec94ef9d80df.js => error.invalid-rules-of-hooks-f3d6c5e9c83d.js} (91%) create mode 100644 compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-f69800950ff0.expect.md rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.rules-of-hooks-dba5889e4ba6.js => error.invalid-rules-of-hooks-f69800950ff0.js} (87%) create mode 100644 compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/rules-of-hooks-c5d1f3143c4c.expect.md rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.rules-of-hooks-f7b5986699ca.js => rules-of-hooks-c5d1f3143c4c.js} (80%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.rules-of-hooks-279ac76f53af.js => todo.bail.rules-of-hooks-279ac76f53af.js} (100%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.rules-of-hooks-27c18dc8dad2.js => todo.bail.rules-of-hooks-27c18dc8dad2.js} (100%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.rules-of-hooks-28a78701970c.js => todo.bail.rules-of-hooks-28a78701970c.js} (100%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.rules-of-hooks-3d692676194b.js => todo.bail.rules-of-hooks-3d692676194b.js} (100%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.rules-of-hooks-6949b255e7eb.js => todo.bail.rules-of-hooks-6949b255e7eb.js} (100%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.rules-of-hooks-69521d94fa03.js => todo.bail.rules-of-hooks-69521d94fa03.js} (100%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.rules-of-hooks-8503ca76d6f8.js => todo.bail.rules-of-hooks-8503ca76d6f8.js} (100%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.rules-of-hooks-93dc5d5e538a.js => todo.bail.rules-of-hooks-93dc5d5e538a.js} (100%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.rules-of-hooks-d0935abedc42.js => todo.bail.rules-of-hooks-d0935abedc42.js} (100%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.rules-of-hooks-e0a5db3ae21e.js => todo.bail.rules-of-hooks-e0a5db3ae21e.js} (100%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.rules-of-hooks-e29c874aa913.js => todo.bail.rules-of-hooks-e29c874aa913.js} (100%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.rules-of-hooks-e9f9bac89f8f.js => todo.bail.rules-of-hooks-e9f9bac89f8f.js} (100%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.rules-of-hooks-fadd52c1e460.js => todo.bail.rules-of-hooks-fadd52c1e460.js} (100%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-92503f581023.js => todo.error.invalid-rules-of-hooks-0a1dbff27ba0.js} (87%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-b4af90990150.js => todo.error.invalid-rules-of-hooks-0de1224ce64b.js} (89%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-880ce4a7e686.js => todo.error.invalid-rules-of-hooks-191029ac48c8.js} (91%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-f486864c4bec.js => todo.error.invalid-rules-of-hooks-206e2811c87c.js} (87%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-c277f25e7c03.js => todo.error.invalid-rules-of-hooks-28a7111f56a7.js} (93%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-7451860cd46f.js => todo.error.invalid-rules-of-hooks-2c51251df67a.js} (62%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-251e67613de1.js => todo.error.invalid-rules-of-hooks-368024110a58.js} (88%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-310a4e022130.js => todo.error.invalid-rules-of-hooks-449a37146a83.js} (88%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-429b3b1a8ee4.js => todo.error.invalid-rules-of-hooks-5a7ac9a6e8fa.js} (84%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-1a1e29f21a79.js => todo.error.invalid-rules-of-hooks-76a74b4666e9.js} (86%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-de96bb13ad47.js => todo.error.invalid-rules-of-hooks-8303403b8e4c.js} (75%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-cdcb36730551.js => todo.error.invalid-rules-of-hooks-8566f9a360e2.js} (87%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-42576e5c5613.js => todo.error.invalid-rules-of-hooks-99b5c750d1d1.js} (80%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-be9bff592ca0.js => todo.error.invalid-rules-of-hooks-9c79feec4b9b.js} (63%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-4d1a9ed4d44a.js => todo.error.invalid-rules-of-hooks-a0058f0b446d.js} (85%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-0a42415d4990.js => todo.error.invalid-rules-of-hooks-a63fd4f9dcc0.js} (85%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-c0069d062d50.js => todo.error.invalid-rules-of-hooks-acb56658fe7e.js} (68%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-3d8726664cf7.js => todo.error.invalid-rules-of-hooks-c59788ef5676.js} (91%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-60e23f3caf5b.js => todo.error.invalid-rules-of-hooks-d842d36db450.js} (87%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-52cd6055b4fb.js => todo.error.invalid-rules-of-hooks-d952b82c2597.js} (87%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-fbe12b5ccfce.js => todo.error.invalid-rules-of-hooks-ddeca9708b63.js} (60%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-112dd48477e6.js => todo.error.invalid-rules-of-hooks-e675f0a672d8.js} (85%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-e803203d651b.js => todo.error.invalid-rules-of-hooks-e69ffce323c3.js} (65%) rename compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/{todo.error.rules-of-hooks-7bcc5c5c0416.js => todo.error.invalid-rules-of-hooks-f6f37b63b2d4.js} (73%) diff --git a/compiler/forget/scripts/build-react-hooks-fixures.js b/compiler/forget/scripts/build-react-hooks-fixures.js index 3ec9cd4a06..6e2a367bec 100644 --- a/compiler/forget/scripts/build-react-hooks-fixures.js +++ b/compiler/forget/scripts/build-react-hooks-fixures.js @@ -71,14 +71,15 @@ for (const fixture of fixtures) { let code = fixture.code; let prefix = ""; if (error !== null) { - prefix = `todo.`; + prefix = `todo.bail.`; code = `// @skip\n// Unsupported input\n${code}`; } else if (fixture.valid === false) { - prefix = `error.`; if (passes) { - // oops, passed when we expected an error - prefix = `todo.error.`; - code = `// @skip\n// Passed but should have errored\n${code}`; + prefix = `todo.error.invalid-`; + code = `// @skip\n// Passed but should have failed\n${code}`; + } else { + prefix = `error.invalid-`; + code = `// Expected to fail\n${code}`; } } else if (!passes) { // oops, error when it should have passed diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-1dd104f3e579.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-1b9527f967f3.expect.md similarity index 96% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-1dd104f3e579.expect.md rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-1b9527f967f3.expect.md index c73794ad22..b390c52a5a 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-1dd104f3e579.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-1b9527f967f3.expect.md @@ -2,6 +2,8 @@ ## Input ```javascript +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function useHookInLoops() { @@ -23,13 +25,13 @@ function useHookInLoops() { ## Error ``` -[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) - [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) -[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) +[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) [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) + +[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) ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-1dd104f3e579.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-1b9527f967f3.js similarity index 92% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-1dd104f3e579.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-1b9527f967f3.js index 2fb10722a6..0522e7c9af 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-1dd104f3e579.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-1b9527f967f3.js @@ -1,3 +1,5 @@ +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function useHookInLoops() { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-70d37bc6dabc.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-2aabd222fc6a.expect.md similarity index 93% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-70d37bc6dabc.expect.md rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-2aabd222fc6a.expect.md index 48f4ab1bd8..12e793e081 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-70d37bc6dabc.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-2aabd222fc6a.expect.md @@ -2,6 +2,8 @@ ## Input ```javascript +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function ComponentWithConditionalHook() { @@ -16,7 +18,7 @@ function ComponentWithConditionalHook() { ## Error ``` -[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) +[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) ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-70d37bc6dabc.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-2aabd222fc6a.js similarity index 89% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-70d37bc6dabc.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-2aabd222fc6a.js index 455b7fb367..67e02f0d8d 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-70d37bc6dabc.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-2aabd222fc6a.js @@ -1,3 +1,5 @@ +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function ComponentWithConditionalHook() { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-3d95dc7a5f98.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-49d341e5d68f.expect.md similarity index 93% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-3d95dc7a5f98.expect.md rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-49d341e5d68f.expect.md index bf1bf3336d..eb8e7ee930 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-3d95dc7a5f98.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-49d341e5d68f.expect.md @@ -2,6 +2,8 @@ ## Input ```javascript +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function useLabeledBlock() { @@ -17,7 +19,7 @@ function useLabeledBlock() { ## Error ``` -[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) +[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) ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-3d95dc7a5f98.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-49d341e5d68f.js similarity index 89% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-3d95dc7a5f98.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-49d341e5d68f.js index e5f6732143..c2a04744db 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-3d95dc7a5f98.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-49d341e5d68f.js @@ -1,3 +1,5 @@ +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function useLabeledBlock() { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-bfa72d1b8135.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-79128a755612.expect.md similarity index 93% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-bfa72d1b8135.expect.md rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-79128a755612.expect.md index a8401e92a7..f0271f6b18 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-bfa72d1b8135.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-79128a755612.expect.md @@ -2,6 +2,8 @@ ## Input ```javascript +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function ComponentWithHookInsideLoop() { @@ -16,7 +18,7 @@ function ComponentWithHookInsideLoop() { ## Error ``` -[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) +[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) ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-bfa72d1b8135.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-79128a755612.js similarity index 89% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-bfa72d1b8135.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-79128a755612.js index 25177f5938..22d89c85fd 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-bfa72d1b8135.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-79128a755612.js @@ -1,3 +1,5 @@ +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function ComponentWithHookInsideLoop() { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-ec94ef9d80df.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-9718e30b856c.expect.md similarity index 93% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-ec94ef9d80df.expect.md rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-9718e30b856c.expect.md index 6f3a91949e..721fc2ca13 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-ec94ef9d80df.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-9718e30b856c.expect.md @@ -2,6 +2,8 @@ ## Input ```javascript +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function useHook() { @@ -20,7 +22,7 @@ function useHook() { ## Error ``` -[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) +[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) ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-92708a08b920.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-9718e30b856c.js similarity index 91% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-92708a08b920.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-9718e30b856c.js index c2fc30ec88..431627e606 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-92708a08b920.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-9718e30b856c.js @@ -1,11 +1,13 @@ +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function useHook() { + if (a) return; if (b) { console.log("true"); } else { console.log("false"); } - if (a) return; useState(); } diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-99ca80f8b0b6.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-9bf17c174134.expect.md similarity index 94% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-99ca80f8b0b6.expect.md rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-9bf17c174134.expect.md index 528da10835..1fff343712 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-99ca80f8b0b6.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-9bf17c174134.expect.md @@ -2,6 +2,8 @@ ## Input ```javascript +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function useHook() { @@ -15,9 +17,9 @@ function useHook() { ## Error ``` -[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) +[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) -[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) +[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) ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-99ca80f8b0b6.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-9bf17c174134.js similarity index 87% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-99ca80f8b0b6.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-9bf17c174134.js index 09245c8884..8bb52ccf0e 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-99ca80f8b0b6.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-9bf17c174134.js @@ -1,3 +1,5 @@ +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function useHook() { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-62bded832974.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-b4dcda3d60ed.expect.md similarity index 93% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-62bded832974.expect.md rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-b4dcda3d60ed.expect.md index a79a682a9f..e24a9228e4 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-62bded832974.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-b4dcda3d60ed.expect.md @@ -2,6 +2,8 @@ ## Input ```javascript +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function ComponentWithTernaryHook() { @@ -14,7 +16,7 @@ function ComponentWithTernaryHook() { ## Error ``` -[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) +[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) ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-62bded832974.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-b4dcda3d60ed.js similarity index 88% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-62bded832974.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-b4dcda3d60ed.js index c5754bd624..a6999ffe04 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-62bded832974.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-b4dcda3d60ed.js @@ -1,3 +1,5 @@ +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function ComponentWithTernaryHook() { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-fc7007852fe0.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-c906cace44e9.expect.md similarity index 93% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-fc7007852fe0.expect.md rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-c906cace44e9.expect.md index c466eb9725..e6ec028338 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-fc7007852fe0.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-c906cace44e9.expect.md @@ -2,6 +2,8 @@ ## Input ```javascript +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function useHook() { @@ -15,7 +17,7 @@ function useHook() { ## Error ``` -[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) +[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) ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-fc7007852fe0.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-c906cace44e9.js similarity index 87% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-fc7007852fe0.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-c906cace44e9.js index 7e77918794..6ec7d91cb6 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-fc7007852fe0.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-c906cace44e9.js @@ -1,3 +1,5 @@ +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function useHook() { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-baf61a179e4c.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-d740d54e9c21.expect.md similarity index 93% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-baf61a179e4c.expect.md rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-d740d54e9c21.expect.md index 9b14df8262..1363a11f7b 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-baf61a179e4c.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-d740d54e9c21.expect.md @@ -2,6 +2,8 @@ ## Input ```javascript +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function normalFunctionWithConditionalHook() { @@ -16,7 +18,7 @@ function normalFunctionWithConditionalHook() { ## Error ``` -[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) +[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) ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-baf61a179e4c.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-d740d54e9c21.js similarity index 90% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-baf61a179e4c.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-d740d54e9c21.js index 89bfce1eda..5654baaebb 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-baf61a179e4c.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-d740d54e9c21.js @@ -1,3 +1,5 @@ +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function normalFunctionWithConditionalHook() { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-2e9963324591.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-d85c144bdf40.expect.md similarity index 95% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-2e9963324591.expect.md rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-d85c144bdf40.expect.md index 33298ad7c6..798b5e4876 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-2e9963324591.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-d85c144bdf40.expect.md @@ -2,6 +2,8 @@ ## Input ```javascript +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function useHookInLoops() { @@ -18,9 +20,9 @@ function useHookInLoops() { ## Error ``` -[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) - [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) + +[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) ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-2e9963324591.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-d85c144bdf40.js similarity index 90% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-2e9963324591.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-d85c144bdf40.js index c00a73a62d..34df06aa36 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-2e9963324591.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-d85c144bdf40.js @@ -1,3 +1,5 @@ +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function useHookInLoops() { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-e70a6f5d6d4b.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-ea7c2fb545a9.expect.md similarity index 93% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-e70a6f5d6d4b.expect.md rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-ea7c2fb545a9.expect.md index 0703fedacd..138f8d039d 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-e70a6f5d6d4b.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-ea7c2fb545a9.expect.md @@ -2,6 +2,8 @@ ## Input ```javascript +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function useHookWithConditionalHook() { @@ -16,7 +18,7 @@ function useHookWithConditionalHook() { ## Error ``` -[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) +[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) ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-e70a6f5d6d4b.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-ea7c2fb545a9.js similarity index 89% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-e70a6f5d6d4b.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-ea7c2fb545a9.js index 8b82456138..bad7d009a0 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-e70a6f5d6d4b.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-ea7c2fb545a9.js @@ -1,3 +1,5 @@ +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function useHookWithConditionalHook() { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-92708a08b920.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-f3d6c5e9c83d.expect.md similarity index 93% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-92708a08b920.expect.md rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-f3d6c5e9c83d.expect.md index 95b2471979..74fd75c2d4 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-92708a08b920.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-f3d6c5e9c83d.expect.md @@ -2,6 +2,8 @@ ## Input ```javascript +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function useHook() { @@ -20,7 +22,7 @@ function useHook() { ## Error ``` -[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) +[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) ``` \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-ec94ef9d80df.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-f3d6c5e9c83d.js similarity index 91% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-ec94ef9d80df.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-f3d6c5e9c83d.js index fb5423937b..5ffa1efe1c 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.rules-of-hooks-ec94ef9d80df.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-f3d6c5e9c83d.js @@ -1,11 +1,13 @@ +// Expected to fail + // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. function useHook() { - if (a) return; if (b) { console.log("true"); } else { console.log("false"); } + if (a) return; useState(); } diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-f69800950ff0.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-f69800950ff0.expect.md new file mode 100644 index 0000000000..f2f5a7411b --- /dev/null +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-f69800950ff0.expect.md @@ -0,0 +1,28 @@ + +## Input + +```javascript +// Expected to fail + +// Invalid because it's dangerous and might not warn otherwise. +// This *must* be invalid. +function useHook({ bar }) { + let foo1 = bar && useState(); + let foo2 = bar || useState(); + let foo3 = bar ?? useState(); +} + +``` + + +## Error + +``` +[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) + +[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) + +[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) +``` + + \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-dba5889e4ba6.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-f69800950ff0.js similarity index 87% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-dba5889e4ba6.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-f69800950ff0.js index d508312278..eda703a224 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-dba5889e4ba6.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/error.invalid-rules-of-hooks-f69800950ff0.js @@ -1,5 +1,4 @@ -// @skip -// Unsupported input +// Expected to fail // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/rules-of-hooks-c5d1f3143c4c.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/rules-of-hooks-c5d1f3143c4c.expect.md new file mode 100644 index 0000000000..e24bc84644 --- /dev/null +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/rules-of-hooks-c5d1f3143c4c.expect.md @@ -0,0 +1,23 @@ + +## Input + +```javascript +// Regression test for incorrectly flagged valid code. +function RegressionTest() { + const foo = cond ? a : b; + useState(); +} + +``` + +## Code + +```javascript +// Regression test for incorrectly flagged valid code. +function RegressionTest() { + cond ? a : b; + useState(); +} + +``` + \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-f7b5986699ca.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/rules-of-hooks-c5d1f3143c4c.js similarity index 80% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-f7b5986699ca.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/rules-of-hooks-c5d1f3143c4c.js index f7b4e3b922..8ac4448fda 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-f7b5986699ca.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/rules-of-hooks-c5d1f3143c4c.js @@ -1,6 +1,3 @@ -// @skip -// Unsupported input - // Regression test for incorrectly flagged valid code. function RegressionTest() { const foo = cond ? a : b; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-279ac76f53af.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-279ac76f53af.js similarity index 100% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-279ac76f53af.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-279ac76f53af.js diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-27c18dc8dad2.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-27c18dc8dad2.js similarity index 100% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-27c18dc8dad2.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-27c18dc8dad2.js diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-28a78701970c.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-28a78701970c.js similarity index 100% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-28a78701970c.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-28a78701970c.js diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-3d692676194b.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-3d692676194b.js similarity index 100% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-3d692676194b.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-3d692676194b.js diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-6949b255e7eb.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-6949b255e7eb.js similarity index 100% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-6949b255e7eb.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-6949b255e7eb.js diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-69521d94fa03.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-69521d94fa03.js similarity index 100% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-69521d94fa03.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-69521d94fa03.js diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-8503ca76d6f8.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-8503ca76d6f8.js similarity index 100% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-8503ca76d6f8.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-8503ca76d6f8.js diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-93dc5d5e538a.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-93dc5d5e538a.js similarity index 100% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-93dc5d5e538a.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-93dc5d5e538a.js diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-d0935abedc42.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-d0935abedc42.js similarity index 100% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-d0935abedc42.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-d0935abedc42.js diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-e0a5db3ae21e.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-e0a5db3ae21e.js similarity index 100% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-e0a5db3ae21e.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-e0a5db3ae21e.js diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-e29c874aa913.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-e29c874aa913.js similarity index 100% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-e29c874aa913.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-e29c874aa913.js diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-e9f9bac89f8f.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-e9f9bac89f8f.js similarity index 100% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-e9f9bac89f8f.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-e9f9bac89f8f.js diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-fadd52c1e460.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-fadd52c1e460.js similarity index 100% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.rules-of-hooks-fadd52c1e460.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.bail.rules-of-hooks-fadd52c1e460.js diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-92503f581023.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-0a1dbff27ba0.js similarity index 87% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-92503f581023.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-0a1dbff27ba0.js index cac67930c7..2426fc5a96 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-92503f581023.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-0a1dbff27ba0.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-b4af90990150.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-0de1224ce64b.js similarity index 89% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-b4af90990150.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-0de1224ce64b.js index b841b31af9..6155cf7451 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-b4af90990150.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-0de1224ce64b.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed // Invalid because it's a common misunderstanding. // We *could* make it valid but the runtime error could be confusing. diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-880ce4a7e686.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-191029ac48c8.js similarity index 91% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-880ce4a7e686.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-191029ac48c8.js index 6d5a4b3d5f..0f00a827ea 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-880ce4a7e686.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-191029ac48c8.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed // Invalid because it's dangerous. // Normally, this would crash, but not if you use inline requires. diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-f486864c4bec.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-206e2811c87c.js similarity index 87% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-f486864c4bec.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-206e2811c87c.js index ed58c3837c..872f5805ba 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-f486864c4bec.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-206e2811c87c.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed // This is a false positive (it's valid) that unfortunately // we cannot avoid. Prefer to rename it to not start with "use" diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-c277f25e7c03.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-28a7111f56a7.js similarity index 93% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-c277f25e7c03.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-28a7111f56a7.js index 5f759e3aaa..bcfa1652e9 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-c277f25e7c03.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-28a7111f56a7.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed // Technically this is a false positive. // We *could* make it valid (and it used to be). diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-7451860cd46f.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-2c51251df67a.js similarity index 62% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-7451860cd46f.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-2c51251df67a.js index ffb6a73806..fe81885397 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-7451860cd46f.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-2c51251df67a.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed (class { useHook() { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-251e67613de1.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-368024110a58.js similarity index 88% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-251e67613de1.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-368024110a58.js index 95ae96505f..f2506d1d6e 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-251e67613de1.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-368024110a58.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-310a4e022130.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-449a37146a83.js similarity index 88% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-310a4e022130.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-449a37146a83.js index 607fdcdcd4..e7989ae1a7 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-310a4e022130.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-449a37146a83.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed // Invalid because it's a common misunderstanding. // We *could* make it valid but the runtime error could be confusing. diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-429b3b1a8ee4.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-5a7ac9a6e8fa.js similarity index 84% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-429b3b1a8ee4.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-5a7ac9a6e8fa.js index 71c7a4c203..c14619352d 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-429b3b1a8ee4.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-5a7ac9a6e8fa.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed // These are neither functions nor hooks. function _normalFunctionWithHook() { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-1a1e29f21a79.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-76a74b4666e9.js similarity index 86% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-1a1e29f21a79.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-76a74b4666e9.js index a756e94334..4a46242aa4 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-1a1e29f21a79.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-76a74b4666e9.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed // Invalid because it's a common misunderstanding. // We *could* make it valid but the runtime error could be confusing. diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-de96bb13ad47.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-8303403b8e4c.js similarity index 75% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-de96bb13ad47.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-8303403b8e4c.js index 832df17120..b373065d7c 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-de96bb13ad47.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-8303403b8e4c.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed class ClassComponentWithHook extends React.Component { render() { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-cdcb36730551.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-8566f9a360e2.js similarity index 87% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-cdcb36730551.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-8566f9a360e2.js index 26747b6a81..2c14f8d2e4 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-cdcb36730551.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-8566f9a360e2.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-42576e5c5613.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-99b5c750d1d1.js similarity index 80% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-42576e5c5613.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-99b5c750d1d1.js index ae8b5dce97..da52cf2ac5 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-42576e5c5613.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-99b5c750d1d1.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed class ClassComponentWithFeatureFlag extends React.Component { render() { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-be9bff592ca0.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-9c79feec4b9b.js similarity index 63% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-be9bff592ca0.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-9c79feec4b9b.js index 4b5b4645ea..6f974e4919 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-be9bff592ca0.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-9c79feec4b9b.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed (class { h = () => { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-4d1a9ed4d44a.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-a0058f0b446d.js similarity index 85% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-4d1a9ed4d44a.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-a0058f0b446d.js index 5a1d6c4249..5fb838f90b 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-4d1a9ed4d44a.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-a0058f0b446d.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-0a42415d4990.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-a63fd4f9dcc0.js similarity index 85% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-0a42415d4990.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-a63fd4f9dcc0.js index 2f54ab19f4..d293f5d553 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-0a42415d4990.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-a63fd4f9dcc0.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed // This is invalid because "use"-prefixed functions used in named // functions are assumed to be hooks. diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-c0069d062d50.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-acb56658fe7e.js similarity index 68% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-c0069d062d50.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-acb56658fe7e.js index f7a35bc33f..6f0bf274ca 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-c0069d062d50.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-acb56658fe7e.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed class C { m() { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-3d8726664cf7.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-c59788ef5676.js similarity index 91% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-3d8726664cf7.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-c59788ef5676.js index c558687960..20433257b9 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-3d8726664cf7.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-c59788ef5676.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed // Currently invalid because it violates the convention and removes the "taint" // from a hook. We *could* make it valid to avoid some false positives but let's diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-60e23f3caf5b.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-d842d36db450.js similarity index 87% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-60e23f3caf5b.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-d842d36db450.js index 4e668a3288..ab731ed953 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-60e23f3caf5b.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-d842d36db450.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-52cd6055b4fb.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-d952b82c2597.js similarity index 87% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-52cd6055b4fb.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-d952b82c2597.js index bf85f21da1..dfa7f92bcc 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-52cd6055b4fb.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-d952b82c2597.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed // Invalid because it's a common misunderstanding. // We *could* make it valid but the runtime error could be confusing. diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-fbe12b5ccfce.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-ddeca9708b63.js similarity index 60% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-fbe12b5ccfce.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-ddeca9708b63.js index d20cef5ff7..bbf89905a8 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-fbe12b5ccfce.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-ddeca9708b63.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed (class { i() { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-112dd48477e6.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-e675f0a672d8.js similarity index 85% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-112dd48477e6.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-e675f0a672d8.js index 103fec8710..4999490720 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-112dd48477e6.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-e675f0a672d8.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed // Invalid because it's dangerous and might not warn otherwise. // This *must* be invalid. diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-e803203d651b.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-e69ffce323c3.js similarity index 65% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-e803203d651b.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-e69ffce323c3.js index 95cccc4bdd..48d03d62bc 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-e803203d651b.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-e69ffce323c3.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed (class { useHook = () => { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-7bcc5c5c0416.js b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-f6f37b63b2d4.js similarity index 73% rename from compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-7bcc5c5c0416.js rename to compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-f6f37b63b2d4.js index dd319f315a..3fdc56a900 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.rules-of-hooks-7bcc5c5c0416.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/rules-of-hooks/todo.error.invalid-rules-of-hooks-f6f37b63b2d4.js @@ -1,5 +1,5 @@ // @skip -// Passed but should have errored +// Passed but should have failed Hook.useState(); Hook._useState();