簡體   English   中英

如何配置 eslintrc 並將 React 添加到 eslint(使用 airbnb、typescript)而不創建 react 應用程序

[英]How to configure eslintrc and add React to eslint (with airbnb, typescript) without create react app

我的項目沒有使用 create-react-app。 我正在更新我的 Eslint。 如何將 React 正確添加到 eslintrc.js 文件中?

目前我在extend屬性中有這個:

 extends: [ 'airbnb', 'airbnb-typescript', 'airbnb/hooks', // "plugin:@typescript-eslint/recommended", // "plugin:@typescript-eslint/recommended-requiring-type-checking", // "plugin:eslint-comments/recommended", 'plugin:react/recommended', 'plugin:jest/recommended', 'plugin:prettier/recommended', ],

例如現在 eslint 拋出錯誤:

Function 組件不是 function 聲明 lintreact/function-component-definition)

我怎樣才能為我的 React 組件等使用箭頭函數?

 "react/function-component-definition": [ 2, { namedComponents: "arrow-function", unnamedComponents: "arrow-function", }, ],

“反應/功能組件定義”:[2,{命名組件:“箭頭函數”,未命名組件:“箭頭函數”,},],

只需在 eslintrc.js 文件中添加這些行。 這只允許您添加箭頭 function。

暫無
暫無

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

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