Skip to content
← Back to rules

jest/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": ["jest"],
  "rules": {
    "jest/no-commented-out-tests": "error"
  }
}
ts
import { defineConfig } from "oxlint";

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

版本

此规则在 v0.0.8 中添加。

参考资料