Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

42 lines
880 B
Plaintext

== Why is this an issue?
When a ``++Promise++`` needs to only "resolve" or "reject", it's more efficient and readable to use the methods specially created for such use cases: ``++Promise.resolve(value)++`` and ``++Promise.reject(error)++``.
=== Noncompliant code example
[source,javascript]
----
let fulfilledPromise = new Promise(resolve => resolve(42));
let rejectedPromise = new Promise(function(resolve, reject) {
reject('fail');
});
----
=== Compliant solution
[source,javascript]
----
let fulfilledPromise = Promise.resolve(42);
let rejectedPromise = Promise.reject('fail');
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Replace this trivial promise with "[Promise.resolve(XXX)|Promise.reject(XXX)]".
=== Highlighting
entire "new Promise" expression
endif::env-github,rspecator-view[]