chore(lint): refactor magic-sleep tests to async waits + ratchet rules to error (#735)
Replace raw setTimeout/Atomics.wait synchronization sleeps in 4 test files with a shared async delay()/waitFor() poll-for-condition helper in tests/helpers.cjs, then flip local/no-magic-sleep-in-tests and no-restricted-syntax from warn to error so the debt can't regrow. - tests/helpers.cjs: add delay(ms) + waitFor(predicate, opts), exported - bug-1974: setTimeout backoff -> await delay() - config.test: drop Atomics.wait sleep(); async retry via await delay() - graphify: waitForBuildStatus/cleanupHookRepo async via await delay() - locking-bugs: 3 Atomics.wait poll loops -> await waitFor() - eslint.config.mjs: ratchet both rules warn -> error Refs #733 Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -196,14 +196,14 @@ export default tseslint.config(
|
||||
rules: {
|
||||
...js.configs.recommended.rules,
|
||||
'no-only-tests/no-only-tests': 'error',
|
||||
// Timing anti-patterns — warn for now; flip to error after cleanup
|
||||
'local/no-magic-sleep-in-tests': 'warn',
|
||||
// Timing anti-patterns — ratcheted to error after cleanup (all violations fixed)
|
||||
'local/no-magic-sleep-in-tests': 'error',
|
||||
'local/no-elapsed-assertion': 'warn',
|
||||
// Ban raw fs.rmSync in tests — use helpers.cleanup() for Windows-EBUSY retry budget
|
||||
'local/no-raw-rmsync-in-tests': 'error',
|
||||
// Ban raw setTimeout sync + elapsed/duration-style assertions via no-restricted-syntax
|
||||
'no-restricted-syntax': [
|
||||
'warn',
|
||||
'error',
|
||||
{
|
||||
selector: 'AwaitExpression > NewExpression[callee.name="Promise"] ArrowFunctionExpression CallExpression[callee.name="setTimeout"]',
|
||||
message: 'Raw setTimeout used for synchronization in tests. Use proper async patterns instead.',
|
||||
|
||||
Reference in New Issue
Block a user