【发布时间】:2022-02-21 12:16:34
【问题描述】:
我正在尝试通过我的 create-react-app 中的 eslint CLI 对某些规则进行 lint。我想修正的规则是react/jsx-sort-props。
起初我尝试了这里提供的修复单个规则的格式:How to fix just one rule using eslint
"fix-style":"eslint --fix --rule 'react/jsx-sort-props"
但这给出了错误:
Invalid value for option 'rule' - expected type Object, received value: 'react/jsx-sort-props.
ESLint CLI with --rule option 中讨论了此错误,但似乎没有任何解决方案有效。
跑步:
//package.json
"scripts": {
"fix-style": "eslint --fix --rule 'react/jsx-sort-props: ['warn']'",
}
给予:
$ eslint --fix --rule 'react/jsx-sort-props: ['warn']'
Oops! Something went wrong! :(
ESLint: 7.32.0
No files matching the pattern "['warn']'" were found.
Please check for typing mistakes in the pattern.
那么修复单个规则的正确方法是什么?
操作系统:Windows 10
【问题讨论】:
标签: reactjs eslint create-react-app react-scripts