padding-line-between-statements
Require or disallow padding lines between statements.
此规则报告的一些问题可通过 --fix
ESLint 命令行选项自动修复。
此规则扩展了基本 eslint/padding-line-between-statements
规则。
它增加了对 TypeScript 构造(例如 interface
和 type
)的支持。
英:This rule extends the base eslint/padding-line-between-statements
rule.
It adds support for TypeScript constructs such as interface
and type
.
选项
除了 ESLint 提供的选项外,还可以使用 interface
和 type
作为语句类型。
英: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-export
和 cjs-import
语句类型分别重命名为 exports
和 require
。
英:Note: ESLint cjs-export
and cjs-import
statement types are renamed to exports
and require
respectively.
如何使用
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 内核