sindresorhus/eslint-plugin-unicorn
prefer-set-has doesn't autofix types
Fermée
#1 148 ouverte le 24 mars 2021
enhancementhelp wanted
Métriques du dépôt
- Stars
- (5 022 étoiles)
- Métriques de merge PR
- (Merge moyen 1j 16h) (399 PRs mergées en 30 j)
Description
When "autofixing" an array to a set, the type definition should be fixed too (or the fix should be skipped).
prefer-set-has
const a: Array<'foo' | 'bar'> = ['foo', 'bar']
for (let i = 0; i < 3; i++) {
if (a.includes(someString)) {
console.log(123)
}
}
This is corrected to:
const a: Array<'foo' | 'bar'> = new Set(['foo', 'bar'])
for (let i = 0; i < 3; i++) {
if (a.has(someString)) {
console.log(123)
}
}
Which is confusing and wrong.