Skip to content

Files

Latest commit

 

History

History
35 lines (23 loc) · 778 Bytes

no-new-statics.md

File metadata and controls

35 lines (23 loc) · 778 Bytes

Pattern: Calling new on a Promise static method

Issue: -

Description

Calling a Promise static method with new is invalid, resulting in a TypeError at runtime.

Examples for incorrect code for this rule:

new Promise.resolve(value)
new Promise.reject(error)
new Promise.race([p1, p2])
new Promise.all([p1, p2])

Examples for correct code for this rule:

Promise.resolve(value)
Promise.reject(error)
Promise.race([p1, p2])
Promise.all([p1, p2])

When Not To Use It

If you do not want to be notified when calling new on a Promise static method, you can safely disable this rule.

Further Reading