如何配置Eslintrc并将React添加到ESLINT(使用Airbnb,Typescript)的情况下,而无需创建React App
我的项目不使用Create-React-App。我正在上调我的eslint。如何对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抛出错误:
功能组件不是功能 声明linextreact/function-component-definition)
我如何只为我的react组件等使用箭头函数?
My project is not using create-react-app. I am upadting my Eslint. How do I add React properly to the eslintrc.js file?
Currently I have this in the extend
property:
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',
],
For example now eslint throws error:
Function component is not a function
declarationeslintreact/function-component-definition)
How can I just use arrow functions for my React components etc?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“ react/function-component-definition”:[
2,,
{
名为COMPONENTS:“箭头函数”,
不愿透露姓名:“箭头功能”,
},,
],
只需在您的eslintrc.js文件中添加这些行。这仅允许您添加箭头功能。
"react/function-component-definition": [
2,
{
namedComponents: "arrow-function",
unnamedComponents: "arrow-function",
},
],
Just add these line in your eslintrc.js file. This only allow you to add arrow function.