prefer-array-last-methods
Added in v0.9.4Configuration
rslint.config.ts
Prefer last-oriented array methods over reversing an array and then calling the corresponding forward method.
The rule recognizes:
.reverse().find()and.toReversed().find()→.findLast().reverse().findIndex()and.toReversed().findIndex()→.findLastIndex().reverse().indexOf()and.toReversed().indexOf()→.lastIndexOf().reverse().reduce()and.toReversed().reduce()→.reduceRight()
The rule reports a diagnostic and offers an editor suggestion rather than an automatic fix because replacing reversal can change observable mutation, sparse-array, callback-index, or index-return semantics. Suggestions are withheld when comments occur inside the matched call.
This port follows eslint-plugin-unicorn v75.0.0.