vitest/no-test-return-statement Style
它的作用
禁止在测试中显式返回。
为什么这不好?
Jest 中的测试应该是 void,不应返回值。 如果你返回的是 Promise,那么你应该将测试更新为使用 async/await。
示例
以下是此规则的错误代码示例:
javascript
test("one", () => {
return expect(1).toBe(1);
});以下是此规则的正确代码示例:
javascript
test("one", () => {
expect(1).toBe(1);
});如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"plugins": ["vitest"],
"rules": {
"vitest/no-test-return-statement": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["vitest"],
rules: {
"vitest/no-test-return-statement": "error",
},
});bash
oxlint --deny vitest/no-test-return-statement --vitest-plugin版本
此规则在 v0.2.0 中添加。
