我试图使用插件eslint插件反应按字母顺序对道具名称进行排序,但我得到了以下错误:
[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
}
]
}
}我错过了什么?
发布于 2022-02-14 20:02:13
有两个问题:
2,而不是"2"。(不过,就我个人而言,我建议使用"error" -通过阅读配置规则对您的项目意味着什么- "error"比2更直观)jsx-sort-props.js中存在一个错误--尽管docs引用了一个multiline属性,但是该属性在林特规则实现中的任何地方都不存在,因此当传入包含该属性的对象时会引发错误。把它移开。"rules": {
"react/jsx-sort-props": [
2,
{
"callbacksLast": true,
"shorthandFirst": false,
"shorthandLast": true,
"ignoreCase": true,
"noSortAlphabetically": false
}
]
}https://stackoverflow.com/questions/71117382
复制相似问题