Skip to content

VBC-012: redundant-promise-constructor

warning

Category: clean-code
Analysis: Regex (line by line)
File types: .js, .ts, .tsx, .astro
Scope: source code only, ignoring anything inside strings and comments
Tags: clean-code performance

What it reports

Redundant Promise constructor wrapping at line {line}. This is an anti-pattern called "Promise constructor anti-pattern". Use Promise.resolve() directly or return the value/promise without wrapping it.

Flagged

js
const p = new Promise(resolve => resolve(value));

Not flagged

js
const p = Promise.resolve(value);

Pattern

regex
new Promise\s*\(\s*(resolve|res)\s*=>\s*(resolve|res)\s*\(

Released under the MIT License.