Anser based on @JohannesEwald comment and @KevinAmiranoff answer.
I’m using the following rules:
https://www.npmjs.com/package/eslint-plugin-prefer-arrow
https://eslint.org/docs/rules/prefer-arrow-callback
https://eslint.org/docs/rules/func-style
npm install -D eslint-plugin-prefer-arrow
.eslintrc
or package.json
with eslintConfig
:
"plugins": [
"prefer-arrow"
],
"rules": {
"prefer-arrow/prefer-arrow-functions": [
"error",
{
"disallowPrototype": true,
"singleReturnOnly": false,
"classPropertiesAllowed": false
}
],
"prefer-arrow-callback": [
"error",
{ "allowNamedFunctions": true }
],
"func-style": [
"error",
"expression",
{ "allowArrowFunctions": true }
]
}
I think this works really well. If you need to disable the rules for a specific line I do it like this:
// eslint-disable-next-line func-style, prefer-arrow/prefer-arrow-functions