sindresorhus/eslint-plugin-unicorn

Rule proposal: `prefer-string-repeat`

Open

#1,774 opened on Mar 30, 2022

View on GitHub
 (3 comments) (4 reactions) (0 assignees)JavaScript (5,022 stars) (468 forks)user submission
help wantednew rule

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

Rule proposal: `prefer-string-repeat` · sindresorhus/eslint-plugin-unicorn#1774 | Good First Issue