Skip to main content

padding-line-between-statements

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

Require or disallow padding lines between statements.

🔧

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


此规则扩展了基本 eslint/padding-line-between-statements 规则。 它增加了对 TypeScript 构造(例如 interfacetype)的支持。

英:This rule extends the base eslint/padding-line-between-statements rule. It adds support for TypeScript constructs such as interface and type.

选项

除了 ESLint 提供的选项外,还可以使用 interfacetype 作为语句类型。

英:In addition to options provided by ESLint, interface and type can be used as statement types.

例如,要在接口和类型定义之前添加空行:

英:For example, to add blank lines before interfaces and type definitions:

{
// Example - Add blank lines before interface and type definitions.
"padding-line-between-statements": "off",
"@typescript-eslint/padding-line-between-statements": [
"error",
{
"blankLine": "always",
"prev": "*",
"next": ["interface", "type"]
}
]
}

注意: ESLint cjs-exportcjs-import 语句类型分别重命名为 exportsrequire

英:Note: ESLint cjs-export and cjs-import statement types are renamed to exports and require respectively.

如何使用

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

选项

参见 eslint/padding-line-between-statements 选项

资源

摘自 ❤️ ESLint 内核