Skip to content
← Back to rules

jest/no-test-prefixes スタイル

An auto-fix is available for this rule.

何をするか

.only および .skip の使用を要求し、f および x は使用しないようにする。

なぜこれは良くないのか

Jest では、焦点テストやスキップテストの定義方法を複数の組み合わせで選択できます:

  • only & skip: it.onlytest.onlydescribe.onlyit.skiptest.skipdescribe.skip
  • 'f' & 'x': fitfdescribexitxtestxdescribe

このルールでは、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

参照