Force class in React to use Arrow Function with Eslint

Asked

Viewed 28 times

0

How do I make an error pro Eslint when someone in the project uses functions within a class that need bind instead of an Arrow Function

1 answer

0

You can use this Eslint plugin to do this: https://www.npmjs.com/package/eslint-plugin-prefer-arrow

Example:

"plugins": [
  "prefer-arrow"
],
"rules": [
  "prefer-arrow/prefer-arrow-functions": [
     "error",
     {
       "disallowPrototype": true,
       "singleReturnOnly": false,
       "classPropertiesAllowed": false
     }
   ]
]

Browser other questions tagged

You are not signed in. Login or sign up in order to post.