Skip to content
← Back to rules

vitest/no-commented-out-tests Suspicious

它的作用

此规则会对被注释掉的测试发出警告。它与 no-disabled-tests 规则类似。

为什么这不好?

你可能会忘记取消注释某些测试。此规则会对被注释掉的测试发出警告。

如果测试不稳定,通常最好跳过它;如果不再需要,则删除它。

示例

以下是此规则错误代码的示例:

javascript
// describe('foo', () => {});
// it('foo', () => {});
// test('foo', () => {});

// describe.skip('foo', () => {});
// it.skip('foo', () => {});
// test.skip('foo', () => {});

如何使用

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

json
{
  "plugins": ["vitest"],
  "rules": {
    "vitest/no-commented-out-tests": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  plugins: ["vitest"],
  rules: {
    "vitest/no-commented-out-tests": "error",
  },
});
bash
oxlint --deny vitest/no-commented-out-tests --vitest-plugin

版本

此规则在 v0.0.8 中添加。

参考资料