【发布时间】:2022-02-14 09:12:40
【问题描述】:
我正在尝试使用插件eslint-plugin-react 在我的项目中按字母顺序对道具名称进行排序。
我已经阅读了jsx-sort-props rules option example,我在这里问自己:<enable> 字段中应该使用什么道具?
...
"react/jsx-sort-props": [<enabled>, {
"callbacksLast": <boolean>,
"shorthandFirst": <boolean>,
"shorthandLast": <boolean>,
"multiline": "ignore" | "first" | "last",
"ignoreCase": <boolean>,
"noSortAlphabetically": <boolean>,
"reservedFirst": <boolean>|<array<string>>,
}]
...
我已经尝试了所有方法,但总是收到无效的配置通知:
*Error: ESLint configuration in .eslintrc.JSON is invalid: Unexpected top-level property "react/jsx-sort-props".*
我正在我的.eslintrc.json 文件中编辑它:
{
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"next/core-web-vitals"
],
"react/jsx-sort-props": [<enabled>, {
"callbacksLast": true,
"shorthandFirst": false,
"shorthandLast": true,
"multiline": "last",
"ignoreCase": true,
"noSortAlphabetically": false,
"reservedFirst": false
}]
}
【问题讨论】:
标签: javascript reactjs json next.js eslint