【发布时间】:2019-09-04 21:34:57
【问题描述】:
我想覆盖规则@typescript/type-annotation-spacing,该规则确定在类型注释中: 前后放置多少空格。
我想覆盖它以在: 之前和之后有一个空格,但默认它后面只有一个。
文档描述了此规则的几个选项,但没有给出在 eslintrc.* 文件中覆盖此规则的完整语法示例。
This rule has an object option:
"before": false, (default for colon) disallows spaces before the colon/arrow.
"before": true, (default for arrow) requires a space before the colon/arrow.
"after": true, (default) requires a space after the colon/arrow.
"after": false, disallows spaces after the colon/arrow.
"overrides", overrides the default options for type annotations with colon (e.g. const foo: string) and function types with arrow (e.g. type Foo = () => {}).
我尝试将此添加到我的 eslintrc 文件中
"rules": {
"@typescript-eslint/type-annotation-spacing": {
before: true,
after: true,
severity: "warn"
}
}
然后我得到这个错误:
Configuration for rule "@typescript-eslint/type-annotation-spacing" is invalid:
Severity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '{ before: true, after: true, severity: "warn" }').
我尝试了其他几种变体,但它们都导致了类似的错误。
正确的语法是什么?
【问题讨论】:
-
我认为,语法与原版 eslint 相同。查看他们的文档以了解语法。
-
好吧,如果你能说出你做了什么,而不是投反对票,那就太好了。然后阅读文档顺便说一句
-
对不起作用的解决方案投反对票没有错
标签: typescript eslint