简体   繁体   English

如何配置 eslintrc 并将 React 添加到 eslint(使用 airbnb、typescript)而不创建 react 应用程序

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

相关问题 没有eslint插件反应的ESLint + Airbnb - ESLint + Airbnb without eslint-plugin-react Eslint 插件“反应”在 eslintrc.json >> eslint-config-airbnb 之间发生冲突 - Eslint Plugin "react"was conflicted between .eslintrc.json >> eslint-config-airbnb 如何在 Create React App 中向 ESLint 添加规则 - how to add rules to ESLint in Create React App eslint 与 airbnb 反应 - eslint react with airbnb 创建 React 应用程序:ESLint 配置不适用于 Typescript - Create React App: ESLint config is not working with Typescript 错误:无法加载在“.eslintrc”中声明的解析器“babel-eslint”:在 create-react-app 中找不到模块“babel-eslint” - Error: Failed to load parser 'babel-eslint' declared in '.eslintrc': Cannot find module 'babel-eslint' in create-react-app 创建反应应用程序 - 没有打字稿,得到错误:无法加载解析器'@typescript-eslint/parser' - create react app - without typescript , got Error: Failed to load parser '@typescript-eslint/parser' 关于“create-react-app --template typescript”如何与 typescript-eslint 连接的困惑 - Confusion about how `create-react-app --template typescript` hooked up with typescript-eslint 更漂亮的 eslint:使用 'prettier' 或 'plugin:prettier/recommended' 和 React Typescript airbnb eslint 配置 - Prettier eslint: use 'prettier' or 'plugin:prettier/recommended' with React Typescript airbnb eslint config 如何在 create react app 中运行 eslint - How to run eslint in create react app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM