array-callback-return
eslint
Suggestion
eslint.config.js
export default [
{
rules: {
"array-callback-return": "error",
},
},
];Enforce return statements in callbacks of array methods
const indexMap = myArray.reduce(function(memo, item, index) {
memo[item] = index;
}, {});
const foo = Array.from(nodes, function(node) {
if (node.tagName === "DIV") {
return true;
}
});
const bar = foo.filter(function(x) {
if (x) {
return true;
} else {
return;
}
});const indexMap = myArray.reduce(function(memo, item, index) {
memo[item] = index;
return memo;
}, {});
const foo = Array.from(nodes, function(node) {
if (node.tagName === "DIV") {
return true;
}
return false;
});
const bar = foo.map(node => node.getAttribute("id"));Examples from the ESLint documentation.
array-callback-return
eslint
export default [
{
rules: {
"array-callback-return": "error",
},
},
];array-callback-return
eslint plugin · pedantic
{
"rules": {
"array-callback-return": "error"
}
}suspicious/useIterableCallbackReturn
suspicious · since 2.0.0
{
"linter": {
"rules": {
"suspicious": {
"useIterableCallbackReturn": "error"
}
}
}
}Disallow template literal placeholder syntax in regular strings
Disallow the use of eval()-like methods
Disallow octal escape sequences in string literals