sindresorhus/eslint-plugin-unicorn

Rule proposal: `prefer-string-repeat`

Closed

#1,774 opened on Mar 30, 2022

 (3 comments) (5 reactions) (0 assignees)JavaScript (468 forks)user submission
help wantednew rule

Repository metrics

Stars
 (5,022 stars)
PR merge metrics
 (Avg merge 1d 16h) (399 merged PRs in 30d)

Description

Description

https://github.com/eslint/eslint/pull/15731#issuecomment-1082586113

Fail

Array.from({length: 10 + 1}).join('*')
Array.from({length: 10}).fill('*').join('')
Array.from({length: 10}, () => '*').join('')

Pass

'*'.repeat(10)
String(foo).repeat(10)

Contributor guide