jest/padding-around-test-blocks Style
它的作用
此规则强制在 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", () => {});如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"plugins": ["jest"],
"rules": {
"jest/padding-around-test-blocks": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["jest"],
rules: {
"jest/padding-around-test-blocks": "error",
},
});bash
oxlint --deny jest/padding-around-test-blocks --jest-plugin版本
此规则在 v1.13.0 中添加。
