π Prefer last-oriented array methods over Array#reverse() or Array#toReversed() followed by a method.
πΌ This rule is enabled in the following configs: β
recommended, βοΈ unopinionated.
π‘ This rule is manually fixable by editor suggestions.
Prefer last-oriented array methods over reversing an array and then calling the forward method.
Last-oriented methods express the traversal direction directly and avoid reversing the array before the operation.
This rule reports .reverse() and .toReversed() followed by .find(), .findIndex(), .indexOf(), or .reduce().
This rule only provides editor suggestions. The replacement can change observable behavior for mutation, sparse arrays, callback index or array arguments, and index-returning methods.
// β
const result = array.reverse().find(isUnicorn);
// β
const result = array.findLast(isUnicorn);// β
const result = array.toReversed().reduce(reducer, initialValue);
// β
const result = array.reduceRight(reducer, initialValue);