我在哪里可以在 CRA 中找到 .eslintrc?

dot*_*one 11 reactjs eslint create-react-app prettier prettier-eslint

使用 时npx create-react-app appnamereact-scripts安装的包包含一个 eslint 依赖项,其中包含“发现常见错误的最小规则集”。我想使用 prettier 和 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.
Run Code Online (Sandbox Code Playgroud)

Dav*_*haw 9

您的 CRA 应用程序中的 Package.json 包含此

"eslintConfig": {
  "extends": "react-app"
},
Run Code Online (Sandbox Code Playgroud)

您应该能够创建一个.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