[英]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.