How to handle eslint no-param-reassign rule in Array.prototype.reduce() functions
问题 I've recently added the eslint rule no-param-reassign. However, when I use reduce to build out an object (empty object as initialValue ), I find myself needing to modify the accumulator (first arg of callback function) on each callback iteration, which causes a no-param-reassign linter complaint (as one would expect it would). const newObject = ['a', 'b', 'c'].reduce((result, item, index) => { result[item] = index; // <-- causes the no-param-reassign complaint return result; }, {}); Is there