Skip to content
← Back to rules

vitest/prefer-todo Style

🛠️ An auto-fix is available for this rule.

它的作用

当测试用例为空时,最好将它们标记为 test.todo,这样它们会在摘要输出中被高亮显示。

为什么这不好?

如果在不使用 test.todo 的情况下使用空测试用例,此规则会触发警告。

示例

此规则的错误代码示例:

javascript
test("i need to write this test"); // 无效
test("i need to write this test", () => {}); // 无效
test.skip("i need to write this test", () => {}); // 无效

此规则的正确代码示例:

javascript
test.todo("i need to write this test");

如何使用

To enable this rule using the config file or in the CLI, you can use:

json
{
  "plugins": ["vitest"],
  "rules": {
    "vitest/prefer-todo": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  plugins: ["vitest"],
  rules: {
    "vitest/prefer-todo": "error",
  },
});
bash
oxlint --deny vitest/prefer-todo --vitest-plugin

版本

此规则是在 v0.0.16 中添加的。

参考资料