Skip to main content

space-before-blocks

danger
This rule will soon be moved to eslint-stylistic. See What About Formatting? for more information.

Enforce consistent spacing before blocks.

🔧

此规则报告的一些问题可通过 --fix ESLint 命令行选项自动修复


此规则扩展了基本 eslint/space-before-blocks 规则。 它增加了对接口和枚举的支持。

英:This rule extends the base eslint/space-before-blocks rule. It adds support for interfaces and enums.

enum Breakpoint{
Large, Medium;
}

interface State{
currentBreakpoint: Breakpoint;
}
Open in Playground

选项

如果传递了更具体的选项对象,这些块将遵循 classes 配置选项。

英:In case a more specific options object is passed these blocks will follow classes configuration option.

如何使用

.eslintrc.cjs
module.exports = {
"rules": {
// Note: you must disable the base rule as it can report incorrect errors
"space-before-blocks": "off",
"@typescript-eslint/space-before-blocks": "error"
}
};
在线运行试试这个规则 ↗

选项

参见 eslint/space-before-blocks 选项

资源

摘自 ❤️ ESLint 内核