sbdchd / eslint-plugin-cake

:cake: Sweet rules for ESLint
MIT License
1 stars 0 forks source link

Prefer `array.some()` to `!!array.find()` #2

Open sbdchd opened 3 years ago

sbdchd commented 3 years ago

.some() is equivalent to !!array.find() or array.find() != null

// error
!!array.find(someFn)
array.find(someFn) != null
array.findIndex(someFn) != -1
array.findIndex(someFn) >= 0
array.findIndex(someFn) < 0
Boolean(array.find(someFn))

// okay
array.some(checkFn)
array.find(someFn) != someValue

Probably want to use type information to avoid false positives