Skip to content

Commit 0e50125

Browse files
Merge pull request #19788 from Snuffleupagus/no-array-reduce
Enable the `no-array-reduce` ESLint plugin rule
2 parents 85e6f3c + 38d0125 commit 0e50125

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export default [
127127
"perfectionist/sort-named-exports": "error",
128128
"unicorn/no-abusive-eslint-disable": "error",
129129
"unicorn/no-array-push-push": "error",
130+
"unicorn/no-array-reduce": ["error", { allowSimpleOperations: true }],
130131
"unicorn/no-console-spaces": "error",
131132
"unicorn/no-instanceof-builtins": "error",
132133
"unicorn/no-invalid-remove-event-listener": "error",

test/stats/statcmp.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,7 @@ function pad(s, length, dir /* default: 'right' */) {
7676
}
7777

7878
function mean(array) {
79-
function add(a, b) {
80-
return a + b;
81-
}
82-
return array.reduce(add, 0) / array.length;
79+
return array.reduce((a, b) => a + b, 0) / array.length;
8380
}
8481

8582
/* Comparator for row key sorting. */

0 commit comments

Comments
 (0)