airbnb / airbnb/javascript

Consider allowing anonymous function expressions

Open
#450 6 comments 0 reactions 0 assignees View on GitHub
needs eslint rule change/addition pull request wanted question
Dominant language
JavaScript
Stars
148k
Forks
26.6k
PR merge metrics
No merged PRs in 30d

Description

At the moment [you forbid](https://github.com/airbnb/javascript/blob/ea093e0373cc4dfa07c69ef7c75d81bd06bdf0c2/packages/eslint-config-airbnb/.eslintrc#L140) unnamed function expressions like `function() {}`. That’s a good thing.

But when using the new function bind syntax with **[trine](https://github.com/jussi-kalliokoski/trine)**-style [libraries](https://github.com/roobie/mori-ext), you can’t use arrow functions because they inherit `this` from the outer scope.

So a good old anonymous function expression:

``` js
[my, collection]::map(function() {
return !!this;
});
```

…often feels more natural than inventing obscure names:

``` js
[my, collection]::map(function justCastToBoolean() {
return !!this;
});
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with packages/eslint-config-airbnb/.eslintrc at the linked rule around line 140, then inspect the surrounding function-naming configuration and any related style-guide documentation. Compare its behavior for ordinary anonymous functions with the bind-syntax example; done means the intended exception is defined clearly and the relevant configuration or documentation reflects it.

Written by the indexing model from the issue text.

Assessment

Tech stack
eslint, javascript
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.