jest/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"); // 不正このルールは eslint-plugin-vitest と互換性があります。これを使用するには、.oxlintrc.json に以下の設定を追加します:
json
{
"rules": {
"vitest/no-test-prefixes": "error"
}
}使い方
設定ファイルまたは CLI でこのルールを 有効化 するには、次のようにします:
json
{
"plugins": ["jest"],
"rules": {
"jest/no-test-prefixes": "error"
}
}bash
oxlint --deny jest/no-test-prefixes --jest-plugin