Summary
no-done-callback and no-test-return-statement currently miss test callbacks declared with Vitest's options object:
test('example', { timeout: 1000 }, (done) => {
done()
})
test('example', { retry: 2 }, () => {
return Promise.resolve()
})
These forms are currently not reported.
Vitest supports the test(name, options, fn) signature, so these rules should treat the third argument as the test callback when the second argument is an options object.
Reproduction
Add the following cases to the invalid section of each rule test file.
tests/no-done-callback.test.ts
{
code: "test('uses done', { timeout: 1000 }, (done) => { done() })",
errors: [{ messageId: 'noDoneCallback' }],
}
tests/no-test-return-statement.test.ts
{
code: "test('returns', { retry: 2 }, () => { return Promise.resolve() })",
errors: [{ messageId: 'noTestReturnStatement' }],
}
Then run:
pnpm test tests/no-done-callback.test.ts tests/no-test-return-statement.test.ts
Currently, these cases fail because the rules only inspect the second argument as the test callback and do not recognize the callback in test(name, options, fn).
Summary
no-done-callbackandno-test-return-statementcurrently miss test callbacks declared with Vitest's options object:These forms are currently not reported.
Vitest supports the
test(name, options, fn)signature, so these rules should treat the third argument as the test callback when the second argument is an options object.Reproduction
Add the following cases to the invalid section of each rule test file.
tests/no-done-callback.test.tstests/no-test-return-statement.test.tsThen run:
Currently, these cases fail because the rules only inspect the second argument as the test callback and do not recognize the callback in
test(name, options, fn).