![](/img/trans.png)
[英]TSLint object-literal-sort-keys is sorted alphabetically but error persists
[英]object-literal-sort-keys needs type info to use "match-declaration-order" or "match-declaration-order-only"
在我的tslint.json
,我将object-literal-sort-keys
定义为match-declaration-order
:
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended"
],
"jsRules": {},
"rules": {
"no-console": false,
"object-literal-sort-keys": [
true,
"match-declaration-order"
],
"max-line-length": [
true,
200
],
"typedef": [
true,
"member-variable-declaration",
"variable-declaration"
]
},
"rulesDirectory": []
}
但是我总是收到这个错误:
object-literal-sort-keys needs type info to use "match-declaration-order" or
"match-declaration-order-only".
See https://palantir.github.io/tslint/usage/type-checking/ for documentation on
how to enable this feature.
我已经尝试了文档中显示的示例,但它们并没有解决问题。 消除此错误的唯一方法是使用object-literal-sort-keys
默认设置,但随后我必须按字母顺序对所有 arrays 进行排序。
我如何配置object-literal-sort-keys
才能消除此错误 go?
object-literal-sort-keys规则的选项"match-declaration-order"
要求 tslint 具有类型信息,因为它需要根据其定义的类型检查 object 文字。 为此,tslint 需要知道同一应用程序中使用的tsconfig.json
文件。 这可以作为标志提供, --project
或--p
。 完整的命令将如下所示:
npx tslint -p tsconfig.json -c tslint.json
这将对将为项目编译的每个文件进行 lint。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.