jest/padding-around-test-blocks 风格
它的作用
此规则强制在 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