0

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?

meez
  • 3,783
  • 5
  • 37
  • 91

1 Answers1

0

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

"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.

Saiful
  • 7
  • 1
  • where does the `2` stands for? Enable? And what about my eslintrc.js config? Is `'plugin:react/recommended',` to correct way here adding React to eslint without create-react-app? – meez Jul 04 '22 at 10:27