Sindre Sorhus

Results 4140 comments of Sindre Sorhus

`Array#includes` would be better for this, which we already have a rule for, so I'm not sure the point of this rule?

Ok. This rule makes sense then. We should make what you said above clear in the rule docs though.

> Maybe, should if (foo.indexOf('bar') < 0) {} also be checked? No point, since it's already caught by `prefer-includes`.

The benefit of `new Promise()` is that it makes it harder to make mistakes. For example, it's easier to cause an unhandled rejection with `Promise.withResolvers()` or accidentally synchronously throw in...

@fregante I'm not saying `Promise.withResolvers` is not useful, but this issue is asking to prefer `Promise.withResolvers`, and I'm arguing that `new Promise` is a better default.

I misunderstood your statement. I used to use `p-defer` more before, but transitioned to `new Promise` for the reasons I mentioned.

Accepted, with the mentioned limited scope.