TristonJ / eslint-plugin-prefer-arrow

ESLint plugin to prefer arrow functions
MIT License
54 stars 10 forks source link

Option to ignore non-arrow functions passed to Mocha functions #25

Open rhansen opened 3 years ago

rhansen commented 3 years ago

Mocha's documentation says:

Passing arrow functions (aka “lambdas”) to Mocha is discouraged. Lambdas lexically bind this and cannot access the Mocha context.

It would be nice if this plugin played nice with Mocha callbacks.

I opened an issue against the mocha plugin as well: https://github.com/lo1tuma/eslint-plugin-mocha/issues/275

tehXor commented 3 years ago

https://mochajs.org/#arrow-functions

There is a reason mocha is not using arrow functions. And most likely in a bigger project there are more scenarios where it would be bad practice to use arrow functions. With rules like this I get the feeling people who are writing and using them have forgotten the actual features of the language they are using (or never knew them from the start) and since they cannot think beyond their own 10 lines of code anyways they limit features like that. But take that with a grain of salt, I just came here from a quite non-pleasing migration from TSLint to ESLint, which automatically added this rule and so I ended up with a similar situation like you and I wanted to check if this rule at least has reasonable options (it has not). Obviously there are a lot of reasonable linting rules and even this one may be in some projects but as it is we probably should just drop it ;-)