Skip to content
← Back to rules

vitest/padding-around-after-all-blocks Style

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

功能说明

此规则要求在一个或多个 afterAll 语句之前和之后各保留一行空白。

为什么这不好?

代码格式不一致会使代码更难阅读和理解。此规则有助于确保 afterAll 块在视觉上与代码的其他部分分隔开来,使其在浏览测试文件时更容易识别。

示例

以下是此规则的错误代码示例:

js
const thing = 123;
afterAll(() => {});

以下是此规则的正确代码示例:

js
const thing = 123;

afterAll(() => {});

如何使用

To enable this rule using the config file or in the CLI, you can use:

json
{
  "plugins": ["vitest"],
  "rules": {
    "vitest/padding-around-after-all-blocks": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  plugins: ["vitest"],
  rules: {
    "vitest/padding-around-after-all-blocks": "error",
  },
});
bash
oxlint --deny vitest/padding-around-after-all-blocks --vitest-plugin

版本

此规则在 vnext 中添加。

参考资料