![](/img/trans.png)
[英]Error when enabling react/jsx-sort-props [Rules of eslint-plugin-react]
[英]Invalid configuration for rule "react/jsx-sort-props"
我正在嘗試使用插件eslint-plugin-react按字母順序對道具名稱進行排序,但出現此錯誤:
[Error ] .eslintrc.json: Configuration for rule "react/jsx-sort-props" is invalid: Value {"callbacksLast":true,"shorthandFirst":false,"shorthandLast":true,"multiline":"last","ignoreCase":true,"noSortAlphabetically":false} should NOT have additional properties.
這是我的.eslintrc.json
文件:
{
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"next/core-web-vitals"
],
"rules": {
"react/jsx-sort-props": [
"2",
{
"callbacksLast": true,
"shorthandFirst": false,
"shorthandLast": true,
"multiline": "last",
"ignoreCase": true,
"noSortAlphabetically": false
}
]
}
}
我缺少什么?
有兩個問題:
2
,而不是"2"
。 (不過,就我個人而言,我建議改用"error"
——通過閱讀配置可以更清楚地了解規則對你的項目意味着什么—— "error"
比2
更直觀)jsx-sort-props.js
中存在一個錯誤 - 盡管文檔引用了multiline
屬性,但該屬性在 lint 規則實現中的任何地方都不存在,因此當您傳入包含該內容的 object 時會拋出錯誤財產。 去掉它。"rules": {
"react/jsx-sort-props": [
2,
{
"callbacksLast": true,
"shorthandFirst": false,
"shorthandLast": true,
"ignoreCase": true,
"noSortAlphabetically": false
}
]
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.