vitest/no-done-callback
@vitest/eslint-plugin
Suggestion
eslint.config.js
import vitest from "@vitest/eslint-plugin";
export default [
{
plugins: { vitest },
rules: {
"vitest/no-done-callback": "error",
},
},
];This rule is deprecated. Check its documentation for a replacement before enabling it.
test('foo', (done) => {
setTimeout(done, 1000)
})
test('foo', (done) => {
setTimeout(() => done(), 1000)
})
test('foo', (done) => {
setTimeout(() => {
done()
}, 1000)
})
test('foo', (done) => {
setTimeout(() => {
done()
}, 1000)
})test('foo', async () => {
await new Promise((resolve) => setTimeout(resolve, 1000))
})
test('foo', async () => {
await new Promise((resolve) => setTimeout(() => resolve(), 1000))
})
test('foo', async () => {
await new Promise((resolve) =>
setTimeout(() => {
resolve()
}, 1000),
)
})
test('foo', async () => {
await new Promise((resolve) =>
setTimeout(() => {
resolve()
}, 1000),
)
})
test.concurrent('foo', ({ expect }) => {
expect(1).toMatchSnapshot()
})
test.concurrent('foo', (context) => {
context.expect(1).toBe(1)
})
// …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-done-callback
@vitest/eslint-plugin
import vitest from "@vitest/eslint-plugin";
export default [
{
plugins: { vitest },
rules: {
"vitest/no-done-callback": "error",
},
},
];Oxlint does not have this rule.
style/noDoneCallback
style · since 1.6.1
{
"linter": {
"rules": {
"style": {
"noDoneCallback": "error"
}
}
}
}Disallow using a callback in asynchronous tests and hooks
Require toThrow() to be called with an error message
Enforce using type parameters with vitest mock functions