Skip to content
← Back to rules

jest/padding-around-test-blocks スタイル

🛠️ An auto-fix is available for this rule.

何を行うか

このルールは、1つ以上の test/it 文の前後に対して空行を強制します。

なぜ問題なのか

コードのフォーマットが一貫していないと、コードの読みやすさや理解のしやすさが低下します。このルールにより、テストブロックが他のコードから視覚的に分離されることを確保し、テストファイルを確認する際にテストブロックをより簡単に識別できるようにします。

このルールに違反する誤りの例:

js
const thing = 123;
test("foo", () => {});
test("bar", () => {});
js
const thing = 123;
it("foo", () => {});
it("bar", () => {});

このルールに準拠する正しい例:

js
const thing = 123;

test("foo", () => {});

test("bar", () => {});
js
const thing = 123;

it("foo", () => {});

it("bar", () => {});

使い方

設定ファイルまたは CLI でこのルールを有効化するには、以下のように使用できます:

json
{
  "plugins": ["jest"],
  "rules": {
    "jest/padding-around-test-blocks": "error"
  }
}
bash
oxlint --deny jest/padding-around-test-blocks --jest-plugin

参照