wikimedia / eslint-config-wikimedia

JavaScript style guide for Wikimedia.
https://www.mediawiki.org/wiki/Manual:Coding_conventions/JavaScript
MIT License
29 stars 20 forks source link

Prefer arrow callbacks in ES6 code #572

Closed edg2s closed 6 months ago

edg2s commented 6 months ago

We should consider the following rules in ES6 code:

This results in arrow functions being used for callbacks (unless they reference this or arguments, in which case they would need be converted manually). When arrow functions contain a single return statement, the body-less style is prefered (e.g. ( x ) => x + 1. Also a single line is prefered for such body-less functions.

jdforrester commented 6 months ago

Seems sensible. Worth posting in https://www.mediawiki.org/wiki/Manual_talk:Coding_conventions/JavaScript for visibility?