unicorn/no-array-reduce
eslint-plugin-unicorn
Safe autofix
eslint.config.js
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/no-array-reduce": "error",
},
},
];array.reduce(reducer);array.reduce(reducer, initialValue);[].reduce.apply(array, [reducer, initialValue]);// eslint-disable-next-line unicorn/no-array-reduce
array.reduce(reducer);let result = initialValue;
for (const [index, element] of array.entries()) {
result = reducer(result, element, index, array);
}array.reduce((total, value) => total + value);Examples from the ESLint documentation.
unicorn/no-array-reduce
eslint-plugin-unicorn
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/no-array-reduce": "error",
},
},
];unicorn/no-array-reduce
unicorn plugin · restriction
{
"rules": {
"unicorn/no-array-reduce": "error"
}
}Biome does not have this rule.
Disallow member access from await expression.
Enforce consistent style for escaping ${ in template literals.
Disallow confusing uses of Array#with().
Enforce consistent assertion style with node:assert.
Prefer export…from when re-exporting.