sindresorhus/eslint-plugin-unicorn
Use `Promise.withResolvers` instead of `new Promise()`?
Chiusa
#2403 aperta il 22 lug 2024
help wantednew rule
Metriche repository
- Star
- (5022 stelle)
- Metriche merge PR
- (Merge medio 1g 16h) (399 PR mergiate in 30 g)
Descrizione
I think in most cases need a promise, using Promise.withResolvers() should be more readable than new Promise(), because new Promise needs a new function scope.
I opened this issue instead of a rule proposal, since I'm not sure about it and want to discuss it first.
Welcome to post cases where new Promise() should be preferred.
The only case in my mind is the arrow function body.
const foo = () => new Promise(resolve => {
resolve()
});