sindresorhus/eslint-plugin-unicorn
Rule proposal: Prefer array `last` methods over `reverse`
Chiusa
#2417 aperta il 31 lug 2024
help wantednew rule
Metriche repository
- Star
- (5022 stelle)
- Metriche merge PR
- (Merge medio 4h 30m) (26 PR mergiate in 30 g)
Descrizione
Description
It was mentioned in https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1323 but it was closed in favor of prefer-array-find, which only covered filter instead.
Fail
array.reverse().find(logic);
array.reverse().findIndex(logic);
array.reverse().indexOf(logic);
array.reverse().reduce(logic);
array.toReversed().find(logic);
array.toReversed().findIndex(logic);
array.toReversed().indexOf(logic);
array.toReversed().reduce(logic);
Pass
array.findLast(logic);
array.findLastIndex(logic);
array.lastIndexOf(logic);
array.reduceRight(logic);
Proposed rule name
avoid-array-reverse
Additional Info
No response