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

languages: Prefer arrow callbacks in ES6 #573

Closed edg2s closed 6 months ago

edg2s commented 6 months ago

Also prefer single-line body-less style when possible.

Fixes #572

edg2s commented 6 months ago

cc @matmarex

Krinkle commented 6 months ago

If there isn't one already, I suggest adding a QUnit.test() case that involves this.something (e.g. from a beforeEach hook), to make sure it neither warns about nor tries to "fix" those. Or, I suppose, really in any input file, it doesn't have to be a QUnit test per-se.

edg2s commented 6 months ago

prefer-arrow-callback is conservative and the autofix is designed to never introduce an error, e.g. if this or arguments is present in the function body:

https://eslint.org/docs/latest/rules/prefer-arrow-callback#:~:text=unbound%20function%20expression

edg2s commented 6 months ago

Added https://github.com/wikimedia/eslint-config-wikimedia/pull/573/files#diff-86bcbe79dd5ebf49dae82bbc6b83b36dfacc16943ed661dd6d319337a93007a0