Skip to content
← Back to rules

jest/no-commented-out-tests 可疑

An auto-fix is available for this rule.

它的作用

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

为什么这是个问题?

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

通常情况下,如果测试不稳定,应跳过该测试;如果测试已不再需要,则应将其删除。

示例

此规则的 错误 代码示例:

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

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

此规则与 eslint-plugin-vitest 兼容。要使用它,请在您的 .oxlintrc.json 中添加以下配置:

json
{
  "rules": {
    "vitest/no-commented-out-tests": "error"
  }
}

如何使用

要通过配置文件或 CLI 启用 此规则,可以使用:

json
{
  "plugins": ["jest"],
  "rules": {
    "jest/no-commented-out-tests": "error"
  }
}
bash
oxlint --deny jest/no-commented-out-tests --jest-plugin

参考资料