sindresorhus/eslint-plugin-unicorn
Rule proposal: Have `prefer-spread` handle `for..of`
Chiusa
#1713 aperta il 3 feb 2022
enhancementhelp wanted
Metriche repository
- Star
- (5022 stelle)
- Metriche merge PR
- (Merge medio 4h 30m) (26 PR mergiate in 30 g)
Descrizione
Description
Often no-for-loop results in something that is a simple spread, which prefer-spread should handle
This works for both arrays and iterators.
Fail
const result = []
for (const element of array) {
result.push(element)
}
const result = []
for (const [index, element] of array.entries()) {
result[index] = element
}
Pass
const result = [...array]