[英]How to configure eslintrc and add React to eslint (with airbnb, typescript) without create react app
My project is not using create-react-app.我的项目没有使用 create-react-app。 I am upadting my Eslint.
我正在更新我的 Eslint。 How do I add React properly to the eslintrc.js file?
如何将 React 正确添加到 eslintrc.js 文件中?
Currently I have this in the extend
property:目前我在
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', ],
For example now eslint throws error:例如现在 eslint 抛出错误:
Function component is not a function declarationeslintreact/function-component-definition)
Function 组件不是 function 声明 lintreact/function-component-definition)
How can I just use arrow functions for my React components etc?我怎样才能为我的 React 组件等使用箭头函数?
"react/function-component-definition": [ 2, { namedComponents: "arrow-function", unnamedComponents: "arrow-function", }, ],
"react/function-component-definition": [ 2, { namedComponents: "arrow-function", unnamedComponents: "arrow-function", }, ], “反应/功能组件定义”:[2,{命名组件:“箭头函数”,未命名组件:“箭头函数”,},],
Just add these line in your eslintrc.js file.只需在 eslintrc.js 文件中添加这些行。 This only allow you to add arrow function.
这只允许您添加箭头 function。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.