# no-duplicate-test-hook

Disallow duplicate lifecycle hooks in one test suite

Repeated hooks of the same kind make suite setup and cleanup order depend on registration order.
Instead, you SHOULD combine each suite's repeated hook bodies into one hook.

- Category: suspicious
- Level: warning
- Fix: none
- Scope: module

## Reported

```ds title="main.ds"
import { beforeEach } from "destack:test";

beforeEach(() => {
    // ...
});
beforeEach(() => {
    // ...
});
```

## Accepted

```ds title="main.ds"
import { beforeEach } from "destack:test";

beforeEach(() => {
    // ...
    // ...
});
```

## Prior art

- [eslint-plugin-jest · no-duplicate-hooks](https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-duplicate-hooks.md)
- [eslint-plugin-playwright · no-duplicate-hooks](https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/no-duplicate-hooks.md)

[language/linter/src/rules/suspicious/no_duplicate_test_hook.rs:7](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/suspicious/no_duplicate_test_hook.rs#L7)
