[英]Invalid configuration for rule "react/jsx-sort-props"
I'm trying to sort props names alphabetically using the plugin eslint-plugin-react but I'm getting this error:我正在尝试使用插件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.
This is my .eslintrc.json
file:这是我的
.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
}
]
}
}
What I'm missing?我缺少什么?
There are two issues:有两个问题:
2
, not "2"
. 2
,而不是"2"
。 (Though, personally, I'd suggest using "error"
instead - it makes it clearer from reading the config what the rule means for your project - "error"
makes more intuitive sense than 2
) "error"
——通过阅读配置可以更清楚地了解规则对你的项目意味着什么—— "error"
比2
更直观)jsx-sort-props.js
- although the docs reference a multiline
property, said property does not exist anywhere in the lint rule implementation, and so an error is thrown when you pass in an object containing that property. jsx-sort-props.js
中存在一个错误 - 尽管文档引用了multiline
属性,但该属性在 lint 规则实现中的任何地方都不存在,因此当您传入包含该内容的 object 时会抛出错误财产。 Remove it."rules": {
"react/jsx-sort-props": [
2,
{
"callbacksLast": true,
"shorthandFirst": false,
"shorthandLast": true,
"ignoreCase": true,
"noSortAlphabetically": false
}
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.