在使用npx create-react-app appname时,安装的react-scripts包包含一个eslint依赖项,该依赖项具有“找到常见错误的最小规则集”。我想使用更漂亮的和eslint,但我找不到信息,如果有的话,eslint插件也作为CRA的一部分安装在哪里,也找不到基本的ESLint配置来查看其中包含了什么。如果需要,我会扩展基本的ESLint配置,但是CRA文档说它是实验性的,所以我想尽可能避免它。
编辑:更多详细信息
如果不手动将ESLint作为依赖项安装,我会得到(有点意料之中的)所有插件和配置依赖项的missing peer dependency错误。
当ESLint作为依赖项安装时,我得到一个CRA错误:
> react-scripts start
There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.
The react-scripts package provided by Create React App requires a dependency:
"eslint": "^6.6.0"
Don't try to install it manually: your package manager does it automatically.
However, a different version of eslint was detected higher up in the tree:
~\client\node_modules\eslint (version: 7.2.0)
Manually installing incompatible versions is known to cause hard-to-debug issues.发布于 2020-06-18 00:17:52
您的CRA应用程序中的Package.json包含以下内容
"eslintConfig": {
"extends": "react-app"
},您应该只需要创建一个.eslintrc文件,然后就可以使用它了。
该配置可在https://github.com/facebook/create-react-app/tree/master/packages/eslint-config-react-app上找到
它使用这些插件
['import', 'flowtype', 'jsx-a11y', 'react', 'react-hooks']。
我个人认为使用Airbnb eslint规则会更好,或者如果您想要更全面的签出eslint-config-auto
https://stackoverflow.com/questions/62318981
复制相似问题