vitest/no-test-prefixes 风格
它的作用
要求使用 .only 和 .skip,而不是 f 和 x。
为什么这不好?
Jest 允许你选择如何定义聚焦和跳过的测试, 并为每种方式提供多种组合:
- only & skip: it.only, test.only, describe.only, it.skip, test.skip, describe.skip.
- 'f' & 'x': fit, fdescribe, xit, xtest, xdescribe.
此规则强制使用 only & skip 列表中的用法。
示例
以下是此规则的错误代码示例:
javascript
fit("foo"); // 无效
fdescribe("foo"); // 无效
xit("foo"); // 无效
xtest("foo"); // 无效
xdescribe("foo"); // 无效如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"plugins": ["vitest"],
"rules": {
"vitest/no-test-prefixes": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["vitest"],
rules: {
"vitest/no-test-prefixes": "error",
},
});bash
oxlint --deny vitest/no-test-prefixes --vitest-plugin版本
此规则在 v0.0.7 中添加。
