[英]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.