Files
Alex Rudenko ea462180be test: run sinon.restore() once in tests/setup.ts (#3240)
`tests/setup.ts` now registers a root-level `afterEach` hook that calls
`sinon.restore()`. Node's test runner inherits `afterEach` hooks in
every nested test, so one hook restores all Sinon fakes after each test
in every file.

Changes:
- Remove `afterEach(() => sinon.restore())` and the `sinon.restore()`
statement inside multi-statement hooks from 46 test files. Remove
`sinon` and `afterEach` imports that became unused.
- Add the ESLint rule `@local/no-sinon-restore-in-hooks`
(`scripts/eslint_rules/no-sinon-restore-in-hooks-rule.js`), enabled for
`**/*.test.ts`. It reports `sinon.restore()` inside `before`,
`beforeEach`, `after`, and `afterEach`. The autofix removes the
statement, or the whole hook when `sinon.restore()` is its only
statement. `sinon.restore()` inside a test body is still allowed (two
tests restore mid-test on purpose).
- Update the "Clean up stubs" rule in `AGENTS.md`.

Verification: `npm run format` is clean and `npm run test` passes
locally.
2026-10-19 10:59:27 +00:00
..
2025-09-11 12:46:05 +02:00