noDoneCallback
此内容尚不支持你的语言。
Diagnostic Category: lint/style/noDoneCallback
Since: v1.6.1
Sources:
- Same as:
jest/no-done-callback
Disallow using a callback in asynchronous tests and hooks.
This rule checks the function parameter of hooks and tests for use of the done
argument, suggesting you return a promise instead.
Examples
Section titled ExamplesInvalid
Section titled Invalidcode-block.js:1:13 lint/style/noDoneCallback ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Disallow using a callback in asynchronous tests and hooks.
> 1 │ beforeEach((done) => {
│ ^^^^
2 │ // …
3 │ });
ℹ Return a Promise instead of relying on callback parameter.
code-block.js:1:20 lint/style/noDoneCallback ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Disallow using a callback in asynchronous tests and hooks.
> 1 │ test(‘tets-name’, (done) => {
│ ^^^^
2 │ // …
3 │ });
ℹ Return a Promise instead of relying on callback parameter.