External callback function
- Dominant language
- JavaScript
- Stars
- 148k
- Forks
- 26.6k
- PR merge metrics
- No merged PRs in 30d
Description
_The following examples are based (but no dependent) on [Express router](https://expressjs.com/en/guide/routing.html)._
**Considering the following correct case:**
[8.1 When you must use function expressions (as when passing an anonymous function), use arrow function notation. ](https://github.com/airbnb/javascript#arrows--use-them)
```
router.get('/url', (req, res) => {
...
});
```
**Should you?**
Write the callback function as an arrow function as well, if called from an external place?
```
// controllers.js
export const getUrlController = (req, res) => {
...
});
```
```
// routes.js
import { getUrlController } from './controllers'
router.get('/url', urlController);
```
Or should it rather be a function in this case?
```
// controllers.js
export const getUrlController = function getUrl(req, res) {
...
};
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing the linked Airbnb arrow-function guidance alongside the Express router examples in the issue. Compare the controllers.js and routes.js examples, then look for a maintainer decision on whether externally defined callbacks need a specific style rule; the issue is done when that guidance is clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100