eslint-plugin-unicorn
eslint-plugin-unicorn copied to clipboard
`unicorn/no-for-loop` false positive: loop through a string (returned by `string.slice()`)
const str = '123'.slice(1) // <-- maybe string.slice() triggers the bug
for (let i = 0; i < str.length; i++) { // <-- unicorn/no-for-loop
console.log(str[i], i)
}
after auto-fix:
const str = '123'.slice(1)
for (const [i, element] of str.entries()) { // <-- Property 'entries' does not exist on type 'string'
console.log(element, i)
}