You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ESLint has various rules to enforce methods or function declarations vs arrow functions. One that’s missing is a way to enforce the use of a short arrow function vs the use of a method with a single return value.
I.e., given this is not used the following are equivalent:
The object-shorthand rule can be used to prefer option 1 over option 2. The arrow-body-style rule can be used to enforce option 3 over option 2. However, there’s no way to enforce option 1 or 3 over the other.
I suggest to add a rule to prefer a short arrow function over a method with a single return value. I’m also fine with a rule that’s the other way around. For me it’s about consistency.
Description
ESLint has various rules to enforce methods or function declarations vs arrow functions. One that’s missing is a way to enforce the use of a short arrow function vs the use of a method with a single return value.
I.e., given
this
is not used the following are equivalent:The
object-shorthand
rule can be used to prefer option 1 over option 2. Thearrow-body-style
rule can be used to enforce option 3 over option 2. However, there’s no way to enforce option 1 or 3 over the other.I suggest to add a rule to prefer a short arrow function over a method with a single return value. I’m also fine with a rule that’s the other way around. For me it’s about consistency.
Fail
Pass
Use the
arrow-body-style
rule to deal with this situation.The text was updated successfully, but these errors were encountered: