簡體   English   中英

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

[英]Where can I find .eslintrc in CRA?

使用npx create-react-app appname時,安裝的react-scripts package 包含一個 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.

您的 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM