Eslint CLI 未找到与模式“['warn']”匹配的文件
Eslint CLI No files matching the pattern "['warn']'" were found
我正在尝试通过我的 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.
此错误在 中进行了讨论,但 none 的解决方案似乎有效。
运行:
//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.
那么修复单个规则的正确方法是什么?
OS: Windows 10
内部single-quotes过早地结束了规则字符串,所以用双引号将整个字符串括起来
尝试:eslint --fix --rule "react/jsx-sort-props: ['warn']"
在我的 package.json
:
中使用命令时需要转义双引号
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"fix-style": "eslint --fix --rule \"react/jsx-sort-props: ['warn']\"",
},
我正在尝试通过我的 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.
此错误在
运行:
//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.
那么修复单个规则的正确方法是什么?
OS: Windows 10
内部single-quotes过早地结束了规则字符串,所以用双引号将整个字符串括起来
尝试:eslint --fix --rule "react/jsx-sort-props: ['warn']"
在我的 package.json
:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"fix-style": "eslint --fix --rule \"react/jsx-sort-props: ['warn']\"",
},