eslint/array-callback-return Pedantic
What it does
Enforce return statements in callbacks of array methods
Why is this bad?
Array has several methods for filtering, mapping, and folding. If we forget to write return statement in a callback of those, it’s probably a mistake. If you don’t want to use a return or don’t need the returned results, consider using .forEach instead.
Example
javascript
let foo = [1, 2, 3, 4];
foo.map((a) => {
console.log(a);
});
How to use
To enable this rule in the CLI or using the config file, you can use:
bash
oxlint --deny array-callback-return
json
{
"rules": {
"array-callback-return": "error"
}
}