vitest/no-identical-title Style
它的作用
这条规则会检查每个测试和测试套件的标题。 当同一测试套件层级下的两个测试套件或两个测试用例具有相同标题时,它会报告问题。
为什么这不好?
两个不同的测试或测试套件使用相同的标题可能会造成混淆。 例如,当某个测试与同一测试套件中的另一个测试具有相同标题并失败时,就更难知道到底是哪个失败了,因此也更难修复。
示例
以下是此规则的错误代码示例:
javascript
describe("baz", () => {
//...
});
describe("baz", () => {
// 与前一个测试套件具有相同的标题
// ...
});如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"plugins": ["vitest"],
"rules": {
"vitest/no-identical-title": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["vitest"],
rules: {
"vitest/no-identical-title": "error",
},
});bash
oxlint --deny vitest/no-identical-title --vitest-plugin版本
此规则在 v0.0.14 中加入。
