vitest/no-duplicate-hooks
@vitest/eslint-plugin
No autofix
eslint.config.js
import vitest from "@vitest/eslint-plugin";
export default [
{
plugins: { vitest },
rules: {
"vitest/no-duplicate-hooks": "error",
},
},
];test('foo', () => {
beforeEach(() => {})
beforeEach(() => {}) // duplicate beforeEach
})test('foo', () => {
beforeEach(() => {})
})Examples from the ESLint documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
vitest/no-duplicate-hooks
@vitest/eslint-plugin
import vitest from "@vitest/eslint-plugin";
export default [
{
plugins: { vitest },
rules: {
"vitest/no-duplicate-hooks": "error",
},
},
];vitest/no-duplicate-hooks
vitest plugin · style
{
"plugins": [
"vitest"
],
"rules": {
"vitest/no-duplicate-hooks": "error"
}
}suspicious/noDuplicateTestHooks
suspicious · since 1.6.0
{
"linter": {
"rules": {
"suspicious": {
"noDuplicateTestHooks": "error"
}
}
}
}Disallow duplicate setup and teardown hooks
Require describe block to be less than set max value or default value
Disallow return statements in tests
Enforce using toBeCalledTimes(1) or toHaveBeenCalledTimes(1)
Enforce using toBeCalledWith() or toHaveBeenCalledWith()