| β¦ | β¦ | @@ -0,0 +1,264 @@ | |
| 178 | + | }, | |
| 179 | + | create(context) { | |
| 180 | + | if (!TEST_FILE_PATTERN.test(context.filename)) return {}; | |
| 181 | + | const drivesTestClock = TEST_CLOCK_DRIVER_PATTERN.test(context.sourceCode.text); | |
π’ Low rules/no-real-time-wait-in-tests.ts:181
A comment or string containing TestClock.adjust or TestClock.setTime sets drivesTestClock to true, suppressing the undriven-sleep diagnostic even when the test never drives the clock. Derive this flag from actual call expressions so documentation and fixture text cannot disable the check.
No longer relevant as of e90b635be35e5ff8b2814ec4ca8304f44bb44b93
Fixed: drivesTestClock now comes from actual TestClock.adjust/TestClock.setTime call expressions, with the dependent reports deferred to Program:exit, and a test covers a comment-only mention.
I still see drivesTestClock derived from context.sourceCode.text via the regex at line 181, so comment/string mentions can still suppress the diagnostic.
Same: on 978d35a drivesTestClock is set only by TestClock.adjust/setTime CallExpressions found in the AST; the source-text regex is gone. Rule test "reports TestClock sleeps when TestClock.adjust appears only in a comment" covers it.
f45927fOpen thread| β¦ | β¦ | @@ -0,0 +1,264 @@ | |
| 229 | + | const tester = enclosingTester(node); | |
| 230 | + | if (Option.isNone(tester)) return; | |
| 231 | + | reportFor( | |
| 232 | + | tester.value === "effect" | |
π High rules/no-real-time-wait-in-tests.ts:230
A timer hidden in a shared helper produces no diagnostic even when a test invokes that helper, so extracting setTimeout into sleep or waitUntil bypasses this rule. enclosingTester only finds lexical test callbacks, and this early return drops the timer call when none is found; report such timer waits as real-clock waits.
No longer relevant as of e90b635be35e5ff8b2814ec4ca8304f44bb44b93
Fixed: Promise-wrapped and timers/promises timers are now reported at module level in test files too, and the existing setImmediate macrotask helpers (plus one subprocess timeout safety net) carry a reasoned disable comment.
I still see the Option.isNone(tester) early return at line 230, so module-level/shared timer calls remain unreported.
That re-review ran on 2551143, an intermediate head from the #22557 rebase. On the current head 978d35a a timer inside a new Promise executor or a timers/promises call at module level is reported (rule test "reports timers hidden in module-level helpers"); the Option.isNone(tester) branch now only defers an Effect.sleep helper until the file is known not to drive the TestClock.