key-spacing
danger
This rule will soon be moved to eslint-stylistic. See What About Formatting? for more information.
Enforce consistent spacing between property names and type annotations in types and interfaces.
🔧
此规则报告的一些问题可通过 --fix
ESLint 命令行选项自动修复。
此规则扩展了基本 eslint/key-spacing
规则。
它增加了对接口、类和类型字面量属性上的类型注释的支持。
英:This rule extends the base eslint/key-spacing
rule.
It adds support for type annotations on interfaces, classes and type literals properties.
如何使用
.eslintrc.cjs
module.exports = {
"rules": {
// Note: you must disable the base rule as it can report incorrect errors
"key-spacing": "off",
"@typescript-eslint/key-spacing": "error"
}
};
选项
资源
摘自 ❤️ ESLint 内核